summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_ring_buffer.h
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-09-24 22:50:32 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-09-24 22:50:32 +0000
commite266b158acecc1e724b61cd236bd24d2e36a9709 (patch)
treefb6eae16860dadea91d3e7fae5bc7330d64caa75 /lib/sanitizer_common/sanitizer_ring_buffer.h
parent09eb360cf9ccee7e1eac74b388cd6f8a4d33d30f (diff)
downloadcompiler-rt-e266b158acecc1e724b61cd236bd24d2e36a9709.tar.gz
Revert "[hwasan] Record and display stack history in stack-based reports."
This reverts commit r342921: test failures on clang-cmake-arm* bots. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@342922 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_ring_buffer.h')
-rw-r--r--lib/sanitizer_common/sanitizer_ring_buffer.h81
1 files changed, 1 insertions, 80 deletions
diff --git a/lib/sanitizer_common/sanitizer_ring_buffer.h b/lib/sanitizer_common/sanitizer_ring_buffer.h
index d15f27fd4..c4649c2be 100644
--- a/lib/sanitizer_common/sanitizer_ring_buffer.h
+++ b/lib/sanitizer_common/sanitizer_ring_buffer.h
@@ -72,91 +72,12 @@ class RingBuffer {
// L: last_, always points to the last data element.
// N: next_, initially equals to last_, is decremented on every push,
// wraps around if it's less or equal than its own address.
+
T *last_;
T *next_;
T data_[1]; // flexible array.
};
-// A ring buffer with externally provided storage that encodes its state in 8
-// bytes. Has significant constraints on size and alignment of storage.
-// See a comment in hwasan/hwasan_thread_list.h for the motivation behind this.
-#if SANITIZER_WORDSIZE == 64
-template <class T>
-class CompactRingBuffer {
- // Top byte of long_ stores the buffer size in pages.
- // Lower bytes store the address of the next buffer element.
- static constexpr int kPageSizeBits = 12;
- static constexpr int kSizeShift = 56;
- static constexpr uptr kNextMask = (1ULL << kSizeShift) - 1;
-
- uptr GetStorageSize() const { return (long_ >> kSizeShift) << kPageSizeBits; }
-
- void Init(void *storage, uptr size) {
- CHECK_EQ(sizeof(CompactRingBuffer<T>), sizeof(void *));
- CHECK(IsPowerOfTwo(size));
- CHECK_GE(size, 1 << kPageSizeBits);
- CHECK_LE(size, 128 << kPageSizeBits);
- CHECK_EQ(size % 4096, 0);
- CHECK_EQ(size % sizeof(T), 0);
- CHECK_EQ((uptr)storage % (size * 2), 0);
- long_ = (uptr)storage | ((size >> kPageSizeBits) << kSizeShift);
- }
-
- void SetNext(const T *next) {
- long_ = (long_ & ~kNextMask) | (uptr)next;
- }
-
- public:
- CompactRingBuffer(void *storage, uptr size) {
- Init(storage, size);
- }
-
- // A copy constructor of sorts.
- CompactRingBuffer(const CompactRingBuffer &other, void *storage) {
- uptr size = other.GetStorageSize();
- internal_memcpy(storage, other.StartOfStorage(), size);
- Init(storage, size);
- uptr Idx = other.Next() - (const T *)other.StartOfStorage();
- SetNext((const T *)storage + Idx);
- }
-
- T *Next() const { return (T *)(long_ & kNextMask); }
-
- void *StartOfStorage() const {
- return (void *)((uptr)Next() & ~(GetStorageSize() - 1));
- }
-
- void *EndOfStorage() const {
- return (void *)((uptr)StartOfStorage() + GetStorageSize());
- }
-
- uptr size() const { return GetStorageSize() / sizeof(T); }
-
- void push(T t) {
- T *next = Next();
- *next = t;
- next++;
- next = (T *)((uptr)next & ~GetStorageSize());
- SetNext(next);
- }
-
- T operator[](uptr Idx) const {
- CHECK_LT(Idx, size());
- const T *Begin = (const T *)StartOfStorage();
- sptr StorageIdx = Next() - Begin;
- StorageIdx -= (sptr)(Idx + 1);
- if (StorageIdx < 0)
- StorageIdx += size();
- return Begin[StorageIdx];
- }
-
- public:
- ~CompactRingBuffer() {}
- CompactRingBuffer(const CompactRingBuffer &) = delete;
-
- uptr long_;
-};
-#endif
} // namespace __sanitizer
#endif // SANITIZER_RING_BUFFER_H