[llvm-commits] [llvm] r171305 - /llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 31 08:53:01 PST 2012
Author: rafael
Date: Mon Dec 31 10:53:01 2012
New Revision: 171305
URL: http://llvm.org/viewvc/llvm-project?rev=171305&view=rev
Log:
Use the generic dump template. Extracted from a patch by Sami Liedes.
Modified:
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=171305&r1=171304&r2=171305&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Mon Dec 31 10:53:01 2012
@@ -162,40 +162,12 @@
<< "\n";
}
-// Iterate through the normal symbols in the ObjectFile
-static void dumpSymbols(const ObjectFile *obj) {
- error_code ec;
- uint32_t count = 0;
- outs() << "Symbols:\n";
- dumpSymbolHeader();
- symbol_iterator it = obj->begin_symbols();
- symbol_iterator ie = obj->end_symbols();
- while (it != ie) {
- dumpSymbol(*it, obj, false);
- it.increment(ec);
- if (ec)
- report_fatal_error("Symbol iteration failed");
- ++count;
- }
- outs() << " Total: " << count << "\n\n";
+static void dumpStaticSymbol(const SymbolRef &Sym, const ObjectFile *obj) {
+ return dumpSymbol(Sym, obj, false);
}
-// Iterate through the dynamic symbols in the ObjectFile.
-static void dumpDynamicSymbols(const ObjectFile *obj) {
- error_code ec;
- uint32_t count = 0;
- outs() << "Dynamic Symbols:\n";
- dumpSymbolHeader();
- symbol_iterator it = obj->begin_dynamic_symbols();
- symbol_iterator ie = obj->end_dynamic_symbols();
- while (it != ie) {
- dumpSymbol(*it, obj, true);
- it.increment(ec);
- if (ec)
- report_fatal_error("Symbol iteration failed");
- ++count;
- }
- outs() << " Total: " << count << "\n\n";
+static void dumpDynamicSymbol(const SymbolRef &Sym, const ObjectFile *obj) {
+ return dumpSymbol(Sym, obj, true);
}
static void dumpSection(const SectionRef &Section, const ObjectFile *obj) {
@@ -213,7 +185,7 @@
<< "\n";
}
-static void dumpLibrary(const LibraryRef &lib) {
+static void dumpLibrary(const LibraryRef &lib, const ObjectFile *obj) {
StringRef path;
lib.getPath(path);
outs() << " " << path << "\n";
@@ -235,23 +207,6 @@
outs() << " Total: " << count << "\n\n";
}
-// Iterate through needed libraries
-static void dumpLibrariesNeeded(const ObjectFile *obj) {
- error_code ec;
- uint32_t count = 0;
- library_iterator it = obj->begin_libraries_needed();
- library_iterator ie = obj->end_libraries_needed();
- outs() << "Libraries needed:\n";
- while (it != ie) {
- dumpLibrary(*it);
- it.increment(ec);
- if (ec)
- report_fatal_error("Needed libraries iteration failed");
- ++count;
- }
- outs() << " Total: " << count << "\n\n";
-}
-
static void dumpHeaders(const ObjectFile *obj) {
outs() << "File Format : " << obj->getFileFormatName() << "\n";
outs() << "Arch : "
@@ -288,15 +243,26 @@
}
dumpHeaders(obj);
- dumpSymbols(obj);
- dumpDynamicSymbols(obj);
+
+ outs() << "Symbols:\n";
+ dumpSymbolHeader();
+ dump(obj, dumpStaticSymbol, obj->begin_symbols(), obj->end_symbols(),
+ "Symbol iteration failed");
+
+ outs() << "Dynamic Symbols:\n";
+ dumpSymbolHeader();
+ dump(obj, dumpDynamicSymbol, obj->begin_dynamic_symbols(),
+ obj->end_dynamic_symbols(), "Symbol iteration failed");
outs() << "Sections:\n";
dumpSectionHeader();
dump(obj, &dumpSection, obj->begin_sections(), obj->end_sections(),
"Section iteration failed");
- dumpLibrariesNeeded(obj);
+ outs() << "Libraries needed:\n";
+ dump(obj, &dumpLibrary, obj->begin_libraries_needed(),
+ obj->end_libraries_needed(), "Needed libraries iteration failed");
+
return 0;
}
More information about the llvm-commits
mailing list