PR symtab/16264 - support DW_AT_main_subprogram
authorTom Tromey <tom@tromey.com>
Mon, 14 Nov 2016 03:56:34 +0000 (20:56 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 2 Dec 2016 16:11:47 +0000 (09:11 -0700)
commit0c1b455e294c6debb4efedc7f1346f3c43249f15
tree99ae140e176b22fcf27a04f7d538e721d5810482
parentf5ac6ab387ef0974f6348ac7febc691fbb6c0eb4
PR symtab/16264 - support DW_AT_main_subprogram

This patch adds support for DW_AT_main_subprogram.
This is PR symtab/16264.

DW_AT_main_subprogram is used to mark a program's entry point.  GCC
can emit this, and I hope to change the Rust compiler to emit it as
well.

GDB already supports an older, pre-DWARF 4 convention adopted by
FORTRAN compilers, namely to emit DW_AT_calling_convention for the
"main" function.  However, I think this support in GDB had a small
bug, in that it seems to rely on the DW_AT_name being read before
DW_AT_calling_convention.  This patch fixes this as well.

Built and regtested on x86-64 Fedora 24 and the buildbot.  New test
case included.

2016-12-02  Tom Tromey  <tom@tromey.com>

PR symtab/16264:
* dwarf2read.c (struct partial_die_info) <main_subprogram>: New
member.
(add_partial_symbol): Call set_objfile_main_name.
(read_partial_die): Handle DW_AT_main_subprogram.
<DW_AT_calling_convention>: don't call set_objfile_main_name, but
set main_subprogram flag.

2016-12-02  Tom Tromey  <tom@tromey.com>

* gdb.dwarf2/main-subprogram.c: New file.
* gdb.dwarf2/main-subprogram.exp: New file.
gdb/ChangeLog
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.dwarf2/main-subprogram.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/main-subprogram.exp [new file with mode: 0644]