From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2207 invoked by alias); 22 Jun 2003 18:34:05 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 2200 invoked from network); 22 Jun 2003 18:34:04 -0000 Received: from unknown (HELO crack.them.org) (146.82.138.56) by sources.redhat.com with SMTP; 22 Jun 2003 18:34:04 -0000 Received: from dsl093-172-017.pit1.dsl.speakeasy.net ([66.93.172.17] helo=nevyn.them.org ident=mail) by crack.them.org with asmtp (Exim 3.12 #1 (Debian)) id 19U9fx-0002jV-00; Sun, 22 Jun 2003 13:34:55 -0500 Received: from drow by nevyn.them.org with local (Exim 3.36 #1 (Debian)) id 19U9f4-0004yF-00; Sun, 22 Jun 2003 14:33:58 -0400 Date: Sun, 22 Jun 2003 18:34:00 -0000 From: Daniel Jacobowitz To: Andrew Cagney Cc: gdb-patches@sources.redhat.com Subject: Re: PR gdb/260: variables not expanded on the add-symbol-file command line Message-ID: <20030622183358.GA18818@nevyn.them.org> Mail-Followup-To: Andrew Cagney , gdb-patches@sources.redhat.com References: <20030621223056.GB31184@nevyn.them.org> <3EF5EE75.70009@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EF5EE75.70009@redhat.com> User-Agent: Mutt/1.5.1i X-SW-Source: 2003-06/txt/msg00707.txt.bz2 On Sun, Jun 22, 2003 at 01:59:17PM -0400, Andrew Cagney wrote: > >This PR gets reported pretty regularly. Since the command line > >overhaul I was hoping to do never materialized, does anyone object to > >this patch to fix the specific problem in add-symbol-file? I believe > >the patch is simple enough to have no copyright issues. > > > >The problem is that the code tries to parse and 0x > >directly, and does not accept convenience variables. > > Yes, looks safe. Here's what I checked in. You get a testcase for free! -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer 2003-06-22 Daniel Jacobowitz * symfile.c (add_symbol_file_command): Use parse_and_eval_address. Suggested by Nick Hibma . 2003-06-22 Daniel Jacobowitz * gdb.base/relocate.exp: Test add-symbol-file with a variable offset. Index: symfile.c =================================================================== RCS file: /cvs/src/src/gdb/symfile.c,v retrieving revision 1.99 diff -u -p -r1.99 symfile.c --- symfile.c 17 Jun 2003 19:15:24 -0000 1.99 +++ symfile.c 22 Jun 2003 18:23:36 -0000 @@ -1807,11 +1807,7 @@ add_symbol_file_command (char *args, int char *val = sect_opts[i].value; char *sec = sect_opts[i].name; - val = sect_opts[i].value; - if (val[0] == '0' && val[1] == 'x') - addr = strtoul (val+2, NULL, 16); - else - addr = strtoul (val, NULL, 10); + addr = parse_and_eval_address (val); /* Here we store the section offsets in the order they were entered on the command line. */ Index: testsuite/gdb.base/relocate.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/relocate.exp,v retrieving revision 1.2 diff -u -p -r1.2 relocate.exp --- testsuite/gdb.base/relocate.exp 20 Jan 2003 15:40:07 -0000 1.2 +++ testsuite/gdb.base/relocate.exp 22 Jun 2003 18:23:37 -0000 @@ -105,4 +105,30 @@ if { "${function_foo_addr}" == "${functi pass "functions have different addresses" } +# Now use a variable as an offset to add-symbol-file, and check that +# the functions' addresses change. + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +gdb_test "set \$offset = 0x10000" "" + +# Load the object file. +gdb_test "add-symbol-file ${binfile} \$offset" \ + "Reading symbols from .*${testfile}\\.o\\.\\.\\.done\\." \ + "add-symbol-file ${testfile}.o \$offset" \ + "add symbol table from file \".*${testfile}\\.o\" at\[ \t\r\n\]+\.text_addr = 0x10000\[\r\n\]+\\(y or n\\) " \ + "y" + +# Print the addresses of functions. +set new_function_foo_addr [get_var_address function_foo] + +# Make sure they have different addresses. +if { "${function_foo_addr}" == "${new_function_foo_addr}" } { + fail "function foo has a different address" +} else { + pass "function foo has a different address" +} + return 0