This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add proper handling for non-local references in nested functions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]