From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24685 invoked by alias); 15 Apr 2005 23:12:26 -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 24654 invoked from network); 15 Apr 2005 23:12:20 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org with SMTP; 15 Apr 2005 23:12:20 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j3FNCKlU017292 for ; Fri, 15 Apr 2005 19:12:20 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j3FNCKO12132 for ; Fri, 15 Apr 2005 19:12:20 -0400 Received: from localhost.localdomain (vpn50-9.rdu.redhat.com [172.16.50.9]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id j3FNCJNO027975 for ; Fri, 15 Apr 2005 19:12:19 -0400 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id j3FNCEiR012329 for ; Fri, 15 Apr 2005 16:12:14 -0700 Date: Fri, 15 Apr 2005 23:12:00 -0000 From: Kevin Buettner To: gdb-patches@sources.redhat.com Subject: Re: [RFC] Eliminate use of deprecated_register_bytes() from remote.c Message-ID: <20050415161212.28c1d511@ironwood.lan> In-Reply-To: <20050415213758.GA13161@nevyn.them.org> References: <20050415143245.4b210dfe@ironwood.lan> <20050415213758.GA13161@nevyn.them.org> Organization: Red Hat Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SW-Source: 2005-04/txt/msg00175.txt.bz2 On Fri, 15 Apr 2005 17:37:58 -0400 Daniel Jacobowitz wrote: > On Fri, Apr 15, 2005 at 02:32:45PM -0700, Kevin Buettner wrote: > > This one seems almost obvious, but I'd like someone else to look it > > over before I check it in... > > > > * remote.c (init_remote_state): Eliminate use of > > deprecated_register_bytes(). > > I'm pretty sure you need an if (regnum < NUM_REGS) on the second piece. I agree that that's the right thing to do, but I'm not convinced that will give us behavior equivalent to what we have now. Consider the following comment/code from regcache.c: /* FIXME: cagney/2002-05-22: Should only need to allocate space for the raw registers. Unfortunately some code still accesses the register array directly using the global registers[]. Until that code has been purged, play safe and over allocating the register buffer. Ulgh! */ descr->sizeof_raw_registers = descr->sizeof_cooked_registers; The ``sizeof_raw_registers'' field is the value returned by deprecated_register_bytes(). So, it seems to me that we're presently setting rs->sizeof_g_packet to a value that's potentially larger than need be. I can think of no reason to continue to over-allocate space for g/G packets in remote.c so I'm happy with this patch instead (which adds the test that you wanted): * remote.c (init_remote_state): Eliminate use of deprecated_register_bytes(). Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.184 diff -u -p -r1.184 remote.c --- remote.c 15 Apr 2005 21:16:09 -0000 1.184 +++ remote.c 15 Apr 2005 22:53:38 -0000 @@ -248,10 +248,7 @@ init_remote_state (struct gdbarch *gdbar int regnum; struct remote_state *rs = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct remote_state); - if (deprecated_register_bytes () != 0) - rs->sizeof_g_packet = deprecated_register_bytes (); - else - rs->sizeof_g_packet = 0; + rs->sizeof_g_packet = 0; /* Assume a 1:1 regnum<->pnum table. */ rs->regs = GDBARCH_OBSTACK_CALLOC (gdbarch, NUM_REGS + NUM_PSEUDO_REGS, @@ -266,8 +263,8 @@ init_remote_state (struct gdbarch *gdbar /* ...name = REGISTER_NAME (regnum); */ /* Compute packet size by accumulating the size of all registers. */ - if (deprecated_register_bytes () == 0) - rs->sizeof_g_packet += register_size (current_gdbarch, regnum); + if (regnum < NUM_REGS) + rs->sizeof_g_packet += register_size (current_gdbarch, regnum); } /* Default maximum number of characters in a packet body. Many