This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
questions about immediate_quit...
- To: gdb at sourceware dot cygnus dot com
- Subject: questions about immediate_quit...
- From: jtc at redback dot com (J.T. Conklin)
- Date: 21 Aug 2000 11:35:58 -0700
- Reply-To: jtc at redback dot com
I found the following code in dcache_peek_byte():
immediate_quit++;
while (done < LINE_SIZE)
{
int try =
(*dcache->read_memory)
(db->addr + done,
db->data + done,
LINE_SIZE - done);
if (try == 0)
return 0;
done += try;
}
immediate_quit--;
Even after reading the comment describing immediate_quit in utils.c,
I'm still a bit puzzled.
* In the above code fragment, immediate quit is incremented before the
read. But it is only decremented if the read succeeds. This would
appear to be an obvious bug.
* From the aforementioned comment, it seems that the dcache is at too
high of a level to bother with immediate_quit. If setting/reset it
is necessary, it should be done in the target i/o functions.
* Examination of various target bits, reveals that in most cases
immediate_quit is set and reset there. However:
- in some cases, instead of incrementing and decrementing immediate_quit,
they are set to 1 and 0.
- in other cases, the value of immediate_quit is saved in old_immediate_quit
then set to 1, and finally set back to the saved value.
The first case potentially loses when such calls are nested, as they
are with the dcache enabled. The second works fine, but I see a
value in using only one idiom throughout the gdb sources.
In conclusion, I think the code touching immediate_quit in dcache.c is
unnecessary, and I'll remove it in my next set of commits.
I also think we should remove all assignments of 0/1 to immediate_quit
and replace them with increments/decrements so that it nests properly.
I think this is important even in code paths that will never nest, as
any occurance in the code may be used as a template by a future
contributor. I prefer good examples without gotchas...
Thoughts?
--jtc
--
J.T. Conklin
RedBack Networks