diff options
author | Brian Gaeke <gaeke@uiuc.edu> | 2003-11-16 23:34:13 +0000 |
---|---|---|
committer | Brian Gaeke <gaeke@uiuc.edu> | 2003-11-16 23:34:13 +0000 |
commit | 1c0b6982d28c910e7555d2c7a98f745f5d701827 (patch) | |
tree | 27452af55f357eadf8cf07e0b662a46def85e828 /tools | |
parent | 2c61d7b240f41dcc3f7a7e4966dc80b804918bc9 (diff) | |
download | external_llvm-1c0b6982d28c910e7555d2c7a98f745f5d701827.zip external_llvm-1c0b6982d28c910e7555d2c7a98f745f5d701827.tar.gz external_llvm-1c0b6982d28c910e7555d2c7a98f745f5d701827.tar.bz2 |
Include Support/FileUtilities.h.
Print module identifier in DumpSymbolNamesFromModule().
In DumpSymbolNamesFromFile(), check whether it is an archive or a bytecode
file, and call the corresponding reader function (ParseBytecodeFile or
ReadArchiveFile).
Unconditionally set MultipleFiles for archives.
Fixes PR117.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10044 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 878aa24..ec024f9 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -19,6 +19,7 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" #include "Support/CommandLine.h" +#include "Support/FileUtilities.h" #include <cctype> using namespace llvm; @@ -96,26 +97,36 @@ void DumpSymbolNameForGlobalValue (GlobalValue &GV) { } void DumpSymbolNamesFromModule (Module *M) { + const std::string &Filename = M->getModuleIdentifier (); + if (OutputFormat == posix && MultipleFiles) { + std::cout << Filename << ":\n"; + } else if (OutputFormat == bsd && MultipleFiles) { + std::cout << "\n" << Filename << ":\n"; + } else if (OutputFormat == sysv) { + std::cout << "\n\nSymbols from " << Filename << ":\n\n" + << "Name Value Class Type" + << " Size Line Section\n"; + } std::for_each (M->begin (), M->end (), DumpSymbolNameForGlobalValue); std::for_each (M->gbegin (), M->gend (), DumpSymbolNameForGlobalValue); } void DumpSymbolNamesFromFile (std::string &Filename) { std::string ErrorMessage; - Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); - if (Result) { - if (OutputFormat == posix && MultipleFiles) { - std::cout << Filename << ":\n"; - } else if (OutputFormat == bsd && MultipleFiles) { - std::cout << "\n" << Filename << ":\n"; - } else if (OutputFormat == sysv) { - std::cout << "\n\nSymbols from " << Filename << ":\n\n" - << "Name Value Class Type" - << " Size Line Section\n"; + if (IsBytecode (Filename)) { + Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); + if (Result) { + DumpSymbolNamesFromModule (Result); + } else { + std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; } - DumpSymbolNamesFromModule (Result); - } else { - std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; + } else if (IsArchive (Filename)) { + std::vector<Module *> Modules; + if (ReadArchiveFile (Filename, Modules, &ErrorMessage)) + std::cerr << ToolName << ": " << Filename << ": " + << ErrorMessage << "\n"; + MultipleFiles = true; + std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule); } } |