* [commit] Allow cached cooked reads
@ 2003-06-16 13:22 Andrew Cagney
2003-06-24 23:02 ` Kevin Buettner
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Cagney @ 2003-06-16 13:22 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 172 bytes --]
Just stumbled across this. When trying to save cooked registers the
regcache was triggering an assertion failure instead of ignoring a bogus
request.
committed,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 826 bytes --]
2003-06-16 Andrew Cagney <cagney@redhat.com>
* 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. */
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [commit] Allow cached cooked reads
2003-06-16 13:22 [commit] Allow cached cooked reads Andrew Cagney
@ 2003-06-24 23:02 ` Kevin Buettner
2003-06-25 21:46 ` Andrew Cagney
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Buettner @ 2003-06-24 23:02 UTC (permalink / raw)
To: Andrew Cagney, gdb-patches
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 <cagney@redhat.com>
>
> * 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?
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];
}
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [commit] Allow cached cooked reads
2003-06-24 23:02 ` Kevin Buettner
@ 2003-06-25 21:46 ` Andrew Cagney
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Cagney @ 2003-06-25 21:46 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
> 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 <cagney@redhat.com>
>>
>> * 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-06-25 21:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-16 13:22 [commit] Allow cached cooked reads Andrew Cagney
2003-06-24 23:02 ` Kevin Buettner
2003-06-25 21:46 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox