<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 19, 2015 at 5:24 PM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@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 Mar 16, 2015, at 2:55 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
>> On Mon, Mar 16, 2015 at 2:45 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com">Paul_Robinson@playstation.sony.com</a>> wrote:<br>
> Beyond the above (that using a new tag would mean this would go from 'free' to 'not free' for GDB) having a new top level tag is pretty substantial (we only have two at the moment, and with our talk of modules being a "bag of dwarf" might go back to having one top level tag? (it's not clear to me from DWARF4 whether DW_TAG_module is currently a top-level tag, I don't think it is?)<br>
><br>
>> The .debug_info section contains one or more compilation units, partial units, or in DWARF 5, type units.  DW_TAG_module isn't a unit, if you want it to be handled independently then it would need to be wrapped in a DW_TAG_partial_unit.  You would probably then use DW_TAG_imported_unit to refer to it, rather than DW_TAG_imported_module.<br>
>><br>
><br>
> This makes a fair bit of sense - though the terminology's never going to quite line up with modules, I suspect, and this would still require modifying existing consumers (well, GDB) that can handle split-dwarf today, I suspect (not sure how it'd handle partial_unit - maybe that does work? - and still don't know how existing consumers would handle imported_unit either - could be worth some testing, as it sounds sort of right out of several less right options).<br>
<br>
</span>Thanks for all the input so far!<br>
To concretize this end of the discussion up let’s sketch some dwarf of how this could look like in practice.<br>
<br>
ELF (no imports)<br>
----------------<br>
<br>
On ELF or COFF a foo.c referencing types from the module Foundation looks like this:<br>
<span class=""><br>
.debug_info:<br>
  DW_TAG_compile_unit<br>
    DW_AT_name(“foo.c”)<br>
<br>
</span>.debug_info.dwo (on ELF: group 0x1234ABCDE, comdat)<br>
  DW_TAG_partial_unit<br></blockquote><div><br>For now I'd suggest we use compile_unit - that way it'll just work with existing split-dwarf consumers. We can see about standardizing a top-level DW_TAG_module or using DW_TAG_partial_unit here later, perhaps? I'm not sure.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="">    DW_AT_dwo_name(“/tmp/org.llvm.clang/ModuleCache/1234ABCDE/Foundation.pcm”)<br>
    DW_AT_dwo_id(“0x1234ABCDE”)<br>
<br>
<br>
</span>Side question: Is .debug_info.dwo the right section to put the module skeleton in, or should it be a .debug_info section like normal fission skeletons?<br></blockquote><div><br>Skeletons go in .debug_info, the dwo sections are just for the .dwo file (or the module file, in our new case - the extension isn't actually important).<br><br>It might be worth you compiling an example or two of split-dwarf to see how this all works hands-on.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Mach-O (no comdat, no imports)<br>
------------------------------<br>
<br>
Mach-O doesn’t do comdat, so with -split-dwarf=Disable (not sure if that option is the best discriminator) this could look like:<br>
<span class=""><br>
.debug_info:<br>
  DW_TAG_compile_unit<br>
    DW_AT_name(“foo.c”)<br>
</span>  DW_TAG_partial_unit<br>
<span class="">    DW_AT_dwo_name(“/tmp/org.llvm.clang/ModuleCache/1234ABCDE/Foundation.pcm”)<br>
    DW_AT_dwo_id(“0x1234ABCDE”)<br>
<br>
<br>
</span>Mach-O (no comdat, with imports)<br>
------------------------------<br>
<br>
If we add the module import information to this, we get:<br>
<span class=""><br>
.debug_info:<br>
  DW_TAG_compile_unit<br>
    DW_AT_name(“foo.c”)<br>
    DW_TAG_imported_module<br>
</span>      DW_AT_import(DW_FORM_ref_addr 0x10)<br></blockquote><div><br>Since we got went down the tangent of explaining split-dwarf many emails ago, I've forgotten (& can't readily find) what we were discussing about what ways the imported_module could work.<br><br>The simplest representation I can think of would be to have it reference, by signature, the module unit (whatever tag it uses) - DW_FORM_ref_sig8, seems the simplest thing to do.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
  DW_TAG_partial_unit<br>
<span class="">    DW_AT_dwo_name(“/tmp/org.llvm.clang/ModuleCache/1234ABCDE/Foundation.pcm”)<br>
    DW_AT_dwo_id(“0x1234ABCDE”)<br>
<br>
</span>0x10:<br></blockquote><div><br>This is inside the partial unit? I figured we'd just put these attributes on the top level (compile_unit, or whatever it might be later) - potentially conditionalized on platform, sure.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
    DW_TAG_module<br>
      DW_AT_name(“Foundation”)<br>
<span class="">      DW_AT_LLVM_sysroot(“/“)<br>
      DW_AT_LLVM_include_dir(“”)<br>
      DW_AT_LLVM_macros(“-DNDEBUG”)<br>
</span>      ...<br>
<br>
<br>
ELF (comdat, with imports)<br>
--------------------------<br>
<br>
But now let’s go back to ELF. Since the skeleton with the partial unit is comdat'd, I assume that this breaks the FORM_ref_addr used in the DW_AT_import. We could reuse the module hash as a signature for the module:<br>
<span class=""><br>
.debug_info:<br>
  DW_TAG_compile_unit<br>
    DW_AT_name(“foo.c”)<br>
    DW_TAG_imported_module<br>
</span>      DW_AT_import(DW_FORM_ref_addr 0x1234ABCDE)<br></blockquote><div><br>Still only really need these imported_modules for lldb, right? I'd consider having them off-by-default for non-darwin, but I'm not strictly wedded to that notion. Wouldn't mind seeing size impact numbers of some kind - if it's really fractional % increase & GDB doesn't fall over when it sees them (in whatever FORM/tag/etc we decide on) then that's not the end of the world.<br><br>Just seems nice if the default mode is the nice, standard, split-dwarf output. Doesn't need anything fancy.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
.debug_info.dwo (group 0x1234ABCDE, comdat)<br>
  DW_TAG_partial_unit<br>
<span class="">    DW_AT_dwo_name(“/tmp/org.llvm.clang/ModuleCache/1234ABCDE/Foundation.pcm”)<br>
    DW_AT_dwo_id(“0x1234ABCDE”)<br>
<br>
</span>    DW_TAG_module<br>
      DW_AT_signature(“0x1234ABCDE”)<br>
      DW_AT_name(“Foundation”)<br>
<br></blockquote><div><br>The thing you haven't covered is the actual .dwo sections (.debug_info.dwo (we'll probably need a simple stub compile_unit to make this correct split-dwarf) and .debug_types.dwo being important - but all the supporting .dwo sections will be necessary) that go in the module file.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is bending the definition of DW_AT_signature, but I guess it could be made to work. Or we could say that for now, users have to choose between the comdat optimization and having the module imports recorded in Dwarf, since GDB wouldn’t know what to do with that information anyway.<br>
<br>
Thoughts?<br>
<span class="HOEnZb"><font color="#888888"><br>
-- adrian</font></span></blockquote></div><br></div></div>