Mercurial > hg > CbC > CbC_llvm
comparison compiler-rt/lib/gwp_asan/common.h @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 1d019706d866 |
children | c4bab56944e8 |
comparison
equal
deleted
inserted
replaced
173:0572611fdcc8 | 207:2e18cbf3894f |
---|---|
47 // actual number of collected frames may be less than this as the stack | 47 // actual number of collected frames may be less than this as the stack |
48 // frames are compressed into a fixed memory range. | 48 // frames are compressed into a fixed memory range. |
49 static constexpr size_t kMaxTraceLengthToCollect = 128; | 49 static constexpr size_t kMaxTraceLengthToCollect = 128; |
50 | 50 |
51 // Records the given allocation metadata into this struct. | 51 // Records the given allocation metadata into this struct. |
52 void RecordAllocation(uintptr_t Addr, size_t Size); | 52 void RecordAllocation(uintptr_t Addr, size_t RequestedSize); |
53 // Record that this allocation is now deallocated. | 53 // Record that this allocation is now deallocated. |
54 void RecordDeallocation(); | 54 void RecordDeallocation(); |
55 | 55 |
56 struct CallSiteInfo { | 56 struct CallSiteInfo { |
57 // Record the current backtrace to this callsite. | 57 // Record the current backtrace to this callsite. |
68 | 68 |
69 // The address of this allocation. If zero, the rest of this struct isn't | 69 // The address of this allocation. If zero, the rest of this struct isn't |
70 // valid, as the allocation has never occurred. | 70 // valid, as the allocation has never occurred. |
71 uintptr_t Addr = 0; | 71 uintptr_t Addr = 0; |
72 // Represents the actual size of the allocation. | 72 // Represents the actual size of the allocation. |
73 size_t Size = 0; | 73 size_t RequestedSize = 0; |
74 | 74 |
75 CallSiteInfo AllocationTrace; | 75 CallSiteInfo AllocationTrace; |
76 CallSiteInfo DeallocationTrace; | 76 CallSiteInfo DeallocationTrace; |
77 | 77 |
78 // Whether this allocation has been deallocated yet. | 78 // Whether this allocation has been deallocated yet. |
81 | 81 |
82 // This holds the state that's shared between the GWP-ASan allocator and the | 82 // This holds the state that's shared between the GWP-ASan allocator and the |
83 // crash handler. This, in conjunction with the Metadata array, forms the entire | 83 // crash handler. This, in conjunction with the Metadata array, forms the entire |
84 // set of information required for understanding a GWP-ASan crash. | 84 // set of information required for understanding a GWP-ASan crash. |
85 struct AllocatorState { | 85 struct AllocatorState { |
86 constexpr AllocatorState() {} | |
87 | |
86 // Returns whether the provided pointer is a current sampled allocation that | 88 // Returns whether the provided pointer is a current sampled allocation that |
87 // is owned by this pool. | 89 // is owned by this pool. |
88 GWP_ASAN_ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const { | 90 GWP_ASAN_ALWAYS_INLINE bool pointerIsMine(const void *Ptr) const { |
89 uintptr_t P = reinterpret_cast<uintptr_t>(Ptr); | 91 uintptr_t P = reinterpret_cast<uintptr_t>(Ptr); |
90 return P < GuardedPagePoolEnd && GuardedPagePool <= P; | 92 return P < GuardedPagePoolEnd && GuardedPagePool <= P; |