Add a DWARFContext& member in DWARFUnit.
authorFrederic Riss <friss@apple.com>
Thu, 4 Sep 2014 06:14:28 +0000 (06:14 +0000)
committerFrederic Riss <friss@apple.com>
Thu, 4 Sep 2014 06:14:28 +0000 (06:14 +0000)
The DWARFContext will be used to pass global 'context' down, like
pointers to related debug info sections or command line options.
The first use will be for the debug_info dumper to be able to access
other debug info section to dump eg. Location Expression inline
in the debug_info dump.

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

lib/DebugInfo/DWARFCompileUnit.h
lib/DebugInfo/DWARFContext.cpp
lib/DebugInfo/DWARFTypeUnit.h
lib/DebugInfo/DWARFUnit.cpp
lib/DebugInfo/DWARFUnit.h

index 4fee0d2f8ad448b890cc83757fbe1ce1942be78b..bf875fbe41fd9dfd9accfb628162ac7edad60515 100644 (file)
@@ -16,10 +16,10 @@ namespace llvm {
 
 class DWARFCompileUnit : public DWARFUnit {
 public:
-  DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
-                   StringRef SS, StringRef SOS, StringRef AOS,
-                   const RelocAddrMap *M, bool LE)
-      : DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}
+  DWARFCompileUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA,
+                   StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
+                   StringRef AOS, const RelocAddrMap *M, bool LE)
+    : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {}
   void dump(raw_ostream &OS);
   // VTable anchor.
   ~DWARFCompileUnit() override;
index fc8d93dce3d0c8a5fde50f532e1f85e3be53da8c..4a57613e42592568fe27760f5b6b6c477b8fa5ee 100644 (file)
@@ -318,7 +318,7 @@ void DWARFContext::parseCompileUnits() {
   const DataExtractor &DIData = DataExtractor(getInfoSection().Data,
                                               isLittleEndian(), 0);
   while (DIData.isValidOffset(offset)) {
-    std::unique_ptr<DWARFCompileUnit> CU(new DWARFCompileUnit(
+    std::unique_ptr<DWARFCompileUnit> CU(new DWARFCompileUnit(*this,
         getDebugAbbrev(), getInfoSection().Data, getRangeSection(),
         getStringSection(), StringRef(), getAddrSection(),
         &getInfoSection().Relocs, isLittleEndian()));
@@ -338,10 +338,10 @@ void DWARFContext::parseTypeUnits() {
     const DataExtractor &DIData =
         DataExtractor(I.second.Data, isLittleEndian(), 0);
     while (DIData.isValidOffset(offset)) {
-      std::unique_ptr<DWARFTypeUnit> TU(
-          new DWARFTypeUnit(getDebugAbbrev(), I.second.Data, getRangeSection(),
-                            getStringSection(), StringRef(), getAddrSection(),
-                            &I.second.Relocs, isLittleEndian()));
+      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
+           getDebugAbbrev(), I.second.Data, getRangeSection(),
+           getStringSection(), StringRef(), getAddrSection(),
+           &I.second.Relocs, isLittleEndian()));
       if (!TU->extract(DIData, &offset))
         break;
       TUs.push_back(std::move(TU));
@@ -357,7 +357,7 @@ void DWARFContext::parseDWOCompileUnits() {
   const DataExtractor &DIData =
       DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);
   while (DIData.isValidOffset(offset)) {
-    std::unique_ptr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(
+    std::unique_ptr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(*this,
         getDebugAbbrevDWO(), getInfoDWOSection().Data, getRangeDWOSection(),
         getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
         &getInfoDWOSection().Relocs, isLittleEndian()));
@@ -377,7 +377,7 @@ void DWARFContext::parseDWOTypeUnits() {
     const DataExtractor &DIData =
         DataExtractor(I.second.Data, isLittleEndian(), 0);
     while (DIData.isValidOffset(offset)) {
-      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(
+      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,
           getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),
           getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),
           &I.second.Relocs, isLittleEndian()));
index 9c76b4f72c7141908bb9f3521dd0c7e3c610a8db..ec1f90d6acce7fa8d193baf7db52d5b6a3fbe5d3 100644 (file)
@@ -19,10 +19,10 @@ private:
   uint64_t TypeHash;
   uint32_t TypeOffset;
 public:
-  DWARFTypeUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
-                StringRef SS, StringRef SOS, StringRef AOS,
-                const RelocAddrMap *M, bool LE)
-      : DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}
+  DWARFTypeUnit(DWARFContext &Context, const DWARFDebugAbbrev *DA,
+                StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
+                StringRef AOS, const RelocAddrMap *M, bool LE)
+    : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {}
   uint32_t getHeaderSize() const override {
     return DWARFUnit::getHeaderSize() + 12;
   }
index 6ed3e04b7bf304c2f42e3851f2d10acfa7949507..fe75ebe2dc58e3fb58171b86be133c4d1f12b185 100644 (file)
 using namespace llvm;
 using namespace dwarf;
 
-DWARFUnit::DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
-                     StringRef SS, StringRef SOS, StringRef AOS,
-                     const RelocAddrMap *M, bool LE)
-    : Abbrev(DA), InfoSection(IS), RangeSection(RS), StringSection(SS),
-      StringOffsetSection(SOS), AddrOffsetSection(AOS), RelocMap(M),
-      isLittleEndian(LE) {
+DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFDebugAbbrev *DA,
+                     StringRef IS, StringRef RS, StringRef SS, StringRef SOS,
+                     StringRef AOS, const RelocAddrMap *M, bool LE)
+  : Context(DC), Abbrev(DA), InfoSection(IS), RangeSection(RS),
+    StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),
+    RelocMap(M), isLittleEndian(LE) {
   clear();
 }
 
index 206d86c3087f6b0d16a53650130f1fdd5ae373da..763caddb9d7df59f61b4cf1cf849b75da328cd0b 100644 (file)
@@ -22,11 +22,14 @@ namespace object {
 class ObjectFile;
 }
 
+class DWARFContext;
 class DWARFDebugAbbrev;
 class StringRef;
 class raw_ostream;
 
 class DWARFUnit {
+  DWARFContext &Context;
+
   const DWARFDebugAbbrev *Abbrev;
   StringRef InfoSection;
   StringRef RangeSection;
@@ -63,12 +66,14 @@ protected:
   virtual uint32_t getHeaderSize() const { return 11; }
 
 public:
-  DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,
-            StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M,
-            bool LE);
+  DWARFUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA, StringRef IS,
+            StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,
+            const RelocAddrMap *M, bool LE);
 
   virtual ~DWARFUnit();
 
+  DWARFContext& getContext() const { return Context; }
+
   StringRef getStringSection() const { return StringSection; }
   StringRef getStringOffsetSection() const { return StringOffsetSection; }
   void setAddrOffsetSection(StringRef AOS, uint32_t Base) {