[dwarfdump] Make .eh_frame an alias for .debug_frame

This patch makes the `.eh_frame` extension an alias for `.debug_frame`.
Up till now it was only possible to dump the section using objdump, but
not with dwarfdump. Since the two are essentially interchangeable, we
dump whichever of the two is present.

As a workaround, this patch also adds parsing for 3 currently
unimplemented CFA instructions: `DW_CFA_def_cfa_expression`,
`DW_CFA_expression`, and `DW_CFA_val_expression`. Because I lack the
required knowledge, I just parse the fields without actually creating
the instructions.

Finally, this also fixes the typo in the `.debug_frame` section name
which incorrectly contained a trailing `s`.

Differential revision: https://reviews.llvm.org/D37852

llvm-svn: 313530
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 373452a..353a5ba 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -222,7 +222,6 @@
 
   Optional<uint64_t> DumpOffset;
   uint64_t DumpType = DumpOpts.DumpType;
-  bool DumpEH = DumpOpts.DumpEH;
   unsigned RecDepth =
       DumpOpts.ShowChildren ? std::numeric_limits<unsigned>::max() : 0;
 
@@ -299,12 +298,13 @@
     getDebugLocDWO()->dump(OS, getRegisterInfo());
   }
 
-  if (shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrames,
+  if (shouldDump(Explicit, ".debug_frame", DIDT_ID_DebugFrame,
                  DObj->getDebugFrameSection())) {
     getDebugFrame()->dump(OS);
   }
-  if (DumpEH && !getEHFrame()->empty()) {
-    OS << "\n.eh_frame contents:\n";
+
+  if (shouldDump(Explicit, ".eh_frame", DIDT_ID_DebugFrame,
+                 DObj->getEHFrameSection())) {
     getEHFrame()->dump(OS);
   }
 
@@ -492,15 +492,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;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
index 475cf25..6e8b5f4 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ b/llvm/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;
+        }
       }
     }
   }