<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 9, 2015 at 11:11 AM, 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">Actually no, we prefer to have the original typedef names in the instantiation name, for source fidelity.</span></p></div></div></blockquote><div><br></div><div>Then perhaps you should keep this change in your tree too - since that's where the need is?</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">  "Name as it is in the source" or something reasonably
 close.  Unwrapping typedefs is going too far.</span></p></div></div></blockquote><div><br></div><div>Yet this isn't the choice upstream in Clang or GCC. I don't know about other DWARF generators, but it seems your interpretation isn't the way some other people/implementers are reading the DWARF spec.<br><br>[This seems like it would present a multitude of challenges to any DWARF debugger dealing with this kind of debug info - it'd have to know far more about the rules of the C++ language (which you've previously argued in favor of avoiding) to perform a variety of operations if the types don't match up fairly trivially.]<br><br>In any case, arguably 5.5.8 (Class Template Instantiations) 1 only applies to definitions of a type, not declarations. ("Each formal parameterized type declaration appearing in the template definition is represented by a debugging information entry with the tag DW_TAG_template_type_parameter") which, I agree, seems like a bug in the spec to not /allow/ them on declarations, but I'd equally argue requiring them would seem too narrow to me.</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"><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="color:rgb(31,73,125);font-family:Calibri,sans-serif;font-size:11pt">Re. "looseness" of the DWARF spec, it is not so loose as you like to think.  Attributes tend to be fairly optional or can be used "in novel ways" but the DIEs
 and their relationships are not like that.  "Where this specification provides a means for describing the source language, implementors are expected to adhere to that specification."</span><br></p></div></blockquote><div><br></div><div>Why would that clause apply to attributes any less than it applies to DIEs? It seems like a fairly broad statement.<br><br>I forget whether we already discussed it - but do you have any size data (preferably/possibly from a fission build or otherwise measurement of "just the debug info" not the whole binary) on, for example, a clang selfhost?<br><br>- Dave</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">--paulr<u></u><u></u></span></p>
<p class="MsoNormal"><a name="1518827de73aaa57__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></a></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> Wednesday, December 09, 2015 10:49 AM<br>
<b>To:</b> Robinson, Paul<br>
<b>Cc:</b> Marshall, Peter; llvm-dev; cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)</span></p><div><div class="h5"><br>
<b>Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.<u></u><u></u></div></div><p></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"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Dec 9, 2015 at 10:40 AM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:<u></u><u></u></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">
That doesn't seem to be the DWARF I'm seeing from Clang (& it'd be surprising if we used the typedef (or otherwise non-canonical) name in the class name):<u></u><u></u></p>
<p class="MsoNormal"><a name="1518827de73aaa57_151880ba5c41f1e2__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span></a><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Finally getting back to this…..  Ha.  We don't unwrap the typedefs ("name as it is in the source"),
 while the upstream compiler does.</span><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Yeah, I imagine you'd want to fix that as I expect it would cause you other problems, no? (or is there some reason you have this change to the compiler? I imagine it'd be hard to have that divergence by accident?)<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">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Providing the template-parameter DIEs is still the correct thing to do per the DWARF</span> <u></u><u></u></p>
</div>
</div>
</blockquote>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">spec.</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">I still don't agree that the DWARF we produce here is incorrect (the DWARF spec is pretty loose on "correctness" of DWARF). If there's some practical problem/use case it'd be useful to understand it so we make sure we're fixing it the right
 way.<br>
