llvm.org GIT mirror llvm / 5dc796d
bugpoint: disabling symbolication of bugpoint-executed programs Initial implementation - needs similar work/testing for other tools bugpoint invokes (llc, lli I think, maybe more). Alternatively (as suggested by chandlerc@) an environment variable could be used. This would allow the option to pass transparently through user scripts, pass to compilers if they happened to be LLVM-ish, etc. I worry a bit about using cl::opt in the crash handling code - LLVM might crash early, perhaps before the cl::opt is properly initialized? Or at least before arguments have been parsed? - should be OK since it defaults to "pretty", so if the crash is very early in opt parsing, etc, then crash reports will still be symbolized. I shyed away from doing this with an environment variable when I realized that would require copying the existing environment and appending the env variable of interest. But it seems there's no existing LLVM API for accessing the environment (even the Support tests for process launching have their own ifdefs for getting the environment). It could be added, but seemed like a higher bar/untested codepath to actually add environment variables. Most importantly, this reduces the runtime of test/BugPoint/metadata.ll in a split-dwarf Debug build from 1m34s to 6.5s by avoiding a lot of symbolication. (this wasn't a problem for non-split-dwarf builds only because the executable was too large to map into memory (due to bugpoint setting a 400MB memory (including address space - not sure why? Going to remove that) limit on the child process) so symbolication would fail fast & wouldn't spend all that time parsing DWARF, etc) Reviewers: chandlerc, dannyb Differential Revision: https://reviews.llvm.org/D33804 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305056 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 2 years ago
3 changed file(s) with 35 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
2525 #include "llvm/Support/Program.h"
2626 #include "llvm/Support/StringSaver.h"
2727 #include "llvm/Support/raw_ostream.h"
28 #include "llvm/Support/Options.h"
2829 #include
29
30 namespace llvm {
3130
3231 //===----------------------------------------------------------------------===//
3332 //=== WARNING: Implementation here must contain only TRULY operating system
3433 //=== independent code.
3534 //===----------------------------------------------------------------------===//
35
36 using namespace llvm;
37
38 static cl::opt
39 DisableSymbolication("disable-symbolication",
40 cl::desc("Disable symbolizing crash backtraces."),
41 cl::init(false), cl::Hidden);
3642
3743 static ManagedStatic>>
3844 CallBacksToRun;
4349 I.first(I.second);
4450 CallBacksToRun->clear();
4551 }
46 }
47
48 using namespace llvm;
4952
5053 static bool findModulesAndOffsets(void **StackTrace, int Depth,
5154 const char **Modules, intptr_t *Offsets,
6972 static bool printSymbolizedStackTrace(StringRef Argv0,
7073 void **StackTrace, int Depth,
7174 llvm::raw_ostream &OS) {
75 if (DisableSymbolication)
76 return false;
77
7278 // Don't recursively invoke the llvm-symbolizer binary.
7379 if (Argv0.find("llvm-symbolizer") != std::string::npos)
7480 return false;
0 ; REQUIRES: loadable_module
1 ; RUN: echo "import sys" > %t.py
2 ; RUN: echo "print('args = ' + str(sys.argv))" >> %t.py
3 ; RUN: echo "exit(1)" >> %t.py
4 ; RUN: not bugpoint -load %llvmshlibdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashcalls -opt-command="%python" -opt-args %t.py | FileCheck %s
5 ; RUN: not --crash opt -load %llvmshlibdir/BugpointPasses%shlibext %s -bugpoint-crashcalls -disable-symbolication 2>&1 | FileCheck --check-prefix=CRASH %s
6
7 ; Test that bugpoint disables symbolication on the opt tool to reduce runtime overhead when opt crashes
8 ; CHECK: args = {{.*}}'-disable-symbolication'
9
10 ; Test that opt, when it crashes & is passed -disable-symbolication, doesn't symbolicate.
11 ; In theory this test should maybe be in test/tools/opt or
12 ; test/Transforms, but since there doesn't seem to be another convenient way to
13 ; crash opt, apart from the BugpointPasses dynamic plugin, this is the spot for
14 ; now.
15 ; CRASH-NOT: Signals.inc
16
17 define void @f() {
18 call void @f()
19 ret void
20 }
201201 } else
202202 Args.push_back(tool.c_str());
203203
204 for (unsigned i = 0, e = OptArgs.size(); i != e; ++i)
205 Args.push_back(OptArgs[i].c_str());
206 Args.push_back("-disable-symbolication");
204207 Args.push_back("-o");
205208 Args.push_back(OutputFilename.c_str());
206 for (unsigned i = 0, e = OptArgs.size(); i != e; ++i)
207 Args.push_back(OptArgs[i].c_str());
208209 std::vector pass_args;
209210 for (unsigned i = 0, e = PluginLoader::getNumPlugins(); i != e; ++i) {
210211 pass_args.push_back(std::string("-load"));