This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
On Tue, Mar 09, 2004 at 08:51:05PM -0500, Andrew Cagney wrote:
>
> >BTW, I think the NORMAL_FRAME check is wrong too:
> >
> > {
> > int i;
> > stuff (i);
> >-> }
> >
> >get signal
>
> Er, hold on. The intent of address-in-block is:
>
> /* An address (not necessarily alligned to an instruction boundary)
> that falls within THIS frame's code block.
>
> When a function call is the last statement in a block, the return
> address for the call may land at the start of the next block.
> Similarly, if a no-return function call is the last statement in
> the function, the return address may end up pointing beyond the
> function, and possibly at the start of the next function.
> The only way to get a PC pointing at the first instruction of a function
> is for that function to have been interrupted just as that first
> instruction was about to be executed -- thats the very case where the
> existing address_in_block correctly leaves the PC as is.
>
> In the example in question:
>
> >
> > {
> > int i;
> > stuff (i);
> > -> }
>
> the existing code correctly puts the PC at the instruction about to
> destroy the prologue.
Think about this for a moment. I'm going to give addresses so that I
can be more precise.
0x10 <stuff>: ret stuff(int) { }
0x20 <main>: push main() {
0x21 <main+1>: push {
0x22 <main+2>: move arg1, i stuff(i)
0x23 <main+3>: call stuff "
0x24 <main+4>: pop }
0x25 <main+5>: pop }
0x26 <main+6>: ret "
The inner scope is probably <main+2> to <main+3> inclusive.
Suppose PC == 0x10. We backtrace. Look at main; saved PC is 0x24. We
want an address in the block. We subtract 1. OK, saved addr-in-block
is 0x23. 'i' is in scope.
Suppose PC == 0x24. Shouldn't this be the same? For the purposes of
looking at local variables, aren't we still in the the block?
Suppose PC was 0x24 and we got a signal. Ditto.
Suppose PC == 0x20 and we get a signal. Obviously we don't want to
change the behavior of this.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer