Skip to content

Commit 6a3b6b5

Browse files
delcypherdanliew-apple
authored andcommitted
[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 (cherry picked from commit 2169568)
1 parent 0bdf7ef commit 6a3b6b5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,16 @@ bool SymbolizerProcess::StartSymbolizerSubprocess() {
151151
GetArgV(path_, argv);
152152
pid_t pid;
153153

154+
// Report how symbolizer is being launched for debugging purposes.
155+
if (Verbosity() >= 3) {
156+
// Only use `Report` for first line so subsequent prints don't get prefixed
157+
// with current PID.
158+
Report("Launching Symbolizer process: ");
159+
for (unsigned index = 0; index < kArgVMax && argv[index]; ++index)
160+
Printf("%s ", argv[index]);
161+
Printf("\n");
162+
}
163+
154164
if (use_posix_spawn_) {
155165
#if SANITIZER_MAC
156166
fd_t fd = internal_spawn(argv, const_cast<const char **>(GetEnvP()), &pid);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clangxx %s -g -o %t
2+
// RUN: %env_tool_opts=verbosity=3 %run %t 2>&1 | FileCheck %s
3+
#include <sanitizer/common_interface_defs.h>
4+
5+
int main(int argc, char **argv) {
6+
// CHECK: Launching Symbolizer process: {{.+}}
7+
__sanitizer_print_stack_trace();
8+
return 0;
9+
}

0 commit comments

Comments
 (0)