From: Nathan Sidwell <nathan@codesourcery.com>
To: gdb-patches@sources.redhat.com
Cc: Paul Brook <paul@codesourcery.com>
Subject: [patch] registers beginning with '$'
Date: Thu, 10 Feb 2005 15:27:00 -0000 [thread overview]
Message-ID: <420B383D.1020406@codesourcery.com> (raw)
[-- 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" \
next reply other threads:[~2005-02-10 10:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-10 15:27 Nathan Sidwell [this message]
2005-03-07 22:58 ` Daniel Jacobowitz
2005-03-08 9:39 ` Nathan Sidwell
2005-03-08 13:43 ` Daniel Jacobowitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=420B383D.1020406@codesourcery.com \
--to=nathan@codesourcery.com \
--cc=gdb-patches@sources.redhat.com \
--cc=paul@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox