This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC/RFA] fix calculation of sizeof_g_packet
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: "Theodore A. Roth" <troth at openavr dot org>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Tue, 03 Jun 2003 18:22:27 -0400
- Subject: Re: [RFC/RFA] fix calculation of sizeof_g_packet
- References: <Pine.LNX.4.53.0306031443400.17269@knuth.amplepower.com>
The attached patch changes init_remote_state() so that sizeof_g_packet
computed using REGISTER_RAW_SIZE() instead of blindly set to
DEPRECATED_REGISTER_BYTES.
I'm assuming two things which I'm not sure are true:
1) REGISTER_RAW_SIZE() is usable for all targets now
2) REGISTER_RAW_SIZE() is valid when passed pseudo register.
Ok to commit?
Just a few tweaks.
2003-06-03 Theodore A. Roth <troth@openavr.org>
* remote.c (init_remote_state): Compute sizeof_g_packet by
accumulation of the size of all registers instead of using
DEPRECATED_REGISTER_BYTES.
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.100
diff -u -p -r1.100 remote.c
--- remote.c 17 May 2003 05:59:58 -0000 1.100
+++ remote.c 3 Jun 2003 21:36:30 -0000
@@ -261,9 +261,7 @@ init_remote_state (struct gdbarch *gdbar
int regnum;
struct remote_state *rs = xmalloc (sizeof (struct remote_state));
- /* Start out by having the remote protocol mimic the existing
- behavour - just copy in the description of the register cache. */
- rs->sizeof_g_packet = DEPRECATED_REGISTER_BYTES; /* OK */
+ rs->sizeof_g_packet = 0;
For the moment it is safer to do:
if (DEPRECATED_REGISTER_BYTES_P ())
rs-> ... = ...;
else
rs-> ... = 0;
/* Assume a 1:1 regnum<->pnum table. */
rs->regs = xcalloc (NUM_REGS + NUM_PSEUDO_REGS, sizeof (struct packet_reg));
@@ -274,8 +272,10 @@ init_remote_state (struct gdbarch *gdbar
r->regnum = regnum;
r->offset = REGISTER_BYTE (regnum);
r->in_g_packet = (regnum < NUM_REGS);
- /* ...size = REGISTER_RAW_SIZE (regnum); */
/* ...name = REGISTER_NAME (regnum); */
+
+ /* Compute packet size by accumulating the size of all registers. */
+ rs->sizeof_g_packet += REGISTER_RAW_SIZE (regnum);
And here:
if (!DEPRECATED_REGISTER_BYTES_P ())
rs-> ... += register_size (current_gdbarch);
register_size is better.
}
/* Default maximum number of characters in a packet body. Many
The problem is that for some targets, the register sizes don't add up to
REGISTER_BYTES.
otherwize ok,
Andrew