This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Add proper handling for non-local references in nested functions
- From: Kevin Buettner <kevinb at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 23 Jul 2015 11:06:53 -0700
- Subject: Re: [PATCH] Add proper handling for non-local references in nested functions
- Authentication-results: sourceware.org; auth=none
- References: <54F47563 dot 4050103 at adacore dot com> <54FF0D05 dot 70907 at redhat dot com> <550C1170 dot 9070208 at adacore dot com> <55685B60 dot 3000004 at redhat dot com> <55775EB0 dot 4080701 at adacore dot com> <55AF5F7E dot 5000600 at adacore dot com> <20150722173957 dot 7ed51f18 at pinnacle dot lan> <55B0C583 dot 6050601 at adacore dot com> <20150723064408 dot 4dd8a9b2 at pinnacle dot lan> <55B112D4 dot 5010304 at adacore dot com>
On Thu, 23 Jul 2015 18:14:12 +0200
Pierre-Marie de Rodat <derodat@adacore.com> wrote:
> On 07/23/2015 03:44 PM, Kevin Buettner wrote:
>
> > I'll test your new patch today. I've encountered a GDB bug related to
> > examining variables with within a nested function. I'm hoping that
> > your patch will fix it...
>
> I am as well: keep me updated! ;-)
Your patch did indeed fix my problem.
Given this test case (which I cobbled together while looking at another
matter)...
--- nested.c ---
int
main ()
{
static int a = 1, b = 2, c = 3;
int d = 4, e = 5, f = 6;
void p (void)
{
c = 7;
f = 8;
__builtin_printf ("%d %d %d %d\n", b, c, e, f);
}
p ();
a = 101; b = 102; c = 103;
d = 104; e = 105; f = 106;
p ();
return 0;
}
--- end nested.c ---
...this is the behavior that I was seeing (without your patch):
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.
Now, with your patch, this is what I see:
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 = 4
(gdb) p e
$5 = 5
(gdb) p f
$6 = 8
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...)
Kevin