diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2014-11-03 22:23:44 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-11-03 22:23:44 +0000 |
| commit | 40733a8024776d7fe088f433a234f85bfc91692f (patch) | |
| tree | cf0cae88305f4e578d476cd71c28b3aaefdb1f38 /compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc | |
| parent | 46ecdeecc4931d42b9d28b38de0081f6d7c0adc6 (diff) | |
| download | bcm5719-llvm-40733a8024776d7fe088f433a234f85bfc91692f.tar.gz bcm5719-llvm-40733a8024776d7fe088f433a234f85bfc91692f.zip | |
[TSan] Use StackTrace from sanitizer_common where applicable
Summary:
This change removes `__tsan::StackTrace` class. There are
now three alternatives:
# Lightweight `__sanitizer::StackTrace`, which doesn't own a buffer
of PCs. It is used in functions that need stack traces in read-only
mode, and helps to prevent unnecessary allocations/copies (e.g.
for StackTraces fetched from StackDepot).
# `__sanitizer::BufferedStackTrace`, which stores buffer of PCs in
a constant array. It is used in TraceHeader (non-Go version)
# `__tsan::VarSizeStackTrace`, which owns buffer of PCs, dynamically
allocated via TSan internal allocator.
Test Plan: compiler-rt test suite
Reviewers: dvyukov, kcc
Reviewed By: kcc
Subscribers: llvm-commits, kcc
Differential Revision: http://reviews.llvm.org/D6004
llvm-svn: 221194
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc')
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc index 0f516a1e4fa..04acd5c8752 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc @@ -36,6 +36,15 @@ uptr StackTrace::GetCurrentPc() { return GET_CALLER_PC(); } +void BufferedStackTrace::Init(const uptr *pcs, uptr cnt, uptr extra_top_pc) { + size = cnt + !!extra_top_pc; + CHECK_LE(size, kStackTraceMax); + internal_memcpy(trace_buffer, pcs, cnt * sizeof(trace_buffer[0])); + if (extra_top_pc) + trace_buffer[cnt] = extra_top_pc; + top_frame_bp = 0; +} + // Check if given pointer points into allocated stack area. static inline bool IsValidFrame(uptr frame, uptr stack_top, uptr stack_bottom) { return frame > stack_bottom && frame < stack_top - 2 * sizeof (uhwptr); |

