[RFC/RFA] fix calculation of sizeof_g_packet
Andrew Cagney
ac131313@redhat.com
Wed Jun 4 02:46:00 GMT 2003
> On Tue, 3 Jun 2003, Andrew Cagney wrote:
>
> :) > 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.
>
>
> :) > - /* 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;
>
> Well, DEPRECATED_REGISTER_BYTES_P() doesn't seem to exist.
> So there should need to be a change in gdbarch.sh I assume.
Doh, sorry. Easier to just test for a non-zero value:
if (DEPRECATED_REGISTER_BYTES == 0)
With that yes, definitly approved.
Andrew
> Round two is attached.
>
> Ok now?
>
> Ted Roth
>
>
> 2003-06-03 Theodore A. Roth <troth@openavr.org>
>
> * gdbarch.sh: Generate a predicate for DEPRECATED_REGISTER_BYTES.
> * gdbarch.[ch]: Re-generate.
> * remote.c (init_remote_state): Compute sizeof_g_packet by
> accumulation of the size of all registers instead of blindly using
> DEPRECATED_REGISTER_BYTES.
>
>
>
> 2003-06-03 Theodore A. Roth <troth@openavr.org>
>
> * gdbarch.sh: Generate a predicate for DEPRECATED_REGISTER_BYTES.
> * gdbarch.[ch]: Re-generate.
> * remote.c (init_remote_state): Compute sizeof_g_packet by
> accumulation of the size of all registers instead of blindly using
> DEPRECATED_REGISTER_BYTES.
>
> Index: gdbarch.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.c,v
> retrieving revision 1.218
> diff -u -p -r1.218 gdbarch.c
> --- gdbarch.c 2 Jun 2003 02:54:33 -0000 1.218
> +++ gdbarch.c 3 Jun 2003 22:58:56 -0000
> @@ -644,6 +644,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
> /* Skip verify of sdb_reg_to_regnum, invalid_p == 0 */
> /* Skip verify of dwarf2_reg_to_regnum, invalid_p == 0 */
> /* Skip verify of register_name, invalid_p == 0 */
> + /* Skip verify of deprecated_register_bytes, has predicate */
> /* Skip verify of register_byte, has predicate */
> /* Skip verify of register_raw_size, invalid_p == 0 */
> /* Skip verify of deprecated_max_register_raw_size, has predicate */
> @@ -1483,6 +1484,15 @@ gdbarch_dump (struct gdbarch *gdbarch, s
> (long) current_gdbarch->deprecated_push_return_address
> /*DEPRECATED_PUSH_RETURN_ADDRESS ()*/);
> #endif
> +#ifdef DEPRECATED_REGISTER_BYTES_P
> + fprintf_unfiltered (file,
> + "gdbarch_dump: %s # %s\n",
> + "DEPRECATED_REGISTER_BYTES_P()",
> + XSTRING (DEPRECATED_REGISTER_BYTES_P ()));
> + fprintf_unfiltered (file,
> + "gdbarch_dump: DEPRECATED_REGISTER_BYTES_P() = %d\n",
> + DEPRECATED_REGISTER_BYTES_P ());
> +#endif
> #ifdef DEPRECATED_REGISTER_BYTES
> fprintf_unfiltered (file,
> "gdbarch_dump: DEPRECATED_REGISTER_BYTES # %s\n",
> @@ -3322,6 +3332,13 @@ set_gdbarch_deprecated_register_size (st
> int deprecated_register_size)
> {
> gdbarch->deprecated_register_size = deprecated_register_size;
> +}
> +
> +int
> +gdbarch_deprecated_register_bytes_p (struct gdbarch *gdbarch)
> +{
> + gdb_assert (gdbarch != NULL);
> + return gdbarch->deprecated_register_bytes != 0;
> }
>
> int
> Index: gdbarch.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.h,v
> retrieving revision 1.188
> diff -u -p -r1.188 gdbarch.h
> --- gdbarch.h 2 Jun 2003 02:54:33 -0000 1.188
> +++ gdbarch.h 3 Jun 2003 22:58:57 -0000
> @@ -662,6 +662,31 @@ extern void set_gdbarch_deprecated_regis
> #define DEPRECATED_REGISTER_SIZE (gdbarch_deprecated_register_size (current_gdbarch))
> #endif
>
> +#if defined (DEPRECATED_REGISTER_BYTES)
> +/* Legacy for systems yet to multi-arch DEPRECATED_REGISTER_BYTES */
> +#if !defined (DEPRECATED_REGISTER_BYTES_P)
> +#define DEPRECATED_REGISTER_BYTES_P() (1)
> +#endif
> +#endif
> +
> +/* Default predicate for non- multi-arch targets. */
> +#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_REGISTER_BYTES_P)
> +#define DEPRECATED_REGISTER_BYTES_P() (0)
> +#endif
> +
> +extern int gdbarch_deprecated_register_bytes_p (struct gdbarch *gdbarch);
> +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_REGISTER_BYTES_P)
> +#error "Non multi-arch definition of DEPRECATED_REGISTER_BYTES"
> +#endif
> +#if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (DEPRECATED_REGISTER_BYTES_P)
> +#define DEPRECATED_REGISTER_BYTES_P() (gdbarch_deprecated_register_bytes_p (current_gdbarch))
> +#endif
> +
> +/* Default (value) for non- multi-arch platforms. */
> +#if (!GDB_MULTI_ARCH) && !defined (DEPRECATED_REGISTER_BYTES)
> +#define DEPRECATED_REGISTER_BYTES (0)
> +#endif
> +
> extern int gdbarch_deprecated_register_bytes (struct gdbarch *gdbarch);
> extern void set_gdbarch_deprecated_register_bytes (struct gdbarch *gdbarch, int deprecated_register_bytes);
> #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) && defined (DEPRECATED_REGISTER_BYTES)
> Index: gdbarch.sh
> ===================================================================
> RCS file: /cvs/src/src/gdb/gdbarch.sh,v
> retrieving revision 1.240
> diff -u -p -r1.240 gdbarch.sh
> --- gdbarch.sh 2 Jun 2003 02:54:34 -0000 1.240
> +++ gdbarch.sh 3 Jun 2003 22:58:58 -0000
> @@ -473,7 +473,7 @@ f:2:SDB_REG_TO_REGNUM:int:sdb_reg_to_reg
> f:2:DWARF2_REG_TO_REGNUM:int:dwarf2_reg_to_regnum:int dwarf2_regnr:dwarf2_regnr:::no_op_reg_to_regnum::0
> f:2:REGISTER_NAME:const char *:register_name:int regnr:regnr:::legacy_register_name::0
> v::DEPRECATED_REGISTER_SIZE:int:deprecated_register_size
> -v::DEPRECATED_REGISTER_BYTES:int:deprecated_register_bytes
> +V::DEPRECATED_REGISTER_BYTES:int:deprecated_register_bytes
> # NOTE: cagney/2002-05-02: This function with predicate has a valid
> # (callable) initial value. As a consequence, even when the predicate
> # is false, the corresponding function works. This simplifies the
> 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 22:59:00 -0000
> @@ -261,9 +261,10 @@ 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 */
> + if (DEPRECATED_REGISTER_BYTES_P ())
> + rs->sizeof_g_packet = DEPRECATED_REGISTER_BYTES;
> + else
> + rs->sizeof_g_packet = 0;
>
> /* Assume a 1:1 regnum<->pnum table. */
> rs->regs = xcalloc (NUM_REGS + NUM_PSEUDO_REGS, sizeof (struct packet_reg));
> @@ -274,8 +275,11 @@ 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. */
> + if (!DEPRECATED_REGISTER_BYTES_P ())
> + rs->sizeof_g_packet += register_size (current_gdbarch, regnum);
> }
>
> /* Default maximum number of characters in a packet body. Many
More information about the Gdb-patches
mailing list