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

Philip Reames listmail at philipreames.com
Sun Jan 4 15:43:08 PST 2015


I would strongly suggest you read this:
http://llvm.org/docs/SourceLevelDebugging.html

This should give you an idea of what llvm is expecting at the IR level 
and how everything would work there.  Once you understand that, you can 
try to map it back to the original C code.  I don't know if the 
appropriate builtins have been added to clang, but in principle*, that 
shouldn't be too hard to do.

I would recommend you take a small hand written C or IR fragment, get 
that working in LLDB or GDB.  Then try to map that back to what your 
source language needs to do.

* Note: Debug information is an area where 'in principle' and 'in 
practice' differ substantially.  I don't know enough to give you any 
better guidance.

p.s. Don't underestimate how much information you can get by simply 
naming your generated C variables reasonably and providing good line 
info.  This may be more than sufficient for most of your users.

p.p.s. Fair warning, debug info has not settled down yet.  There are 
still substantial changes happening on a regular basis.  This means that 
a) you'll need to adapt going forward, b) you'll really want to stay 
current w/TOT to get fixes and c) any documentation you find may be out 
of date.

Philip

On 01/04/2015 10:04 AM, John Smith wrote:
>> On 4 Jan 2015, at 17:56, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
>>
>> On Sun, Jan 04, 2015 at 05:39:30PM +0000, John Smith wrote:
>>> If theres no such switch then... what is considered the "right approach
>>> with LLVM" to creating your own debugger?
>> Depends on what problem you are trying to solve. Emitting appropiate
>> #line data and naming the CC variables as in your original language
>> would help improve the experience. If that is not good enough, I'm not
>> sure if there is any alternative to emitting IR directly with the
>> associated tighter control about debug data getting created.
>> Alternatively, you could try to hook into lldb.
> Is there an LLDB file that can help me figure out where my variables are located?
>
> Like a DWARF file or something?
>
> I've never used DWARF explicitly so I don't know if that's the right thing...
>
> If I could parse a DWARF file... and get the stack pointer... could that be used to get the variables?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list