This is the mail archive of the gdb-prs@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]

[Bug symtab/18746] New: Cannot set breakpoint on nested function or subprogram


https://sourceware.org/bugzilla/show_bug.cgi?id=18746

            Bug ID: 18746
           Summary: Cannot set breakpoint on nested function or subprogram
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: symtab
          Assignee: unassigned at sourceware dot org
          Reporter: kevinb at redhat dot com
  Target Milestone: ---

Created attachment 8462
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8462&action=edit
nested.c

Consider this program (which is also an attachment):

--- 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 ---

It can be compiled as follows:

gcc -o nested -g nested.c

I would like to place a breakpoint on p(), which is nested within main().

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

(I see the same behavior when I try main:p too.)

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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


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