summaryrefslogtreecommitdiff
path: root/tools/llvm-db
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2004-12-30 05:36:08 +0000
committerReid Spencer <rspencer@reidspencer.com>2004-12-30 05:36:08 +0000
commit1ef8bdaedbd98bee35a573b8bc87149f2182cb5e (patch)
treedc21da7903997dfbcf6061f19b35a2a522c740b9 /tools/llvm-db
parentc18671cdcd53df08cbeff7ecf443475f61971b9d (diff)
downloadllvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.gz
llvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.bz2
llvm-1ef8bdaedbd98bee35a573b8bc87149f2182cb5e.tar.xz
For PR351:
* Place a try/catch block around the entire tool to Make sure std::string exceptions are caught and printed before exiting the tool. * Make sure we catch unhandled exceptions at the top level so that we don't abort with a useless message but indicate than an unhandled exception was generated. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-db')
-rw-r--r--tools/llvm-db/llvm-db.cpp61
1 files changed, 34 insertions, 27 deletions
diff --git a/tools/llvm-db/llvm-db.cpp b/tools/llvm-db/llvm-db.cpp
index 2e8dc83c95..f7913dfe47 100644
--- a/tools/llvm-db/llvm-db.cpp
+++ b/tools/llvm-db/llvm-db.cpp
@@ -50,39 +50,46 @@ namespace {
// main Driver function
//
int main(int argc, char **argv, char * const *envp) {
- cl::ParseCommandLineOptions(argc, argv,
- " llvm source-level debugger\n");
- sys::PrintStackTraceOnErrorSignal();
+ try {
+ cl::ParseCommandLineOptions(argc, argv,
+ " llvm source-level debugger\n");
+ sys::PrintStackTraceOnErrorSignal();
- if (!Quiet)
- std::cout << "llvm-db: The LLVM source-level debugger\n";
+ if (!Quiet)
+ std::cout << "llvm-db: The LLVM source-level debugger\n";
- // Merge Inputfile and InputArgs into the InputArgs list...
- if (!InputFile.empty() && InputArgs.empty())
- InputArgs.push_back(InputFile);
+ // Merge Inputfile and InputArgs into the InputArgs list...
+ if (!InputFile.empty() && InputArgs.empty())
+ InputArgs.push_back(InputFile);
- // Create the CLI debugger...
- CLIDebugger D;
+ // Create the CLI debugger...
+ CLIDebugger D;
- // Initialize the debugger with the command line options we read...
- Debugger &Dbg = D.getDebugger();
+ // Initialize the debugger with the command line options we read...
+ Debugger &Dbg = D.getDebugger();
- // Initialize the debugger environment.
- Dbg.initializeEnvironment(envp);
- Dbg.setWorkingDirectory(WorkingDirectory);
- for (unsigned i = 0, e = SourceDirectories.size(); i != e; ++i)
- D.addSourceDirectory(SourceDirectories[i]);
-
- if (!InputArgs.empty()) {
- try {
- D.fileCommand(InputArgs[0]);
- } catch (const std::string &Error) {
- std::cout << "Error: " << Error << "\n";
+ // Initialize the debugger environment.
+ Dbg.initializeEnvironment(envp);
+ Dbg.setWorkingDirectory(WorkingDirectory);
+ for (unsigned i = 0, e = SourceDirectories.size(); i != e; ++i)
+ D.addSourceDirectory(SourceDirectories[i]);
+
+ if (!InputArgs.empty()) {
+ try {
+ D.fileCommand(InputArgs[0]);
+ } catch (const std::string &Error) {
+ std::cout << "Error: " << Error << "\n";
+ }
+
+ Dbg.setProgramArguments(InputArgs.begin()+1, InputArgs.end());
}
- Dbg.setProgramArguments(InputArgs.begin()+1, InputArgs.end());
+ // Now that we have initialized the debugger, run it.
+ return D.run();
+ } catch (const std::string& msg) {
+ std::cerr << argv[0] << ": " << msg << "\n";
+ } catch (...) {
+ std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
}
-
- // Now that we have initialized the debugger, run it.
- return D.run();
+ return 1;
}