<br>
- Dave<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">
<div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">--paulr</span><u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"> </span><u></u><u></u></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, November 13, 2015 11:21 AM<br>
<b>To:</b> Marshall, Peter; llvm-dev<br>
<b>Cc:</b> Robinson, Paul</span><u></u><u></u></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.<u></u><u></u></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">On Fri, Nov 13, 2015 at 6:16 AM, <<a href="mailto:Peter_Marshall@sn.scee.net" target="_blank">Peter_Marshall@sn.scee.net</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Hi Paul,</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">Sorry for the delay, I've been out of the office.</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">I think this example shows that name matching does not always work:</span>
<br>
<br>
<tt><span style="font-size:10.0pt">template<typename T> class A {</span></tt> <br>
<tt><span style="font-size:10.0pt">public:</span></tt> <br>
<tt><span style="font-size:10.0pt">        A(T val);</span></tt> <br>
<tt><span style="font-size:10.0pt">private:</span></tt> <br>
<tt><span style="font-size:10.0pt">        T x;</span></tt> <br>
<tt><span style="font-size:10.0pt">}; </span></tt><br>
<br>
<tt><span style="font-size:10.0pt">struct B {</span></tt> <br>
<tt><span style="font-size:10.0pt">        typedef float MONKEY;</span></tt> <br>
<br>
<tt><span style="font-size:10.0pt">        A<MONKEY> *p;</span></tt> <br>
<tt><span style="font-size:10.0pt">};</span></tt> <br>
<br>
<tt><span style="font-size:10.0pt">B b;</span></tt> <br>
<br>
<tt><span style="font-size:10.0pt">struct C {</span></tt> <br>
<tt><span style="font-size:10.0pt">        typedef int MONKEY;</span></tt> <br>
<br>
<tt><span style="font-size:10.0pt">        A<MONKEY> *p;</span></tt> <br>
<tt><span style="font-size:10.0pt">};</span></tt> <br>
<br>
<tt><span style="font-size:10.0pt">C c;</span></tt> <br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">This gives this DWARF:</span>
<br>
<br>
<tt><span style="font-size:10.0pt">+-0000003f DW_TAG_structure_type "B"</span></tt>
<br>
<tt><span style="font-size:10.0pt">   -DW_AT_name  DW_FORM_strp  "B"</span></tt> <br>
<tt><span style="font-size:10.0pt">  +-00000047 DW_TAG_member "p"</span></tt> <br>
<tt><span style="font-size:10.0pt">     -DW_AT_name  DW_FORM_strp  "p"</span></tt>
<br>
<tt><span style="font-size:10.0pt">    +-DW_AT_type  DW_FORM_ref4  0x00000054</span></tt>
<br>
<tt><span style="font-size:10.0pt">      +-00000054 DW_TAG_pointer_type </span></tt><br>
<tt><span style="font-size:10.0pt">        +-DW_AT_type  DW_FORM_ref4  0x00000059</span></tt>
<br>
<tt><span style="font-size:10.0pt">          +-00000059 DW_TAG_class_type "A<MONKEY>"</span></tt>
<br>
<tt><span style="font-size:10.0pt">             -DW_AT_name  DW_FORM_strp  "A<MONKEY>"</span></tt>
<br>
<tt><span style="font-size:10.0pt">             -DW_AT_declaration  DW_FORM_flag_present  </span></tt>
<br>
<br>
<tt><span style="font-size:10.0pt">+-00000073 DW_TAG_structure_type "C"</span></tt>
<br>
<tt><span style="font-size:10.0pt">   -DW_AT_name  DW_FORM_strp  "C"</span></tt> <br>
<tt><span style="font-size:10.0pt">  +-0000007b DW_TAG_member "p"</span></tt> <br>
<tt><span style="font-size:10.0pt">     -DW_AT_name  DW_FORM_strp  "p"</span></tt>
<br>
<tt><span style="font-size:10.0pt">    +-DW_AT_type  DW_FORM_ref4  0x00000088</span></tt>
<br>
<tt><span style="font-size:10.0pt">      +-00000088 DW_TAG_pointer_type </span></tt><br>
<tt><span style="font-size:10.0pt">        +-DW_AT_type  DW_FORM_ref4  0x0000008d</span></tt>
<br>
<tt><span style="font-size:10.0pt">          +-0000008d DW_TAG_class_type "A<MONKEY>"</span></tt>
<br>
<tt><span style="font-size:10.0pt">             -DW_AT_name  DW_FORM_strp  "A<MONKEY>"</span></tt>
<br>
<tt><span style="font-size:10.0pt">             -DW_AT_declaration  DW_FORM_flag_present  </span></tt>
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">That doesn't seem to be the DWARF I'm seeing from Clang (& it'd be surprising if we used the typedef (or otherwise non-canonical) name in the class name):<br>
<br>
(I've trimmed a few irrelevant attributes)<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000001e:   DW_TAG_variable [2]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x0000004c] = "b")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_type [DW_FORM_ref4]       (cu + 0x0033 => {0x00000033})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000033:   DW_TAG_structure_type [3] *</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000059] = "B")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000003b:     DW_TAG_member [4]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                  DW_AT_name [DW_FORM_strp]     ( .debug_str[0x0000004e] = "p")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                  DW_AT_type [DW_FORM_ref4]     (cu + 0x0048 => {0x00000048})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000047:     NULL</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000048:   DW_TAG_pointer_type [5]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_type [DW_FORM_ref4]       (cu + 0x004d => {0x0000004d})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000004d:   DW_TAG_class_type [6]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000050] = "A<float>")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_declaration [DW_FORM_flag_present]        (true)</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000052:   DW_TAG_variable [2]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x0000005b] = "c")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_type [DW_FORM_ref4]       (cu + 0x0067 => {0x00000067})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000067:   DW_TAG_structure_type [3] *</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x00000064] = "C")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000006f:     DW_TAG_member [4]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                  DW_AT_name [DW_FORM_strp]     ( .debug_str[0x0000004e] = "p")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                  DW_AT_type [DW_FORM_ref4]     (cu + 0x007c => {0x0000007c})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000007b:     NULL</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x0000007c:   DW_TAG_pointer_type [5]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_type [DW_FORM_ref4]       (cu + 0x0081 => {0x00000081})</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">0x00000081:   DW_TAG_class_type [6]  </span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_name [DW_FORM_strp]       ( .debug_str[0x0000005d] = "A<int>")</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Courier New"">                DW_AT_declaration [DW_FORM_flag_present]        (true)</span><u></u><u></u></p>
</div>
</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-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal"><br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">As there are no template parameters for the forward declaration of either A<MONKEY></span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">they are indistinguishable.</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">The reason we currently have no need for the parameters in a template name is because we</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">reconstruct template names from their parameter tags. This allow the pretty printing to match</span>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">the templates from the DWARF to match our demangled symbols from the ELF symbol table.</span>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Arial","sans-serif"">-Pete<br>
</span><br>
<br>
<br>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5f5f5f">From:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">"Robinson, Paul" <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5f5f5f">To:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>, "Marshall,
 Peter" <<a href="mailto:Peter_Marshall@sn.scee.net" target="_blank">Peter_Marshall@sn.scee.net</a>></span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5f5f5f">Cc:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">"<a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank">reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</a>"
        <<a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank">reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</a>>, "cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)"
 <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5f5f5f">Date:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">10/11/2015 01:08</span>
