This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] registers beginning with '$'


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

2005-02-10  Nathan Sidwell  <nathan@codesourcery.com>

	* 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;
  	  }
2005-02-10  Nathan Sidwell  <nathan@codesourcery.com>

	* 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" \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]