[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?

David Chisnall David.Chisnall at cl.cam.ac.uk
Mon Jan 5 03:16:51 PST 2015


On 4 Jan 2015, at 17:39, John Smith <xp0bpe at gmail.com> wrote:
> 
> I was hoping there might be an LLVM compiler switch to say "allocate these variables in a linear straightforward fashion"...

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).

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.

David





More information about the llvm-dev mailing list