<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">"<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">Reading<span> </span></span><a href="http://wiki.dwarfstd.org/index.php?title=Best_Practices" rel="noreferrer" target="_blank" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)">http://wiki.dwarfstd.<wbr>org/index.php?title=Best_<wbr>Practices</a><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">:<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">the DW_AT_name attribute should contain the name of the corresponding<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">program object as it appears in the source code, without any<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">qualifiers such as namespaces, containing classes, or modules (see<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">Section 2.15). A consumer can easily reconstruct the fully-qualified<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">name from the DIE hierarchy. In general, the value of DW_AT_name<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">should be such that a fully-qualified name constructed from the<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">DW_AT_name attributes of the object and its containing objects will<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">uniquely represent that object in a form natural to the source<br></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial;background-color:rgb(255,255,255);float:none;display:inline">language."</span></blockquote><div><br></div><div>And continuing the quote from same webpage: </div><div><br></div><div><i>"<span style="color:rgb(0,0,0);font-family:sans-serif;font-size:12.8px;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">For template instantiations, the DW_AT_name attribute should contain both the source language name of the object and the template parameters that distinguish one instantiation from another. The resulting string should be in the natural form for the language, and should have a canonical representation (i.e., different producers should generate the same representation). For C++, the string should match that produced by the target platform's canonical demangler; spaces should only be inserted where syntactically required by the compiler.</span>"</i></div><div><br></div><div>As I said, for about a year I thought that this is how it supposed to work. Only after I upgraded compiler, I found all those issues.</div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>that you go to the DWARF mailing list and start a discussion about, rather than just proposing a solution.<br>In my experience, the people there have thought a lot about all of these use cases, and you may in fact find a solution that doesn't require doing anything at all.</blockquote><div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">*nod* fair, might be worth it for the broader set of issues Roman seems to be dealing with (beyond the dynamic type identification issues that GDB demonstrates).</blockquote></div><br></div><div><br></div><div>I can ping DWARF maillist about using DWARF as a reflection mechanism. DWARF however is language-agnostic, and this seem to be C++ -specific issue.</div><div> </div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-06 9:58 GMT-08:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><br><div class="gmail_quote"><span class=""><div dir="ltr">On Tue, Mar 6, 2018 at 9:49 AM Daniel Berlin <<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 6, 2018 at 9:20 AM, Roman Popov <span dir="ltr"><<a href="mailto:ripopov@gmail.com" target="_blank">ripopov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span class="m_8628456842171952891m_-4214953866301415756m_-8068890767087486265gmail-im" style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I wonder if abi::__cxa_demangle guarantees unambigous names? </div></div></blockquote><div><br></div></span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">No, it does not.</div></span></blockquote><div><br></div></span><div>Interesting. Can you give an example of type where it fails? </div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>I can't construct one out of thin air, but i believe someone cited one to you on the gdb mailing list. It's entirely possible for the human readable form of two symbols to be the same when the symbols are different.</div><div>I really just don't have the energy to copy the entire discussion on the other mailing list here. </div><div><br></div><div>More to the point, the ABI literally does not guarantee it, and different demanglers for the Itanium ABI (there are a bunch) do different things for human readable names.</div><div>You cite below gcc vs gcc, which is different versions of the same demangler. There are a bunch of Itanium C++ ABI implementations, including demanglers and compilers, and i'd strongly caution you to remember that all the world is not clang and GNU.</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div><br></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> </div><div>I'm currently working on hardware construction library for C++ (similar to Chisel (which is written in Scala)). And since C++ has no standardized reflection, I use DWARF as a source of reflection metadata. And in case of G++ 6.3, which seem to emit same name names as abi::__cxa_demangle, it has never failed so far in my case. And I have very diverse inputs.</div><div>In fact I was working on it for about a year, and I was thinking that it how it supposed to work. Only after I upgraded to g++ 7 I've found out that both modern g++ and clang do not emit unambiguous debuginfo.</div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>This seems to be a different question than i thought you asked.</div><div>If you are asking "where will the demangled name between what abi::__cxa_demangle and what GCC outputs in the debug info differ", it's unlikely to differ if you use the same versions of both ;) </div><div><br></div><div>But it will in some cases. Some bugs, some not.</div><div>Mangled names are not a panacea. I think you also wildly underestimate the cost of demangling every symbol in a large binary, for example, which would required for your suggestion, as well as the size of these symbols, etc. It's enough that people wrote a fast demangler, for example. That's just one issue.</div><div><br></div><div>As for the rest, you are taking a perspective that is pretty strongly focused on your use cases, and currently, DWARF is pretty focused on the other ones.</div><div>If you want to convince the committee/others that it should give up on the part of the best practices i cited, go for it.</div><div><br></div><div>But you started by claiming this was necessary/important to fix the GDB problems here, and it's simply not. In fact, it would not fix most of them without a serious change in the way these things operate, and at high cost.</div><div>Suggesting to change gdb, gcc, clang, to fit your non-debugger use case is taking a very big hammer and saying "it can also pound these nails".</div><div>While true, that doesn't mean you should.</div><div><br></div><div>I'd strongly suggest, if you have concerns about the ability of DWARF to handle your use cases without linkage names,</div></div></div></div></blockquote></span><div><br>I think the only reason Roman's discussing ways that would work without linkage names is because you pretty firmly said that adding linkage names was a bad idea (for the original issue of dynamic class identification).<br><br>Which, sure, it's an idea with some issues - but the alternative (vtable DIEs with address/ref) isn't without complications too - not to dismiss it, but to suggest having some real conversation about the tradeoffs seems worthwhile.<br><br>& while the vtable DIE solution addresses the dynamic class identification case, it doesn't cover the other use cases Roman has in mind - other use cases that sound like they would be solved by having the linkage name of a type provided in the DWARF.<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> that you go to the DWARF mailing list and start a discussion about, rather than just proposing a solution.</div><div><br></div><div>In my experience, the people there have thought a lot about all of these use cases, and you may in fact find a solution that doesn't require doing anything at all.</div></div></div></div></blockquote></span><div><br>*nod* fair, might be worth it for the broader set of issues Roman seems to be dealing with (beyond the dynamic type identification issues that GDB demonstrates).<br> </div></div></div>
</blockquote></div><br></div></div>