<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Jan 31, 2014 at 2:35 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Well, it seems wrong mainly because the description of DW_AT_signature says it applies to incomplete types.<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">A definition of a class member (static data member, or method) would normally have a DW_AT_specification referring to the declaration.  But in this case the
 declaration is buried inside a type unit, and the only thing you can refer to from outside the type unit is the type as a whole, via DW_AT_signature.</span></p></div></div></blockquote><div><br></div><div>Right - so we put just the necessary member declaration inside the type declaration and have the out of line definition's DW_AT_signature refer to that member declaration.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I’m astonished that GCC hasn’t run into this already.  Or is that where the idea for the DW_AT_declaration hack came from?</span></p>
</div></div></blockquote><div><br></div><div>This is what GCC does too, yes.<br><br>Actually GCC does about 3 or 4 different ways to refer to a type unit:<br><br>If there are few (1?) references to a type, the DW_AT_type just uses a DW_FORM_ref_sig8 directly.<br>
If there are several, a stub DW_AT_class/structure at the top level (underneath the compile_unit) with a single DW_AT_signature<br>If there are members definitions that need to refer to declarations, the stub is placed in the correct DW_TAG_namespaces, includes a DW_AT_declaration, and even a DW_AT_name. <br>
<br>Clang currently does something in between - mostly like the 3rd option, the stub goes in the right namespace, but doesn't include the type name (though as of this patch, includes the DW_AT_declaration). This is mostly just a convenient quirk of implementation (that we put it in the fully qualified namespace) - if we found that to be a substantial space savings, we could remove that too, but I didn't want to bother with that until I had some justification.<br>
<br>GDB was already swallowing DWARF like this (at least with DW_AT_declaration) without type units for the vtable optimization (your type has a key function not defined in this TU, so the type definition is not emitted here (only a declaration) - but you have some member definition in this TU (especially - an implicit special member of member template instantiation, but possibly any other member defintion such as a static member variable, or member function) so GCC and Clang both emit just the necessary member declaration into the type declaration and the out of line definition can refer to that declaration).<br>
<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">  Whining about this to Cary might
 help you feel better. </span><span style="font-size:11.0pt;font-family:Wingdings;color:#1f497d">J</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Who gets to file the issue with the DWARF committee?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Friday, January 31, 2014 2:17 PM<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [llvm] r200569 - DebugInfo: Flag type unit references as declarations<u></u><u></u></span></p>
</div>
</div><div><div class="h5">
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Fri, Jan 31, 2014 at 2:08 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">This just seems wrong. <u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">How so? (yeah, I'd sort of like it if the debugger assumed that a DW_TAG_class/structure with a DW_AT_signature was assumed to be a declaration (of sorts)) I can think of a few ways it seems wrong, but curious what you've got in mind.<u></u><u></u></p>

</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"> What prompted it?<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Several failures in gdb.cp/m-static.exp in the GDB 7.5 test suite. (there's still one more failure I'm investigating most likely due to missing DW_AT_stmt_list on type units)<br>
<br>
The story goes something like this:<br>
<br>
* Type goes in a type unit.<br>
* 'skeletal' type (DW_TAG_class with a DW_AT_signature) goes in the compile unit.<br>
* but now you want to reference one of the members of the type from within the compile unit (in m-static's case, it's because you have an out-of-line definition of a static member variable), so insert a declaration of that particular member into the 'skeletal'
 type.<br>
<br>
This freaks out GDB because it assumes the type with members (even though it has DW_AT_signature) is a definition, it seems.<br>
<br>
I can roll back the patch locally to show/demonstrate more specifically what the failure mode is.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">--paulr<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
> -----Original Message-----<br>
> From: <a href="mailto:llvm-commits-bounces@cs.uiuc.edu" target="_blank">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-" target="_blank">llvm-commits-</a><br>
> <a href="mailto:bounces@cs.uiuc.edu" target="_blank">bounces@cs.uiuc.edu</a>] On Behalf Of David Blaikie<br>
> Sent: Friday, January 31, 2014 11:52 AM<br>
> To: <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> Subject: [llvm] r200569 - DebugInfo: Flag type unit references as<br>
> declarations<br>
><br>
> Author: dblaikie<br>
> Date: Fri Jan 31 13:52:26 2014<br>
> New Revision: 200569<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=200569&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=200569&view=rev</a><br>
> Log:<br>
> DebugInfo: Flag type unit references as declarations<br>
><br>
> This ensures DWARF consumers don't confuse these references for<br>
> definitions. I'd argue it might be nice to improve debuggers so we don't<br>
> need this, but it's just one field in an abbreviation anyway - so it<br>
> doesn't seem worth the fight.<br>
><br>
> Modified:<br>
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
>     llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll<br>
><br>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=200569&r1=2<br>
> 00568&r2=200569&view=diff<br>
> ========================================================================<br>
> ======<br>
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jan 31 13:52:26<br>
> 2014<br>
> @@ -3016,6 +3016,11 @@ void DwarfDebug::emitDebugStrDWO() {<br>
>  void DwarfDebug::addDwarfTypeUnitType(DICompileUnit CUNode,<br>
>                                        StringRef Identifier, DIE<br>
> *RefDie,<br>
>                                        DICompositeType CTy) {<br>
> +  // Flag the type unit reference as a declaration so that if it<br>
> contains<br>
> +  // members (implicit special members, static data member definitions,<br>
> member<br>
> +  // declarations for definitions in this CU, etc) consumers don't get<br>
> confused<br>
> +  // and think this is a full definition.<br>
> +  CUMap.begin()->second->addFlag(RefDie, dwarf::DW_AT_declaration);<br>
><br>
>    const DwarfTypeUnit *&TU = DwarfTypeUnits[CTy];<br>
>    if (TU) {<br>
><br>
> Modified: llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/DebugInfo/X86/generate-odr-<br>
> hash.ll?rev=200569&r1=200568&r2=200569&view=diff<br>
> ========================================================================<br>
> ======<br>
> --- llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll (original)<br>
> +++ llvm/trunk/test/DebugInfo/X86/generate-odr-hash.ll Fri Jan 31<br>
> 13:52:26 2014<br>
> @@ -51,8 +51,10 @@<br>
>  ; CHECK: Compile Unit: length = [[CU_SIZE:[0-9a-f]+]]<br>
><br>
>  ; CHECK: DW_TAG_structure_type<br>
> +; CHECK-NEXT: DW_AT_declaration<br>
>  ; CHECK-NEXT: DW_AT_signature<br>
>  ; CHECK: DW_TAG_class_type<br>
> +; CHECK-NEXT: DW_AT_declaration<br>
>  ; CHECK-NEXT: DW_AT_signature<br>
><br>
>  ; Ensure the CU-local type 'walrus' is not placed in a type unit.<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>
<br>
<u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>

</blockquote></div><br></div></div>