Index: include/llvm/BinaryFormat/Dwarf.def =================================================================== --- include/llvm/BinaryFormat/Dwarf.def +++ include/llvm/BinaryFormat/Dwarf.def @@ -833,7 +833,7 @@ HANDLE_DWARF_SECTION(DebugTypes, ".debug_types", "debug-types") HANDLE_DWARF_SECTION(DebugLine, ".debug_line", "debug-line") HANDLE_DWARF_SECTION(DebugLoc, ".debug_loc", "debug-loc") -HANDLE_DWARF_SECTION(DebugFrames, ".debug_frames", "debug-frames") +HANDLE_DWARF_SECTION(DebugFrame, ".debug_frame", "debug-frame") HANDLE_DWARF_SECTION(DebugMacro, ".debug_macro", "debug-macro") HANDLE_DWARF_SECTION(DebugRanges, ".debug_ranges", "debug-ranges") HANDLE_DWARF_SECTION(DebugPubnames, ".debug_pubnames", "debug-pubnames") Index: include/llvm/DebugInfo/DIContext.h =================================================================== --- include/llvm/DebugInfo/DIContext.h +++ include/llvm/DebugInfo/DIContext.h @@ -139,7 +139,6 @@ /// dumped. struct DIDumpOptions { unsigned DumpType = DIDT_All; - bool DumpEH = false; bool SummarizeTypes = false; bool Verbose = false; }; @@ -158,8 +157,7 @@ virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0; - virtual bool verify(raw_ostream &OS, unsigned DumpType = DIDT_All, - DIDumpOptions DumpOpts = {}) { + virtual bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) { // No verifier? Just say things went well. return true; } Index: include/llvm/DebugInfo/DWARF/DWARFContext.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFContext.h +++ include/llvm/DebugInfo/DWARF/DWARFContext.h @@ -123,8 +123,7 @@ void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override; - bool verify(raw_ostream &OS, unsigned DumpType = DIDT_All, - DIDumpOptions DumpOpts = {}) override; + bool verify(raw_ostream &OS, DIDumpOptions DumpOpts = {}) override; using cu_iterator_range = DWARFUnitSection::iterator_range; using tu_iterator_range = DWARFUnitSection::iterator_range; Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -223,7 +223,6 @@ void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts) { uint64_t DumpType = DumpOpts.DumpType; - bool DumpEH = DumpOpts.DumpEH; StringRef Extension = sys::path::extension(DObj->getFileName()); bool IsDWO = (Extension == ".dwo") || (Extension == ".dwp"); @@ -293,11 +292,12 @@ getDebugLocDWO()->dump(OS, getRegisterInfo()); } - if (shouldDump(DIDT_DebugFrames, DObj->getDebugFrameSection())) { + if (shouldDump(DIDT_DebugFrame, DObj->getDebugFrameSection())) { OS << "\n.debug_frame contents:\n"; getDebugFrame()->dump(OS); } - if (DumpEH && !getEHFrame()->empty()) { + + if (shouldDump(DIDT_DebugFrame, DObj->getEHFrameSection())) { OS << "\n.eh_frame contents:\n"; getEHFrame()->dump(OS); } @@ -478,15 +478,14 @@ return DWARFDie(); } -bool DWARFContext::verify(raw_ostream &OS, unsigned DumpType, - DIDumpOptions DumpOpts) { +bool DWARFContext::verify(raw_ostream &OS, DIDumpOptions DumpOpts) { bool Success = true; DWARFVerifier verifier(OS, *this, DumpOpts); Success &= verifier.handleDebugAbbrev(); - if (DumpType & DIDT_DebugInfo) + if (DumpOpts.DumpType & DIDT_DebugInfo) Success &= verifier.handleDebugInfo(); - if (DumpType & DIDT_DebugLine) + if (DumpOpts.DumpType & DIDT_DebugLine) Success &= verifier.handleDebugLine(); Success &= verifier.handleAccelTables(); return Success; Index: lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -188,10 +188,16 @@ break; } case DW_CFA_def_cfa_expression: + // FIXME: Parse the actual instruction. + *Offset += Data.getULEB128(Offset); + break; case DW_CFA_expression: - case DW_CFA_val_expression: - // TODO: implement this - report_fatal_error("Values with expressions not implemented yet!"); + case DW_CFA_val_expression: { + // FIXME: Parse the actual instruction. + Data.getULEB128(Offset); + *Offset += Data.getULEB128(Offset); + break; + } } } } Index: test/Assembler/return-column.s =================================================================== --- test/Assembler/return-column.s +++ test/Assembler/return-column.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -triple i686-unknown-linux-gnu -filetype asm -o - %s | FileCheck %s -check-prefix CHECK-ASM-ROUNDTRIP -// RUN: llvm-mc -triple i686-unknown-linux-gnu -filetype obj -o - %s | llvm-objdump -dwarf=frames - | FileCheck %s -check-prefix CHECK-EH_FRAME +// RUN: llvm-mc -triple i686-unknown-linux-gnu -filetype obj -o - %s | llvm-objdump -dwarf=eh - | FileCheck %s -check-prefix CHECK-EH_FRAME // REQUIRES: x86-registered-target .text @@ -40,4 +40,3 @@ // CHECK-EH_FRAME: Return address column: 65 // CHECK-EH_FRAME-NOT: ........ 00000014 ffffffff CIE - Index: test/DebugInfo/dwarfdump-debug-frame-simple.test =================================================================== --- test/DebugInfo/dwarfdump-debug-frame-simple.test +++ test/DebugInfo/dwarfdump-debug-frame-simple.test @@ -1,4 +1,4 @@ -; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-32bit.elf.o --debug-frames | FileCheck %s -check-prefix FRAMES +; RUN: llvm-dwarfdump %p/Inputs/dwarfdump-test-32bit.elf.o --debug-frame | FileCheck %s -check-prefix FRAMES ; Note: the input file was generated from Inputs/dwarfdump-test-32bit.elf.c ; FRAMES: .debug_frame @@ -25,4 +25,3 @@ ; FRAMES-NOT: CIE ; FRAMES-NOT: FDE - Index: test/MC/X86/i386-darwin-frame-register.ll =================================================================== --- test/MC/X86/i386-darwin-frame-register.ll +++ test/MC/X86/i386-darwin-frame-register.ll @@ -1,4 +1,4 @@ -; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -debug-frames - | FileCheck %s +; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -debug-frame - | FileCheck %s ; IR reduced from a dummy: ; void foo() {} Index: test/tools/dsymutil/X86/frame-1.test =================================================================== --- test/tools/dsymutil/X86/frame-1.test +++ test/tools/dsymutil/X86/frame-1.test @@ -2,7 +2,7 @@ # RUN: rm -rf %t # RUN: mkdir -p %t # RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o -# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-frames - | FileCheck %s +# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-frame - | FileCheck %s # This test is meant to verify that identical CIEs will get reused # in the same file but also inbetween files. For this to happen, we @@ -29,4 +29,3 @@ # CHECK-NOT: FDE # CHECK: FDE cie=00000000 pc=00003000...00003 # CHECK-NOT: FDE - Index: test/tools/dsymutil/X86/frame-2.test =================================================================== --- test/tools/dsymutil/X86/frame-2.test +++ test/tools/dsymutil/X86/frame-2.test @@ -3,7 +3,7 @@ # RUN: mkdir -p %t # RUN: llc -filetype=obj %p/../Inputs/frame-dw2.ll -o %t/frame-dw2.o # RUN: llc -filetype=obj %p/../Inputs/frame-dw4.ll -o %t/frame-dw4.o -# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-frames - | FileCheck %s +# RUN: llvm-dsymutil -f -oso-prepend-path=%t -y %s -o - | llvm-dwarfdump -debug-frame - | FileCheck %s # Check the handling of multiple different CIEs. To have CIEs that # appear to be different, use a dwarf2 version of the file along with @@ -44,4 +44,3 @@ # CHECK-NOT: FDE # CHECK: FDE cie=[[CIEDW2]] pc=00004000...00004 # CHECK-NOT: FDE - Index: test/tools/llvm-objdump/eh_frame-arm64.test =================================================================== --- test/tools/llvm-objdump/eh_frame-arm64.test +++ test/tools/llvm-objdump/eh_frame-arm64.test @@ -1,4 +1,4 @@ -# RUN: llvm-objdump -dwarf=frames %p/Inputs/eh_frame.macho-arm64 2>/dev/null | FileCheck %s +# RUN: llvm-objdump -dwarf=eh %p/Inputs/eh_frame.macho-arm64 2>/dev/null | FileCheck %s # CHECK: .eh_frame contents: Index: test/tools/llvm-objdump/eh_frame-mipsel.test =================================================================== --- test/tools/llvm-objdump/eh_frame-mipsel.test +++ test/tools/llvm-objdump/eh_frame-mipsel.test @@ -1,4 +1,4 @@ -# RUN: llvm-objdump -dwarf=frames %p/Inputs/eh_frame.elf-mipsel | FileCheck %s +# RUN: llvm-objdump -dwarf=eh %p/Inputs/eh_frame.elf-mipsel | FileCheck %s # CHECK: .eh_frame contents: Index: test/tools/llvm-objdump/eh_frame_zero_cie.test =================================================================== --- test/tools/llvm-objdump/eh_frame_zero_cie.test +++ test/tools/llvm-objdump/eh_frame_zero_cie.test @@ -1,4 +1,4 @@ -# RUN: llvm-objdump -dwarf=frames %p/Inputs/eh_frame_zero_cie.o 2>/dev/null | FileCheck %s +# RUN: llvm-objdump -dwarf=eh %p/Inputs/eh_frame_zero_cie.o 2>/dev/null | FileCheck %s # CHECK: .eh_frame contents: Index: tools/llvm-dwarfdump/llvm-dwarfdump.cpp =================================================================== --- tools/llvm-dwarfdump/llvm-dwarfdump.cpp +++ tools/llvm-dwarfdump/llvm-dwarfdump.cpp @@ -60,6 +60,8 @@ cat(SectionCategory)); #include "llvm/BinaryFormat/Dwarf.def" #undef HANDLE_DWARF_SECTION +static opt DumpEHFrame("eh-frame", desc("Dump the .eh_frame section"), + cat(SectionCategory)); static opt DumpUUID("uuid", desc("Show the UUID for each architecture"), cat(DwarfDumpCategory)); static alias DumpUUIDAlias("u", desc("Alias for -uuid"), aliasopt(DumpUUID)); @@ -114,7 +116,7 @@ raw_ostream &stream = Quiet ? nulls() : outs(); stream << "Verifying " << Filename.str() << ":\tfile format " << Obj.getFileFormatName() << "\n"; - bool Result = DICtx->verify(stream, DumpType, getDumpOpts()); + bool Result = DICtx->verify(stream, getDumpOpts()); if (Result) stream << "No errors.\n"; else @@ -211,6 +213,8 @@ DumpType |= DIDT_##ENUM_NAME; #include "llvm/BinaryFormat/Dwarf.def" #undef HANDLE_DWARF_SECTION + if (DumpEHFrame) + DumpType |= DIDT_DebugFrame; if (DumpUUID) DumpType |= DIDT_UUID; if (DumpAll) Index: tools/llvm-objdump/MachODump.cpp =================================================================== --- tools/llvm-objdump/MachODump.cpp +++ tools/llvm-objdump/MachODump.cpp @@ -1279,7 +1279,6 @@ // Dump the complete DWARF structure. DIDumpOptions DumpOpts; DumpOpts.DumpType = DwarfDumpType; - DumpOpts.DumpEH = true; DICtx->dump(outs(), DumpOpts); } } @@ -5833,7 +5832,7 @@ mtime = nullptr; name = nullptr; for(key = xar_prop_first(xf, xp); key; key = xar_prop_next(xp)){ - const char *val = nullptr; + const char *val = nullptr; xar_prop_get(xf, key, &val); #if 0 // Useful for debugging. outs() << "key: " << key << " value: " << val << "\n"; @@ -6023,7 +6022,7 @@ member_type = NULL; member_size_string = NULL; for(key = xar_prop_first(xf, xp); key; key = xar_prop_next(xp)){ - const char *val = nullptr; + const char *val = nullptr; xar_prop_get(xf, key, &val); #if 0 // Useful for debugging. outs() << "key: " << key << " value: " << val << "\n"; Index: tools/llvm-objdump/llvm-objdump.cpp =================================================================== --- tools/llvm-objdump/llvm-objdump.cpp +++ tools/llvm-objdump/llvm-objdump.cpp @@ -191,7 +191,8 @@ cl::opt llvm::DwarfDumpType( "dwarf", cl::init(DIDT_Null), cl::desc("Dump of dwarf debug sections:"), - cl::values(clEnumValN(DIDT_DebugFrames, "frames", ".debug_frame"))); + cl::values(clEnumValN(DIDT_DebugFrame, "frame", ".debug_frame"), + clEnumValN(DIDT_DebugFrame, "eh", ".eh_frame"))); cl::opt PrintSource( "source", @@ -2085,7 +2086,6 @@ // Dump the complete DWARF structure. DIDumpOptions DumpOpts; DumpOpts.DumpType = DwarfDumpType; - DumpOpts.DumpEH = true; DICtx->dump(outs(), DumpOpts); } } Index: unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp =================================================================== --- unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -1661,14 +1661,14 @@ void VerifyWarning(DWARFContext &DwarfContext, StringRef Error) { SmallString<1024> Str; raw_svector_ostream Strm(Str); - EXPECT_TRUE(DwarfContext.verify(Strm, DIDT_All)); + EXPECT_TRUE(DwarfContext.verify(Strm)); EXPECT_TRUE(Str.str().contains(Error)); } void VerifyError(DWARFContext &DwarfContext, StringRef Error) { SmallString<1024> Str; raw_svector_ostream Strm(Str); - EXPECT_FALSE(DwarfContext.verify(Strm, DIDT_All)); + EXPECT_FALSE(DwarfContext.verify(Strm)); EXPECT_TRUE(Str.str().contains(Error)); }