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...
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) {