[llvm] r191209 - DebugInfo: Wrap section data and relocs together for dwarf dumping support

Eric Christopher echristo at gmail.com
Mon Sep 23 10:49:47 PDT 2013


Looks good. Thanks.

On Mon, Sep 23, 2013 at 10:42 AM, David Blaikie <dblaikie at gmail.com> wrote:
> Author: dblaikie
> Date: Mon Sep 23 12:42:01 2013
> New Revision: 191209
>
> URL: http://llvm.org/viewvc/llvm-project?rev=191209&view=rev
> Log:
> DebugInfo: Wrap section data and relocs together for dwarf dumping support
>
> This is a small step that may enable some simplifications in producer
> (DWARFContext) and consumer (DWARFCompileUnit and other places) by
> making a more complete abstraction around the data and relocations for a
> section. Small initial steps could include simple changes such as
> passing the pair to DWARFCompileUnit's ctor rather than passing the data
> and relocs separately. I don't intend to pursue any such changes
> immediately, however.
>
> The motivation for doing this now is that type unit dumping will need to
> deal with these data+reloc pairs moreso than the existing dumping
> support has needed to associate the data as type unit sections are named
> the same (debug_types) and comdat group folded. So to implement dumping
> and reloc handling we'll need a mapping of section->data+relocs.
>
> Modified:
>     llvm/trunk/lib/DebugInfo/DWARFContext.cpp
>     llvm/trunk/lib/DebugInfo/DWARFContext.h
>
> Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191209&r1=191208&r2=191209&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
> +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Mon Sep 23 12:42:01 2013
> @@ -69,10 +69,10 @@ void DWARFContext::dump(raw_ostream &OS,
>          cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_stmt_list,
>                                                               -1U);
>        if (stmtOffset != -1U) {
> -        DataExtractor lineData(getLineSection(), isLittleEndian(),
> +        DataExtractor lineData(getLineSection().Data, isLittleEndian(),
>                                 savedAddressByteSize);
>          DWARFDebugLine::DumpingState state(OS);
> -        DWARFDebugLine::parseStatementTable(lineData, &lineRelocMap(), &stmtOffset, state);
> +        DWARFDebugLine::parseStatementTable(lineData, &getLineSection().Relocs, &stmtOffset, state);
>        }
>      }
>    }
> @@ -206,8 +206,8 @@ const DWARFDebugLoc *DWARFContext::getDe
>    if (Loc)
>      return Loc.get();
>
> -  DataExtractor LocData(getLocSection(), isLittleEndian(), 0);
> -  Loc.reset(new DWARFDebugLoc(locRelocMap()));
> +  DataExtractor LocData(getLocSection().Data, isLittleEndian(), 0);
> +  Loc.reset(new DWARFDebugLoc(getLocSection().Relocs));
>    // assume all compile units have the same address byte size
>    if (getNumCompileUnits())
>      Loc->parse(LocData, getCompileUnitAtIndex(0)->getAddressByteSize());
> @@ -252,7 +252,7 @@ const DWARFDebugFrame *DWARFContext::get
>  const DWARFLineTable *
>  DWARFContext::getLineTableForCompileUnit(DWARFCompileUnit *cu) {
>    if (!Line)
> -    Line.reset(new DWARFDebugLine(&lineRelocMap()));
> +    Line.reset(new DWARFDebugLine(&getLineSection().Relocs));
>
>    unsigned stmtOffset =
>      cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_stmt_list,
> @@ -265,20 +265,20 @@ DWARFContext::getLineTableForCompileUnit
>      return lt;
>
>    // We have to parse it first.
> -  DataExtractor lineData(getLineSection(), isLittleEndian(),
> +  DataExtractor lineData(getLineSection().Data, isLittleEndian(),
>                           cu->getAddressByteSize());
>    return Line->getOrParseLineTable(lineData, stmtOffset);
>  }
>
>  void DWARFContext::parseCompileUnits() {
>    uint32_t offset = 0;
> -  const DataExtractor &DIData = DataExtractor(getInfoSection(),
> +  const DataExtractor &DIData = DataExtractor(getInfoSection().Data,
>                                                isLittleEndian(), 0);
>    while (DIData.isValidOffset(offset)) {
>      OwningPtr<DWARFCompileUnit> CU(new DWARFCompileUnit(
> -        getDebugAbbrev(), getInfoSection(), getAbbrevSection(),
> +        getDebugAbbrev(), getInfoSection().Data, getAbbrevSection(),
>          getRangeSection(), getStringSection(), StringRef(), getAddrSection(),
> -        &infoRelocMap(), isLittleEndian()));
> +        &getInfoSection().Relocs, isLittleEndian()));
>      if (!CU->extract(DIData, &offset)) {
>        break;
>      }
> @@ -289,14 +289,14 @@ void DWARFContext::parseCompileUnits() {
>
>  void DWARFContext::parseDWOCompileUnits() {
>    uint32_t offset = 0;
> -  const DataExtractor &DIData = DataExtractor(getInfoDWOSection(),
> -                                              isLittleEndian(), 0);
> +  const DataExtractor &DIData =
> +      DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);
>    while (DIData.isValidOffset(offset)) {
>      OwningPtr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(
> -        getDebugAbbrevDWO(), getInfoDWOSection(), getAbbrevDWOSection(),
> +        getDebugAbbrevDWO(), getInfoDWOSection().Data, getAbbrevDWOSection(),
>          getRangeDWOSection(), getStringDWOSection(),
> -        getStringOffsetDWOSection(), getAddrSection(), &infoDWORelocMap(),
> -        isLittleEndian()));
> +        getStringOffsetDWOSection(), getAddrSection(),
> +        &getInfoDWOSection().Relocs, isLittleEndian()));
>      if (!DWOCU->extract(DIData, &offset)) {
>        break;
>      }
> @@ -574,17 +574,17 @@ DWARFContextInMemory::DWARFContextInMemo
>      }
>
>      StringRef *Section = StringSwitch<StringRef*>(name)
> -        .Case("debug_info", &InfoSection)
> +        .Case("debug_info", &InfoSection.Data)
>          .Case("debug_abbrev", &AbbrevSection)
> -        .Case("debug_loc", &LocSection)
> -        .Case("debug_line", &LineSection)
> +        .Case("debug_loc", &LocSection.Data)
> +        .Case("debug_line", &LineSection.Data)
>          .Case("debug_aranges", &ARangeSection)
>          .Case("debug_frame", &DebugFrameSection)
>          .Case("debug_str", &StringSection)
>          .Case("debug_ranges", &RangeSection)
>          .Case("debug_pubnames", &PubNamesSection)
>          .Case("debug_gnu_pubnames", &GnuPubNamesSection)
> -        .Case("debug_info.dwo", &InfoDWOSection)
> +        .Case("debug_info.dwo", &InfoDWOSection.Data)
>          .Case("debug_abbrev.dwo", &AbbrevDWOSection)
>          .Case("debug_str.dwo", &StringDWOSection)
>          .Case("debug_str_offsets.dwo", &StringOffsetDWOSection)
> @@ -611,10 +611,10 @@ DWARFContextInMemory::DWARFContextInMemo
>      // TODO: Add support for relocations in other sections as needed.
>      // Record relocations for the debug_info and debug_line sections.
>      RelocAddrMap *Map = StringSwitch<RelocAddrMap*>(RelSecName)
> -        .Case("debug_info", &InfoRelocMap)
> -        .Case("debug_loc", &LocRelocMap)
> -        .Case("debug_info.dwo", &InfoDWORelocMap)
> -        .Case("debug_line", &LineRelocMap)
> +        .Case("debug_info", &InfoSection.Relocs)
> +        .Case("debug_loc", &LocSection.Relocs)
> +        .Case("debug_info.dwo", &InfoDWOSection.Relocs)
> +        .Case("debug_line", &LineSection.Relocs)
>          .Default(0);
>      if (!Map)
>        continue;
>
> Modified: llvm/trunk/lib/DebugInfo/DWARFContext.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.h?rev=191209&r1=191208&r2=191209&view=diff
> ==============================================================================
> --- llvm/trunk/lib/DebugInfo/DWARFContext.h (original)
> +++ llvm/trunk/lib/DebugInfo/DWARFContext.h Mon Sep 23 12:42:01 2013
> @@ -48,6 +48,11 @@ class DWARFContext : public DIContext {
>    void parseDWOCompileUnits();
>
>  public:
> +  struct Section {
> +    StringRef Data;
> +    RelocAddrMap Relocs;
> +  };
> +
>    DWARFContext() : DIContext(CK_DWARF) {}
>    virtual ~DWARFContext();
>
> @@ -113,28 +118,24 @@ public:
>
>    virtual bool isLittleEndian() const = 0;
>    virtual uint8_t getAddressSize() const = 0;
> -  virtual const RelocAddrMap &infoRelocMap() const = 0;
> -  virtual const RelocAddrMap &lineRelocMap() const = 0;
> -  virtual const RelocAddrMap &locRelocMap() const = 0;
> -  virtual StringRef getInfoSection() = 0;
> +  virtual const Section &getInfoSection() = 0;
>    virtual StringRef getAbbrevSection() = 0;
> -  virtual StringRef getLocSection() = 0;
> +  virtual const Section &getLocSection() = 0;
>    virtual StringRef getARangeSection() = 0;
>    virtual StringRef getDebugFrameSection() = 0;
> -  virtual StringRef getLineSection() = 0;
> +  virtual const Section &getLineSection() = 0;
>    virtual StringRef getStringSection() = 0;
>    virtual StringRef getRangeSection() = 0;
>    virtual StringRef getPubNamesSection() = 0;
>    virtual StringRef getGnuPubNamesSection() = 0;
>
>    // Sections for DWARF5 split dwarf proposal.
> -  virtual StringRef getInfoDWOSection() = 0;
> +  virtual const Section &getInfoDWOSection() = 0;
>    virtual StringRef getAbbrevDWOSection() = 0;
>    virtual StringRef getStringDWOSection() = 0;
>    virtual StringRef getStringOffsetDWOSection() = 0;
>    virtual StringRef getRangeDWOSection() = 0;
>    virtual StringRef getAddrSection() = 0;
> -  virtual const RelocAddrMap &infoDWORelocMap() const = 0;
>
>    static bool isSupportedVersion(unsigned version) {
>      return version == 2 || version == 3 || version == 4;
> @@ -155,23 +156,19 @@ class DWARFContextInMemory : public DWAR
>    virtual void anchor();
>    bool IsLittleEndian;
>    uint8_t AddressSize;
> -  RelocAddrMap InfoRelocMap;
> -  RelocAddrMap LocRelocMap;
> -  RelocAddrMap LineRelocMap;
> -  StringRef InfoSection;
> +  Section InfoSection;
>    StringRef AbbrevSection;
> -  StringRef LocSection;
> +  Section LocSection;
>    StringRef ARangeSection;
>    StringRef DebugFrameSection;
> -  StringRef LineSection;
> +  Section LineSection;
>    StringRef StringSection;
>    StringRef RangeSection;
>    StringRef PubNamesSection;
>    StringRef GnuPubNamesSection;
>
>    // Sections for DWARF5 split dwarf proposal.
> -  RelocAddrMap InfoDWORelocMap;
> -  StringRef InfoDWOSection;
> +  Section InfoDWOSection;
>    StringRef AbbrevDWOSection;
>    StringRef StringDWOSection;
>    StringRef StringOffsetDWOSection;
> @@ -185,22 +182,19 @@ public:
>    ~DWARFContextInMemory();
>    virtual bool isLittleEndian() const { return IsLittleEndian; }
>    virtual uint8_t getAddressSize() const { return AddressSize; }
> -  virtual const RelocAddrMap &infoRelocMap() const { return InfoRelocMap; }
> -  virtual const RelocAddrMap &locRelocMap() const { return LocRelocMap; }
> -  virtual const RelocAddrMap &lineRelocMap() const { return LineRelocMap; }
> -  virtual StringRef getInfoSection() { return InfoSection; }
> +  virtual const Section &getInfoSection() { return InfoSection; }
>    virtual StringRef getAbbrevSection() { return AbbrevSection; }
> -  virtual StringRef getLocSection() { return LocSection; }
> +  virtual const Section &getLocSection() { return LocSection; }
>    virtual StringRef getARangeSection() { return ARangeSection; }
>    virtual StringRef getDebugFrameSection() { return DebugFrameSection; }
> -  virtual StringRef getLineSection() { return LineSection; }
> +  virtual const Section &getLineSection() { return LineSection; }
>    virtual StringRef getStringSection() { return StringSection; }
>    virtual StringRef getRangeSection() { return RangeSection; }
>    virtual StringRef getPubNamesSection() { return PubNamesSection; }
>    virtual StringRef getGnuPubNamesSection() { return GnuPubNamesSection; }
>
>    // Sections for DWARF5 split dwarf proposal.
> -  virtual StringRef getInfoDWOSection() { return InfoDWOSection; }
> +  virtual const Section &getInfoDWOSection() { return InfoDWOSection; }
>    virtual StringRef getAbbrevDWOSection() { return AbbrevDWOSection; }
>    virtual StringRef getStringDWOSection() { return StringDWOSection; }
>    virtual StringRef getStringOffsetDWOSection() {
> @@ -210,9 +204,6 @@ public:
>    virtual StringRef getAddrSection() {
>      return AddrSection;
>    }
> -  virtual const RelocAddrMap &infoDWORelocMap() const {
> -    return InfoDWORelocMap;
> -  }
>  };
>
>  }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list