<br>
<span style="font-size:7.5pt;font-family:"Arial","sans-serif";color:#5f5f5f">Subject:        </span><span style="font-size:7.5pt;font-family:"Arial","sans-serif"">RE: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.</span>
<u></u><u></u></p>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="3" width="100%" noshade style="color:#a0a0a0" align="center">
</div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
<br>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">|
</span>when/where/why are types acquired from the mangled names of ELF symbols, rather than from corresponding DWARF?
<br>
<a name="1518827de73aaa57_151880ba5c41f1e2_1510134cf808aa9d__MailE"></a><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Pete, can you help me out here?  David seems to want an ironclad case for not being able to do something any other way, before he will let me put the template type parameters on
 the declaration of a template instantiation.  (He does not deny that doing so would be valid DWARF, only that it can't possibly be *useful* DWARF.)</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Thanks,</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">--paulr</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<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 [</span><a href="mailto:dblaikie@gmail.com" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">mailto:dblaikie@gmail.com</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<b><br>
Sent:</b> Monday, November 09, 2015 4:08 PM<b><br>
To:</b> Robinson, Paul<b><br>
Cc:</b> <a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank">
reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</a>; cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)<b><br>
Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.</span>
<br>
  <br>
  <br>
  <br>
On Mon, Nov 9, 2015 at 3:55 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">|
</span>Why is matching by name insufficient/not correct? <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">I'm told we look at the mangled names in the ELF symbol table, demangle them, and look in the DWARF for the corresponding types.</span>
<br>
  <br>
