summaryrefslogtreecommitdiff
path: root/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2012-12-05 20:12:35 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2012-12-05 20:12:35 +0000
commiteef7b6219ebe5d0ded0be4adb3003055fa8a63c4 (patch)
treee61ae4017a7f1403a7d09efc78e915a504837167 /tools/llvm-objdump/llvm-objdump.cpp
parent717a142823f84bd3aa958755ead1d991860ca8f4 (diff)
downloadllvm-eef7b6219ebe5d0ded0be4adb3003055fa8a63c4.tar.gz
llvm-eef7b6219ebe5d0ded0be4adb3003055fa8a63c4.tar.bz2
llvm-eef7b6219ebe5d0ded0be4adb3003055fa8a63c4.tar.xz
Add dump of Win64 EH unwind data.
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
Diffstat (limited to 'tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp29
1 files changed, 26 insertions, 3 deletions
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<bool>
NoShowRawInsn("no-show-raw-insn", cl::desc("When disassembling instructions, "
"do not print the instruction bytes."));
+static cl::opt<bool>
+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<COFFObjectFile>(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;
}