[PATCH] D107028: [llvm-objdump][NFC] Add quiet disassembly
Necip Fazil Yildiran via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 29 15:13:10 PDT 2021
necipfazil updated this revision to Diff 362899.
necipfazil marked an inline comment as done.
necipfazil added a comment.
Fix nit
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D107028/new/
https://reviews.llvm.org/D107028
Files:
llvm/tools/llvm-objdump/llvm-objdump.cpp
Index: llvm/tools/llvm-objdump/llvm-objdump.cpp
===================================================================
--- llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -219,6 +219,8 @@
std::string objdump::Prefix;
uint32_t objdump::PrefixStrip;
+static bool QuietDisasm = false;
+
DebugVarsFormat objdump::DbgVariables = DVDisabled;
int objdump::DbgIndent = 52;
@@ -1062,6 +1064,8 @@
FOS.flush();
}
+static raw_ostream &disasmOuts() { return QuietDisasm ? nulls() : outs(); }
+
static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj,
MCContext &Ctx, MCDisassembler *PrimaryDisAsm,
MCDisassembler *SecondaryDisAsm,
@@ -1281,25 +1285,26 @@
if (!PrintedSection) {
PrintedSection = true;
- outs() << "\nDisassembly of section ";
+ disasmOuts() << "\nDisassembly of section ";
if (!SegmentName.empty())
- outs() << SegmentName << ",";
- outs() << SectionName << ":\n";
+ disasmOuts() << SegmentName << ",";
+ disasmOuts() << SectionName << ":\n";
}
- outs() << '\n';
+ disasmOuts() << '\n';
if (LeadingAddr)
- outs() << format(Is64Bits ? "%016" PRIx64 " " : "%08" PRIx64 " ",
- SectionAddr + Start + VMAAdjustment);
+ disasmOuts() << format(Is64Bits ? "%016" PRIx64 " " : "%08" PRIx64 " ",
+ SectionAddr + Start + VMAAdjustment);
if (Obj->isXCOFF() && SymbolDescription) {
- outs() << getXCOFFSymbolDescription(Symbols[SI], SymbolName) << ":\n";
+ disasmOuts() << getXCOFFSymbolDescription(Symbols[SI], SymbolName)
+ << ":\n";
} else
- outs() << '<' << SymbolName << ">:\n";
+ disasmOuts() << '<' << SymbolName << ">:\n";
// Don't print raw contents of a virtual section. A virtual section
// doesn't have any contents in the file.
if (Section.isVirtual()) {
- outs() << "...\n";
+ disasmOuts() << "...\n";
continue;
}
@@ -1323,11 +1328,11 @@
//
if (Status.hasValue()) {
if (Status.getValue() == MCDisassembler::Fail) {
- outs() << "// Error in decoding " << SymbolName
- << " : Decoding failed region as bytes.\n";
+ disasmOuts() << "// Error in decoding " << SymbolName
+ << " : Decoding failed region as bytes.\n";
for (uint64_t I = 0; I < Size; ++I) {
- outs() << "\t.byte\t " << format_hex(Bytes[I], 1, /*Upper=*/true)
- << "\n";
+ disasmOuts() << "\t.byte\t "
+ << format_hex(Bytes[I], 1, /*Upper=*/true) << "\n";
}
}
} else {
@@ -1355,7 +1360,7 @@
Symbols[SI].Type != ELF::STT_OBJECT &&
!DisassembleAll;
bool DumpARMELFData = false;
- formatted_raw_ostream FOS(outs());
+ formatted_raw_ostream FOS(disasmOuts());
std::unordered_map<uint64_t, std::string> AllLabels;
if (SymbolizeOperands)
@@ -2543,6 +2548,8 @@
llvm::cl::ParseCommandLineOptions(2, Argv);
}
+ QuietDisasm = false;
+
// objdump defaults to a.out if no filenames specified.
if (InputFilenames.empty())
InputFilenames.push_back("a.out");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107028.362899.patch
Type: text/x-patch
Size: 3423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/6b8258a7/attachment.bin>
More information about the llvm-commits
mailing list