[compiler-rt] 2169568 - [Sanitizer Common] Show command used to launch symbolizer process at high verbosity level.

Dan Liew via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 13:36:51 PDT 2020


Author: Dan Liew
Date: 2020-04-13T13:36:29-07:00
New Revision: 2169568d9f535a5ffa921d7ec0869c0f8b18f6ac

URL: https://github.com/llvm/llvm-project/commit/2169568d9f535a5ffa921d7ec0869c0f8b18f6ac
DIFF: https://github.com/llvm/llvm-project/commit/2169568d9f535a5ffa921d7ec0869c0f8b18f6ac.diff

LOG: [Sanitizer Common] Show command used to launch symbolizer process at high verbosity level.

Summary:
In preparation for writing a test for a bug fix we need to be able to
see the command used to launch the symbolizer process. This feature
will likely be useful for debugging how the Sanitizers use the
symbolizer in general.

This patch causes the command line used to launch the process to be
shown at verbosity level 3 and higher.

A small test case is included.

Reviewers: kubamracek, yln, vitalybuka, eugenis, kcc

Subscribers: #sanitizers, llvm-commits

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D77622

Added: 
    compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.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 4c3cd966dd5a..f1dff2408e11 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -151,6 +151,16 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
   GetArgV(path_, argv);
   pid_t pid;
 
+  // Report how symbolizer is being launched for debugging purposes.
+  if (Verbosity() >= 3) {
+    // Only use `Report` for first line so subsequent prints don't get prefixed
+    // with current PID.
+    Report("Launching Symbolizer process: ");
+    for (unsigned index = 0; index < kArgVMax && argv[index]; ++index)
+      Printf("%s ", argv[index]);
+    Printf("\n");
+  }
+
   if (use_posix_spawn_) {
 #if SANITIZER_MAC
     fd_t fd = internal_spawn(argv, const_cast<const char **>(GetEnvP()), &pid);

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp b/compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp
new file mode 100644
index 000000000000..262e50bf7be2
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp
@@ -0,0 +1,9 @@
+// RUN: %clangxx %s -g -o %t
+// RUN: %env_tool_opts=verbosity=3 %run %t 2>&1 | FileCheck %s
+#include <sanitizer/common_interface_defs.h>
+
+int main(int argc, char **argv) {
+  // CHECK: Launching Symbolizer process: {{.+}}
+  __sanitizer_print_stack_trace();
+  return 0;
+}


        


More information about the llvm-commits mailing list