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:22:55 -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> <20150723110653 dot 3f4e2f11 at pinnacle dot lan>
Hi Pierre-Marie,
On Thu, 23 Jul 2015 11:06:53 -0700
Kevin Buettner <kevinb@redhat.com> wrote:
> --- 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 ---
I came across something else (for someone) to ponder while playing with
the above code. I don't necessarily expect your current patch to handle
this case, but since you've been looking at nested subprograms, you may
have some insight into what's happening.
The situation is that I want to place a breakpoint on the function p().
How do I do this?
This is what I've tried:
1) Placing a breakpoint on p without qualification does not work:
(gdb) b p
Function "p" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
2) Placing a breakpoint on main::p doesn't work:
(gdb) b main::p
Function "main::p" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
3a) However, the completion mechanism seems to think that p is a viable
candidate for a breakpoint:
(gdb) b p
p printf printf@plt
3b) But, as in (1), when we try it (by hitting <Enter> here), it
does not work:
Function "p" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
4) Perhaps p will be visible if we run to a breakpoint in main? (Nope.)
(gdb) b main
Breakpoint 1 at 0x400525: file nested.c, line 5.
(gdb) run
Starting program: /mesquite2/.ironwood2/1158876/nested
Breakpoint 1, main () at nested.c:5
5 int d = 4, e = 5, f = 6;
(gdb) b p
Function "p" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb)
So, there it is.
I want to be perfectly clear that I do NOT want this issue to hold up
your patch. I'm just throwing it out there in case you want to look
at it.
Kevin