From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99214 invoked by alias); 9 Oct 2015 03:20:12 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 99199 invoked by uid 89); 9 Oct 2015 03:20:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f175.google.com Received: from mail-wi0-f175.google.com (HELO mail-wi0-f175.google.com) (209.85.212.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 09 Oct 2015 03:20:09 +0000 Received: by wicge5 with SMTP id ge5so50266775wic.0 for ; Thu, 08 Oct 2015 20:20:06 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.180.75.38 with SMTP id z6mr7191916wiv.36.1444360806803; Thu, 08 Oct 2015 20:20:06 -0700 (PDT) Received: by 10.27.142.215 with HTTP; Thu, 8 Oct 2015 20:20:06 -0700 (PDT) In-Reply-To: References: Date: Fri, 09 Oct 2015 03:20:00 -0000 Message-ID: Subject: Re: Using C++ code inside gdb From: Ashutosh To: Klaus Rudolph Cc: gdb@sourceware.org Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-10/txt/msg00027.txt.bz2 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 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