This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: Using C++ code inside gdb
- From: Ashutosh <ashutoshpal2006 at gmail dot com>
- To: Klaus Rudolph <lts-rudolph at gmx dot de>
- Cc: gdb at sourceware dot org
- Date: Fri, 9 Oct 2015 08:50:06 +0530
- Subject: Re: Using C++ code inside gdb
- Authentication-results: sourceware.org; auth=none
- References: <CADHm+ztUrxkStMRgqTFTnz+d02jHT5wTCmJH3qwUQximA5x+Kg at mail dot gmail dot com> <trinity-a6c327d7-3c17-4ad4-90d9-d0aca0d72c07-1444309529343 at 3capp-gmx-bs23>
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 <lts-rudolph@gmx.de> 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