]> granicus.if.org Git - llvm/commitdiff
[DWARF] Introduce Dump Options
authorAdrian Prantl <aprantl@apple.com>
Thu, 1 Jun 2017 18:18:23 +0000 (18:18 +0000)
committerAdrian Prantl <aprantl@apple.com>
Thu, 1 Jun 2017 18:18:23 +0000 (18:18 +0000)
This commit introduces a structure that holds all the flags that
control the pretty printing of dwarf output.

Patch by Spyridoula Gravani!

Differential Revision: https://reviews.llvm.org/D33749

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304446 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
include/llvm/DebugInfo/DWARF/DWARFContext.h
include/llvm/DebugInfo/PDB/PDBContext.h
lib/DebugInfo/DWARF/DWARFContext.cpp
lib/DebugInfo/PDB/PDBContext.cpp
tools/llvm-dwarfdump/llvm-dwarfdump.cpp
tools/llvm-objdump/MachODump.cpp
tools/llvm-objdump/llvm-objdump.cpp

index d51408122fc9bce12bea3d559d8fcfb31bdc5d36..2ab1c95085221b501388e275a035353fc306caad 100644 (file)
@@ -146,6 +146,14 @@ enum DIDumpType {
   DIDT_TUIndex,
 };
 
+/// Container for dump options that control which debug information will be
+/// dumped.
+struct DIDumpOptions {
+    DIDumpType DumpType = DIDT_All;
+    bool DumpEH = false;
+    bool SummarizeTypes = false;
+};
+
 class DIContext {
 public:
   enum DIContextKind {
@@ -158,8 +166,7 @@ public:
 
   DIContextKind getKind() const { return Kind; }
 
-  virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
-                    bool DumpEH = false, bool SummarizeTypes = false) = 0;
+  virtual void dump(raw_ostream &OS, DIDumpOptions DumpOpts) = 0;
 
   virtual bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) {
     // No verifier? Just say things went well.
index 7fa68f3f2314e085e8cc579cc0f5b6b36d561fca..519ecf61855807c37e51449ff3bf4a33ac12dfaa 100644 (file)
@@ -105,8 +105,7 @@ public:
     return DICtx->getKind() == CK_DWARF;
   }
 
-  void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
-            bool DumpEH = false, bool SummarizeTypes = false) override;
+  void dump(raw_ostream &OS, DIDumpOptions DumpOpts) override;
 
   bool verify(raw_ostream &OS, DIDumpType DumpType = DIDT_All) override;
 
index 84ab8ed173cb0b2be0b2dec71ad0effaa58a3e93..0ce49f5ef92237fac249f4a9d13ecaf93e6d712b 100644 (file)
@@ -41,8 +41,7 @@ namespace pdb {
       return DICtx->getKind() == CK_PDB;
     }
 
-    void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All,
-              bool DumpEH = false, bool SummarizeTypes = false) override;
+    void dump(raw_ostream &OS, DIDumpOptions DIDumpOpts) override;
 
     DILineInfo getLineInfoForAddress(
         uint64_t Address,
index 5ed55ce4c0dc605678cd0b7d83520903cd8ae700..1be156d6ea9b7f126f07c28d2ff140531ca91ad6 100644 (file)
@@ -84,8 +84,12 @@ static void dumpAccelSection(raw_ostream &OS, StringRef Name,
   Accel.dump(OS);
 }
 
-void DWARFContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH,
-                        bool SummarizeTypes) {
+void DWARFContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts){
+
+  DIDumpType DumpType = DumpOpts.DumpType;
+  bool DumpEH = DumpOpts.DumpEH;
+  bool SummarizeTypes = DumpOpts.SummarizeTypes;
+
   if (DumpType == DIDT_All || DumpType == DIDT_Abbrev) {
     OS << ".debug_abbrev contents:\n";
     getDebugAbbrev()->dump(OS);
index 94b81ecf561e23cdf51de7183e1c68261ebfd07c..f6b6b951ebe143741c92fc106fbb0f1674646669 100644 (file)
@@ -29,8 +29,7 @@ PDBContext::PDBContext(const COFFObjectFile &Object,
     Session->setLoadAddress(ImageBase.get());
 }
 
-void PDBContext::dump(raw_ostream &OS, DIDumpType DumpType, bool DumpEH,
-                      bool SummarizeTypes) {}
+void PDBContext::dump(raw_ostream &OS, DIDumpOptions DumpOpts){}
 
 DILineInfo PDBContext::getLineInfoForAddress(uint64_t Address,
                                              DILineInfoSpecifier Specifier) {
index 8ecf184809948e22d3a252b725886693f5bfb34e..2b5babe7982478a5246b11026bd7a27789944cdf 100644 (file)
@@ -95,8 +95,12 @@ static void DumpObjectFile(ObjectFile &Obj, Twine Filename) {
 
   outs() << Filename.str() << ":\tfile format " << Obj.getFileFormatName()
          << "\n\n";
+
   // Dump the complete DWARF structure.
-  DICtx->dump(outs(), DumpType, false, SummarizeTypes);
+  DIDumpOptions DumpOpts;
+  DumpOpts.DumpType = DumpType;
+  DumpOpts.SummarizeTypes = SummarizeTypes;
+  DICtx->dump(outs(), DumpOpts);
 }
 
 static void DumpInput(StringRef Filename) {
index 9e02951a4a93f63c75fff1be0f191916c7a4e033..a260d6ff42c5353d4e72ef0541719462003d24ac 100644 (file)
@@ -1271,7 +1271,10 @@ static void ProcessMachO(StringRef Name, MachOObjectFile *MachOOF,
   if (DwarfDumpType != DIDT_Null) {
     std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(*MachOOF));
     // Dump the complete DWARF structure.
-    DICtx->dump(outs(), DwarfDumpType, true /* DumpEH */);
+    DIDumpOptions DumpOpts;
+    DumpOpts.DumpType = DwarfDumpType;
+    DumpOpts.DumpEH = true;
+    DICtx->dump(outs(), DumpOpts);
   }
 }
 
index 18fa0e0740849ce6273e5f2efb23720989b9aa80..6a91515709089a5ea663ad1c92f628fa37997409 100644 (file)
@@ -2064,7 +2064,10 @@ static void DumpObject(ObjectFile *o, const Archive *a = nullptr) {
   if (DwarfDumpType != DIDT_Null) {
     std::unique_ptr<DIContext> DICtx(new DWARFContextInMemory(*o));
     // Dump the complete DWARF structure.
-    DICtx->dump(outs(), DwarfDumpType, true /* DumpEH */);
+    DIDumpOptions DumpOpts;
+    DumpOpts.DumpType = DwarfDumpType;
+    DumpOpts.DumpEH = true;
+    DICtx->dump(outs(), DumpOpts);
   }
 }