* [patch] registers beginning with '$'
@ 2005-02-10 15:27 Nathan Sidwell
2005-03-07 22:58 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Sidwell @ 2005-02-10 15:27 UTC (permalink / raw)
To: gdb-patches; +Cc: Paul Brook
[-- Attachment #1: Type: text/plain, Size: 740 bytes --]
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
[-- Attachment #2: regnames.patch --]
[-- Type: text/plain, Size: 1778 bytes --]
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;
}
[-- Attachment #3: pctest.patch --]
[-- Type: text/plain, Size: 2641 bytes --]
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" \
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] registers beginning with '$'
2005-02-10 15:27 [patch] registers beginning with '$' Nathan Sidwell
@ 2005-03-07 22:58 ` Daniel Jacobowitz
2005-03-08 9:39 ` Nathan Sidwell
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-03-07 22:58 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gdb-patches, Paul Brook
On Thu, Feb 10, 2005 at 10:32:29AM +0000, Nathan Sidwell wrote:
> 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?
This one I'm less sure about. If you tell GDB the register names do
not contain '$', what output is wrong?
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] registers beginning with '$'
2005-03-07 22:58 ` Daniel Jacobowitz
@ 2005-03-08 9:39 ` Nathan Sidwell
2005-03-08 13:43 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Nathan Sidwell @ 2005-03-08 9:39 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Paul Brook
Daniel Jacobowitz wrote:
> On Thu, Feb 10, 2005 at 10:32:29AM +0000, Nathan Sidwell wrote:
>
>>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?
>
>
> This one I'm less sure about. If you tell GDB the register names do
> not contain '$', what output is wrong?
The output from the 'info regs' command will then not have the '$'.
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] registers beginning with '$'
2005-03-08 9:39 ` Nathan Sidwell
@ 2005-03-08 13:43 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2005-03-08 13:43 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: gdb-patches, Paul Brook
On Tue, Mar 08, 2005 at 09:39:21AM +0000, Nathan Sidwell wrote:
> Daniel Jacobowitz wrote:
> >On Thu, Feb 10, 2005 at 10:32:29AM +0000, Nathan Sidwell wrote:
> >
> >>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?
> >
> >
> >This one I'm less sure about. If you tell GDB the register names do
> >not contain '$', what output is wrong?
>
> The output from the 'info regs' command will then not have the '$'.
Then you should provide gdbarch_print_registers_info; you can make this
look however you want on a per-target basis.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-03-08 13:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-10 15:27 [patch] registers beginning with '$' Nathan Sidwell
2005-03-07 22:58 ` Daniel Jacobowitz
2005-03-08 9:39 ` Nathan Sidwell
2005-03-08 13:43 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox