[llvm] r217128 - Add a DWARFContext& member in DWARFUnit.

Frédéric Riss friss at apple.com
Thu Sep 4 06:37:57 PDT 2014


> On 04 Sep 2014, at 15:18, David Blaikie <dblaikie at gmail.com> wrote:
> On Sep 3, 2014 11:27 PM, "Frederic Riss" <friss at apple.com <mailto:friss at apple.com>> wrote:
> >
> > Author: friss
> > Date: Thu Sep  4 01:14:28 2014
> > New Revision: 217128
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=217128&view=rev <http://llvm.org/viewvc/llvm-project?rev=217128&view=rev>
> > Log:
> > Add a DWARFContext& member in DWARFUnit.
> >
> > 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.
> 
> Hmm, how is this useful for location expression dumping? What extra info do you need there? I guess I'll see when you get to those patches, but just curious.
> 
For location expression dumping, it allows you to access the DebugLoc object for the file being processed. I also use it in another patch to access to ‘search’ functions that only the Context provides (like DWARFContext::getLineTableForUnit()). It is also useful to resolve cross Unit references.

The context will also be the natural place to put things like dumping options if we and up adding some.
> (I was expecting this to be used for stuff like low_pc rendering for example)
> 

I have nothing planned for low_pc. What do you have in mind? Putting line information on these attributes?
> Hmm - and how did we do rendering of DW_form_strp without access to other sections via the unit? I guess we passed in the string table specifically? Can we remove that explicit passing notes that we have the whole unit?
> 
> 

The Unit contains pointers to some interesting sections’ data, among which there is the string section data. We could certainly add a string getter to the context and remove the sections data from the Unit.

Fred
> > Modified:
> >     llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h
> >     llvm/trunk/lib/DebugInfo/DWARFContext.cpp
> >     llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h
> >     llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
> >     llvm/trunk/lib/DebugInfo/DWARFUnit.h
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h?rev=217128&r1=217127&r2=217128&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h?rev=217128&r1=217127&r2=217128&view=diff>
> > ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h Thu Sep  4 01:14:28 2014
> > @@ -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;
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=217128&r1=217127&r2=217128&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=217128&r1=217127&r2=217128&view=diff>
> > ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep  4 01:14:28 2014
> > @@ -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()));
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h?rev=217128&r1=217127&r2=217128&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h?rev=217128&r1=217127&r2=217128&view=diff>
> > ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h Thu Sep  4 01:14:28 2014
> > @@ -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;
> >    }
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=217128&r1=217127&r2=217128&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=217128&r1=217127&r2=217128&view=diff>
> > ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Sep  4 01:14:28 2014
> > @@ -17,12 +17,12 @@
> >  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();
> >  }
> >
> >
> > Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.h?rev=217128&r1=217127&r2=217128&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.h?rev=217128&r1=217127&r2=217128&view=diff>
> > ==============================================================================
> > --- llvm/trunk/lib/DebugInfo/DWARFUnit.h (original)
> > +++ llvm/trunk/lib/DebugInfo/DWARFUnit.h Thu Sep  4 01:14:28 2014
> > @@ -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) {
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits <http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140904/70849487/attachment.html>


More information about the llvm-commits mailing list