From eef7b6219ebe5d0ded0be4adb3003055fa8a63c4 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Wed, 5 Dec 2012 20:12:35 +0000 Subject: Add dump of Win64 EH unwind data. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new command line option -unwind-info dumps the Win64 EH unwind data to the console. This is a nice feature if you need to debug generated EH data (e.g. from LLVM). Includes a test case. Initial patch by João Matos, extensions and rework by Kai Nacke. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169415 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-objdump/llvm-objdump.cpp | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'tools/llvm-objdump/llvm-objdump.cpp') diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index f1749f031b..2838a2a2b3 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -104,9 +104,16 @@ static cl::opt NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling instructions, " "do not print the instruction bytes.")); +static cl::opt +UnwindInfo("unwind-info", cl::desc("Display unwind information")); + +static cl::alias +UnwindInfoShort("u", cl::desc("Alias for --unwind-info"), + cl::aliasopt(UnwindInfo)); + static StringRef ToolName; -static bool error(error_code ec) { +bool llvm::error(error_code ec) { if (!ec) return false; outs() << ToolName << ": error reading file: " << ec.message() << ".\n"; @@ -165,7 +172,7 @@ void llvm::DumpBytes(StringRef bytes) { outs() << output; } -static bool RelocAddressLess(RelocationRef a, RelocationRef b) { +bool llvm::RelocAddressLess(RelocationRef a, RelocationRef b) { uint64_t a_addr, b_addr; if (error(a.getAddress(a_addr))) return false; if (error(b.getAddress(b_addr))) return false; @@ -573,6 +580,19 @@ static void PrintSymbolTable(const ObjectFile *o) { } } +static void PrintUnwindInfo(const ObjectFile *o) { + outs() << "Unwind info:\n\n"; + + if (const COFFObjectFile *coff = dyn_cast(o)) { + printCOFFUnwindInfo(coff); + } else { + // TODO: Extract DWARF dump tool to objdump. + errs() << "This operation is only currently supported " + "for COFF object files.\n"; + return; + } +} + static void DumpObject(const ObjectFile *o) { outs() << '\n'; outs() << o->getFileName() @@ -588,6 +608,8 @@ static void DumpObject(const ObjectFile *o) { PrintSectionContents(o); if (SymbolTable) PrintSymbolTable(o); + if (UnwindInfo) + PrintUnwindInfo(o); } /// @brief Dump each object file in \a a; @@ -666,7 +688,8 @@ int main(int argc, char **argv) { && !Relocations && !SectionHeaders && !SectionContents - && !SymbolTable) { + && !SymbolTable + && !UnwindInfo) { cl::PrintHelpMessage(); return 2; } -- cgit v1.2.3-18-g5258