diff options
author | Kostya Serebryany <kcc@google.com> | 2018-10-10 22:24:44 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2018-10-10 22:24:44 +0000 |
commit | d7c60e42e376ee31d70c1312604c64cbd6fd85fb (patch) | |
tree | cfbc4238ebfb87a773a9e1a99add75ed50a3cc70 /compiler-rt/lib/hwasan/hwasan_allocator.cc | |
parent | 0e192395f162e7571a1f92ba1528a8080e507777 (diff) | |
download | bcm5719-llvm-d7c60e42e376ee31d70c1312604c64cbd6fd85fb.tar.gz bcm5719-llvm-d7c60e42e376ee31d70c1312604c64cbd6fd85fb.zip |
[hwasan] when reporting a bug, print some very basic information about the heap chunk (in addition to the more detailed info that we may fail to show)
llvm-svn: 344193
Diffstat (limited to 'compiler-rt/lib/hwasan/hwasan_allocator.cc')
-rw-r--r-- | compiler-rt/lib/hwasan/hwasan_allocator.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cc b/compiler-rt/lib/hwasan/hwasan_allocator.cc index b9c379ea449..ddc0928625a 100644 --- a/compiler-rt/lib/hwasan/hwasan_allocator.cc +++ b/compiler-rt/lib/hwasan/hwasan_allocator.cc @@ -23,6 +23,14 @@ namespace __hwasan { +static Allocator allocator; +static AllocatorCache fallback_allocator_cache; +static SpinMutex fallback_mutex; +static atomic_uint8_t hwasan_allocator_tagging_enabled; + +static const tag_t kFallbackAllocTag = 0xBB; +static const tag_t kFallbackFreeTag = 0xBC; + bool HwasanChunkView::IsAllocated() const { return metadata_ && metadata_->alloc_context_id && metadata_->requested_size; } @@ -40,13 +48,13 @@ u32 HwasanChunkView::GetAllocStackId() const { return metadata_->alloc_context_id; } -static Allocator allocator; -static AllocatorCache fallback_allocator_cache; -static SpinMutex fallback_mutex; -static atomic_uint8_t hwasan_allocator_tagging_enabled; +uptr HwasanChunkView::ActualSize() const { + return allocator.GetActuallyAllocatedSize(reinterpret_cast<void *>(block_)); +} -static const tag_t kFallbackAllocTag = 0xBB; -static const tag_t kFallbackFreeTag = 0xBC; +bool HwasanChunkView::FromSmallHeap() const { + return allocator.FromPrimary(reinterpret_cast<void *>(block_)); +} void GetAllocatorStats(AllocatorStatCounters s) { allocator.GetStats(s); |