Not quite sure I follow that - when/where/why are types acquired from the mangled names of ELF symbols, rather than from corresponding DWARF? (eg: the DWARF describing the type of a function's parameter?)
<br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">  Now, the mangled name (for predefined types in particular) provides a type description, not the name-as-emitted-by-Clang, and in fact the same type can have more than one name
 ('const int' and 'int const' for a trivial example).  The name Clang provides in the DWARF does not necessarily match the name produced by the demangler; this makes name-matching way more trouble than you'd think.  We're not interested in teaching the debugger
 how to parse template instantiation names.</span> <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Having the template type parameter means we have an unambiguous description of the type, and can match it easily.</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">|
</span>including unreferenced entities fails source fidelity <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">I'll assume you meant to say _excluding_ unreferenced entities fails source fidelity,</span>
<br>
  <br>
Indeed <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">which is quite true, but there is a valid engineering tradeoff in that what the DWARF actually contains (or not, in the case of, say, unused function declarations or unreferenced
 class contents) represents one possible valid source that could have produced the same object.  (I'm curious why an unreferenced formal parameter of a function still gets described, if this is your argument for omitting template parameters.)</span>
<br>
  <br>
Omitting parameters would make the function description unusable for callers, for example - so there's some value in describing them so that a debugger can evaluate expressions involving calls to the function, yes?
<br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Omitting template parameters however is not the same as omitting unreferenced entities, because the template parameters *are* referenced—by the template instantiation itself;</span>
<br>
  <br>
Not quite sure I follow that logic. It's quite possible to have unreferenced template parameters:<br>
<br>
 template<typename><br>
 void f() { } <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">and, omitting them from the source does not produce a valid program.</span>
<br>
<br>
Omitting the names still produces a valid program - though I'm not quite sure which omission you're referring to. (& even if we omit the names, we still describe the parameters - as we do for unused/unnamed function parameters)<br>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">  Now, one of the 3 debuggers Clang explicitly supports (i.e. gdb) seems not to mind that they're missing, but the other two would benefit from having these things, and I would
 really like to have Clang produce these things.</span> <br>
  <br>
It sounds like the LLDB bug you cited is being treated as an LLDB bug, not a Clang one, for now. So I'm not sure it's relevant to justifying Clang changes just yet, unless they come back & suggest that they don't actually have enough information to implement
 the features they would like to implement.<br>
<br>
& equally I'd like to understand the features that you'd like to build with this info that can't be built without it (as a minimum: features that GDB doesn't support, since any features GDB does support seem to be implementable with the current info Clang and
 GCC emit)<br>
<br>
- David <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Thanks,</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">--paulr</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<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:</span><a href="mailto:dblaikie@gmail.com" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">dblaikie@gmail.com</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<b><br>
Sent:</b> Monday, November 09, 2015 1:46 PM</span> <br>
<b><br>
To:</b> Robinson, Paul<b><br>
Cc:</b> <a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank">
reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</a>; cfe-commits (<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>)<b><br>
Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.
<br>
  <br>
  <br>
  <br>
