John Smith
2015-Jan-04 17:39 UTC
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
> > On 4 Jan 2015, at 16:44, Joerg Sonnenberger <joerg at britannica.bec.de> wrote: > > On Sun, Jan 04, 2015 at 03:02:30PM +0000, John Smith wrote: >> "all I need is the ability to get the current variables off the current >> function... > > Finding the functions on the stack is easy. Finding which auto variables > are where is *much* harder.That explains why I couldn't find anything. I was hoping there might be an LLVM compiler switch to say "allocate these variables in a linear straightforward fashion"... If theres no such switch then... what is considered the "right approach with LLVM" to creating your own debugger? Or anything that helps with my original question.
Joerg Sonnenberger
2015-Jan-04 17:56 UTC
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
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. Joerg
John Smith
2015-Jan-04 18:04 UTC
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
> 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?
David Chisnall
2015-Jan-05 11:16 UTC
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
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
RICHARD STUCKEY
2015-Jan-05 12:16 UTC
[LLVMdev] Writing my own debugger... use __builtin_frame_address or is there something better?
"So I thought "it won't be too hard to make my own debugger"... ">From someone who has spent most of his career writing debuggers: "Errrr,no". 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. (*) 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. On 5 January 2015 at 11:16, David Chisnall <David.Chisnall at cl.cam.ac.uk> wrote:> 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 > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150105/73ce0666/attachment.html>