<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 10, 2014 at 12:45 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"><span class=""><br>
> On 09 Sep 2014, at 23:40, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Tue, Sep 9, 2014 at 5:53 AM, Frederic Riss <<a href="mailto:friss@apple.com">friss@apple.com</a>> wrote:<br>
> Hi dblaikie, samsonov, echristo, aprantl,<br>
><br>
> There is no simple way to get the origin section of a DWARFUnit. It is necessary<br>
> to know from which section a Unit has been extracted to be able to resolve<br>
> cross-unit references (to find the right list to search fo the reference<br>
> target).<br>
><br>
> Would it make more sense to give it the actual section (or some kind of alias/handle to it) rather than a flag? That way it'd work for fission (split-dwarf) as well, and type units that may be in comdat sections?<br>
<br>
</span>Although this discriminates on origin section, the way it’s used is just to lookup the right Unit list in the context.</blockquote><div><br></div><div>OK - then perhaps it should just be a pointer/reference/whatever to the relevant unit list? Or do you need this for other purposes as well?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> It’s not the actual section that matters (the unit already contains a StringRef pointing to the section data). The next patch introduces:<br>
<br>
DWARFUnit *DWARFContext::getUnitForOffset(const DWARFUnit *Unit, uint32_t Offset) {<br>
   switch (Unit->getKind()) {<br>
   case DWARFUnit::UK_Compile:<br>
     return getCompileUnitForOffset(Offset);<br>
   case DWARFUnit::UK_DWOCompile:<br>
     return getDWOCompileUnitForOffset(Offset);<br>
   case DWARFUnit::UK_Type:<br>
     return getTypeUnitForOffset(Offset);<br>
   case DWARFUnit::UK_DWOType:<br>
     return getDWOTypeUnitForOffset(Offset);<br>
   }<br>
   llvm_unreachable("Unkown unit type in getUnitForOffset.");<br>
 }<br>
<br>
I’m open to any other way to achieve that. And this handles LTO and fission uses (or I can’t see what issues you’re thinking about).<br>
<br>
Fred<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> This patch adds a field and an accessor to the DWARFUnit that indicates where<br>
> it originated from. This information will be used in a subsequent patch to<br>
> implement a generic version of DWARFContext::getCompilationUnitForOffset()<br>
> that will work with arbitrary unit types.<br>
><br>
> Note that this is nearly implemented like the start of LLVM-style RTTI for<br>
> the DWARFUnit, but it seems that we don't need separate classes to represent<br>
> the DWO variants of Units as only their origin changes. Thus we only<br>
> introduce this discriminant field.<br>
><br>
> <a href="http://reviews.llvm.org/D5264" target="_blank">http://reviews.llvm.org/D5264</a><br>
><br>
> Files:<br>
>   lib/DebugInfo/DWARFCompileUnit.h<br>
>   lib/DebugInfo/DWARFContext.cpp<br>
>   lib/DebugInfo/DWARFTypeUnit.h<br>
>   lib/DebugInfo/DWARFUnit.cpp<br>
>   lib/DebugInfo/DWARFUnit.h<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>