On Thu, Nov 5, 2015 at 11:05 AM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">|
</span>What was your primary motivation? <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">A similar concern to PR20455 from our own debugger.  It much helps matching up the forward declaration and definition to have the parameters properly specified.</span>
<br>
  <br>
Why is matching by name insufficient/not correct? <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">|
</span>maybe it's possible to remangle the template using just the string name <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">I have no idea what you're talking about here.</span>
<br>
  <br>
Looking at PR20455 you linked, LLDB isn't finding the right function because of mangling:
<br>
<span style="font-size:10.0pt;font-family:"Courier New"">call to a function 'basic_string<char, char_traits<char> >::operator[](int) const' ('_ZNK12basic_stringIc17char_traits<char>EixEi') that is not present in the target
</span><br>
It hasn't created the correct mangled name of operator[] - what I was saying is it might be possible to parse the template parameter from the pretty name, and use that to produce the mangled name. It /looks/ like GDB can manage this. Maybe only because we also
 include the mangled name of the member function? Not sure.<br>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">| | Choosing to emit a forward/incomplete declaration in the first place fails source fidelity,
</span><br>
| How so? <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">When the source has a full definition but Clang chooses to emit only the declaration, per CGDebugInfo.cpp/shouldOmitDefinition().</span>
<br>
  <br>
Sure, in the same way that including unreferenced entities fails source fidelity - all tradeoffs to reduce debug info size.<br>
<br>
Though the behavior is visible in a simpler example that doesn't have that failing (& if your change goes in, the test case should probably be simplified like this):<br>
<br>
template<typename T> struct foo; <br>
foo<int> *f; <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">--paulr</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<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:</span><a href="mailto:dblaikie@gmail.com" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">dblaikie@gmail.com</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<b><br>
Sent:</b> Thursday, November 05, 2015 12:10 AM<b><br>
To:</b> Robinson, Paul<b><br>
Cc:</b> </span><a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">;
 cfe-commits (</span><a href="mailto:cfe-commits@lists.llvm.org" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">cfe-commits@lists.llvm.org</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">)</span>
<br>
<b><br>
Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.
<br>
  <br>
  <br>
  <br>
On Wed, Nov 4, 2015 at 11:32 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>> wrote:
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">Would citing PR20455 help?  It wasn't actually my primary motivation but it's not too far off.  Having the template parameters there lets you know what's going on in the DWARF,
 without having to fetch and parse the name string of every struct you come across.  Actually I'm not sure parsing the name string is unambiguous either; each parameter is either a typename, or an expression, but without the parameter DIEs you don't know which,
 a-priori.  (What does <foo> mean? Depends on whether you think it should be a type name or a value; you can't tell, syntactically, you have to do some lookups.  Ah, but if you had the parameter DIEs, you would Just Know.)</span>
<br>
  <br>
For LLDB's needs, I'm not sure it's sufficient either - but I wouldn't mind an answer before we use it as the basis for this change (it sounds like maybe it's possible to remangle the template using just the string name, rather than needing an explicit representation
 of the parameters)<br>
<br>
What was your primary motivation? <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> Choosing to emit a forward/incomplete declaration in the first place fails source fidelity,
</span><br>
  <br>
How so? You might have only a template declaration (template<typename T> struct foo; foo<int> *f;) or you may've only instantiated the declaration (the C++ language requires you to instantiate or avoid instantiating certain things in certain places, so in some
 contexts you /only/ have an instantiated declaration, not a definition) <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">but it is a practical engineering tradeoff of compile/link performance against utility; and, after all, the source *could* have been written that way, with no semantic difference.
  But, if we're going to emit a white-lie incomplete declaration, we should do so correctly.</span>
<br>
  <br>
Again, "correct" in DWARF is a fairly nebulous concept. <br>
  <br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">--paulr</span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080">P.S. We should talk about this forward-declaration tactic wrt LTO sometime.  I have a case where a nested class got forward-declared; it's entirely conceivable that the outer class
 with the inner forward-declared class would end up being picked by LTO, leaving the user with no debug info for the inner class contents.</span>
