diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-13 20:56:34 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2016-12-02 09:11:47 -0700 |
commit | 0c1b455e294c6debb4efedc7f1346f3c43249f15 (patch) | |
tree | 99ae140e176b22fcf27a04f7d538e721d5810482 /gdb/dwarf2read.c | |
parent | f5ac6ab387ef0974f6348ac7febc691fbb6c0eb4 (diff) | |
download | gdb-0c1b455e294c6debb4efedc7f1346f3c43249f15.zip gdb-0c1b455e294c6debb4efedc7f1346f3c43249f15.tar.gz gdb-0c1b455e294c6debb4efedc7f1346f3c43249f15.tar.bz2 |
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.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 558159a..ed10e03 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -1105,6 +1105,9 @@ struct partial_die_info unsigned int has_pc_info : 1; unsigned int may_be_inlined : 1; + /* This DIE has been marked DW_AT_main_subprogram. */ + unsigned int main_subprogram : 1; + /* Flag set if the SCOPE field of this structure has been computed. */ unsigned int scope_set : 1; @@ -6930,6 +6933,9 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) &objfile->static_psymbols, addr, cu->language, objfile); } + + if (pdi->main_subprogram && actual_name != NULL) + set_objfile_main_name (objfile, actual_name, cu->language); break; case DW_TAG_constant: { @@ -15949,19 +15955,18 @@ read_partial_die (const struct die_reader_specs *reader, to describe functions' calling conventions. However, because it's a necessary piece of information in - Fortran, and because DW_CC_program is the only piece of debugging - information whose definition refers to a 'main program' at all, - several compilers have begun marking Fortran main programs with - DW_CC_program --- even when those functions use the standard - calling conventions. - - So until DWARF specifies a way to provide this information and - compilers pick up the new representation, we'll support this - practice. */ + Fortran, and before DWARF 4 DW_CC_program was the only + piece of debugging information whose definition refers to + a 'main program' at all, several compilers marked Fortran + main programs with DW_CC_program --- even when those + functions use the standard calling conventions. + + Although DWARF now specifies a way to provide this + information, we support this practice for backward + compatibility. */ if (DW_UNSND (&attr) == DW_CC_program - && cu->language == language_fortran - && part_die->name != NULL) - set_objfile_main_name (objfile, part_die->name, language_fortran); + && cu->language == language_fortran) + part_die->main_subprogram = 1; break; case DW_AT_inline: if (DW_UNSND (&attr) == DW_INL_inlined @@ -15978,6 +15983,10 @@ read_partial_die (const struct die_reader_specs *reader, } break; + case DW_AT_main_subprogram: + part_die->main_subprogram = DW_UNSND (&attr); + break; + default: break; } |