[compiler-rt] r189801 - ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs.
Alexey Samsonov
samsonov at google.com
Tue Sep 3 06:22:51 PDT 2013
Author: samsonov
Date: Tue Sep 3 08:22:51 2013
New Revision: 189801
URL: http://llvm.org/viewvc/llvm-project?rev=189801&view=rev
Log:
ASan, LSan, MSan: try to find llvm-symbolizer binary in PATH if it is not provided. Now we don't need to explicitly set the location of llvm-symbolizer in lit test configs.
Modified:
compiler-rt/trunk/lib/asan/asan_rtl.cc
compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
compiler-rt/trunk/lib/lsan/lit_tests/AsanConfig/lit.cfg
compiler-rt/trunk/lib/lsan/lit_tests/LsanConfig/lit.cfg
compiler-rt/trunk/lib/lsan/lsan.cc
compiler-rt/trunk/lib/msan/lit_tests/lit.cfg
compiler-rt/trunk/lib/msan/msan.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Sep 3 08:22:51 2013
@@ -532,10 +532,8 @@ void __asan_init() {
InitializeAllocator();
// Start symbolizer process if necessary.
- const char* external_symbolizer = common_flags()->external_symbolizer_path;
- if (common_flags()->symbolize && external_symbolizer &&
- external_symbolizer[0]) {
- InitializeExternalSymbolizer(external_symbolizer);
+ if (common_flags()->symbolize) {
+ InitializeExternalSymbolizer(common_flags()->external_symbolizer_path);
}
// On Linux AsanThread::ThreadStart() calls malloc() that's why asan_inited
Modified: compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/lit.cfg?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/lit.cfg Tue Sep 3 08:22:51 2013
@@ -70,9 +70,6 @@ config.substitutions.append( ("%clang_as
config.substitutions.append( ("%clangxx_asan ", (" " + config.clang + " " +
clang_asan_cxxflags + " ")) )
-# Setup path to external LLVM symbolizer to run AddressSanitizer output tests.
-config.environment['ASAN_SYMBOLIZER_PATH'] = config.llvm_symbolizer_path
-
# Setup path to asan_symbolize.py script.
asan_source_dir = get_required_attr(config, "asan_source_dir")
asan_symbolize = os.path.join(asan_source_dir, "scripts", "asan_symbolize.py")
Modified: compiler-rt/trunk/lib/lsan/lit_tests/AsanConfig/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/AsanConfig/lit.cfg?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/AsanConfig/lit.cfg (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/AsanConfig/lit.cfg Tue Sep 3 08:22:51 2013
@@ -30,4 +30,3 @@ config.substitutions.append( ("%clang_ls
clang_lsan_cflags + " ")) )
config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
-config.environment['ASAN_SYMBOLIZER_PATH'] = config.llvm_symbolizer_path
Modified: compiler-rt/trunk/lib/lsan/lit_tests/LsanConfig/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/LsanConfig/lit.cfg?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/LsanConfig/lit.cfg (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/LsanConfig/lit.cfg Tue Sep 3 08:22:51 2013
@@ -28,5 +28,3 @@ clang_lsan_cflags = config.clang_cflags
config.substitutions.append( ("%clang_lsan ", (" " + config.clang + " " +
clang_lsan_cflags + " ")) )
-
-config.environment['LSAN_SYMBOLIZER_PATH'] = config.llvm_symbolizer_path
Modified: compiler-rt/trunk/lib/lsan/lsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lsan.cc?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/lsan.cc (original)
+++ compiler-rt/trunk/lib/lsan/lsan.cc Tue Sep 3 08:22:51 2013
@@ -25,8 +25,7 @@ namespace __lsan {
static void InitializeCommonFlags() {
CommonFlags *cf = common_flags();
cf->external_symbolizer_path = GetEnv("LSAN_SYMBOLIZER_PATH");
- cf->symbolize = (cf->external_symbolizer_path &&
- cf->external_symbolizer_path[0]);
+ cf->symbolize = true;
cf->strip_path_prefix = "";
cf->fast_unwind_on_malloc = true;
cf->malloc_context_size = 30;
@@ -53,10 +52,8 @@ void Init() {
SetCurrentThread(tid);
// Start symbolizer process if necessary.
- const char* external_symbolizer = common_flags()->external_symbolizer_path;
- if (common_flags()->symbolize && external_symbolizer &&
- external_symbolizer[0]) {
- InitializeExternalSymbolizer(external_symbolizer);
+ if (common_flags()->symbolize) {
+ InitializeExternalSymbolizer(common_flags()->external_symbolizer_path);
}
InitCommonLsan();
Modified: compiler-rt/trunk/lib/msan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/lit_tests/lit.cfg?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/msan/lit_tests/lit.cfg Tue Sep 3 08:22:51 2013
@@ -65,9 +65,6 @@ config.substitutions.append( ("%clangxx_
" ".join([config.clang] + clang_msan_cxxflags) +
" ") )
-# Setup path to external LLVM symbolizer to run MemorySanitizer output tests.
-config.environment['MSAN_SYMBOLIZER_PATH'] = config.llvm_symbolizer_path
-
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
Modified: compiler-rt/trunk/lib/msan/msan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/msan.cc?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/msan.cc (original)
+++ compiler-rt/trunk/lib/msan/msan.cc Tue Sep 3 08:22:51 2013
@@ -324,8 +324,9 @@ void __msan_init() {
}
const char *external_symbolizer = common_flags()->external_symbolizer_path;
+ bool symbolizer_started = InitializeExternalSymbolizer(external_symbolizer);
if (external_symbolizer && external_symbolizer[0]) {
- CHECK(InitializeExternalSymbolizer(external_symbolizer));
+ CHECK(symbolizer_started);
}
GetThreadStackTopAndBottom(/* at_initialization */true,
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer.h Tue Sep 3 08:22:51 2013
@@ -79,7 +79,8 @@ const char *Demangle(const char *name);
const char *DemangleCXXABI(const char *name);
// Starts external symbolizer program in a subprocess. Sanitizer communicates
-// with external symbolizer via pipes.
+// with external symbolizer via pipes. If path_to_symbolizer is NULL or empty,
+// tries to look for llvm-symbolizer in PATH.
bool InitializeExternalSymbolizer(const char *path_to_symbolizer);
const int kSymbolizerStartupTimeMillis = 10;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc?rev=189801&r1=189800&r2=189801&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc Tue Sep 3 08:22:51 2013
@@ -345,6 +345,11 @@ class Symbolizer {
}
bool InitializeExternalSymbolizer(const char *path_to_symbolizer) {
+ if (!path_to_symbolizer || path_to_symbolizer[0] == '\0') {
+ path_to_symbolizer = FindPathToBinary("llvm-symbolizer");
+ if (!path_to_symbolizer)
+ return false;
+ }
int input_fd, output_fd;
if (!StartSymbolizerSubprocess(path_to_symbolizer, &input_fd, &output_fd))
return false;
More information about the llvm-commits
mailing list