[compiler-rt] r341507 - [hwasan] when verbose_threads==1, print the memory usage per thread
Kostya Serebryany via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 5 16:52:31 PDT 2018
Author: kcc
Date: Wed Sep 5 16:52:31 2018
New Revision: 341507
URL: http://llvm.org/viewvc/llvm-project?rev=341507&view=rev
Log:
[hwasan] when verbose_threads==1, print the memory usage per thread
Modified:
compiler-rt/trunk/lib/hwasan/hwasan_allocator.h
compiler-rt/trunk/lib/hwasan/hwasan_thread.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_ring_buffer.h
Modified: compiler-rt/trunk/lib/hwasan/hwasan_allocator.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_allocator.h?rev=341507&r1=341506&r2=341507&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_allocator.h (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_allocator.h Wed Sep 5 16:52:31 2018
@@ -86,6 +86,8 @@ HwasanChunkView FindHeapChunkByAddress(u
// Information about one (de)allocation that happened in the past.
// These are recorded in a thread-local ring buffer.
+// TODO: this is currently 24 bytes (20 bytes + alignment).
+// Compress it to 16 bytes or extend it to be more useful.
struct HeapAllocationRecord {
uptr tagged_addr;
u32 alloc_context_id;
Modified: compiler-rt/trunk/lib/hwasan/hwasan_thread.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_thread.cc?rev=341507&r1=341506&r2=341507&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_thread.cc (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_thread.cc Wed Sep 5 16:52:31 2018
@@ -100,8 +100,13 @@ void Thread::Init() {
CHECK(MemIsApp(stack_bottom_));
CHECK(MemIsApp(stack_top_ - 1));
}
- if (flags()->verbose_threads)
+ if (flags()->verbose_threads) {
+ if (IsMainThread()) {
+ Printf("sizeof(Thread): %zd sizeof(RB): %zd\n", sizeof(Thread),
+ heap_allocations_->SizeInBytes());
+ }
Print("Creating : ");
+ }
}
void Thread::ClearShadowForThreadStackAndTLS() {
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_ring_buffer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_ring_buffer.h?rev=341507&r1=341506&r2=341507&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_ring_buffer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_ring_buffer.h Wed Sep 5 16:52:31 2018
@@ -38,6 +38,9 @@ class RingBuffer {
reinterpret_cast<T *>(reinterpret_cast<uptr>(this) +
2 * sizeof(T *));
}
+
+ uptr SizeInBytes() { return SizeInBytes(size()); }
+
void push(T t) {
*next_ = t;
next_--;
More information about the llvm-commits
mailing list