aboutsummaryrefslogtreecommitdiff
path: root/tools/llvm-db
diff options
context:
space:
mode:
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;
}