<div dir="ltr">+some of the debug info cabal (& Duncan, as an emeritus member, and person who plumbed a lot of the current debug info syntax support in)<br><br>Visitor seems plausible though I haven't looked at the code in detail to see if it'd work perfectly.<br><br><div class="gmail_quote"><div dir="ltr">On Tue, May 29, 2018 at 7:56 AM Sohail Somani (Fizz Buzz Inc.) 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"><u></u>





<div>[Resending due to accidental markdown rendering - sorry]<br><br><div style="font-family:Arial">Hi list,<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">Let's talk about adding a new type of debug info metadata. Here are the steps (at minimum - probably incomplete) one needs to take:<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">1. Create a new class in the hierarchy<br></div>
<div style="font-family:Arial">2. Implement two forms of `MD_NODE_GET`<br></div>
<div style="font-family:Arial">3. Specialize `MDNodeKeyImpl`<br></div>
<div style="font-family:Arial">4. Modify `LLParser.cpp` and add serialization code for your special type<br></div>
<div style="font-family:Arial">5. Modify `AsmWriter.cpp` and add serialization code for your special type <br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">I believe we can accomplish everything needed for debug info with just step 1 using a pattern found in Boost Serialization. Imagine a new API based on this concept:<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">```<br></div>
<div style="font-family:Arial">class DIMyFancyType : public MDNode {<br></div>
<div style="font-family:Arial">  StringRef FileName;<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">  template<typename Visitor><br></div>
<div style="font-family:Arial">  void visit(Visitor & v) {<br>     DINode::visit(s); // or not, if you stay true to boost.serialization</div>
<div style="font-family:Arial">     <a href="http://v.name" target="_blank">v.name</a>("DIMyFancyType");</div>
<div style="font-family:Arial">     v.property("FileName",FileName);<br>  }<br>};</div>
<div style="font-family:Arial">```<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">With this, we could implement steps 2-5 using a little bit of template meta-programming and we could also implement escape hatches where needed to get more specific, allowing us to keep many things in one place.</div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">I imagine since there is now a `.def` file for the metadata (very useful!) that this is on somebody's mind and not just my own, so I'm curious about what people think. I realize that "new forms of debug metadata" is possibly not a very popular use case as there has been only one new kind added in the last few years. However, in my humble opinion, it would make it easier to add richer information allowing those of us extending LLVM to create better debuggers/debugging experiences.<br></div>
<div style="font-family:Arial"><br></div>
<div style="font-family:Arial">Thanks for your time!</div>
<div style="font-family:Arial"><br></div>
<div id="m_-1482018131165573299sig66433728"><div class="m_-1482018131165573299signature">--<br></div>
<div class="m_-1482018131165573299signature">Sohail Somani<br></div>
<div class="m_-1482018131165573299signature">Fizz Buzz Inc.<br></div>
<div class="m_-1482018131165573299signature">Booking schedule: <a href="https://sohailsomani.youcanbook.me" target="_blank">https://sohailsomani.youcanbook.me</a></div>
</div>
<div style="font-family:Arial"><br></div>
</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>