<br>
  <br>
I believe this Just Works(tm). The things that can vary per-insntance of a type (implicit special members, member template implicit specializations, and nested types*) are not added to the type's child list, but they reference the child as their parent. So
 they continue to apply no matter which instance of the type is picked for uniquing (because of the name-based referencing, so the nested type definition just says "my parent is _Zfoo" and whatever _Zfoo we end up picking in the LTO linking/metadata deduplication
 will serve that role just fine)<br>
<br>
* we could just do a better job of modelling nested types (& other non-globally scoped types) in a way that more closely models the source by emitting a declaration where they were declared, and a definition where they are defined (with the usual DW_AT_specification
 to wire them up) <br>
  <br>
<a name="1518827de73aaa57_151880ba5c41f1e2_1510134cf808aa9d_150eea"></a><span style="font-size:10.0pt;font-family:"Calibri","sans-serif";color:#004080"> </span>
<br>
<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:</span><a href="mailto:dblaikie@gmail.com" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">dblaikie@gmail.com</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">]
<b><br>
Sent:</b> Wednesday, November 04, 2015 8:30 PM<b><br>
To:</b> </span><a href="mailto:reviews%2BD14358%2Bpublic%2Bd3104135076f0a10@reviews.llvm.org" target="_blank"><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">reviews+D14358+public+d3104135076f0a10@reviews.llvm.org</span></a><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">;
 Robinson, Paul<b><br>
Subject:</b> Re: [PATCH] D14358: DWARF's forward decl of a template should have template parameters.</span>
<br>
  <br>
  <br>
  <br>
On Wed, Nov 4, 2015 at 5:53 PM, Paul Robinson via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:
<br>
probinson added a comment.<br>
<br>
GCC 4.8.4 on Linux doesn't produce these, but DWARF 4 section 5.5.8 says a class template instantiation is just like the equivalent non-template class entry, with the exception of the template parameter entries.  I read that as meaning an incomplete description
 (i.e. with DW_AT_declaration) lets you omit all the other children, but not the template parameters.
<br>
  <br>
As usual, I think it's pretty hard to argue that DWARF /requires/ anything (permissive & all that). And I'm not sure that having these is particularly valuable/useful - what use do you have in mind for them?<br>
<br>
Wouldn't hurt to have some size info about the cost here, though I don't imagine it's massive, it does open us up to emitting a whole slew of new types (the types the template is instantiated with, and anything that depends on - breaking/avoiding type edges
 can, in my experience, be quite beneficial (I described an example of this in my lightning talk last week)).
<br>
  <br>
<br>
I don't think omitting the template DIEs was an intentional optimization, in the sense of being a decision separate from deciding to emit the incomplete/forward declaration in the first place.  They were just omitted because we were omitting everything, but
 everything turns out to be non-compliant. <br>
<br>
<u><span style="color:blue"><br>
</span></u><a href="http://reviews.llvm.org/D14358" target="_blank">http://reviews.llvm.org/D14358</a><br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<u><span style="color:blue"><br>
</span></u><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><u><span style="color:blue"><br>
</span></u><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a>
<br>
  <br>
  <br>
  <br>
  <u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif""><br>
**********************************************************************<br>
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify
<a href="mailto:postmaster@scee.net" target="_blank">postmaster@scee.net</a><br>
This footnote also confirms that this email message has been checked for all known viruses.<br>
Sony Computer Entertainment Europe Limited<br>
Registered Office: 10 Great Marlborough Street, London W1F 7LP, United Kingdom<br>
Registered in England: 3277793<br>
**********************************************************************<br>
</span><span style="font-size:18.0pt;font-family:Webdings;color:green"><br>
P</span><b><i><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:green"> Please consider the environment before printing this e-mail</span></i></b>
<u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></div></div>
</div>
</div>

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