[compiler-rt] 8df3e1f - Add option to symbolize inline frames for InternalSymbolizer
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 19:57:07 PDT 2020
Author: Vitaly Buka
Date: 2020-06-23T19:56:53-07:00
New Revision: 8df3e1fd86fce6fd39954021bd7501842216dbe8
URL: https://github.com/llvm/llvm-project/commit/8df3e1fd86fce6fd39954021bd7501842216dbe8
DIFF: https://github.com/llvm/llvm-project/commit/8df3e1fd86fce6fd39954021bd7501842216dbe8.diff
LOG: Add option to symbolize inline frames for InternalSymbolizer
Summary:
Currently, there is no way to let the `InternalSymbolizer` implemented
functions know if inline frames should be symbolized. This patch updates
the function `__sanitizer_symbolize_code` to include a parameter for
this ASAN option and toggle between LLVM symbolization functions when
appropriate.
Fixes the following two failing tests when internal symbolization is
enabled:
```
SanitizerCommon-*-x86_64-Linux :: print-stack-trace.cpp
SanitizerCommon-*-x86_64-Linux :: symbolize_pc_inline.cpp
```
Reviewers: vitalybuka, kcc, filcab
Reviewed By: vitalybuka
Subscribers: #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D79280
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
index d7b931bc2379..cbe5b5336b32 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -321,9 +321,10 @@ class Addr2LinePool : public SymbolizerTool {
#if SANITIZER_SUPPORTS_WEAK_HOOKS
extern "C" {
-SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
-bool __sanitizer_symbolize_code(const char *ModuleName, u64 ModuleOffset,
- char *Buffer, int MaxLength);
+SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE bool
+__sanitizer_symbolize_code(const char *ModuleName, u64 ModuleOffset,
+ char *Buffer, int MaxLength,
+ bool SymbolizeInlineFrames);
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
bool __sanitizer_symbolize_data(const char *ModuleName, u64 ModuleOffset,
char *Buffer, int MaxLength);
@@ -346,7 +347,8 @@ class InternalSymbolizer : public SymbolizerTool {
bool SymbolizePC(uptr addr, SymbolizedStack *stack) override {
bool result = __sanitizer_symbolize_code(
- stack->info.module, stack->info.module_offset, buffer_, kBufferSize);
+ stack->info.module, stack->info.module_offset, buffer_, kBufferSize,
+ common_flags()->symbolize_inline_frames);
if (result) ParseSymbolizePCOutput(buffer_, stack);
return result;
}
diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp b/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
index ba285bc1e884..4902be0bf51e 100644
--- a/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
+++ b/compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include <stdio.h>
+
#include <string>
#include "llvm/DebugInfo/Symbolize/DIPrinter.h"
@@ -32,17 +33,25 @@ extern "C" {
typedef uint64_t u64;
bool __sanitizer_symbolize_code(const char *ModuleName, uint64_t ModuleOffset,
- char *Buffer, int MaxLength) {
+ char *Buffer, int MaxLength,
+ bool SymbolizeInlineFrames) {
std::string Result;
{
llvm::raw_string_ostream OS(Result);
llvm::symbolize::DIPrinter Printer(OS);
// TODO: it is neccessary to set proper SectionIndex here.
// object::SectionedAddress::UndefSection works for only absolute addresses.
- auto ResOrErr = getDefaultSymbolizer()->symbolizeInlinedCode(
- ModuleName,
- {ModuleOffset, llvm::object::SectionedAddress::UndefSection});
- Printer << (ResOrErr ? ResOrErr.get() : llvm::DIInliningInfo());
+ if (SymbolizeInlineFrames) {
+ auto ResOrErr = getDefaultSymbolizer()->symbolizeInlinedCode(
+ ModuleName,
+ {ModuleOffset, llvm::object::SectionedAddress::UndefSection});
+ Printer << (ResOrErr ? ResOrErr.get() : llvm::DIInliningInfo());
+ } else {
+ auto ResOrErr = getDefaultSymbolizer()->symbolizeCode(
+ ModuleName,
+ {ModuleOffset, llvm::object::SectionedAddress::UndefSection});
+ Printer << (ResOrErr ? ResOrErr.get() : llvm::DILineInfo());
+ }
}
return __sanitizer::internal_snprintf(Buffer, MaxLength, "%s",
Result.c_str()) < MaxLength;
More information about the llvm-commits
mailing list