From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14892 invoked by alias); 2 Jun 2009 16:27:28 -0000 Received: (qmail 14884 invoked by uid 22791); 2 Jun 2009 16:27:27 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 02 Jun 2009 16:27:21 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 069A729003D for ; Tue, 2 Jun 2009 18:27:19 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zzWPbmDN7Dwf for ; Tue, 2 Jun 2009 18:27:18 +0200 (CEST) Received: from province.act-europe.fr (province.act-europe.fr [10.10.0.214]) by mel.act-europe.fr (Postfix) with ESMTP id 59CFD290026 for ; Tue, 2 Jun 2009 18:27:18 +0200 (CEST) Received: by province.act-europe.fr (Postfix, from userid 560) id 4C67D16637F; Tue, 2 Jun 2009 18:27:18 +0200 (CEST) Date: Tue, 02 Jun 2009 16:27:00 -0000 From: Jerome Guitton To: gdb@sourceware.org Subject: add-symbol-file/load and scripts Message-ID: <20090602162718.GA21116@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) 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 X-SW-Source: 2009-06/txt/msg00007.txt.bz2 Hello, I would like to have your opinion on a small improvement that I am considering in add-symbol-file/load. add-symbol-file takes two mandatory parameters: the name of symbol file and the address of the text section. It can be asked if the second parameter can be optional; the text's address, as initialized in the symbol file itself, would be the appropriate defaut. The rational of this suggestion is to use the same default as the load command, when it is implemented as in generic_load (GDB writing directly into the target's memory). In this case, the load address is the address of the text section (if no offset is given in parameter). For now, in this default case, the user has to copy-paste the address from the output of the load command to feed it to add-symb... This user can feel that GDB could have guessed where the file had been loaded, as it just gave it in the output: (gdb) load module_1.elf Loading section .text, size 0x50 lma 0x6c0000 Loading section .spare, size 0xb0 lma 0x6c0050 Loading section .text, size 0x6c lma 0x6c0100 Loading section .spare, size 0x294 lma 0x6c016c Loading section .text, size 0x3c4c lma 0x6c0400 Loading section .spare, size 0x43b4 lma 0x6c404c Loading section .text, size 0x73a8 lma 0x6c8400 Loading section .spare, size 0x20858 lma 0x6cf7a8 Start address 0x6c0000, load size 196608 (gdb) add-symbol-file module_1.elf 0x6c0000 And the copy-paste thing makes it difficult to use add-symbol-file into a script, of course. We can ask ourselves if 0x6c000 would not have been an appropriate default for the second parameter of add-symbol-file... I am not sure it makes complete sense for any object format, though. Another solution may just be to set "$_" to the start address of the module after the load. In which case, the user would just have to do: (gdb) load module_1.elf [...] (gdb) add-symbol-file module_1.elf $_ The thing is, GDB may not be able to know the start address of the module that it just loaded. I depends on the target implementation of load. But I do not think that it is the case in general. We may handle these cases by setting $_ to void. Any of the solutions are easy to implement. And they both make it possible to use these commands in a script. Opinions/thoughts?