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
This commit is contained in:
Brian Gaeke 2003-11-16 23:34:13 +00:00
parent 2c61d7b240
commit 1c0b6982d2

View File

@ -19,6 +19,7 @@
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Reader.h"
#include "Support/CommandLine.h" #include "Support/CommandLine.h"
#include "Support/FileUtilities.h"
#include <cctype> #include <cctype>
using namespace llvm; using namespace llvm;
@ -96,26 +97,36 @@ void DumpSymbolNameForGlobalValue (GlobalValue &GV) {
} }
void DumpSymbolNamesFromModule (Module *M) { 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->begin (), M->end (), DumpSymbolNameForGlobalValue);
std::for_each (M->gbegin (), M->gend (), DumpSymbolNameForGlobalValue); std::for_each (M->gbegin (), M->gend (), DumpSymbolNameForGlobalValue);
} }
void DumpSymbolNamesFromFile (std::string &Filename) { void DumpSymbolNamesFromFile (std::string &Filename) {
std::string ErrorMessage; std::string ErrorMessage;
Module *Result = ParseBytecodeFile(Filename, &ErrorMessage); if (IsBytecode (Filename)) {
if (Result) { Module *Result = ParseBytecodeFile(Filename, &ErrorMessage);
if (OutputFormat == posix && MultipleFiles) { if (Result) {
std::cout << Filename << ":\n"; DumpSymbolNamesFromModule (Result);
} else if (OutputFormat == bsd && MultipleFiles) { } else {
std::cout << "\n" << Filename << ":\n"; std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
} else if (OutputFormat == sysv) {
std::cout << "\n\nSymbols from " << Filename << ":\n\n"
<< "Name Value Class Type"
<< " Size Line Section\n";
} }
DumpSymbolNamesFromModule (Result); } else if (IsArchive (Filename)) {
} else { std::vector<Module *> Modules;
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n"; if (ReadArchiveFile (Filename, Modules, &ErrorMessage))
std::cerr << ToolName << ": " << Filename << ": "
<< ErrorMessage << "\n";
MultipleFiles = true;
std::for_each (Modules.begin (), Modules.end (), DumpSymbolNamesFromModule);
} }
} }