llvm.org GIT mirror llvm / 87b47cc
Use the generic dump template. Extracted from a patch by Sami Liedes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171305 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
1 changed file(s) with 21 addition(s) and 55 deletion(s). Raw diff Collapse all Expand all
161161 << "\n";
162162 }
163163
164 // Iterate through the normal symbols in the ObjectFile
165 static void dumpSymbols(const ObjectFile *obj) {
166 error_code ec;
167 uint32_t count = 0;
168 outs() << "Symbols:\n";
169 dumpSymbolHeader();
170 symbol_iterator it = obj->begin_symbols();
171 symbol_iterator ie = obj->end_symbols();
172 while (it != ie) {
173 dumpSymbol(*it, obj, false);
174 it.increment(ec);
175 if (ec)
176 report_fatal_error("Symbol iteration failed");
177 ++count;
178 }
179 outs() << " Total: " << count << "\n\n";
180 }
181
182 // Iterate through the dynamic symbols in the ObjectFile.
183 static void dumpDynamicSymbols(const ObjectFile *obj) {
184 error_code ec;
185 uint32_t count = 0;
186 outs() << "Dynamic Symbols:\n";
187 dumpSymbolHeader();
188 symbol_iterator it = obj->begin_dynamic_symbols();
189 symbol_iterator ie = obj->end_dynamic_symbols();
190 while (it != ie) {
191 dumpSymbol(*it, obj, true);
192 it.increment(ec);
193 if (ec)
194 report_fatal_error("Symbol iteration failed");
195 ++count;
196 }
197 outs() << " Total: " << count << "\n\n";
164 static void dumpStaticSymbol(const SymbolRef &Sym, const ObjectFile *obj) {
165 return dumpSymbol(Sym, obj, false);
166 }
167
168 static void dumpDynamicSymbol(const SymbolRef &Sym, const ObjectFile *obj) {
169 return dumpSymbol(Sym, obj, true);
198170 }
199171
200172 static void dumpSection(const SectionRef &Section, const ObjectFile *obj) {
212184 << "\n";
213185 }
214186
215 static void dumpLibrary(const LibraryRef &lib) {
187 static void dumpLibrary(const LibraryRef &lib, const ObjectFile *obj) {
216188 StringRef path;
217189 lib.getPath(path);
218190 outs() << " " << path << "\n";
234206 outs() << " Total: " << count << "\n\n";
235207 }
236208
237 // Iterate through needed libraries
238 static void dumpLibrariesNeeded(const ObjectFile *obj) {
239 error_code ec;
240 uint32_t count = 0;
241 library_iterator it = obj->begin_libraries_needed();
242 library_iterator ie = obj->end_libraries_needed();
243 outs() << "Libraries needed:\n";
244 while (it != ie) {
245 dumpLibrary(*it);
246 it.increment(ec);
247 if (ec)
248 report_fatal_error("Needed libraries iteration failed");
249 ++count;
250 }
251 outs() << " Total: " << count << "\n\n";
252 }
253
254209 static void dumpHeaders(const ObjectFile *obj) {
255210 outs() << "File Format : " << obj->getFileFormatName() << "\n";
256211 outs() << "Arch : "
287242 }
288243
289244 dumpHeaders(obj);
290 dumpSymbols(obj);
291 dumpDynamicSymbols(obj);
245
246 outs() << "Symbols:\n";
247 dumpSymbolHeader();
248 dump(obj, dumpStaticSymbol, obj->begin_symbols(), obj->end_symbols(),
249 "Symbol iteration failed");
250
251 outs() << "Dynamic Symbols:\n";
252 dumpSymbolHeader();
253 dump(obj, dumpDynamicSymbol, obj->begin_dynamic_symbols(),
254 obj->end_dynamic_symbols(), "Symbol iteration failed");
292255
293256 outs() << "Sections:\n";
294257 dumpSectionHeader();
295258 dump(obj, &dumpSection, obj->begin_sections(), obj->end_sections(),
296259 "Section iteration failed");
297260
298 dumpLibrariesNeeded(obj);
261 outs() << "Libraries needed:\n";
262 dump(obj, &dumpLibrary, obj->begin_libraries_needed(),
263 obj->end_libraries_needed(), "Needed libraries iteration failed");
264
299265 return 0;
300266 }
301267