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

symtab/1379: GDB doesn't scope nested functions properly


>Number:         1379
>Category:       symtab
>Synopsis:       GDB doesn't scope nested functions properly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 16 18:38:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     jingham@apple.com
>Release:        Top of tree as of 09-16-2003
>Organization:
>Environment:
Gnu Linux
>Description:
Compile the file attached to the report for PR 1195.  You will have to use -gstabs+, because of 1195, you won't be able to see subproc at all with Dwarf.

Then break in main and step into nested and from there into subproc.  

Now try to do:

(gdb) print w
No symbol "w" in current context.

That is wrong, "w" is in fact visible to subproc.  If you want to test this, change 

int t = z + 1;

to 

int t = z + w + 1

and this will compile fine...

Fixing this will be a bit of a bear, since you are going to have to scope the nested function - into the correct place in the block structure of its main program.  Stabs doesn't really tell you where the nested function is defined, but once you noticed that it was nested (stabs does tell you this) you could go to the line table for the function, find the first line, then go to the nesting function, find where that line number is in its block structure, and insert the nested function there.  Yecch...

Dwarf2 actually records the nested function in the correct place in the blocks already.  But gdb is going to have to start noticing this at all before it can handle the scoping problem.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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