From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29289 invoked by alias); 4 Dec 2003 15:11:34 -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 29264 invoked from network); 4 Dec 2003 15:11:33 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 4 Dec 2003 15:11:33 -0000 Received: from gnu.org (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 9EE342B8F; Thu, 4 Dec 2003 10:11:28 -0500 (EST) Message-ID: <3FCF4EA0.2030803@gnu.org> Date: Thu, 04 Dec 2003 15:11:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jonathan Larmour Cc: gdb-patches@sources.redhat.com Subject: Re: powerpc remote target registers References: <3FC7FF5D.7060906@eCosCentric.com> <3FCB8DDC.30603@gnu.org> <3FCC21B2.30000@eCosCentric.com> <3FCD6527.9000506@gnu.org> <3FCEE306.5050604@eCosCentric.com> Content-Type: multipart/mixed; boundary="------------060308030805000706070407" X-SW-Source: 2003-12/txt/msg00111.txt.bz2 This is a multi-part message in MIME format. --------------060308030805000706070407 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 2268 > Andrew Cagney wrote: > > But then the registers aren't marked as cached at all, so they're now requested from the target each time you do "info all-registers", even though they come up with 0s. Should I pretend the registers not supplied by the target were 0, or should I mark them as unavailable (i.e. the same as what having an "x" does) so at least it's consistent? > > > Ah, they should be supplied but with a value of zero. The protocol (for historic reasons) specifies that a short G packet should have the missing entries treated as zero (like you intended). > > Good, in which case the attached patch (against 6.0) should do it. Mostly indent changes, boringly enough. > > > 2003-12-04 Jonathan Larmour > > * remote.c (remote_fetch_registers): If target doesn't supply > registers, set them to zero. > > Thanks, Try the attached, its basicly the same but with a few not very obvious tweaks: supply_register is actually deprecated (but you couldn't tell :-); ->offset is really only valid when ->in_g_packet; avoids an assuption about the total size of the buffer and the behavior of get packet. I think I got the logic right. Andrew (PS: paperwork sent) > --- remote.c.old 2003-12-02 03:05:46.000000000 +0000 > +++ remote.c 2003-12-04 07:19:38.000000000 +0000 > @@ -3498,19 +3498,31 @@ remote_fetch_registers (int regnum) > warning ("Remote reply is too short: %s", buf); > } > > supply_them: > { > - int i; > + int i, end_targ_regs=0; > for (i = 0; i < NUM_REGS + NUM_PSEUDO_REGS; i++) > { > struct packet_reg *r = &rs->regs[i]; > + > + if (buf[r->offset * 2] == 0) > + end_targ_regs = 1; /* end of registers supplied by target */ > if (r->in_g_packet) > { > - supply_register (r->regnum, regs + r->offset); > - if (buf[r->offset * 2] == 'x') > - set_register_cached (i, -1); > + if (end_targ_regs) > + { > + /* If the target hasn't sent enough registers, set > + the remainder to 0. */ > + supply_register (r->regnum, 0); > + } > + else > + { > + supply_register (r->regnum, regs + r->offset); > + if (buf[r->offset * 2] == 'x') > + set_register_cached (i, -1); > + } > } > } > } > } > --------------060308030805000706070407 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 1455 2003-12-04 Andrew Cagney * remote.c (remote_fetch_registers): For short packets, explicitly supply a zero value. Use regcache_raw_supply. Fix suggested by Jonathan Larmour. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.122 diff -u -r1.122 remote.c --- remote.c 10 Nov 2003 21:20:44 -0000 1.122 +++ remote.c 4 Dec 2003 15:05:49 -0000 @@ -3558,9 +3558,23 @@ struct packet_reg *r = &rs->regs[i]; if (r->in_g_packet) { - supply_register (r->regnum, regs + r->offset); - if (buf[r->offset * 2] == 'x') - set_register_cached (i, -1); + if (r->offset * 2 >= strlen (buf)) + /* A short packet that didn't include the register's + value, this implies that the register is zero (and + not that the register is unavailable). Supply that + zero value. */ + regcache_raw_supply (current_regcache, r->regnum, NULL); + else if (buf[r->offset * 2] == 'x') + { + gdb_assert (r->offset * 2 < strlen (buf)); + /* The register isn't available, mark it as such (at + the same time setting the value to zero). */ + regcache_raw_supply (current_regcache, r->regnum, NULL); + set_register_cached (i, -1); + } + else + regcache_raw_supply (current_regcache, r->regnum, + regs + r->offset); } } } --------------060308030805000706070407--