This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch/rfc, rfa:doco] Deprecate NPC_REGNUM
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 14 Sep 2003 19:35:55 -0400
- Subject: [patch/rfc, rfa:doco] Deprecate NPC_REGNUM
Hello,
Core GDB uses NPC_REGNUM in two ways:
- in generic write pc to upate the next pc
Architectures (HP/UX and SPARC) can (and I suspect do) implement
TARGET_WRITE_PC to do this directly
- procfs_fetch_registers contains the performance tweak:
if (FP0_REGNUM >= 0) /* need floating point? */
{
if ((regno >= 0 && regno < FP0_REGNUM) ||
regno == PC_REGNUM ||
(NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
regno == DEPRECATED_FP_REGNUM ||
regno == SP_REGNUM)
return; /* not a floating point register */
if ((fpregs = proc_get_fpregs (pi)) == NULL)
proc_error (pi, "fetch_registers, get_fpregs", __LINE__);
supply_fpregset (fpregs);
}
Even without NPC_REGNUM, GDB works. The regset stuff should make it
possible to both cleanup the code and rewrite that performance hack into
oblivion.
Eli, doco ok?
I'll follow up in a few days,
Andrew
Index: doc/ChangeLog
2003-09-14 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Target Architecture Definition): Rename
NPC_REGNUM to DEPRECATED_NPC_REGNUM. Add cross reference to
TARGET_WRITE_PC.
2003-09-14 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (DEPRECATED_NPC_REGNUM): Deprecate NPC_REGNUM.
* gdbarch.h, gdbarch.c: Regenerate.
* core-sol2.c, hppa-tdep.c, lynx-nat.c, procfs.c: Update.
* regcache.c, remote-vxsparc.c, sparc-linux-nat.c: Update.
* sparc-nat.c, sparc-tdep.c, sparc64-tdep.c: Update.
* sparcnbsd-tdep.c: Update.
Index: core-sol2.c
===================================================================
RCS file: /cvs/src/src/gdb/core-sol2.c,v
retrieving revision 1.10
diff -u -r1.10 core-sol2.c
--- core-sol2.c 14 Nov 2002 20:37:28 -0000 1.10
+++ core-sol2.c 14 Sep 2003 22:45:43 -0000
@@ -103,7 +103,7 @@
= gregs->r_ps;
*(int *) &deprecated_registers[REGISTER_BYTE (PC_REGNUM)]
= gregs->r_pc;
- *(int *) &deprecated_registers[REGISTER_BYTE (NPC_REGNUM)]
+ *(int *) &deprecated_registers[REGISTER_BYTE (DEPRECATED_NPC_REGNUM)]
= gregs->r_npc;
*(int *) &deprecated_registers[REGISTER_BYTE (Y_REGNUM)]
= gregs->r_y;
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.268
diff -u -r1.268 gdbarch.sh
--- gdbarch.sh 13 Sep 2003 14:12:40 -0000 1.268
+++ gdbarch.sh 14 Sep 2003 22:50:55 -0000
@@ -453,7 +453,9 @@
v:2:PC_REGNUM:int:pc_regnum::::-1:-1::0
v:2:PS_REGNUM:int:ps_regnum::::-1:-1::0
v:2:FP0_REGNUM:int:fp0_regnum::::0:-1::0
-v:2:NPC_REGNUM:int:npc_regnum::::0:-1::0
+# Replace DEPRECATED_NPC_REGNUM with an implementation of WRITE_PC
+# that updates PC, NPC and even NNPC.
+v:2:DEPRECATED_NPC_REGNUM:int:deprecated_npc_regnum::::0:-1::0
# Convert stab register number (from \`r\' declaration) to a gdb REGNUM.
f:2:STAB_REG_TO_REGNUM:int:stab_reg_to_regnum:int stab_regnr:stab_regnr:::no_op_reg_to_regnum::0
# Provide a default mapping from a ecoff register number to a gdb REGNUM.
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.95
diff -u -r1.95 hppa-tdep.c
--- hppa-tdep.c 14 Sep 2003 16:32:12 -0000 1.95
+++ hppa-tdep.c 14 Sep 2003 22:53:04 -0000
@@ -2630,7 +2630,7 @@
write_register_pid (31, v | 0x3, ptid);
write_register_pid (PC_REGNUM, v, ptid);
- write_register_pid (NPC_REGNUM, v + 4, ptid);
+ write_register_pid (DEPRECATED_NPC_REGNUM, v + 4, ptid);
}
/* return the alignment of a type in bytes. Structures have the maximum
@@ -5174,7 +5174,7 @@
set_gdbarch_sp_regnum (gdbarch, 30);
set_gdbarch_fp0_regnum (gdbarch, 64);
set_gdbarch_pc_regnum (gdbarch, PCOQ_HEAD_REGNUM);
- set_gdbarch_npc_regnum (gdbarch, PCOQ_TAIL_REGNUM);
+ set_gdbarch_deprecated_npc_regnum (gdbarch, PCOQ_TAIL_REGNUM);
set_gdbarch_deprecated_register_raw_size (gdbarch, hppa_register_raw_size);
set_gdbarch_deprecated_register_byte (gdbarch, hppa_register_byte);
set_gdbarch_deprecated_register_virtual_size (gdbarch, hppa_register_raw_size);
Index: lynx-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/lynx-nat.c,v
retrieving revision 1.14
diff -u -r1.14 lynx-nat.c
--- lynx-nat.c 8 May 2003 22:33:14 -0000 1.14
+++ lynx-nat.c 14 Sep 2003 22:53:10 -0000
@@ -305,7 +305,7 @@
supply_register (PS_REGNUM, (char *) &ec.psr);
supply_register (Y_REGNUM, (char *) &ec.y);
supply_register (PC_REGNUM, (char *) &ec.pc);
- supply_register (NPC_REGNUM, (char *) &ec.npc);
+ supply_register (DEPRECATED_NPC_REGNUM, (char *) &ec.npc);
supply_register (WIM_REGNUM, (char *) &ec.wim);
memcpy (&deprecated_registers[REGISTER_BYTE (O0_REGNUM)], ec.o,
@@ -390,7 +390,7 @@
ec.psr = read_register (PS_REGNUM);
ec.y = read_register (Y_REGNUM);
ec.pc = read_register (PC_REGNUM);
- ec.npc = read_register (NPC_REGNUM);
+ ec.npc = read_register (DEPRECATED_NPC_REGNUM);
ec.wim = read_register (WIM_REGNUM);
memcpy (ec.o, &deprecated_registers[REGISTER_BYTE (O0_REGNUM)],
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.46
diff -u -r1.46 procfs.c
--- procfs.c 29 Apr 2003 01:49:47 -0000 1.46
+++ procfs.c 14 Sep 2003 22:53:49 -0000
@@ -3705,7 +3705,7 @@
{
if ((regno >= 0 && regno < FP0_REGNUM) ||
regno == PC_REGNUM ||
- (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
+ (DEPRECATED_NPC_REGNUM >= 0 && regno == DEPRECATED_NPC_REGNUM) ||
regno == DEPRECATED_FP_REGNUM ||
regno == SP_REGNUM)
return; /* not a floating point register */
@@ -3779,7 +3779,7 @@
{
if ((regno >= 0 && regno < FP0_REGNUM) ||
regno == PC_REGNUM ||
- (NPC_REGNUM >= 0 && regno == NPC_REGNUM) ||
+ (DEPRECATED_NPC_REGNUM >= 0 && regno == DEPRECATED_NPC_REGNUM) ||
regno == DEPRECATED_FP_REGNUM ||
regno == SP_REGNUM)
return; /* not a floating point register */
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.97
diff -u -r1.97 regcache.c
--- regcache.c 29 Aug 2003 13:04:44 -0000 1.97
+++ regcache.c 14 Sep 2003 22:54:07 -0000
@@ -1343,8 +1343,8 @@
#ifdef PC_REGNUM
if (PC_REGNUM >= 0)
write_register_pid (PC_REGNUM, pc, ptid);
- if (NPC_REGNUM >= 0)
- write_register_pid (NPC_REGNUM, pc + 4, ptid);
+ if (DEPRECATED_NPC_REGNUM >= 0)
+ write_register_pid (DEPRECATED_NPC_REGNUM, pc + 4, ptid);
#else
internal_error (__FILE__, __LINE__,
"generic_target_write_pc");
Index: remote-vxsparc.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-vxsparc.c,v
retrieving revision 1.12
diff -u -r1.12 remote-vxsparc.c
--- remote-vxsparc.c 2 Jun 2003 02:09:39 -0000 1.12
+++ remote-vxsparc.c 14 Sep 2003 22:55:11 -0000
@@ -157,7 +157,7 @@
if (regno >= 0)
{
if ((G0_REGNUM <= regno && regno <= I7_REGNUM)
- || (Y_REGNUM <= regno && regno <= NPC_REGNUM))
+ || (Y_REGNUM <= regno && regno <= DEPRECATED_NPC_REGNUM))
in_fp_regs = 0;
else
in_gp_regs = 0;
Index: sparc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-linux-nat.c,v
retrieving revision 1.4
diff -u -r1.4 sparc-linux-nat.c
--- sparc-linux-nat.c 7 Jul 2003 15:56:03 -0000 1.4
+++ sparc-linux-nat.c 14 Sep 2003 22:55:11 -0000
@@ -40,7 +40,7 @@
supply_register (PS_REGNUM, (char *) (regp + 32));
supply_register (PC_REGNUM, (char *) (regp + 33));
- supply_register (NPC_REGNUM, (char *) (regp + 34));
+ supply_register (DEPRECATED_NPC_REGNUM, (char *) (regp + 34));
supply_register (Y_REGNUM, (char *) (regp + 35));
supply_register (WIM_REGNUM, (char *) (regp + 36));
@@ -65,8 +65,8 @@
if (regno == -1 || regno == PC_REGNUM)
regcache_collect (PC_REGNUM, regp + 33);
- if (regno == -1 || regno == NPC_REGNUM)
- regcache_collect (NPC_REGNUM, regp + 34);
+ if (regno == -1 || regno == DEPRECATED_NPC_REGNUM)
+ regcache_collect (DEPRECATED_NPC_REGNUM, regp + 34);
if (regno == -1 || regno == Y_REGNUM)
regcache_collect (Y_REGNUM, regp + 35);
Index: sparc-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-nat.c,v
retrieving revision 1.19
diff -u -r1.19 sparc-nat.c
--- sparc-nat.c 7 Jul 2003 15:56:03 -0000 1.19
+++ sparc-nat.c 14 Sep 2003 22:55:11 -0000
@@ -108,7 +108,7 @@
= inferior_registers.r_ps;
*(int *) &deprecated_registers[REGISTER_BYTE (PC_REGNUM)]
= inferior_registers.r_pc;
- *(int *) &deprecated_registers[REGISTER_BYTE (NPC_REGNUM)]
+ *(int *) &deprecated_registers[REGISTER_BYTE (DEPRECATED_NPC_REGNUM)]
= inferior_registers.r_npc;
*(int *) &deprecated_registers[REGISTER_BYTE (Y_REGNUM)] = inferior_registers.r_y;
@@ -117,7 +117,7 @@
deprecated_register_valid[Y_REGNUM] = 1;
deprecated_register_valid[PS_REGNUM] = 1;
deprecated_register_valid[PC_REGNUM] = 1;
- deprecated_register_valid[NPC_REGNUM] = 1;
+ deprecated_register_valid[DEPRECATED_NPC_REGNUM] = 1;
/* If we don't set these valid, read_register_bytes() rereads
all the regs every time it is called! FIXME. */
deprecated_register_valid[WIM_REGNUM] = 1; /* Not true yet, FIXME */
@@ -261,7 +261,7 @@
inferior_registers.r_pc =
*(int *) &deprecated_registers[REGISTER_BYTE (PC_REGNUM)];
inferior_registers.r_npc =
- *(int *) &deprecated_registers[REGISTER_BYTE (NPC_REGNUM)];
+ *(int *) &deprecated_registers[REGISTER_BYTE (DEPRECATED_NPC_REGNUM)];
inferior_registers.r_y =
*(int *) &deprecated_registers[REGISTER_BYTE (Y_REGNUM)];
@@ -318,7 +318,7 @@
15 * REGISTER_RAW_SIZE (G1_REGNUM));
*(int *) &deprecated_registers[REGISTER_BYTE (PS_REGNUM)] = gregs->r_ps;
*(int *) &deprecated_registers[REGISTER_BYTE (PC_REGNUM)] = gregs->r_pc;
- *(int *) &deprecated_registers[REGISTER_BYTE (NPC_REGNUM)] = gregs->r_npc;
+ *(int *) &deprecated_registers[REGISTER_BYTE (DEPRECATED_NPC_REGNUM)] = gregs->r_npc;
*(int *) &deprecated_registers[REGISTER_BYTE (Y_REGNUM)] = gregs->r_y;
/* My best guess at where to get the locals and input
Index: sparc-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc-tdep.c,v
retrieving revision 1.125
diff -u -r1.125 sparc-tdep.c
--- sparc-tdep.c 14 Sep 2003 16:32:14 -0000 1.125
+++ sparc-tdep.c 14 Sep 2003 22:55:14 -0000
@@ -168,7 +168,7 @@
Beihl (beihl@mcc.com). */
/* npc4 and next_pc describe the situation at the time that the
- step-breakpoint was set, not necessary the current value of NPC_REGNUM. */
+ step-breakpoint was set, not necessary the current value of DEPRECATED_NPC_REGNUM. */
static CORE_ADDR next_pc, npc4, target;
static int brknpc4, brktrg;
typedef char binsn_quantum[BREAKPOINT_MAX];
@@ -195,7 +195,7 @@
if (insert_breakpoints_p)
{
/* Always set breakpoint for NPC. */
- next_pc = read_register (NPC_REGNUM);
+ next_pc = read_register (DEPRECATED_NPC_REGNUM);
npc4 = next_pc + 4; /* branch not taken */
target_insert_breakpoint (next_pc, break_mem[0]);
@@ -1320,10 +1320,10 @@
write_register (PC_REGNUM,
read_memory_integer (fsr[PC_REGNUM],
REGISTER_RAW_SIZE (PC_REGNUM)));
- if (fsr[NPC_REGNUM])
- write_register (NPC_REGNUM,
- read_memory_integer (fsr[NPC_REGNUM],
- REGISTER_RAW_SIZE (NPC_REGNUM)));
+ if (fsr[DEPRECATED_NPC_REGNUM])
+ write_register (DEPRECATED_NPC_REGNUM,
+ read_memory_integer (fsr[DEPRECATED_NPC_REGNUM],
+ REGISTER_RAW_SIZE (DEPRECATED_NPC_REGNUM)));
}
else if (get_frame_extra_info (frame)->flat)
{
@@ -1342,7 +1342,7 @@
}
write_register (PC_REGNUM, pc);
- write_register (NPC_REGNUM, pc + 4);
+ write_register (DEPRECATED_NPC_REGNUM, pc + 4);
}
else if (fsr[I7_REGNUM])
{
@@ -1350,7 +1350,7 @@
pc = PC_ADJUST ((CORE_ADDR) read_memory_integer (fsr[I7_REGNUM],
SPARC_INTREG_SIZE));
write_register (PC_REGNUM, pc);
- write_register (NPC_REGNUM, pc + 4);
+ write_register (DEPRECATED_NPC_REGNUM, pc + 4);
}
flush_cached_frames ();
}
@@ -1479,7 +1479,7 @@
/* These require a bit more care. */
supply_register (PC_REGNUM, ((char *) (regp + R_PC)) + offset);
- supply_register (NPC_REGNUM, ((char *) (regp + R_nPC)) + offset);
+ supply_register (DEPRECATED_NPC_REGNUM, ((char *) (regp + R_nPC)) + offset);
supply_register (Y_REGNUM, ((char *) (regp + R_Y)) + offset);
if (GDB_TARGET_IS_SPARC64)
@@ -1598,8 +1598,8 @@
if ((regno == -1) || (regno == PC_REGNUM))
deprecated_read_register_gen (PC_REGNUM, (char *) (regp + R_PC) + offset);
- if ((regno == -1) || (regno == NPC_REGNUM))
- deprecated_read_register_gen (NPC_REGNUM, (char *) (regp + R_nPC) + offset);
+ if ((regno == -1) || (regno == DEPRECATED_NPC_REGNUM))
+ deprecated_read_register_gen (DEPRECATED_NPC_REGNUM, (char *) (regp + R_nPC) + offset);
if ((regno == -1) || (regno == Y_REGNUM))
deprecated_read_register_gen (Y_REGNUM, (char *) (regp + R_Y) + offset);
@@ -3384,7 +3384,7 @@
set_gdbarch_frame_args_skip (gdbarch, 68);
set_gdbarch_function_start_offset (gdbarch, 0);
set_gdbarch_long_bit (gdbarch, 4 * TARGET_CHAR_BIT);
- set_gdbarch_npc_regnum (gdbarch, SPARC32_NPC_REGNUM);
+ set_gdbarch_deprecated_npc_regnum (gdbarch, SPARC32_NPC_REGNUM);
set_gdbarch_pc_regnum (gdbarch, SPARC32_PC_REGNUM);
set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
set_gdbarch_deprecated_push_arguments (gdbarch, sparc32_push_arguments);
@@ -3433,7 +3433,7 @@
set_gdbarch_frame_args_skip (gdbarch, 136);
set_gdbarch_function_start_offset (gdbarch, 0);
set_gdbarch_long_bit (gdbarch, 8 * TARGET_CHAR_BIT);
- set_gdbarch_npc_regnum (gdbarch, SPARC64_NPC_REGNUM);
+ set_gdbarch_deprecated_npc_regnum (gdbarch, SPARC64_NPC_REGNUM);
set_gdbarch_pc_regnum (gdbarch, SPARC64_PC_REGNUM);
set_gdbarch_ptr_bit (gdbarch, 8 * TARGET_CHAR_BIT);
set_gdbarch_deprecated_push_arguments (gdbarch, sparc64_push_arguments);
Index: sparc64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v
retrieving revision 1.2
diff -u -r1.2 sparc64-tdep.c
--- sparc64-tdep.c 22 Aug 2003 18:52:50 -0000 1.2
+++ sparc64-tdep.c 14 Sep 2003 22:56:03 -0000
@@ -1356,7 +1356,7 @@
/* Register numbers of various important registers. */
set_gdbarch_sp_regnum (gdbarch, SPARC_SP_REGNUM); /* %sp */
set_gdbarch_pc_regnum (gdbarch, SPARC64_PC_REGNUM); /* %pc */
- set_gdbarch_npc_regnum (gdbarch, SPARC64_NPC_REGNUM);
+ set_gdbarch_deprecated_npc_regnum (gdbarch, SPARC64_NPC_REGNUM);
set_gdbarch_fp0_regnum (gdbarch, SPARC_F0_REGNUM); /* %f0 */
/* Call dummy code. */
Index: sparcnbsd-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcnbsd-tdep.c,v
retrieving revision 1.6
diff -u -r1.6 sparcnbsd-tdep.c
--- sparcnbsd-tdep.c 7 Jul 2003 15:56:08 -0000 1.6
+++ sparcnbsd-tdep.c 14 Sep 2003 22:56:03 -0000
@@ -59,8 +59,8 @@
if (regno == PC_REGNUM || regno == -1)
supply_register (PC_REGNUM, regs + REG32_OFFSET_PC);
- if (regno == NPC_REGNUM || regno == -1)
- supply_register (NPC_REGNUM, regs + REG32_OFFSET_NPC);
+ if (regno == DEPRECATED_NPC_REGNUM || regno == -1)
+ supply_register (DEPRECATED_NPC_REGNUM, regs + REG32_OFFSET_NPC);
if (regno == Y_REGNUM || regno == -1)
supply_register (Y_REGNUM, regs + REG32_OFFSET_Y);
@@ -126,8 +126,8 @@
if (regno == PC_REGNUM || regno == -1)
supply_register (PC_REGNUM, regs + REG64_OFFSET_PC);
- if (regno == NPC_REGNUM || regno == -1)
- supply_register (NPC_REGNUM, regs + REG64_OFFSET_NPC);
+ if (regno == DEPRECATED_NPC_REGNUM || regno == -1)
+ supply_register (DEPRECATED_NPC_REGNUM, regs + REG64_OFFSET_NPC);
if (regno == Y_REGNUM || regno == -1)
{
@@ -220,8 +220,8 @@
if (regno == PC_REGNUM || regno == -1)
regcache_collect (PC_REGNUM, regs + REG32_OFFSET_PC);
- if (regno == NPC_REGNUM || regno == -1)
- regcache_collect (NPC_REGNUM, regs + REG32_OFFSET_NPC);
+ if (regno == DEPRECATED_NPC_REGNUM || regno == -1)
+ regcache_collect (DEPRECATED_NPC_REGNUM, regs + REG32_OFFSET_NPC);
if (regno == Y_REGNUM || regno == -1)
regcache_collect (Y_REGNUM, regs + REG32_OFFSET_Y);
@@ -261,8 +261,8 @@
if (regno == PC_REGNUM || regno == -1)
regcache_collect (PC_REGNUM, regs + REG64_OFFSET_PC);
- if (regno == NPC_REGNUM || regno == -1)
- regcache_collect (NPC_REGNUM, regs + REG64_OFFSET_NPC);
+ if (regno == DEPRECATED_NPC_REGNUM || regno == -1)
+ regcache_collect (DEPRECATED_NPC_REGNUM, regs + REG64_OFFSET_NPC);
if (regno == Y_REGNUM || regno == -1)
regcache_collect (Y_REGNUM, regs + REG64_OFFSET_Y);
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.161
diff -u -r1.161 gdbint.texinfo
--- doc/gdbint.texinfo 13 Sep 2003 14:12:41 -0000 1.161
+++ doc/gdbint.texinfo 14 Sep 2003 22:56:59 -0000
@@ -3677,10 +3677,13 @@
This should only need to be defined if @code{TARGET_READ_PC} and
@code{TARGET_WRITE_PC} are not defined.
-@item NPC_REGNUM
-@findex NPC_REGNUM
+@item DEPRECATED_NPC_REGNUM
+@findex DEPRECATED_NPC_REGNUM
The number of the ``next program counter'' register, if defined.
+@code{DEPRECATED_NPC_REGNUM} has been replaced by @code{TARGET_WRITE_PC}
+(@pxref{TARGET_WRITE_PC}).
+
@item PARM_BOUNDARY
@findex PARM_BOUNDARY
If non-zero, round arguments to a boundary of this many bits before
@@ -3909,6 +3912,7 @@
@findex TARGET_READ_PC
@itemx TARGET_WRITE_PC (@var{val}, @var{pid})
@findex TARGET_WRITE_PC
+@anchor{TARGET_WRITE_PC}
@itemx TARGET_READ_SP
@findex TARGET_READ_SP
@itemx TARGET_READ_FP