diff options
author | Kostya Serebryany <kcc@google.com> | 2013-10-18 14:50:44 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-10-18 14:50:44 +0000 |
commit | 6d95869fa900da9ddd68e15e2aa065854cfa176b (patch) | |
tree | 56c2d87779d8736d1ca4016d6974f89424f61670 | |
parent | acd18b94d494ea946599ae40425ef9ee670b0183 (diff) | |
download | compiler-rt-6d95869fa900da9ddd68e15e2aa065854cfa176b.tar.gz compiler-rt-6d95869fa900da9ddd68e15e2aa065854cfa176b.tar.bz2 compiler-rt-6d95869fa900da9ddd68e15e2aa065854cfa176b.tar.xz |
[asan] reduce the size of AsanThreadContext by storing the stack trace in the stack depot
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@192979 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/asan_report.cc | 5 | ||||
-rw-r--r-- | lib/asan/asan_stack.cc | 7 | ||||
-rw-r--r-- | lib/asan/asan_stack.h | 1 | ||||
-rw-r--r-- | lib/asan/asan_thread.cc | 6 | ||||
-rw-r--r-- | lib/asan/asan_thread.h | 8 |
5 files changed, 17 insertions, 10 deletions
diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc index 864c3e96..c62e00be 100644 --- a/lib/asan/asan_report.cc +++ b/lib/asan/asan_report.cc @@ -20,6 +20,7 @@ #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_flags.h" #include "sanitizer_common/sanitizer_report_decorator.h" +#include "sanitizer_common/sanitizer_stackdepot.h" #include "sanitizer_common/sanitizer_symbolizer.h" namespace __asan { @@ -485,7 +486,9 @@ void DescribeThread(AsanThreadContext *context) { context->parent_tid, ThreadNameWithParenthesis(context->parent_tid, tname, sizeof(tname))); - PrintStack(&context->stack); + uptr stack_size; + const uptr *stack_trace = StackDepotGet(context->stack_id, &stack_size); + PrintStack(stack_trace, stack_size); // Recursively described parent thread if needed. if (flags()->print_full_thread_history) { AsanThreadContext *parent_context = diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index ca75f630..aec75818 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -24,10 +24,13 @@ static bool MaybeCallAsanSymbolize(const void *pc, char *out_buffer, : false; } -void PrintStack(StackTrace *stack) { - StackTrace::PrintStack(stack->trace, stack->size, common_flags()->symbolize, +void PrintStack(const uptr *trace, uptr size) { + StackTrace::PrintStack(trace, size, common_flags()->symbolize, MaybeCallAsanSymbolize); } +void PrintStack(StackTrace *stack) { + PrintStack(stack->trace, stack->size); +} } // namespace __asan diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index fefd76b5..7f5fd661 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -22,6 +22,7 @@ namespace __asan { void PrintStack(StackTrace *stack); +void PrintStack(const uptr *trace, uptr size); } // namespace __asan diff --git a/lib/asan/asan_thread.cc b/lib/asan/asan_thread.cc index 5f75f600..a52ab5a0 100644 --- a/lib/asan/asan_thread.cc +++ b/lib/asan/asan_thread.cc @@ -19,6 +19,7 @@ #include "asan_mapping.h" #include "sanitizer_common/sanitizer_common.h" #include "sanitizer_common/sanitizer_placement_new.h" +#include "sanitizer_common/sanitizer_stackdepot.h" #include "lsan/lsan_common.h" namespace __asan { @@ -27,9 +28,8 @@ namespace __asan { void AsanThreadContext::OnCreated(void *arg) { CreateThreadContextArgs *args = static_cast<CreateThreadContextArgs*>(arg); - if (args->stack) { - internal_memcpy(&stack, args->stack, sizeof(stack)); - } + if (args->stack) + stack_id = StackDepotPut(args->stack->trace, args->stack->size); thread = args->thread; thread->set_context(this); } diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 5d0a6c94..11771ecd 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -38,12 +38,12 @@ class AsanThreadContext : public ThreadContextBase { : ThreadContextBase(tid), announced(false), destructor_iterations(kPthreadDestructorIterations), + stack_id(0), thread(0) { - internal_memset(&stack, 0, sizeof(stack)); } bool announced; - int destructor_iterations; - StackTrace stack; + u8 destructor_iterations; + u32 stack_id; AsanThread *thread; void OnCreated(void *arg); @@ -51,7 +51,7 @@ class AsanThreadContext : public ThreadContextBase { }; // AsanThreadContext objects are never freed, so we need many of them. -COMPILER_CHECK(sizeof(AsanThreadContext) <= 4096); +COMPILER_CHECK(sizeof(AsanThreadContext) <= 256); // AsanThread are stored in TSD and destroyed when the thread dies. class AsanThread { |