forked from OSchip/llvm-project
[sanitizer] Move internal_symbolizer "inline" option
This option is per process anyway. I'd like to add more options, but having them as parameters of __sanitizer_symbolize_code looks inconvenient. Reviewed By: browneee Differential Revision: https://reviews.llvm.org/D116201
This commit is contained in:
parent
eafc64ed63
commit
f103ee2e9e
|
@ -11,3 +11,4 @@ INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_code)
|
|||
INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_data)
|
||||
INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_demangle)
|
||||
INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_flush)
|
||||
INTERFACE_WEAK_FUNCTION(__sanitizer_symbolize_set_inline_frames)
|
||||
|
|
|
@ -319,8 +319,7 @@ class Addr2LinePool final : public SymbolizerTool {
|
|||
extern "C" {
|
||||
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE bool
|
||||
__sanitizer_symbolize_code(const char *ModuleName, u64 ModuleOffset,
|
||||
char *Buffer, int MaxLength,
|
||||
bool SymbolizeInlineFrames);
|
||||
char *Buffer, int MaxLength);
|
||||
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE bool
|
||||
__sanitizer_symbolize_data(const char *ModuleName, u64 ModuleOffset,
|
||||
char *Buffer, int MaxLength);
|
||||
|
@ -328,11 +327,16 @@ SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
|
|||
__sanitizer_symbolize_flush();
|
||||
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE int
|
||||
__sanitizer_symbolize_demangle(const char *Name, char *Buffer, int MaxLength);
|
||||
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE bool
|
||||
__sanitizer_symbolize_set_inline_frames(bool InlineFrames);
|
||||
} // extern "C"
|
||||
|
||||
class InternalSymbolizer final : public SymbolizerTool {
|
||||
public:
|
||||
static InternalSymbolizer *get(LowLevelAllocator *alloc) {
|
||||
if (__sanitizer_symbolize_set_inline_frames)
|
||||
CHECK(__sanitizer_symbolize_set_inline_frames(
|
||||
common_flags()->symbolize_inline_frames));
|
||||
if (__sanitizer_symbolize_code && __sanitizer_symbolize_data)
|
||||
return new (*alloc) InternalSymbolizer();
|
||||
return 0;
|
||||
|
@ -340,8 +344,7 @@ class InternalSymbolizer final : public SymbolizerTool {
|
|||
|
||||
bool SymbolizePC(uptr addr, SymbolizedStack *stack) override {
|
||||
bool result = __sanitizer_symbolize_code(
|
||||
stack->info.module, stack->info.module_offset, buffer_, kBufferSize,
|
||||
common_flags()->symbolize_inline_frames);
|
||||
stack->info.module, stack->info.module_offset, buffer_, kBufferSize);
|
||||
if (result)
|
||||
ParseSymbolizePCOutput(buffer_, stack);
|
||||
return result;
|
||||
|
|
|
@ -17,10 +17,15 @@
|
|||
#include "llvm/DebugInfo/Symbolize/DIPrinter.h"
|
||||
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
|
||||
|
||||
static llvm::symbolize::LLVMSymbolizer *Symbolizer = nullptr;
|
||||
static bool InlineFrames = true;
|
||||
|
||||
static llvm::symbolize::LLVMSymbolizer *getDefaultSymbolizer() {
|
||||
static llvm::symbolize::LLVMSymbolizer *DefaultSymbolizer =
|
||||
new llvm::symbolize::LLVMSymbolizer();
|
||||
return DefaultSymbolizer;
|
||||
if (Symbolizer)
|
||||
return Symbolizer;
|
||||
llvm::symbolize::LLVMSymbolizer::Options Opts;
|
||||
Symbolizer = new llvm::symbolize::LLVMSymbolizer(Opts);
|
||||
return Symbolizer;
|
||||
}
|
||||
|
||||
static llvm::symbolize::PrinterConfig getDefaultPrinterConfig() {
|
||||
|
@ -43,8 +48,7 @@ extern "C" {
|
|||
typedef uint64_t u64;
|
||||
|
||||
bool __sanitizer_symbolize_code(const char *ModuleName, uint64_t ModuleOffset,
|
||||
char *Buffer, int MaxLength,
|
||||
bool SymbolizeInlineFrames) {
|
||||
char *Buffer, int MaxLength) {
|
||||
std::string Result;
|
||||
{
|
||||
llvm::raw_string_ostream OS(Result);
|
||||
|
@ -55,7 +59,7 @@ bool __sanitizer_symbolize_code(const char *ModuleName, uint64_t ModuleOffset,
|
|||
|
||||
// TODO: it is neccessary to set proper SectionIndex here.
|
||||
// object::SectionedAddress::UndefSection works for only absolute addresses.
|
||||
if (SymbolizeInlineFrames) {
|
||||
if (InlineFrames) {
|
||||
auto ResOrErr = getDefaultSymbolizer()->symbolizeInlinedCode(
|
||||
ModuleName,
|
||||
{ModuleOffset, llvm::object::SectionedAddress::UndefSection});
|
||||
|
@ -93,7 +97,10 @@ bool __sanitizer_symbolize_data(const char *ModuleName, uint64_t ModuleOffset,
|
|||
Result.c_str()) < MaxLength;
|
||||
}
|
||||
|
||||
void __sanitizer_symbolize_flush() { getDefaultSymbolizer()->flush(); }
|
||||
void __sanitizer_symbolize_flush() {
|
||||
if (Symbolizer)
|
||||
Symbolizer->flush();
|
||||
}
|
||||
|
||||
int __sanitizer_symbolize_demangle(const char *Name, char *Buffer,
|
||||
int MaxLength) {
|
||||
|
@ -105,6 +112,11 @@ int __sanitizer_symbolize_demangle(const char *Name, char *Buffer,
|
|||
: 0;
|
||||
}
|
||||
|
||||
bool __sanitizer_symbolize_set_inline_frames(bool Value) {
|
||||
InlineFrames = Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Override __cxa_atexit and ignore callbacks.
|
||||
// This prevents crashes in a configuration when the symbolizer
|
||||
// is built into sanitizer runtime and consequently into the test process.
|
||||
|
|
|
@ -159,6 +159,7 @@ SYMBOLIZER_API_LIST=__sanitizer_symbolize_code
|
|||
SYMBOLIZER_API_LIST+=,__sanitizer_symbolize_data
|
||||
SYMBOLIZER_API_LIST+=,__sanitizer_symbolize_flush
|
||||
SYMBOLIZER_API_LIST+=,__sanitizer_symbolize_demangle
|
||||
SYMBOLIZER_API_LIST+=,__sanitizer_symbolize_set_inline_frames
|
||||
|
||||
LIBCXX_ARCHIVE_DIR=$(dirname $(find $LIBCXX_BUILD -name libc++.a | head -n1))
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ __sanitizer_symbolize_code T
|
|||
__sanitizer_symbolize_data T
|
||||
__sanitizer_symbolize_demangle T
|
||||
__sanitizer_symbolize_flush T
|
||||
__sanitizer_symbolize_set_inline_frames T
|
||||
__strdup U
|
||||
__udivdi3 U
|
||||
__umoddi3 U
|
||||
|
|
|
@ -6,3 +6,4 @@ ___sanitizer_symbolize_code
|
|||
___sanitizer_symbolize_data
|
||||
___sanitizer_symbolize_demangle
|
||||
___sanitizer_symbolize_flush
|
||||
___sanitizer_symbolize_set_inline_frames
|
||||
|
|
Loading…
Reference in New Issue