mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
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
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user