<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jun 19, 2017 at 12:49 PM Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.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">We have clang/lib/AST/MicrosoftMangle.cpp, so looks like what I should do is to write code that do the reverse of it. One thing I should be careful is to produce the exact same outputs as Microsoft's UnDecorateSymbolName function would output so that the behavior doesn't change between Windows and non-Windows platforms, but it probably shouldn't be hard.</div></blockquote><div><br></div><div>Just to be clear - once LLVM has its own demangler, it should probably use it on all platforms, so there'd be no worry about different behavior between LLVM on Windows and LLVM elsewhere.<br><br>But that said, it's probably still important/worthwhile to make sure it's consistent with the platform demangler.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 19, 2017 at 12:34 PM, Martin J. O'Riordan <span dir="ltr"><<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.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-IE" link="#0563C1" vlink="#954F72"><div class="m_-7778762790247424585m_3846031347778843642WordSection1"><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">A long time ago, when I devised the grammar and structure of the Microsoft C++ name mangling scheme (decorated names), the document describing the object model and the name decoration scheme were made publically available.  Perhaps this is still available publically, or perhaps Microsoft might be willing to share an up to date definition of the name-decoration grammar, especially in light of the integration of CodeView debugging information into LLVM, which somewhat ties in with this.<u></u><u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">This was expressed as a regular BNF grammar, so it should be possible to create a clean-room implementation of both the “mangler” and “de-mangler” from that BNF definition if it still exists in that form.  Does the recently added CodeView debug information not provide this description (I admit I haven’t looked)?<u></u><u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">Certainly tools like ‘</span><span style="font-size:12.0pt">c++filt</span><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">’ do not know about the Microsoft name decoration scheme, but LLVM does know how to mangle the names using the VC++ ABI, and since the mangling follows a regular grammar, the de-mangling should be relatively straight-forward to implement.<u></u><u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">All the best,<u></u><u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif">            MartinO<u></u><u></u></span></p><div><div class="m_-7778762790247424585h5"><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span style="font-size:12.0pt;font-family:"Book Antiqua",serif"><u></u> <u></u></span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><span lang="EN-US">-----Original Message-----<br>From: llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>] On Behalf Of Davide Italiano via llvm-dev<br>Sent: 19 June 2017 19:00<br>To: Rui Ueyama <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>><br>Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>Subject: Re: [llvm-dev] VC C++ demangler</span></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">On Mon, Jun 19, 2017 at 10:53 AM, Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span style="color:windowtext;text-decoration:none">llvm-dev@lists.llvm.org</span></a>> wrote:<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> Hi,<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> We have a demangler for the Itanium ABI, but looks like we don't have <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> one for the MSVC-style symbols. Is there any good demangler we can <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> import to LLVM?<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> If there's no suitable demangler, I'd like to write one. Currently, we <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> are using `UnDecorateSymbolName` function, but the function is <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> available only on Windows (which is problematic when you are doing a <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> cross-build), and the function is not thread-safe. These two seem to <u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">> be an enough reason to have our own demanler.<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">I'm not aware of a suitable one, currently. I agree it would be very useful to have.<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><u></u> <u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">--<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">Davide<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><u></u> <u></u></p></div></div><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">"There are no solved problems; there are only problems that are more or less solved" -- Henri Poincare _______________________________________________<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText">LLVM Developers mailing list<u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span style="color:windowtext;text-decoration:none">llvm-dev@lists.llvm.org</span></a><u></u><u></u></p><p class="m_-7778762790247424585m_3846031347778843642MsoPlainText"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank"><span style="color:windowtext;text-decoration:none">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</span></a><u></u><u></u></p></div></div></blockquote></div><br></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>