llvm.org GIT mirror llvm / 2760cc2
llvm-objdump: Some style cleanups to follow LLVM coding style Rename "ec" to "EC", and rename some iterators. Then fix whitespace using clang-format-diff. (As requested in http://llvm-reviews.chandlerc.com/D2559) Differential Revision: http://llvm-reviews.chandlerc.com/D2594 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200053 91177308-0d34-0410-b5e6-96231b3b80d8 Mark Seaborn 6 years ago
1 changed file(s) with 70 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
148148
149149 static StringRef ToolName;
150150
151 bool llvm::error(error_code ec) {
152 if (!ec) return false;
153
154 outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
151 bool llvm::error(error_code EC) {
152 if (!EC)
153 return false;
154
155 outs() << ToolName << ": error reading file: " << EC.message() << ".\n";
155156 outs().flush();
156157 return true;
157158 }
380381 }
381382 }
382383
383
384 error_code ec;
385 for (section_iterator i = Obj->begin_sections(),
386 e = Obj->end_sections();
387 i != e; i.increment(ec)) {
388 if (error(ec)) break;
389 bool text;
390 if (error(i->isText(text))) break;
391 if (!text) continue;
384 error_code EC;
385 for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
386 I != E; I.increment(EC)) {
387 if (error(EC))
388 break;
389 bool Text;
390 if (error(I->isText(Text)))
391 break;
392 if (!Text)
393 continue;
392394
393395 uint64_t SectionAddr;
394 if (error(i->getAddress(SectionAddr))) break;
396 if (error(I->getAddress(SectionAddr)))
397 break;
395398
396399 // Make a list of all the symbols in this section.
397400 std::vector > Symbols;
398 for (symbol_iterator si = Obj->begin_symbols(),
399 se = Obj->end_symbols();
400 si != se; si.increment(ec)) {
401 for (symbol_iterator SI = Obj->begin_symbols(), SE = Obj->end_symbols();
402 SI != SE; SI.increment(EC)) {
401403 bool contains;
402 if (!error(i->containsSymbol(*si, contains)) && contains) {
404 if (!error(I->containsSymbol(*SI, contains)) && contains) {
403405 uint64_t Address;
404 if (error(si->getAddress(Address))) break;
405 if (Address == UnknownAddressOrSize) continue;
406 if (error(SI->getAddress(Address)))
407 break;
408 if (Address == UnknownAddressOrSize)
409 continue;
406410 Address -= SectionAddr;
407411
408412 StringRef Name;
409 if (error(si->getName(Name))) break;
413 if (error(SI->getName(Name)))
414 break;
410415 Symbols.push_back(std::make_pair(Address, Name));
411416 }
412417 }
417422 // Make a list of all the relocations for this section.
418423 std::vector Rels;
419424 if (InlineRelocs) {
420 for (relocation_iterator ri = i->begin_relocations(),
421 re = i->end_relocations();
422 ri != re; ri.increment(ec)) {
423 if (error(ec)) break;
424 Rels.push_back(*ri);
425 for (relocation_iterator RI = I->begin_relocations(),
426 RE = I->end_relocations();
427 RI != RE; RI.increment(EC)) {
428 if (error(EC))
429 break;
430 Rels.push_back(*RI);
425431 }
426432 }
427433
429435 std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
430436
431437 StringRef SegmentName = "";
432 if (const MachOObjectFile *MachO =
433 dyn_cast(Obj)) {
434 DataRefImpl DR = i->getRawDataRefImpl();
438 if (const MachOObjectFile *MachO = dyn_cast(Obj)) {
439 DataRefImpl DR = I->getRawDataRefImpl();
435440 SegmentName = MachO->getSectionFinalSegmentName(DR);
436441 }
437442 StringRef name;
438 if (error(i->getName(name))) break;
443 if (error(I->getName(name)))
444 break;
439445 outs() << "Disassembly of section ";
440446 if (!SegmentName.empty())
441447 outs() << SegmentName << ",";
451457 raw_svector_ostream CommentStream(Comments);
452458
453459 StringRef Bytes;
454 if (error(i->getContents(Bytes))) break;
460 if (error(I->getContents(Bytes)))
461 break;
455462 StringRefMemoryObject memoryObject(Bytes, SectionAddr);
456463 uint64_t Size;
457464 uint64_t Index;
458465 uint64_t SectSize;
459 if (error(i->getSize(SectSize))) break;
466 if (error(I->getSize(SectSize)))
467 break;
460468
461469 std::vector::const_iterator rel_cur = Rels.begin();
462470 std::vector::const_iterator rel_end = Rels.end();
478486 outs() << '\n' << Symbols[si].second << ":\n";
479487
480488 #ifndef NDEBUG
481 raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
489 raw_ostream &DebugOut = DebugFlag ? dbgs() : nulls();
482490 #else
483 raw_ostream &DebugOut = nulls();
491 raw_ostream &DebugOut = nulls();
484492 #endif
485493
486494 for (Index = Start; Index < End; Index += Size) {
533541 }
534542
535543 static void PrintRelocations(const ObjectFile *o) {
536 error_code ec;
544 error_code EC;
537545 for (section_iterator si = o->begin_sections(), se = o->end_sections();
538 si != se; si.increment(ec)){
539 if (error(ec)) return;
546 si != se; si.increment(EC)) {
547 if (error(EC))
548 return;
540549 if (si->begin_relocations() == si->end_relocations())
541550 continue;
542551 StringRef secname;
544553 outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
545554 for (relocation_iterator ri = si->begin_relocations(),
546555 re = si->end_relocations();
547 ri != re; ri.increment(ec)) {
548 if (error(ec)) return;
556 ri != re; ri.increment(EC)) {
557 if (error(EC))
558 return;
549559
550560 bool hidden;
551561 uint64_t address;
565575 static void PrintSectionHeaders(const ObjectFile *o) {
566576 outs() << "Sections:\n"
567577 "Idx Name Size Address Type\n";
568 error_code ec;
578 error_code EC;
569579 unsigned i = 0;
570580 for (section_iterator si = o->begin_sections(), se = o->end_sections();
571 si != se; si.increment(ec)) {
572 if (error(ec)) return;
581 si != se; si.increment(EC)) {
582 if (error(EC))
583 return;
573584 StringRef Name;
574 if (error(si->getName(Name))) return;
585 if (error(si->getName(Name)))
586 return;
575587 uint64_t Address;
576588 if (error(si->getAddress(Address))) return;
577589 uint64_t Size;
589601 }
590602
591603 static void PrintSectionContents(const ObjectFile *o) {
592 error_code ec;
593 for (section_iterator si = o->begin_sections(),
594 se = o->end_sections();
595 si != se; si.increment(ec)) {
596 if (error(ec)) return;
604 error_code EC;
605 for (section_iterator si = o->begin_sections(), se = o->end_sections();
606 si != se; si.increment(EC)) {
607 if (error(EC))
608 return;
597609 StringRef Name;
598610 StringRef Contents;
599611 uint64_t BaseAddr;
684696 if (const COFFObjectFile *coff = dyn_cast(o))
685697 PrintCOFFSymbolTable(coff);
686698 else {
687 error_code ec;
688 for (symbol_iterator si = o->begin_symbols(),
689 se = o->end_symbols(); si != se; si.increment(ec)) {
690 if (error(ec)) return;
699 error_code EC;
700 for (symbol_iterator si = o->begin_symbols(), se = o->end_symbols();
701 si != se; si.increment(EC)) {
702 if (error(EC))
703 return;
691704 StringRef Name;
692705 uint64_t Address;
693706 SymbolRef::Type Type;
800813
801814 /// @brief Dump each object file in \a a;
802815 static void DumpArchive(const Archive *a) {
803 for (Archive::child_iterator i = a->child_begin(),
804 e = a->child_end(); i != e; ++i) {
816 for (Archive::child_iterator i = a->child_begin(), e = a->child_end(); i != e;
817 ++i) {
805818 OwningPtr child;
806 if (error_code ec = i->getAsBinary(child)) {
819 if (error_code EC = i->getAsBinary(child)) {
807820 // Ignore non-object files.
808 if (ec != object_error::invalid_file_type)
809 errs() << ToolName << ": '" << a->getFileName() << "': " << ec.message()
821 if (EC != object_error::invalid_file_type)
822 errs() << ToolName << ": '" << a->getFileName() << "': " << EC.message()
810823 << ".\n";
811824 continue;
812825 }