With the main-subprogram executable (the test-case for PR16264), without -readnow we end up in mymain, as expected: ... $ ./gdb -batch /data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/main-subprogram/main-subprogram -ex start Temporary breakpoint 1 at 0x4004ab Temporary breakpoint 1, 0x00000000004004ab in mymain () ... But with -readnow, we end up in main instead: ... $ ./gdb -readnow -batch /data/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.dwarf2/main-subprogram/main-subprogram.stripped -ex start Temporary breakpoint 1 at 0x4004b6 Temporary breakpoint 1, 0x00000000004004b6 in main () ...
Tentative patch: ... diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index b0bdecf96f..229877dded 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -13741,6 +13741,10 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) newobj->name = new_symbol (die, read_type_die (die, cu), cu, (struct symbol *) templ_func); + attr = dwarf2_attr (die, DW_AT_main_subprogram, cu); + if (attr) + set_objfile_main_name (objfile, SYMBOL_LINKAGE_NAME (newobj->name), cu->language); + /* If there is a location expression for DW_AT_frame_base, record it. */ attr = dwarf2_attr (die, DW_AT_frame_base, cu); ...
patch submitted: https://sourceware.org/ml/gdb-patches/2019-05/msg00156.html
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=81873cc81effbd657efe5f525d369e430ce77d7a commit 81873cc81effbd657efe5f525d369e430ce77d7a Author: Tom de Vries <tdevries@suse.de> Date: Mon Jun 10 09:28:30 2019 +0200 [gdb/symtab] Support DW_AT_main_subprogram with -readnow. DW_AT_main_subprogram is supported in normal mode in read_partial_die, but not in -readnow mode. Fix this by adding support for DW_AT_main_subprogram in read_func_scope. Tested on x86_64-linux with native and RFC target board readnow ( https://sourceware.org/ml/gdb-patches/2019-05/msg00073.html ). gdb/ChangeLog: 2019-06-10 Tom de Vries <tdevries@suse.de> PR symtab/16264 PR symtab/24517 * dwarf2read.c (read_func_scope): Handle DW_AT_main_subprogram.
Patch committed.