diff options
author | Aliaksey Kandratsenka <alk@tut.by> | 2014-08-10 19:38:07 -0700 |
---|---|---|
committer | Aliaksey Kandratsenka <alk@tut.by> | 2014-11-02 18:29:55 -0800 |
commit | 8de46e66fcd2577758ab297b553bb0f468d8a97a (patch) | |
tree | a0da4c1da89cbab2e94ca04bad018978ad2fdcb6 | |
parent | 2e5ee0488996437aeef2028ad95d969b56abcad1 (diff) | |
download | gperftools-8de46e66fcd2577758ab297b553bb0f468d8a97a.tar.gz |
don't add leaf function twice to profile under libunwind
-rw-r--r-- | src/profiler.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/profiler.cc b/src/profiler.cc index a2a4faa..5368106 100644 --- a/src/profiler.cc +++ b/src/profiler.cc @@ -356,9 +356,18 @@ void CpuProfiler::prof_handler(int sig, siginfo_t*, void* signal_ucontext, // profile size unnecessarily. int depth = GetStackTraceWithContext(stack + 1, arraysize(stack) - 1, 2, signal_ucontext); - depth++; // To account for pc value in stack[0]; - instance->collector_.Add(depth, stack); + void **used_stack; + if (stack[1] == stack[0]) { + // in case of libunwind we will have PC in stack[1]. + // We don't want this double PC entry + used_stack = stack + 1; + } else { + used_stack = stack; + depth++; // To account for pc value in stack[0]; + } + + instance->collector_.Add(depth, used_stack); } } |