Re: Using C++ code inside gdb
Ashutosh <[email protected]>
| Newsgroups | gmane.comp.gdb.devel |
|---|---|
| Message-ID | <CADHm+zt377vKH=-4T5W9x=f=fHDhxfvDw6GOKXeD+33Hw6pi7g@mail.gmail.com> |
Hi Klaus, Thanks for your reply. Actually, I want to extend gdb to support targets with multiple memories and for that I wanted to add this module inside gdb code. This module would be called from with-in the gdb code, for example, when a user prints a variable on the command-line, gdb before issuing a request to the target to read the corresponding memory address, would first call my module to get some memory-specific info. And, I want the module to be contained inside a namespace like C++ class. So, basically, I want to add C++ code inside the gdb code and was looking for any guidelines/caveats regarding the same. The solution that you propose doesn't fit the scenario I am shooting for, as I want the module functions to be called from with-in gdb and not from the command-line interface. Sorry for not clarifying the context earlier. Thanks and Regards, ash On Thu, Oct 8, 2015 at 6:35 PM, Klaus Rudolph <[email protected]> wrote: > >> >> I plan to add a standalone module inside gdb code that contains >> information about the memories in the target, but want to organize it >> in the form of a C++ class. My question is: Has anybody earlier tried >> adding C++ code to gdb code-base and how easy it would be to do so? >> Any guidelines? >> > > You can call every function/method with "print funcName" from gdb command line. So if you add your debug code to your executable you should be able > to run every function from your debug extension. You must take care that your debug code is not optimized out because > you have no calls from your application to the debug code itself. So you do not need any changes to the debugger or gdbserver > itself. > > But maybe I have a misunderstanding from your question... > > Regards > Klaus