|
|
a909d0 |
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
|
a909d0 |
From: Keith Seitz <keiths@redhat.com>
|
|
|
a909d0 |
Date: Wed, 5 May 2021 13:57:13 -0700
|
|
|
a909d0 |
Subject: gdb-rhbz1934673-fortran-nameless-modules.patch
|
|
|
a909d0 |
|
|
|
a909d0 |
;; Fix segfault with nameless fortran modules.
|
|
|
a909d0 |
;; Bernhard Heckel, RH BZ 1943673
|
|
|
a909d0 |
|
|
|
a909d0 |
Dwarf: Don't add nameless modules to partial symbol table
|
|
|
a909d0 |
|
|
|
a909d0 |
A name for BLOCK DATA in Fortran is optional. If no name has been
|
|
|
a909d0 |
assigned, GDB crashes during read-in of DWARF when BLOCK DATA is
|
|
|
a909d0 |
represented via DW_TAG_module. BLOCK DATA is used for one-time
|
|
|
a909d0 |
initialization of non-pointer variables in named common blocks.
|
|
|
a909d0 |
|
|
|
a909d0 |
As of now there is no issue when gfortran is used as DW_TAG_module is
|
|
|
a909d0 |
not emitted. However, with Intel ifort the nameless DW_TAG_module is
|
|
|
a909d0 |
present and has the following form:
|
|
|
a909d0 |
|
|
|
a909d0 |
...
|
|
|
a909d0 |
<1>: Abbrev Number: 7 (DW_TAG_module)
|
|
|
a909d0 |
<de> DW_AT_decl_line : 46
|
|
|
a909d0 |
<df> DW_AT_decl_file : 1
|
|
|
a909d0 |
<e0> DW_AT_description : (indirect string, offset: 0x110): block
|
|
|
a909d0 |
data
|
|
|
a909d0 |
<e4> DW_AT_high_pc : 0x402bb7
|
|
|
a909d0 |
<ec> DW_AT_low_pc : 0x402bb7
|
|
|
a909d0 |
...
|
|
|
a909d0 |
|
|
|
a909d0 |
The missing name leads to a crash in add_partial_symbol, during length
|
|
|
a909d0 |
calculation.
|
|
|
a909d0 |
|
|
|
a909d0 |
gdb/ChangeLog:
|
|
|
a909d0 |
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
|
|
|
a909d0 |
|
|
|
a909d0 |
* dwarf2read.c (add_partial_symbol): Skip nameless modules.
|
|
|
a909d0 |
|
|
|
a909d0 |
gdb/testsuite/Changelog:
|
|
|
a909d0 |
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
|
|
|
a909d0 |
|
|
|
a909d0 |
* gdb.fortran/block-data.f: New.
|
|
|
a909d0 |
* gdb.fortran/block-data.exp: New.
|
|
|
a909d0 |
|
|
|
a909d0 |
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
|
|
|
a909d0 |
--- a/gdb/dwarf2read.c
|
|
|
a909d0 |
+++ b/gdb/dwarf2read.c
|
|
|
a909d0 |
@@ -8936,11 +8936,15 @@ add_partial_symbol (struct partial_die_info *pdi, struct dwarf2_cu *cu)
|
|
|
a909d0 |
0, cu->language, objfile);
|
|
|
a909d0 |
break;
|
|
|
a909d0 |
case DW_TAG_module:
|
|
|
a909d0 |
- add_psymbol_to_list (actual_name, strlen (actual_name),
|
|
|
a909d0 |
- built_actual_name != NULL,
|
|
|
a909d0 |
- MODULE_DOMAIN, LOC_TYPEDEF,
|
|
|
a909d0 |
- &objfile->global_psymbols,
|
|
|
a909d0 |
- 0, cu->language, objfile);
|
|
|
a909d0 |
+ /* With Fortran 77 there might be a "BLOCK DATA" module
|
|
|
a909d0 |
+ available without any name. If so, we skip the module as it
|
|
|
a909d0 |
+ doesn't bring any value. */
|
|
|
a909d0 |
+ if (actual_name != nullptr)
|
|
|
a909d0 |
+ add_psymbol_to_list (actual_name, strlen (actual_name),
|
|
|
a909d0 |
+ built_actual_name != NULL,
|
|
|
a909d0 |
+ MODULE_DOMAIN, LOC_TYPEDEF,
|
|
|
a909d0 |
+ &objfile->global_psymbols,
|
|
|
a909d0 |
+ 0, cu->language, objfile);
|
|
|
a909d0 |
break;
|
|
|
a909d0 |
case DW_TAG_class_type:
|
|
|
a909d0 |
case DW_TAG_interface_type:
|
|
|
a909d0 |
@@ -16777,9 +16781,6 @@ read_module_type (struct die_info *die, struct dwarf2_cu *cu)
|
|
|
a909d0 |
struct type *type;
|
|
|
a909d0 |
|
|
|
a909d0 |
module_name = dwarf2_name (die, cu);
|
|
|
a909d0 |
- if (!module_name)
|
|
|
a909d0 |
- complaint (_("DW_TAG_module has no name, offset %s"),
|
|
|
a909d0 |
- sect_offset_str (die->sect_off));
|
|
|
a909d0 |
type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
|
|
|
a909d0 |
|
|
|
a909d0 |
return set_die_type (die, type, cu);
|
|
|
a909d0 |
diff --git a/gdb/testsuite/gdb.fortran/block-data.exp b/gdb/testsuite/gdb.fortran/block-data.exp
|
|
|
a909d0 |
new file mode 100644
|
|
|
a909d0 |
--- /dev/null
|
|
|
a909d0 |
+++ b/gdb/testsuite/gdb.fortran/block-data.exp
|
|
|
a909d0 |
@@ -0,0 +1,63 @@
|
|
|
a909d0 |
+# Copyright 2016-2019 Free Software Foundation, Inc.
|
|
|
a909d0 |
+#
|
|
|
a909d0 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
a909d0 |
+# it under the terms of the GNU General Public License as published by
|
|
|
a909d0 |
+# the Free Software Foundation; either version 3 of the License, or
|
|
|
a909d0 |
+# (at your option) any later version.
|
|
|
a909d0 |
+#
|
|
|
a909d0 |
+# This program is distributed in the hope that it will be useful,
|
|
|
a909d0 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a909d0 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a909d0 |
+# GNU General Public License for more details.
|
|
|
a909d0 |
+#
|
|
|
a909d0 |
+# You should have received a copy of the GNU General Public License
|
|
|
a909d0 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+# Test anonymous block-data statements.
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+# A name for BLOCK DATA in Fortran is optional. BLOCK DATA is used
|
|
|
a909d0 |
+# for one-time initialization of non-pointer variables in named common
|
|
|
a909d0 |
+# blocks. GDB used to crash with 'Intel ifort'-generated code, which
|
|
|
a909d0 |
+# outputs nameless DW_TAG_module, unlike with gfortran which just
|
|
|
a909d0 |
+# doesn't emit DW_TAG_module in this case.
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+if { [skip_fortran_tests] } { return -1 }
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+standard_testfile .f
|
|
|
a909d0 |
+load_lib "fortran.exp"
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
|
|
|
a909d0 |
+ return -1
|
|
|
a909d0 |
+}
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+if ![runto MAIN__] then {
|
|
|
a909d0 |
+ untested "couldn't run to breakpoint MAIN__"
|
|
|
a909d0 |
+ return -1
|
|
|
a909d0 |
+}
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+with_test_prefix "default values" {
|
|
|
a909d0 |
+ gdb_test "print doub1" "= 1\.11\\d+"
|
|
|
a909d0 |
+ gdb_test "print doub2" "= 2\.22\\d+"
|
|
|
a909d0 |
+ gdb_test "print char1" "= 'abcdef'"
|
|
|
a909d0 |
+ gdb_test "print char2" "= 'ghijkl'"
|
|
|
a909d0 |
+}
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+gdb_breakpoint [gdb_get_line_number "! BP_BEFORE_SUB"]
|
|
|
a909d0 |
+gdb_continue_to_breakpoint "! BP_BEFORE_SUB" ".*! BP_BEFORE_SUB.*"
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+with_test_prefix "before sub" {
|
|
|
a909d0 |
+ gdb_test "print doub1" "= 11\.11\\d+"
|
|
|
a909d0 |
+ gdb_test "print doub2" "= 22\.22\\d+"
|
|
|
a909d0 |
+ gdb_test "print char1" "= 'ABCDEF'"
|
|
|
a909d0 |
+ gdb_test "print char2" "= 'GHIJKL'"
|
|
|
a909d0 |
+}
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+gdb_breakpoint [gdb_get_line_number "! BP_SUB"]
|
|
|
a909d0 |
+gdb_continue_to_breakpoint "! BP_SUB" ".*! BP_SUB.*"
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+with_test_prefix "in sub" {
|
|
|
a909d0 |
+ gdb_test "print doub1" "= 11\.11\\d+"
|
|
|
a909d0 |
+ gdb_test "print doub2" "= 22\.22\\d+"
|
|
|
a909d0 |
+ gdb_test "print char1" "= 'ABCDEF'"
|
|
|
a909d0 |
+ gdb_test "print char2" "= 'GHIJKL'"
|
|
|
a909d0 |
+}
|
|
|
a909d0 |
diff --git a/gdb/testsuite/gdb.fortran/block-data.f b/gdb/testsuite/gdb.fortran/block-data.f
|
|
|
a909d0 |
new file mode 100644
|
|
|
a909d0 |
--- /dev/null
|
|
|
a909d0 |
+++ b/gdb/testsuite/gdb.fortran/block-data.f
|
|
|
a909d0 |
@@ -0,0 +1,56 @@
|
|
|
a909d0 |
+! Copyright 2016-2019 Free Software Foundation, Inc.
|
|
|
a909d0 |
+!
|
|
|
a909d0 |
+! This program is free software; you can redistribute it and/or modify
|
|
|
a909d0 |
+! it under the terms of the GNU General Public License as published by
|
|
|
a909d0 |
+! the Free Software Foundation; either version 3 of the License, or
|
|
|
a909d0 |
+! (at your option) any later version.
|
|
|
a909d0 |
+!
|
|
|
a909d0 |
+! This program is distributed in the hope that it will be useful,
|
|
|
a909d0 |
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a909d0 |
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
a909d0 |
+! GNU General Public License for more details.
|
|
|
a909d0 |
+!
|
|
|
a909d0 |
+! You should have received a copy of the GNU General Public License
|
|
|
a909d0 |
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
a909d0 |
+!
|
|
|
a909d0 |
+! Check that GDB can handle block data with no global name.
|
|
|
a909d0 |
+!
|
|
|
a909d0 |
+! MAIN
|
|
|
a909d0 |
+ PROGRAM bdata
|
|
|
a909d0 |
+ DOUBLE PRECISION doub1, doub2
|
|
|
a909d0 |
+ CHARACTER*6 char1, char2
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ COMMON /BLK1/ doub1, char1
|
|
|
a909d0 |
+ COMMON /BLK2/ doub2, char2
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ doub1 = 11.111
|
|
|
a909d0 |
+ doub2 = 22.222
|
|
|
a909d0 |
+ char1 = 'ABCDEF'
|
|
|
a909d0 |
+ char2 = 'GHIJKL'
|
|
|
a909d0 |
+ CALL sub_block_data ! BP_BEFORE_SUB
|
|
|
a909d0 |
+ STOP
|
|
|
a909d0 |
+ END
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+! BLOCK DATA
|
|
|
a909d0 |
+ BLOCK DATA
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ DOUBLE PRECISION doub1, doub2
|
|
|
a909d0 |
+ CHARACTER*6 char1, char2
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ COMMON /BLK1/ doub1, char1
|
|
|
a909d0 |
+ COMMON /BLK2/ doub2, char2
|
|
|
a909d0 |
+ DATA doub1, doub2 /1.111, 2.222/
|
|
|
a909d0 |
+ DATA char1, char2 /'abcdef', 'ghijkl'/
|
|
|
a909d0 |
+ END
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+! SUBROUTINE
|
|
|
a909d0 |
+ SUBROUTINE sub_block_data
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ DOUBLE PRECISION doub1, doub2
|
|
|
a909d0 |
+ CHARACTER*6 char1, char2
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ COMMON /BLK1/ doub1, char1
|
|
|
a909d0 |
+ COMMON /BLK2/ doub2, char2
|
|
|
a909d0 |
+
|
|
|
a909d0 |
+ char1 = char2; ! BP_SUB
|
|
|
a909d0 |
+ END
|