From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25594 invoked by alias); 10 Feb 2005 10:32:48 -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 25500 invoked from network); 10 Feb 2005 10:32:38 -0000 Received: from unknown (HELO mail.codesourcery.com) (65.74.133.9) by sourceware.org with SMTP; 10 Feb 2005 10:32:38 -0000 Received: (qmail 32095 invoked from network); 10 Feb 2005 10:32:37 -0000 Received: from localhost (HELO ?192.168.189.167?) (nathan@127.0.0.1) by mail.codesourcery.com with SMTP; 10 Feb 2005 10:32:37 -0000 Message-ID: <420B383D.1020406@codesourcery.com> Date: Thu, 10 Feb 2005 15:27:00 -0000 From: Nathan Sidwell Organization: Codesourcery LLC User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913 MIME-Version: 1.0 To: gdb-patches@sources.redhat.com CC: Paul Brook Subject: [patch] registers beginning with '$' Content-Type: multipart/mixed; boundary="------------010705050200010805070602" X-SW-Source: 2005-02/txt/msg00086.txt.bz2 This is a multi-part message in MIME format. --------------010705050200010805070602 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 740 Hi, I had the misfortune to port to an architecture where register names all start with a '$' and the pc reg is '$PC'. This patch fixes expression printing of registers so that such names don't result in '$$name' being printed. It fixes register name lookup so that the leading '$' need not be specified (several places strip leading '$' on the name to be looked up). It also makes the register name lookup case insensitive. I also attach testsuite patches to allow $pc or $PC as the pc name. built and tested on i686-pc-linux-gnu, and an unreleased architecture, ok? nathan -- Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk --------------010705050200010805070602 Content-Type: text/plain; name="regnames.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="regnames.patch" Content-length: 1778 2005-02-10 Nathan Sidwell * expprint.c (print_subexp_standard): Don't print two '$' symbols. * user-regs.c (user_reg_map_name_to_regnum): Be flexible about leading '$'. Do case insensitive match on register name. Index: expprint.c =================================================================== RCS file: /cvs/src/src/gdb/expprint.c,v retrieving revision 1.21 diff -c -3 -p -r1.21 expprint.c *** expprint.c 9 Nov 2004 14:43:25 -0000 1.21 --- expprint.c 10 Feb 2005 10:08:32 -0000 *************** print_subexp_standard (struct expression *** 132,137 **** --- 132,139 ---- int regnum = longest_to_int (exp->elts[pc + 1].longconst); const char *name = user_reg_map_regnum_to_name (current_gdbarch, regnum); + if (*name == '$') + name++; (*pos) += 2; fprintf_filtered (stream, "$%s", name); return; Index: user-regs.c =================================================================== RCS file: /cvs/src/src/gdb/user-regs.c,v retrieving revision 1.5 diff -c -3 -p -r1.5 user-regs.c *** user-regs.c 15 Mar 2004 20:38:08 -0000 1.5 --- user-regs.c 10 Feb 2005 10:08:32 -0000 *************** user_reg_map_name_to_regnum (struct gdba *** 133,140 **** for (i = 0; i < maxregs; i++) { const char *regname = gdbarch_register_name (gdbarch, i); ! if (regname != NULL && len == strlen (regname) ! && strncmp (regname, name, len) == 0) { return i; } --- 133,146 ---- for (i = 0; i < maxregs; i++) { const char *regname = gdbarch_register_name (gdbarch, i); ! ! if (regname == NULL) ! continue; ! ! if (*regname == '$' && *name != '$') ! regname++; ! if (len == strlen (regname) ! && strncasecmp (regname, name, len) == 0) { return i; } --------------010705050200010805070602 Content-Type: text/plain; name="pctest.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pctest.patch" Content-length: 2641 2005-02-10 Nathan Sidwell * gdb.base/pc-fp.exp: Allow pc or PC. * gdb.trace/report.exp: Allow pc or PC. Index: testsuite/gdb.base/pc-fp.exp =================================================================== RCS file: /home/icera/Repository/gnu/gdb/testsuite/gdb.base/pc-fp.exp,v retrieving revision 1.1 retrieving revision 1.2 diff -c -3 -p -r1.1 -r1.2 *** testsuite/gdb.base/pc-fp.exp 15 Jul 2004 10:27:34 -0000 1.1 --- testsuite/gdb.base/pc-fp.exp 6 Feb 2005 13:54:02 -0000 1.2 *************** set valueof_fp [get_valueofx "/x" "\$fp" *** 81,87 **** # display since that encodes and then decodes the expression parameter # (and hence uses the mechanisms we're trying to test). ! gdb_test "display/i \$pc" "1: x/i +\\\$pc +${valueof_pc}.*" gdb_test "display/w \$fp" "2: x/xw +\\\$fp +${valueof_fp}.*" # FIXME: cagney/2002-09-04: Should also check that ``info registers --- 81,87 ---- # display since that encodes and then decodes the expression parameter # (and hence uses the mechanisms we're trying to test). ! gdb_test "display/i \$pc" "1: x/i +\\\$(pc)|(PC) +${valueof_pc}.*" gdb_test "display/w \$fp" "2: x/xw +\\\$fp +${valueof_fp}.*" # FIXME: cagney/2002-09-04: Should also check that ``info registers Index: testsuite/gdb.trace/report.exp =================================================================== RCS file: /home/icera/Repository/gnu/gdb/testsuite/gdb.trace/report.exp,v retrieving revision 1.1 retrieving revision 1.2 diff -c -3 -p -r1.1 -r1.2 *** testsuite/gdb.trace/report.exp 15 Jul 2004 10:32:41 -0000 1.1 --- testsuite/gdb.trace/report.exp 6 Feb 2005 13:54:04 -0000 1.2 *************** gdb_test "tdump" \ *** 218,228 **** gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \ "\$tracepoint" "$tdp2" ! # regs were collected at tdp2. ! # How to match for the output of "info registers" on an unknown architecture? ! # For now, assume that every architecture has a register called "pc". gdb_test "tdump" \ ! "\[\r\n\]pc .*" \ "9.1: tdump, regs collected" gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \ --- 218,229 ---- gdb_tfind_test "9.1: find frame for TP $tdp2" "tracepoint $tdp2" \ "\$tracepoint" "$tdp2" ! # regs were collected at tdp2. How to match for the output of "info ! # registers" on an unknown architecture? For now, assume that every ! # architecture has a register called "pc" or "PC" possibly with a ! # preceding '$'. gdb_test "tdump" \ ! "\[\r\n\]\\$?(pc)|(PC) .*" \ "9.1: tdump, regs collected" gdb_tfind_test "9.1: find frame for TP $tdp3" "tracepoint $tdp3" \ --------------010705050200010805070602--