<div dir="ltr"><div><div><div>"So I thought "it won't be too hard to make my own debugger"...  "<br><br></div>From someone who has spent most of his career writing debuggers:  "Errrr, no".<br><br></div>I am currently working on adding debug information generation to the front end of an LLVM-based compiler, and that has taken over a year of full-time work so far (*) - and that's just to generate the information for use by an existing debugger based on gdb.  If you are planning on developing a new debugger from scratch, be prepared to devote several years of your life to it.<br><br></div>(*) though in large part that's because I've had to implement all aspects of functions in the generated IR, as the LLVM DIBuilder API does not support inlined functions, and the front end inlines all calls.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On 5 January 2015 at 11:16, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 4 Jan 2015, at 17:39, John Smith <<a href="mailto:xp0bpe@gmail.com">xp0bpe@gmail.com</a>> wrote:<br>
><br>
> I was hoping there might be an LLVM compiler switch to say "allocate these variables in a linear straightforward fashion"...<br>
<br>
</span>Doing this will significantly impact the performance of the register allocator and various mid-level optimisations.  If you are willing to take this hit, you can do it relatively easily by generating a single C structure containing all of your local variables.  You can also follow the approach taken in the 'garbage collection in uncooperative environments' paper and create a linked list of these structures that can be walked by your debugger as well as by the garbage collector (if you need one).<br>
<br>
Your best bet, however, is to ditch the idea of generating C and generate LLVM IR, with the relevant debug info, directly.  This will also allow you to use all of the existing infrastructure in lldb for debugging, simply requiring you to write language-specific parts.<br>
<span class="HOEnZb"><font color="#888888"><br>
David<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>