[PATCH] Add proper handling for non-local references in nested functions
Pierre-Marie de Rodat
derodat@adacore.com
Fri Jul 24 09:26:00 GMT 2015
On 07/23/2015 08:06 PM, Kevin Buettner wrote:
> Your patch did indeed fix my problem.
>
> Given this test case (which I cobbled together while looking at another
> matter)...
> [...]
> Breakpoint 1, p () at nested.c:11
> 11 __builtin_printf ("%d %d %d %d\n", b, c, e, f);
> (gdb) p a
> $1 = 1
> (gdb) p b
> $2 = 2
> (gdb) p c
> $3 = 7
> (gdb) p d
> $4 = 32767
> (gdb) p e
> $5 = 5
> (gdb) p f
> $6 = 8
>
> Note that the value of d is wrong.
Out of curiosity, I had a quick look and I understood what is going on
(without my most recent patch) in this example:
a, b and c are static variables, so they aren't on the stack and thus
GDB locates/prints them correctly. The e and f non-local variables are
referenced from p and thus GCC materializes them as local references in
the debug. info. for p, so GDB locates/prints the correctly.
d is both located on the outer frame and not referenced from p, so the
only description GDB has is the outer scope variable... which is
incorrectly used to locate/print the variable as of today.
> So, with your patch, the value of d is correct.
>
> I don't know why, but with your patch from yesterday, I was still
> seeing the faulty behavior. (It is possible that I messed up with
> my testing...)
That's most likely because my previous patch was broken, as I said in
the first mail I sent on Thursday. ;-)
--
Pierre-Marie de Rodat
More information about the Gdb-patches
mailing list