<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 4, 2014 at 6:37 AM, Frédéric Riss <span dir="ltr"><<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class=""><blockquote type="cite"><div>On 04 Sep 2014, at 15:18, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div>
<div><p dir="ltr">
On Sep 3, 2014 11:27 PM, "Frederic Riss" <<a href="mailto:friss@apple.com" target="_blank">friss@apple.com</a>> wrote:<br>
><br>
> Author: friss<br>
> Date: Thu Sep  4 01:14:28 2014<br>
> New Revision: 217128<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=217128&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=217128&view=rev</a><br>
> Log:<br>
> Add a DWARFContext& member in DWARFUnit.<br>
><br>
> The DWARFContext will be used to pass global 'context' down, like<br>
> pointers to related debug info sections or command line options.<br>
> The first use will be for the debug_info dumper to be able to access<br>
> other debug info section to dump eg. Location Expression inline<br>
> in the debug_info dump.</p><p dir="ltr">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.</p></div></blockquote>
</div><div>For location expression dumping, it allows you to access the DebugLoc object for the file being processed.</div></div></div></blockquote><div><br></div><div>Oh, that's for debug_loc references? That's fair I suppose (in the same way that referencing strings, filenames, etc does).</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div> 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.</div>
</div></div></blockquote><div><br></div><div>*nod*</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br></div>
<div>The context will also be the natural place to put things like dumping options if we and up adding some.</div><div class=""><blockquote type="cite"><div><p dir="ltr">(I was expecting this to be used for stuff like low_pc rendering for example)</p>
</div></blockquote><div><br></div></div>I have nothing planned for low_pc. What do you have in mind? Putting line information on these attributes?</div></div></blockquote><div><br>Ah, no worries - in terms of unicorns/ponies/whatever, I was thinking we could render addresses (low/high_pc, etc) in the same form as a debugger, as symbol+offset. (so low_pc of a subprogram would simply be "<symbol()>" and then low_pc of some scope within it might be "<symbol()+42>" etc... )<br>
<br>[As a side note: Eric and I were tossing around ideas for how we might reduce the number of relocations in debug info further, possibly by allowing low_pc to be relative to the low_pc of its enclosing scope - with some interesting shenanigans for debug_ranges, etc]<br>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class=""><br><blockquote type="cite"><div><p dir="ltr">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?</p>
<div><br></div></div></blockquote><div><br></div></div><div>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.</div>
<div><br></div><div>Fred</div><div><div class="h5"><blockquote type="cite"><div><p dir="ltr">
> Modified:<br>
>     llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h<br>
>     llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
>     llvm/trunk/lib/DebugInfo/DWARFUnit.h<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h?rev=217128&r1=217127&r2=217128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h?rev=217128&r1=217127&r2=217128&view=diff</a><br>


> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFCompileUnit.h Thu Sep  4 01:14:28 2014<br>
> @@ -16,10 +16,10 @@ namespace llvm {<br>
><br>
>  class DWARFCompileUnit : public DWARFUnit {<br>
>  public:<br>
> -  DWARFCompileUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,<br>
> -                   StringRef SS, StringRef SOS, StringRef AOS,<br>
> -                   const RelocAddrMap *M, bool LE)<br>
> -      : DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}<br>
> +  DWARFCompileUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA,<br>
> +                   StringRef IS, StringRef RS, StringRef SS, StringRef SOS,<br>
> +                   StringRef AOS, const RelocAddrMap *M, bool LE)<br>
> +    : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {}<br>
>    void dump(raw_ostream &OS);<br>
>    // VTable anchor.<br>
>    ~DWARFCompileUnit() override;<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=217128&r1=217127&r2=217128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=217128&r1=217127&r2=217128&view=diff</a><br>


> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Thu Sep  4 01:14:28 2014<br>
> @@ -318,7 +318,7 @@ void DWARFContext::parseCompileUnits() {<br>
>    const DataExtractor &DIData = DataExtractor(getInfoSection().Data,<br>
>                                                isLittleEndian(), 0);<br>
>    while (DIData.isValidOffset(offset)) {<br>
> -    std::unique_ptr<DWARFCompileUnit> CU(new DWARFCompileUnit(<br>
> +    std::unique_ptr<DWARFCompileUnit> CU(new DWARFCompileUnit(*this,<br>
>          getDebugAbbrev(), getInfoSection().Data, getRangeSection(),<br>
>          getStringSection(), StringRef(), getAddrSection(),<br>
>          &getInfoSection().Relocs, isLittleEndian()));<br>
> @@ -338,10 +338,10 @@ void DWARFContext::parseTypeUnits() {<br>
>      const DataExtractor &DIData =<br>
>          DataExtractor(I.second.Data, isLittleEndian(), 0);<br>
>      while (DIData.isValidOffset(offset)) {<br>
> -      std::unique_ptr<DWARFTypeUnit> TU(<br>
> -          new DWARFTypeUnit(getDebugAbbrev(), I.second.Data, getRangeSection(),<br>
> -                            getStringSection(), StringRef(), getAddrSection(),<br>
> -                            &I.second.Relocs, isLittleEndian()));<br>
> +      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,<br>
> +           getDebugAbbrev(), I.second.Data, getRangeSection(),<br>
> +           getStringSection(), StringRef(), getAddrSection(),<br>
> +           &I.second.Relocs, isLittleEndian()));<br>
>        if (!TU->extract(DIData, &offset))<br>
>          break;<br>
>        TUs.push_back(std::move(TU));<br>
> @@ -357,7 +357,7 @@ void DWARFContext::parseDWOCompileUnits(<br>
>    const DataExtractor &DIData =<br>
>        DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0);<br>
>    while (DIData.isValidOffset(offset)) {<br>
> -    std::unique_ptr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(<br>
> +    std::unique_ptr<DWARFCompileUnit> DWOCU(new DWARFCompileUnit(*this,<br>
>          getDebugAbbrevDWO(), getInfoDWOSection().Data, getRangeDWOSection(),<br>
>          getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),<br>
>          &getInfoDWOSection().Relocs, isLittleEndian()));<br>
> @@ -377,7 +377,7 @@ void DWARFContext::parseDWOTypeUnits() {<br>
>      const DataExtractor &DIData =<br>
>          DataExtractor(I.second.Data, isLittleEndian(), 0);<br>
>      while (DIData.isValidOffset(offset)) {<br>
> -      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(<br>
> +      std::unique_ptr<DWARFTypeUnit> TU(new DWARFTypeUnit(*this,<br>
>            getDebugAbbrevDWO(), I.second.Data, getRangeDWOSection(),<br>
>            getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(),<br>
>            &I.second.Relocs, isLittleEndian()));<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h?rev=217128&r1=217127&r2=217128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h?rev=217128&r1=217127&r2=217128&view=diff</a><br>


> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFTypeUnit.h Thu Sep  4 01:14:28 2014<br>
> @@ -19,10 +19,10 @@ private:<br>
>    uint64_t TypeHash;<br>
>    uint32_t TypeOffset;<br>
>  public:<br>
> -  DWARFTypeUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,<br>
> -                StringRef SS, StringRef SOS, StringRef AOS,<br>
> -                const RelocAddrMap *M, bool LE)<br>
> -      : DWARFUnit(DA, IS, RS, SS, SOS, AOS, M, LE) {}<br>
> +  DWARFTypeUnit(DWARFContext &Context, const DWARFDebugAbbrev *DA,<br>
> +                StringRef IS, StringRef RS, StringRef SS, StringRef SOS,<br>
> +                StringRef AOS, const RelocAddrMap *M, bool LE)<br>
> +    : DWARFUnit(Context, DA, IS, RS, SS, SOS, AOS, M, LE) {}<br>
>    uint32_t getHeaderSize() const override {<br>
>      return DWARFUnit::getHeaderSize() + 12;<br>
>    }<br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=217128&r1=217127&r2=217128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.cpp?rev=217128&r1=217127&r2=217128&view=diff</a><br>


> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFUnit.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFUnit.cpp Thu Sep  4 01:14:28 2014<br>
> @@ -17,12 +17,12 @@<br>
>  using namespace llvm;<br>
>  using namespace dwarf;<br>
><br>
> -DWARFUnit::DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,<br>
> -                     StringRef SS, StringRef SOS, StringRef AOS,<br>
> -                     const RelocAddrMap *M, bool LE)<br>
> -    : Abbrev(DA), InfoSection(IS), RangeSection(RS), StringSection(SS),<br>
> -      StringOffsetSection(SOS), AddrOffsetSection(AOS), RelocMap(M),<br>
> -      isLittleEndian(LE) {<br>
> +DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFDebugAbbrev *DA,<br>
> +                     StringRef IS, StringRef RS, StringRef SS, StringRef SOS,<br>
> +                     StringRef AOS, const RelocAddrMap *M, bool LE)<br>
> +  : Context(DC), Abbrev(DA), InfoSection(IS), RangeSection(RS),<br>
> +    StringSection(SS), StringOffsetSection(SOS), AddrOffsetSection(AOS),<br>
> +    RelocMap(M), isLittleEndian(LE) {<br>
>    clear();<br>
>  }<br>
><br>
><br>
> Modified: llvm/trunk/lib/DebugInfo/DWARFUnit.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.h?rev=217128&r1=217127&r2=217128&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFUnit.h?rev=217128&r1=217127&r2=217128&view=diff</a><br>


> ==============================================================================<br>
> --- llvm/trunk/lib/DebugInfo/DWARFUnit.h (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARFUnit.h Thu Sep  4 01:14:28 2014<br>
> @@ -22,11 +22,14 @@ namespace object {<br>
>  class ObjectFile;<br>
>  }<br>
><br>
> +class DWARFContext;<br>
>  class DWARFDebugAbbrev;<br>
>  class StringRef;<br>
>  class raw_ostream;<br>
><br>
>  class DWARFUnit {<br>
> +  DWARFContext &Context;<br>
> +<br>
>    const DWARFDebugAbbrev *Abbrev;<br>
>    StringRef InfoSection;<br>
>    StringRef RangeSection;<br>
> @@ -63,12 +66,14 @@ protected:<br>
>    virtual uint32_t getHeaderSize() const { return 11; }<br>
><br>
>  public:<br>
> -  DWARFUnit(const DWARFDebugAbbrev *DA, StringRef IS, StringRef RS,<br>
> -            StringRef SS, StringRef SOS, StringRef AOS, const RelocAddrMap *M,<br>
> -            bool LE);<br>
> +  DWARFUnit(DWARFContext& Context, const DWARFDebugAbbrev *DA, StringRef IS,<br>
> +            StringRef RS, StringRef SS, StringRef SOS, StringRef AOS,<br>
> +            const RelocAddrMap *M, bool LE);<br>
><br>
>    virtual ~DWARFUnit();<br>
><br>
> +  DWARFContext& getContext() const { return Context; }<br>
> +<br>
>    StringRef getStringSection() const { return StringSection; }<br>
>    StringRef getStringOffsetSection() const { return StringOffsetSection; }<br>
>    void setAddrOffsetSection(StringRef AOS, uint32_t Base) {<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</p>
</div></blockquote></div></div></div><br></div></blockquote></div><br></div></div>