aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-nm
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
commit996ec72d48e86d16dc14b1c014be4c13d2f1f686 (patch)
tree388b95aebb8676f1fcbf8447e60a06c6223ed613 /llvm/tools/llvm-nm
parenta6d9c1415ce032235324f70cd074a4bad4c1cb86 (diff)
downloadllvm-996ec72d48e86d16dc14b1c014be4c13d2f1f686.zip
llvm-996ec72d48e86d16dc14b1c014be4c13d2f1f686.tar.gz
llvm-996ec72d48e86d16dc14b1c014be4c13d2f1f686.tar.bz2
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. llvm-svn: 19192
Diffstat (limited to 'llvm/tools/llvm-nm')
-rw-r--r--llvm/tools/llvm-nm/llvm-nm.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index ba5e031..4234905 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -152,20 +152,27 @@ void DumpSymbolNamesFromFile (std::string &Filename) {
}
int main(int argc, char **argv) {
- cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
- sys::PrintStackTraceOnErrorSignal();
-
- ToolName = argv[0];
- if (BSDFormat) OutputFormat = bsd;
- if (POSIXFormat) OutputFormat = posix;
+ try {
+ cl::ParseCommandLineOptions(argc, argv, " llvm symbol table dumper\n");
+ sys::PrintStackTraceOnErrorSignal();
+
+ ToolName = argv[0];
+ if (BSDFormat) OutputFormat = bsd;
+ if (POSIXFormat) OutputFormat = posix;
+
+ switch (InputFilenames.size()) {
+ case 0: InputFilenames.push_back("-");
+ case 1: break;
+ default: MultipleFiles = true;
+ }
- switch (InputFilenames.size()) {
- case 0: InputFilenames.push_back("-");
- case 1: break;
- default: MultipleFiles = true;
+ std::for_each (InputFilenames.begin (), InputFilenames.end (),
+ DumpSymbolNamesFromFile);
+ return 0;
+ } catch (const std::string& msg) {
+ std::cerr << argv[0] << ": " << msg << "\n";
+ } catch (...) {
+ std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
}
-
- std::for_each (InputFilenames.begin (), InputFilenames.end (),
- DumpSymbolNamesFromFile);
- return 0;
+ return 1;
}