From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1650 invoked by alias); 4 Jun 2003 02:46:24 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 30003 invoked from network); 4 Jun 2003 02:44:47 -0000 Received: from unknown (HELO localhost.redhat.com) (24.157.166.107) by sources.redhat.com with SMTP; 4 Jun 2003 02:44:47 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 23E4D2B2F; Tue, 3 Jun 2003 22:44:36 -0400 (EDT) Message-ID: <3EDD5D13.3060902@redhat.com> Date: Wed, 04 Jun 2003 02:46:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030223 X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Theodore A. Roth" Cc: gdb-patches@sources.redhat.com Subject: Re: [RFC/RFA] fix calculation of sizeof_g_packet References: <3EDD1FA3.9020306@redhat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-06/txt/msg00157.txt.bz2 > 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 > > * 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 > > * 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