diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-10-02 17:01:18 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2018-10-02 17:01:18 +0000 |
commit | 83e57e21234ae8675ca50701dfeb6ac324a749f1 (patch) | |
tree | f53861b54d51284dbf5e2abe7ab0ca2099ea2a8c /compiler-rt/lib/sanitizer_common | |
parent | a35e55eff9cdf932b9dae7775ee6edb53e84825d (diff) | |
download | bcm5719-llvm-83e57e21234ae8675ca50701dfeb6ac324a749f1.tar.gz bcm5719-llvm-83e57e21234ae8675ca50701dfeb6ac324a749f1.zip |
[sanitizer] Include inlined frames into __sanitizer_symbolize_pc output
Summary:
Behavior for existing used is not changing as the first line is going
to be the same, and it was invalid to try to read more lines.
New clients can read until they get empty string.
Reviewers: eugenis, morehouse
Subscribers: kubamracek, eraman, llvm-commits
Differential Revision: https://reviews.llvm.org/D52743
llvm-svn: 343605
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc index 747a4a70172..c87b18e1b69 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc @@ -114,11 +114,25 @@ void __sanitizer_symbolize_pc(uptr pc, const char *fmt, char *out_buf, return; } InternalScopedString frame_desc(GetPageSizeCached()); - RenderFrame(&frame_desc, fmt, 0, frame->info, - common_flags()->symbolize_vs_style, - common_flags()->strip_path_prefix); - internal_strncpy(out_buf, frame_desc.data(), out_buf_size); - out_buf[out_buf_size - 1] = 0; + uptr frame_num = 0; + // Reserve one byte for the final 0. + char *out_end = out_buf + out_buf_size - 1; + for (SymbolizedStack *cur = frame; cur && out_buf < out_end; + cur = cur->next) { + frame_desc.clear(); + RenderFrame(&frame_desc, fmt, frame_num++, cur->info, + common_flags()->symbolize_vs_style, + common_flags()->strip_path_prefix); + if (!frame_desc.length()) + continue; + // Reserve one byte for the terminating 0. + uptr n = out_end - out_buf - 1; + internal_strncpy(out_buf, frame_desc.data(), n); + out_buf += __sanitizer::Min<uptr>(n, frame_desc.length()); + *out_buf++ = 0; + } + CHECK(out_buf <= out_end); + *out_buf = 0; } SANITIZER_INTERFACE_ATTRIBUTE |