<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Mar 3, 2018, at 11:30 PM, Daniel Berlin via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">To explain to others who didn't follow that thread:<div class=""><br class=""></div><div class="">GDB currently does something amazingly stupid (and has since i wrote it) to find the RTTI type.  There were no other good options at the type.</div><div class=""><br class=""></div><div class="">What it does is find the vtable for the object, find the symbol that represents the vtable, demangle it, , chops off "vtable for", and tries to find the symbol for the string that results.</div></div></div></blockquote><div><br class=""></div>Glorious. :)</div><div><br class=""></div><div>Do any of the common C++ demangler implementations provide any sort of API to get at the demangler tree?  We did this in Swift, and even though our tree design isn't real great, it's been a huge help for implementing various reflection / debugging features.</div><div><br class=""></div><div>John.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">If you don't emit the linkage name, there are cases it won't find it, because this is a really dumb way of trying to find the answer :)</div><div class=""><br class=""></div><div class="">It also wont' find it depending on what demangler you use, etc.</div><div class=""><br class=""></div><div class="">Here's a more direct way:</div><div class="">For each vtable DIE, link to the concrete type it represents.</div><div class=""><br class=""></div><div class="">Now you just go from vtable object to concrete type with no string lookup, which is faster, doesnt' require linkage names, doesn't depend on demanglers matching, etc.</div><div class=""><br class=""></div><div class="">As an added bonus: This is what Tom Tromey already added to Rust to do this. So it's even been implemented before.<br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Mar 3, 2018 at 8:20 PM, Daniel Berlin <span dir="ltr" class=""><<a href="mailto:dberlin@dberlin.org" target="_blank" class="">dberlin@dberlin.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Fri, Mar 2, 2018 at 3:58 PM, Roman Popov via llvm-dev <span dir="ltr" class=""><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" class="">llvm-dev@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi all,<div class=""><br class=""></div><div class="">As you may know modern C++ debuggers (GDB and LLDB) support dynamic type identification for polymorphic objects, by utilizing C++ RTTI.  </div><div class="">Unfortunately this feature does not work with Clang and GDB >= 7.x .  The last compiler that worked well was G++ 6.x</div><div class=""><br class=""></div><div class="">I've asked about this issue both on GDB and LLDB maillists. Unfortunately it's hard or impossible to fix it on debugger side.</div></div></blockquote><div class=""><br class=""></div></span><div class="">Errr, i posited a solution on the gdb mailing list that i haven't seen shot down so far, that doesn't require linkage names, it only requires one new attribute that is a DW_FORM_ref, and very cheap.</div><div class=""> </div><div class="">I also wrote the RTTI code for GDB :)<br class=""><br class=""></div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Currently what debugger has to do is to demangle RTTI name and try to match it to DW_AT_name attribute to find type. As you can see it does not work for any of 3 examples.</div><div class=""><br class=""></div><div class="">I've asked about the problem on G++ maillist, and one of the proposed solutions is to emit DW_AT_linkage_name for types. </div><div class=""><br class=""></div><div class="">Can this solution be also implemented in LLVM? </div></div></blockquote><div class=""><br class=""></div></span><div class="">Please, no.</div><div class=""><br class=""></div><div class="">This is completely unneeded and wastes a huge amount of space.</div><div class=""><br class=""></div><div class="">As you can see from the replies to my solution on the gdb mailing list, it is used by other languages (rust, for example) *anyway*, so we might as well use it for C++ too.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>