From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8173 invoked by alias); 25 Jun 2003 21:46:17 -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 14115 invoked from network); 25 Jun 2003 21:06:25 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.131) by sources.redhat.com with SMTP; 25 Jun 2003 21:06:25 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 843D62B5F; Wed, 25 Jun 2003 17:01:34 -0400 (EDT) Message-ID: <3EFA0DAE.4030403@redhat.com> Date: Wed, 25 Jun 2003 21: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: Kevin Buettner Cc: gdb-patches@sources.redhat.com Subject: Re: [commit] Allow cached cooked reads References: <3EEDC499.4010209@redhat.com> <1030624220608.ZM22089@localhost.localdomain> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-06/txt/msg00775.txt.bz2 > On Jun 16, 9:22am, Andrew Cagney wrote: > > >> Just stumbled across this. When trying to save cooked registers the >> regcache was triggering an assertion failure instead of ignoring a bogus >> request. >> >> 2003-06-16 Andrew Cagney >> >> * regcache.c (do_cooked_read): Do not use register_valid_p. >> >> Index: regcache.c >> =================================================================== >> RCS file: /cvs/src/src/gdb/regcache.c,v >> retrieving revision 1.87 >> diff -u -r1.87 regcache.c >> --- regcache.c 9 Jun 2003 01:02:06 -0000 1.87 >> +++ regcache.c 16 Jun 2003 13:18:46 -0000 >> @@ -423,8 +423,7 @@ >> do_cooked_read (void *src, int regnum, void *buf) >> { >> struct regcache *regcache = src; >> - if (!regcache_valid_p (regcache, regnum) >> - && regcache->readonly_p) >> + if (!regcache->register_valid_p[regnum] && regcache->readonly_p) >> /* Don't even think about fetching a register from a read-only >> cache when the register isn't yet valid. There isn't a target >> from which the register value can be fetched. */ > > > Which assertion was failing? The check for regcache != NULL or the > bounds check? The bounds check. If regcache were NULL, GDB would be sunk. > I'm wondering if the new code above should include some bounds checks. > Alternately, go back to using regcache_valid_p() and weaken the > assertions in regcache_valid_p() somewhat. E.g, perhaps rewrite > regcache_valid_p() from: > int > regcache_valid_p (struct regcache *regcache, int regnum) > { > gdb_assert (regcache != NULL); > gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers); > return regcache->register_valid_p[regnum]; > } > > to: > > int > regcache_valid_p (struct regcache *regcache, int regnum) > { > gdb_assert (regcache != NULL); > gdb_assert (regnum >= 0); > return regnum < regcache->descr->nr_raw_registers) > && regcache->register_valid_p[regnum]; > } The intent of the external function is to indicate to external code if a raw register is valid (as in fetched). So external code trying to call this with regnum >= NUM_REGS is broken. Andrew