Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 62 - Name of nested functions is not available in debug info
Summary: Name of nested functions is not available in debug info
Status: RESOLVED INVALID
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: All All
: --- minor
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2013-06-12 16:46 CEST by Johannes Pfau
Modified: 2014-02-17 11:58 CET (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Pfau 2013-06-12 16:46:03 CEST
It seems we have a small bug with debug info and nested functions as the name of nested functions is not available in debug info.

----------
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:620
0x40774e ???
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:595
0x40797f ???
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:630
0x40774e ???
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:595
----------

Should be similar to (this are the symbols as in the symbol table):
----------
2) 0x40740e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runMain()
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:620
3) 0x407b6e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:595
4) 0x407d9f extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void runAll()
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:630
5) 0x407b6e extern (C) int rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).void tryExec(scope void delegate())
	../../../../gcc-4.8.0/libphobos/libdruntime/rt/dmain2.d:595
----------

I found this while using libbacktrace: https://github.com/mirrors/gcc/blob/master/libbacktrace/

Pull request coming soon...
Comment 1 Johannes Pfau 2014-02-17 11:58:24 CET
This is a bug in libbacktrace, reported here:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60240



Iain, what was the reason we don't mark nested function declarations as TREE_PUBLIC again? It seems GCC only emits the mangled name into debug info for public functions.

Test case:
-----------
void main()
{
    void a()
    {
    }
    a();
}
-----------

compile with
gdc test.d test.d -c -g
objdump -W test.o > dwarf.info

Search for "test.main.a". Then you'll see there's a DW_TAG_subprogram with "DW_AT_name" set, but "DW_AT_linkage_name" is not set.

The TREE_PUBLIC check is in "dwarf2out.c:add_linkage_name":
  if (debug_info_level > DINFO_LEVEL_TERSE
      && (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
      && TREE_PUBLIC (decl)
      && !DECL_ABSTRACT (decl)
      && !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
      && die->die_tag != DW_TAG_member)
    {