From 3ca50c34ec35d459534d922938ae3f3f7acb7987 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 24 Oct 2014 18:34:43 +0000 Subject: [PATCH] Add runtime flag 'symbolize_inline_frames' to disable symbolization of inlined frames done in llvm-symbolizer llvm-svn: 220582 --- compiler-rt/lib/sanitizer_common/sanitizer_flags.cc | 3 +++ compiler-rt/lib/sanitizer_common/sanitizer_flags.h | 1 + .../sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc | 7 ++++++- .../test/sanitizer_common/TestCases/print-stack-trace.cc | 12 ++++++++---- compiler-rt/test/sanitizer_common/lit.common.cfg | 5 +++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc b/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc index 4fb14d7..55644e0 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc @@ -67,6 +67,7 @@ void SetCommonFlagsDefaults(CommonFlags *f) { f->suppressions = ""; f->print_suppressions = true; f->disable_coredump = (SANITIZER_WORDSIZE == 64); + f->symbolize_inline_frames = true; } void ParseCommonFlagsFromString(CommonFlags *f, const char *str) { @@ -158,6 +159,8 @@ void ParseCommonFlagsFromString(CommonFlags *f, const char *str) { "Disable core dumping. By default, disable_core=1 on 64-bit to avoid " "dumping a 16T+ core file. Ignored on OSes that don't dump core by" "default and for sanitizers that don't reserve lots of virtual memory."); + ParseFlag(str, &f->symbolize_inline_frames, "symbolize_inline_frames", + "Print inlined frames in stacktraces. Defaults to true."); // Do a sanity check for certain flags. if (f->malloc_context_size < 1) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_flags.h b/compiler-rt/lib/sanitizer_common/sanitizer_flags.h index a9c5d35..6d1d9b60 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_flags.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_flags.h @@ -61,6 +61,7 @@ struct CommonFlags { const char *suppressions; bool print_suppressions; bool disable_coredump; + bool symbolize_inline_frames; }; inline CommonFlags *common_flags() { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc index dfca523..636fdea 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -348,7 +348,12 @@ class LLVMSymbolizerProcess : public SymbolizerProcess { #else const char* const kSymbolizerArch = "--default-arch=unknown"; #endif - execl(path_to_binary, path_to_binary, kSymbolizerArch, (char *)0); + + const char *const inline_flag = common_flags()->symbolize_inline_frames + ? "--inlining=true" + : "--inlining=false"; + execl(path_to_binary, path_to_binary, inline_flag, kSymbolizerArch, + (char *)0); } }; diff --git a/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc b/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc index d675c75..a842ca6 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc +++ b/compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cc @@ -1,13 +1,14 @@ // RUN: %clangxx -O0 %s -o %t && %run %t 2>&1 | FileCheck %s // RUN: %clangxx -O3 %s -o %t && %run %t 2>&1 | FileCheck %s -// +// RUN: %tool_options=symbolize_inline_frames=false %run %t 2>&1 | FileCheck %s --check-prefix=NOINLINE + // Not yet implemented for TSan. // https://code.google.com/p/address-sanitizer/issues/detail?id=243 // XFAIL: tsan #include -void FooBarBaz() { +static inline void FooBarBaz() { __sanitizer_print_stack_trace(); } @@ -16,5 +17,8 @@ int main() { return 0; } // CHECK: {{ #0 0x.* in __sanitizer_print_stack_trace}} -// CHECK: {{ #1 0x.* in FooBarBaz(\(\))? .*print-stack-trace.cc:11}} -// CHECK: {{ #2 0x.* in main.*print-stack-trace.cc:15}} +// CHECK: {{ #1 0x.* in FooBarBaz(\(\))? .*print-stack-trace.cc:12}} +// CHECK: {{ #2 0x.* in main.*print-stack-trace.cc:16}} + +// NOINLINE: #0 0x{{.*}} in __sanitizer_print_stack_trace +// NOINLINE: #1 0x{{.*}} in main{{.*}}print-stack-trace.cc:12 diff --git a/compiler-rt/test/sanitizer_common/lit.common.cfg b/compiler-rt/test/sanitizer_common/lit.common.cfg index 3b44e00..fb37815 100644 --- a/compiler-rt/test/sanitizer_common/lit.common.cfg +++ b/compiler-rt/test/sanitizer_common/lit.common.cfg @@ -7,12 +7,16 @@ config.name = "SanitizerCommon-" + config.tool_name if config.tool_name == "asan": tool_cflags = ["-fsanitize=address"] + tool_options = "ASAN_OPTIONS" elif config.tool_name == "tsan": tool_cflags = ["-fsanitize=thread"] + tool_options = "TSAN_OPTIONS" elif config.tool_name == "msan": tool_cflags = ["-fsanitize=memory"] + tool_options = "MSAN_OPTIONS" elif config.tool_name == "lsan": tool_cflags = ["-fsanitize=leak"] + tool_options = "LSAN_OPTIONS" else: lit_config.fatal("Unknown tool for sanitizer_common tests: %r" % config.tool_name) @@ -26,6 +30,7 @@ def build_invocation(compile_flags): config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) ) config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) ) +config.substitutions.append( ("%tool_options", tool_options) ) config.suffixes = ['.c', '.cc', '.cpp'] -- 2.7.4