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

Dan Liew via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 19:38:41 PDT 2020


delcypher created this revision.
delcypher added reviewers: kubamracek, yln, vitalybuka, eugenis, kcc.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
delcypher added a child revision: D77623: [Darwin] Fix a bug where the symbolizer would examine the wrong process..

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 Sanitizer's 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77622

Files:
  compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
  compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp
===================================================================
--- /dev/null
+++ compiler-rt/test/sanitizer_common/TestCases/symbolize_debug_argv.cpp
@@ -0,0 +1,9 @@
+// RUN: %clangxx %s -g -USHARED_LIB -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;
+}
Index: compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
===================================================================
--- compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
+++ compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp
@@ -151,6 +151,16 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77622.255568.patch
Type: text/x-patch
Size: 1411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200407/6e7c5d13/attachment.bin>


More information about the llvm-commits mailing list