diff options
author | Bernhard Heckel <bernhard.heckel@intel.com> | 2019-02-27 15:21:12 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2019-06-11 19:20:09 +0100 |
commit | a5fd13a91534b1c79a4b61995894a5bb4f08d3b0 (patch) | |
tree | ccca118c9784175d6a3a5f27f9f26c9c16079eb0 /gdb/dwarf2read.c | |
parent | 2057d69dccf36206be3bec5d48ff165621e9a06c (diff) | |
download | gdb-a5fd13a91534b1c79a4b61995894a5bb4f08d3b0.zip gdb-a5fd13a91534b1c79a4b61995894a5bb4f08d3b0.tar.gz gdb-a5fd13a91534b1c79a4b61995894a5bb4f08d3b0.tar.bz2 |
Dwarf: Don't add nameless modules to partial symbol table
A name for BLOCK DATA in Fortran is optional. If no name has been
assigned, GDB crashes during read-in of DWARF when BLOCK DATA is
represented via DW_TAG_module. BLOCK DATA is used for one-time
initialization of non-pointer variables in named common blocks.
As of now there is no issue when gfortran is used as DW_TAG_module is
not emitted. However, with Intel ifort the nameless DW_TAG_module is
present and has the following form:
...
<1><dd>: Abbrev Number: 7 (DW_TAG_module)
<de> DW_AT_decl_line : 46
<df> DW_AT_decl_file : 1
<e0> DW_AT_description : (indirect string, offset: 0x110): block
data
<e4> DW_AT_high_pc : 0x402bb7
<ec> DW_AT_low_pc : 0x402bb7
...
The missing name leads to a crash in add_partial_symbol, during length
calculation.
gdb/ChangeLog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* dwarf2read.c (add_partial_symbol): Skip nameless modules.
gdb/testsuite/Changelog:
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* gdb.fortran/block-data.f: New.
* gdb.fortran/block-data.exp: New.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r-- | gdb/dwarf2read.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 06c319d..4cf9fcf 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9018,11 +9018,15 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu) 0, cu->language, objfile); break; case DW_TAG_module: - add_psymbol_to_list (actual_name, strlen (actual_name), - built_actual_name != NULL, - MODULE_DOMAIN, LOC_TYPEDEF, -1, - psymbol_placement::GLOBAL, - 0, cu->language, objfile); + /* With Fortran 77 there might be a "BLOCK DATA" module + available without any name. If so, we skip the module as it + doesn't bring any value. */ + if (actual_name != nullptr) + add_psymbol_to_list (actual_name, strlen (actual_name), + built_actual_name != NULL, + MODULE_DOMAIN, LOC_TYPEDEF, -1, + psymbol_placement::GLOBAL, + 0, cu->language, objfile); break; case DW_TAG_class_type: case DW_TAG_interface_type: @@ -16955,9 +16959,6 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu) struct type *type; module_name = dwarf2_name (die, cu); - if (!module_name) - complaint (_("DW_TAG_module has no name, offset %s"), - sect_offset_str (die->sect_off)); type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name); return set_die_type (die, type, cu); |