llvm.org GIT mirror llvm / cc14d25
Change various llvm utilities to use PrettyStackTraceProgram in their main routines. This makes the tools print their argc/argv commands if they crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66248 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
16 changed file(s) with 112 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
406406 return true;
407407 }
408408
409 struct APIntUnsignedOrdering {
410 bool operator()(const APInt &LHS, const APInt &RHS) const {
411 return LHS.ult(RHS);
412 }
413 };
414
409415 /// ProcessSwitchOnDuplicateCond - We found a block and a predecessor of that
410416 /// block that switch on exactly the same condition. This means that we almost
411417 /// always know the direction of the edge in the DESTBB:
473479 return true;
474480 }
475481
482 #if 0
483 // Figure out on which of the condition allow us to get to DESTBB. If DESTBB
484 // is the default label, we compute the set of values COND is known not to be
485 // otherwise we compute the set of options that COND could be.
486 SmallVector KnownValues;
487 bool DestBBIsDefault = PredSI->getSuccessor(0) == DestBB;
488
489 if (DestBBIsDefault) {
490 // DestBB the default case. Collect the values where PredBB can't branch to
491 // DestBB.
492 for (unsigned i = 1/*skip default*/, e = PredSI->getNumCases(); i != e; ++i)
493 if (PredSI->getSuccessor(i) != DestBB)
494 KnownValues.push_back(PredSI->getCaseValue(i)->getValue());
495 } else {
496 // Not the default case. Collect the values where PredBB can branch to
497 // DestBB.
498 for (unsigned i = 1/*skip default*/, e = PredSI->getNumCases(); i != e; ++i)
499 if (PredSI->getSuccessor(i) == DestBB)
500 KnownValues.push_back(PredSI->getCaseValue(i)->getValue());
501 }
502
503 std::sort(KnownValues.begin(), KnownValues.end(), APIntUnsignedOrdering());
504 return false;
505 cerr << "\nFOUND THREAD BLOCKS:\n";
506 PredBB->dump();
507 DestBB->dump();
508 #endif
509
476510 return false;
477511 }
478512
1919 #include "llvm/Support/CommandLine.h"
2020 #include "llvm/Support/ManagedStatic.h"
2121 #include "llvm/Support/PluginLoader.h"
22 #include "llvm/Support/PrettyStackTrace.h"
2223 #include "llvm/System/Process.h"
2324 #include "llvm/System/Signals.h"
2425 #include "llvm/LinkAllVMCore.h"
6364 }
6465
6566 int main(int argc, char **argv) {
66 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
67 llvm::sys::PrintStackTraceOnErrorSignal();
68 llvm::PrettyStackTraceProgram X(argc, argv);
69 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
6770 cl::ParseCommandLineOptions(argc, argv,
6871 "LLVM automatic testcase reducer. See\nhttp://"
6972 "llvm.org/cmds/bugpoint.html"
7073 " for more information.\n");
71 sys::PrintStackTraceOnErrorSignal();
7274 sys::SetInterruptFunction(BugpointInterruptFunction);
7375
7476 BugDriver D(argv[0], AsChild, FindBugs, TimeoutValue, MemoryLimit);
3030 #include "llvm/Support/ManagedStatic.h"
3131 #include "llvm/Support/MemoryBuffer.h"
3232 #include "llvm/Support/PluginLoader.h"
33 #include "llvm/Support/PrettyStackTrace.h"
3334 #include "llvm/Support/RegistryParser.h"
3435 #include "llvm/Support/raw_ostream.h"
3536 #include "llvm/Analysis/Verifier.h"
191192 // main - Entry point for the llc compiler.
192193 //
193194 int main(int argc, char **argv) {
194 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
195 sys::PrintStackTraceOnErrorSignal();
196 PrettyStackTraceProgram X(argc, argv);
197 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
195198 cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
196 sys::PrintStackTraceOnErrorSignal();
197199
198200 // Load the module to be compiled...
199201 std::string ErrorMessage;
2424 #include "llvm/Support/ManagedStatic.h"
2525 #include "llvm/Support/MemoryBuffer.h"
2626 #include "llvm/Support/PluginLoader.h"
27 #include "llvm/Support/PrettyStackTrace.h"
2728 #include "llvm/System/Process.h"
2829 #include "llvm/System/Signals.h"
2930 #include
8283 // main Driver function
8384 //
8485 int main(int argc, char **argv, char * const *envp) {
86 sys::PrintStackTraceOnErrorSignal();
87 PrettyStackTraceProgram X(argc, argv);
88
8589 atexit(do_shutdown); // Call llvm_shutdown() on exit.
8690 cl::ParseCommandLineOptions(argc, argv,
8791 "llvm interpreter & dynamic compiler\n");
88 sys::PrintStackTraceOnErrorSignal();
8992
9093 // If the user doesn't want core files, disable them.
9194 if (DisableCoreFiles)
1515 #include "llvm/Bitcode/Archive.h"
1616 #include "llvm/Support/CommandLine.h"
1717 #include "llvm/Support/ManagedStatic.h"
18 #include "llvm/Support/PrettyStackTrace.h"
1819 #include "llvm/System/Signals.h"
1920 #include
2021 #include
685686
686687 // main - main program for llvm-ar .. see comments in the code
687688 int main(int argc, char **argv) {
688 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
689 // Print a stack trace if we signal out.
690 sys::PrintStackTraceOnErrorSignal();
691 PrettyStackTraceProgram X(argc, argv);
692 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
689693
690694 // Have the command line options parsed and handle things
691695 // like --help and --version.
693697 "LLVM Archiver (llvm-ar)\n\n"
694698 " This program archives bitcode files into single libraries\n"
695699 );
696
697 // Print a stack trace if we signal out.
698 sys::PrintStackTraceOnErrorSignal();
699700
700701 int exitCode = 0;
701702
2020 #include "llvm/Bitcode/ReaderWriter.h"
2121 #include "llvm/Support/CommandLine.h"
2222 #include "llvm/Support/ManagedStatic.h"
23 #include "llvm/Support/PrettyStackTrace.h"
2324 #include "llvm/Support/Streams.h"
2425 #include "llvm/Support/SystemUtils.h"
2526 #include "llvm/Support/raw_ostream.h"
5051 cl::desc("Do not run verifier on input LLVM (dangerous!)"));
5152
5253 int main(int argc, char **argv) {
53 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
54 // Print a stack trace if we signal out.
55 sys::PrintStackTraceOnErrorSignal();
56 PrettyStackTraceProgram X(argc, argv);
57 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
5458 cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");
55 sys::PrintStackTraceOnErrorSignal();
5659
5760 int exitCode = 0;
5861 std::ostream *Out = 0;
3232 #include "llvm/Support/CommandLine.h"
3333 #include "llvm/Support/ManagedStatic.h"
3434 #include "llvm/Support/MemoryBuffer.h"
35 #include "llvm/Support/PrettyStackTrace.h"
3536 #include "llvm/System/Signals.h"
3637 #include
3738 #include
500501
501502
502503 int main(int argc, char **argv) {
503 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
504 // Print a stack trace if we signal out.
505 sys::PrintStackTraceOnErrorSignal();
506 PrettyStackTraceProgram X(argc, argv);
507 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
504508 cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n");
505509
506 sys::PrintStackTraceOnErrorSignal();
507
508510 return AnalyzeBitcode();
509511 }
1414 #include "CLIDebugger.h"
1515 #include "llvm/Support/CommandLine.h"
1616 #include "llvm/Support/ManagedStatic.h"
17 #include "llvm/Support/PrettyStackTrace.h"
1718 #include "llvm/System/Signals.h"
1819 #include
1920 using namespace llvm;
4849 // main Driver function
4950 //
5051 int main(int argc, char **argv, char * const *envp) {
51 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
52 // Print a stack trace if we signal out.
53 sys::PrintStackTraceOnErrorSignal();
54 PrettyStackTraceProgram X(argc, argv);
55
56 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
5257 std::cout << "NOTE: llvm-db is known useless right now.\n";
5358 try {
5459 cl::ParseCommandLineOptions(argc, argv,
5560 "llvm source-level debugger\n");
56 sys::PrintStackTraceOnErrorSignal();
5761
5862 if (!Quiet)
5963 std::cout << "llvm-db: The LLVM source-level debugger\n";
2222 #include "llvm/Support/CommandLine.h"
2323 #include "llvm/Support/ManagedStatic.h"
2424 #include "llvm/Support/MemoryBuffer.h"
25 #include "llvm/Support/PrettyStackTrace.h"
2526 #include "llvm/Support/Streams.h"
2627 #include "llvm/Support/raw_ostream.h"
2728 #include "llvm/System/Signals.h"
4445 DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
4546
4647 int main(int argc, char **argv) {
47 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
48 // Print a stack trace if we signal out.
49 sys::PrintStackTraceOnErrorSignal();
50 PrettyStackTraceProgram X(argc, argv);
51
52 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
4853 try {
4954 cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
50 sys::PrintStackTraceOnErrorSignal();
5155
5256 std::ostream *Out = &std::cout; // Default to printing to stdout.
5357 std::string ErrorMessage;
1919 #include "llvm/Support/CommandLine.h"
2020 #include "llvm/Support/ManagedStatic.h"
2121 #include "llvm/Support/MemoryBuffer.h"
22 #include "llvm/Support/PrettyStackTrace.h"
2223 #include "llvm/System/Signals.h"
2324 #include
2425 #include
5556 cl::value_desc("global"));
5657
5758 int main(int argc, char **argv) {
58 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
59 // Print a stack trace if we signal out.
60 sys::PrintStackTraceOnErrorSignal();
61 PrettyStackTraceProgram X(argc, argv);
62
63 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
5964 cl::ParseCommandLineOptions(argc, argv, "llvm extractor\n");
60 sys::PrintStackTraceOnErrorSignal();
6165
6266 std::auto_ptr M;
6367
3232 #include "llvm/Support/FileUtilities.h"
3333 #include "llvm/Support/ManagedStatic.h"
3434 #include "llvm/Support/MemoryBuffer.h"
35 #include "llvm/Support/PrettyStackTrace.h"
3536 #include "llvm/Support/Streams.h"
3637 #include "llvm/Support/SystemUtils.h"
3738 #include "llvm/System/Signals.h"
500501 }
501502
502503 int main(int argc, char **argv, char **envp) {
503 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
504 // Print a stack trace if we signal out.
505 sys::PrintStackTraceOnErrorSignal();
506 PrettyStackTraceProgram X(argc, argv);
507
508 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
504509 try {
505510 // Initial global variable above for convenience printing of program name.
506511 progname = sys::Path(argv[0]).getBasename();
507512
508513 // Parse the command line options
509514 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
510 sys::PrintStackTraceOnErrorSignal();
511515
512516 // Construct a Linker (now that Verbose is set)
513517 Linker TheLinker(progname, OutputFilename, Verbose);
1818 #include "llvm/Support/CommandLine.h"
1919 #include "llvm/Support/ManagedStatic.h"
2020 #include "llvm/Support/MemoryBuffer.h"
21 #include "llvm/Support/PrettyStackTrace.h"
2122 #include "llvm/Support/Streams.h"
2223 #include "llvm/System/Signals.h"
2324 #include "llvm/System/Path.h"
7879 }
7980
8081 int main(int argc, char **argv) {
81 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
82 // Print a stack trace if we signal out.
83 sys::PrintStackTraceOnErrorSignal();
84 PrettyStackTraceProgram X(argc, argv);
85
86 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
8287 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
83 sys::PrintStackTraceOnErrorSignal();
84 assert(InputFilenames.size() > 0 && "OneOrMore is not working");
8588
8689 unsigned BaseArg = 0;
8790 std::string ErrorMessage;
2121 #include "llvm/Support/CommandLine.h"
2222 #include "llvm/Support/ManagedStatic.h"
2323 #include "llvm/Support/MemoryBuffer.h"
24 #include "llvm/Support/PrettyStackTrace.h"
2425 #include "llvm/System/Signals.h"
2526 #include
2627 #include
165166 }
166167
167168 int main(int argc, char **argv) {
168 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
169 // Print a stack trace if we signal out.
170 sys::PrintStackTraceOnErrorSignal();
171 PrettyStackTraceProgram X(argc, argv);
172
173 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
169174 cl::ParseCommandLineOptions(argc, argv, "llvm symbol table dumper\n");
170 sys::PrintStackTraceOnErrorSignal();
171175
172176 ToolName = argv[0];
173177 if (BSDFormat) OutputFormat = bsd;
2020 #include "llvm/Support/CommandLine.h"
2121 #include "llvm/Support/ManagedStatic.h"
2222 #include "llvm/Support/MemoryBuffer.h"
23 #include "llvm/Support/PrettyStackTrace.h"
2324 #include "llvm/Support/raw_ostream.h"
2425 #include "llvm/System/Signals.h"
2526 #include
110111
111112
112113 int main(int argc, char **argv) {
113 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
114 // Print a stack trace if we signal out.
115 sys::PrintStackTraceOnErrorSignal();
116 PrettyStackTraceProgram X(argc, argv);
117
118 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
114119 try {
115120 cl::ParseCommandLineOptions(argc, argv, "llvm profile dump decoder\n");
116 sys::PrintStackTraceOnErrorSignal();
117121
118122 // Read in the bitcode file...
119123 std::string ErrorMessage;
1414 #include "llvm/Bitcode/Archive.h"
1515 #include "llvm/Support/CommandLine.h"
1616 #include "llvm/Support/ManagedStatic.h"
17 #include "llvm/Support/PrettyStackTrace.h"
1718 #include "llvm/System/Signals.h"
1819 #include
1920 #include
4142 }
4243
4344 int main(int argc, char **argv) {
44 llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
45 // Print a stack trace if we signal out.
46 llvm::sys::PrintStackTraceOnErrorSignal();
47 llvm::PrettyStackTraceProgram X(argc, argv);
48
49 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
4550
4651 // Have the command line options parsed and handle things
4752 // like --help and --version.
5055 " This program adds or updates an index of bitcode symbols\n"
5156 " to an LLVM archive file."
5257 );
53
54 // Print a stack trace if we signal out.
55 sys::PrintStackTraceOnErrorSignal();
5658
5759 int exitCode = 0;
5860
2121 #include "llvm/System/Signals.h"
2222 #include "llvm/Support/FileUtilities.h"
2323 #include "llvm/Support/MemoryBuffer.h"
24 #include "llvm/Support/PrettyStackTrace.h"
2425 #include "CallingConvEmitter.h"
2526 #include "CodeEmitterGen.h"
2627 #include "RegisterInfoEmitter.h"
129130 }
130131
131132 int main(int argc, char **argv) {
133 sys::PrintStackTraceOnErrorSignal();
134 PrettyStackTraceProgram X(argc, argv);
132135 cl::ParseCommandLineOptions(argc, argv);
133136
134137 // Parse the input file.