diff options
author | Kostya Serebryany <kcc@google.com> | 2013-12-11 13:54:01 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-12-11 13:54:01 +0000 |
commit | 21aedb6e552cb18b48be973c0e2088a0440f29d7 (patch) | |
tree | 109d25f23656ffd564ad8a2660a385e63b275680 | |
parent | 9d9a1e5e13f7a0cd33d4482f80c1c139d2c60c05 (diff) |
[asan] if verbosity>=2, print the fake stack usage stats at thread exit; No functionality change in non-verboze mode
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@197037 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_fake_stack.cc | 9 | ||||
-rw-r--r-- | lib/asan/asan_fake_stack.h | 2 | ||||
-rw-r--r-- | lib/asan/asan_thread.cc | 7 | ||||
-rw-r--r-- | lib/asan/asan_thread.h | 4 | ||||
-rw-r--r-- | lib/asan/tests/asan_fake_stack_test.cc | 8 |
5 files changed, 19 insertions, 11 deletions
diff --git a/lib/asan/asan_fake_stack.cc b/lib/asan/asan_fake_stack.cc index 1ff97f430..837bac8d2 100644 --- a/lib/asan/asan_fake_stack.cc +++ b/lib/asan/asan_fake_stack.cc @@ -52,8 +52,15 @@ FakeStack *FakeStack::Create(uptr stack_size_log) { return res; } -void FakeStack::Destroy() { +void FakeStack::Destroy(int tid) { PoisonAll(0); + if (common_flags()->verbosity >= 2) { + InternalScopedString str(kNumberOfSizeClasses * 50); + for (uptr class_id = 0; class_id < kNumberOfSizeClasses; class_id++) + str.append("%zd: %zd/%zd; ", class_id, hint_position_[class_id], + NumberOfFrames(stack_size_log(), class_id)); + Report("T%d: FakeStack destroyed: %s\n", tid, str.data()); + } UnmapOrDie(this, RequiredSize(stack_size_log_)); } diff --git a/lib/asan/asan_fake_stack.h b/lib/asan/asan_fake_stack.h index f17ee0268..726fb094a 100644 --- a/lib/asan/asan_fake_stack.h +++ b/lib/asan/asan_fake_stack.h @@ -65,7 +65,7 @@ class FakeStack { // CTOR: create the FakeStack as a single mmap-ed object. static FakeStack *Create(uptr stack_size_log); - void Destroy(); + void Destroy(int tid); // stack_size_log is at least 15 (stack_size >= 32K). static uptr SizeRequiredForFlags(uptr stack_size_log) { diff --git a/lib/asan/asan_thread.cc b/lib/asan/asan_thread.cc index cbbfe7678..34db5c374 100644 --- a/lib/asan/asan_thread.cc +++ b/lib/asan/asan_thread.cc @@ -93,17 +93,18 @@ void AsanThread::TSDDtor(void *tsd) { } void AsanThread::Destroy() { - VReport(1, "T%d exited\n", tid()); + int tid = this->tid(); + VReport(1, "T%d exited\n", tid); malloc_storage().CommitBack(); if (flags()->use_sigaltstack) UnsetAlternateSignalStack(); - asanThreadRegistry().FinishThread(tid()); + asanThreadRegistry().FinishThread(tid); FlushToDeadThreadStats(&stats_); // We also clear the shadow on thread destruction because // some code may still be executing in later TSD destructors // and we don't want it to have any poisoned stack. ClearShadowForThreadStackAndTLS(); - DeleteFakeStack(); + DeleteFakeStack(tid); uptr size = RoundUpTo(sizeof(AsanThread), GetPageSizeCached()); UnmapOrDie(this, size); } diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 3e612b2c7..6bcb01ba3 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -78,12 +78,12 @@ class AsanThread { return addr >= stack_bottom_ && addr < stack_top_; } - void DeleteFakeStack() { + void DeleteFakeStack(int tid) { if (!fake_stack_) return; FakeStack *t = fake_stack_; fake_stack_ = 0; SetTLSFakeStack(0); - t->Destroy(); + t->Destroy(tid); } bool has_fake_stack() { diff --git a/lib/asan/tests/asan_fake_stack_test.cc b/lib/asan/tests/asan_fake_stack_test.cc index 1c98125eb..ebb4fe281 100644 --- a/lib/asan/tests/asan_fake_stack_test.cc +++ b/lib/asan/tests/asan_fake_stack_test.cc @@ -63,7 +63,7 @@ TEST(FakeStack, CreateDestroy) { for (int i = 0; i < 1000; i++) { for (uptr stack_size_log = 20; stack_size_log <= 22; stack_size_log++) { FakeStack *fake_stack = FakeStack::Create(stack_size_log); - fake_stack->Destroy(); + fake_stack->Destroy(0); } } } @@ -98,7 +98,7 @@ TEST(FakeStack, GetFrame) { EXPECT_EQ(base + 0*stack_size + 64 * 7, fs->GetFrame(stack_size_log, 0, 7U)); EXPECT_EQ(base + 1*stack_size + 128 * 3, fs->GetFrame(stack_size_log, 1, 3U)); EXPECT_EQ(base + 2*stack_size + 256 * 5, fs->GetFrame(stack_size_log, 2, 5U)); - fs->Destroy(); + fs->Destroy(0); } TEST(FakeStack, Allocate) { @@ -127,7 +127,7 @@ TEST(FakeStack, Allocate) { fs->Deallocate(reinterpret_cast<uptr>(it->first), it->second); } } - fs->Destroy(); + fs->Destroy(0); } static void RecursiveFunction(FakeStack *fs, int depth) { @@ -144,7 +144,7 @@ TEST(FakeStack, RecursiveStressTest) { const uptr stack_size_log = 16; FakeStack *fs = FakeStack::Create(stack_size_log); RecursiveFunction(fs, 22); // with 26 runs for 2-3 seconds. - fs->Destroy(); + fs->Destroy(0); } } // namespace __asan |