Blame SOURCES/gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch

ce65b8
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
ce65b8
From: Sergio Durigan Junior <sergiodj@redhat.com>
ce65b8
Date: Fri, 11 Jan 2019 11:31:59 -0500
ce65b8
Subject: 
ce65b8
 gdb-rhbz1560010-fix-assertion-symbol-language-dict-language-5of5.patch
ce65b8
ce65b8
;; Fix 'Assertion `SYMBOL_LANGUAGE (sym) == DICT_LANGUAGE (dict)->la_language' failed.'
ce65b8
;; Keith Seitz, RHBZ#1560010.
ce65b8
ce65b8
gdb/23712: Test case for multidictionary
ce65b8
ce65b8
This is a test derived from one of the reproducers in symtab/23010.
ce65b8
The DIE tree used here is typical of compilations with LTO, where an
ce65b8
artificial parent DIE of language C99 imports DIEs of other languages.
ce65b8
ce65b8
gdb/testsuite/ChangeLog:
ce65b8
ce65b8
	PR gdb/23712
ce65b8
	PR symtab/23010
ce65b8
	* gdb.dwarf2/multidictionary.exp: New file.
ce65b8
ce65b8
diff --git a/gdb/testsuite/gdb.dwarf2/multidictionary.exp b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
ce65b8
new file mode 100644
ce65b8
--- /dev/null
ce65b8
+++ b/gdb/testsuite/gdb.dwarf2/multidictionary.exp
ce65b8
@@ -0,0 +1,157 @@
ce65b8
+# Copyright 2019 Free Software Foundation, Inc.
ce65b8
+
ce65b8
+# This program is free software; you can redistribute it and/or modify
ce65b8
+# it under the terms of the GNU General Public License as published by
ce65b8
+# the Free Software Foundation; either version 3 of the License, or
ce65b8
+# (at your option) any later version.
ce65b8
+#
ce65b8
+# This program is distributed in the hope that it will be useful,
ce65b8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ce65b8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ce65b8
+# GNU General Public License for more details.
ce65b8
+#
ce65b8
+# You should have received a copy of the GNU General Public License
ce65b8
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
ce65b8
+
ce65b8
+# A test of multi-language dictionaries, a solution to symtab/23010 et al.
ce65b8
+
ce65b8
+load_lib dwarf.exp
ce65b8
+
ce65b8
+# This test can only be run on targets which support DWARF.
ce65b8
+if {![dwarf2_support]} {
ce65b8
+    return 0
ce65b8
+}
ce65b8
+
ce65b8
+standard_testfile main.c .S
ce65b8
+
ce65b8
+# Create the DWARF.  This is derived from the reproducer in the bug
ce65b8
+# mentioned above.  This DIE tree is typical of compilations wtih
ce65b8
+# LTO enabled.
ce65b8
+
ce65b8
+set asm_file [standard_output_file $srcfile2]
ce65b8
+Dwarf::assemble $asm_file {
ce65b8
+    declare_labels D45d9 D5079 D5080 D50a9 D50af D5ab2 D5ac2 D5ace D5acf
ce65b8
+    declare_labels D2135f D2216a D22171 D226c4 D226ca D244ca \
ce65b8
+	D245da D245e6
ce65b8
+    declare_labels D41c21 D42025 D42045 D42038 D42045 D420b5
ce65b8
+
ce65b8
+    cu {} {
ce65b8
+	D45d9: compile_unit {
ce65b8
+	    {language @DW_LANG_C_plus_plus}
ce65b8
+	    {name "SerialPortUtils.cpp"}
ce65b8
+	} {
ce65b8
+	    D5079: base_type {
ce65b8
+		{byte_size 1 sdata}
ce65b8
+		{encoding @DW_ATE_unsigned}
ce65b8
+		{name "char"}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D5080: const_type {
ce65b8
+		{type :$D5079}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D50a9: pointer_type {
ce65b8
+		{byte_size 4 sdata}
ce65b8
+		{type :$D5080}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D50af: const_type {
ce65b8
+		{type :$D50a9}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D5ab2: subprogram {
ce65b8
+		{external 1 flag}
ce65b8
+		{linkage_name "_Z18SerialSyncWriteStrPKc"}
ce65b8
+	    } {
ce65b8
+		D5ac2: formal_parameter {
ce65b8
+		    {name "msg"}
ce65b8
+		    {type :$D50af}
ce65b8
+		}
ce65b8
+		D5ace: lexical_block {} {
ce65b8
+		    D5acf: DW_TAG_variable {
ce65b8
+			{name "p"}
ce65b8
+			{type :$D50a9}
ce65b8
+		    }
ce65b8
+		}
ce65b8
+	    }
ce65b8
+	}
ce65b8
+    }
ce65b8
+
ce65b8
+    cu {} {
ce65b8
+	D2135f: compile_unit {
ce65b8
+	    {language @DW_LANG_C_plus_plus}
ce65b8
+	    {name "Main.cpp"}
ce65b8
+	} {
ce65b8
+	    D2216a: base_type {
ce65b8
+		{byte_size 1 sdata}
ce65b8
+		{encoding @DW_ATE_unsigned_char}
ce65b8
+		{name "char"}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D22171: const_type {
ce65b8
+		{type :$D2216a}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D226c4: pointer_type {
ce65b8
+		{byte_size 4 sdata}
ce65b8
+		{type :$D22171}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D226ca: const_type {
ce65b8
+		{type :$D226c4}
ce65b8
+	    }
ce65b8
+
ce65b8
+	    D245da: subprogram {
ce65b8
+		{name "PrintPanicMsg"}
ce65b8
+	    } {
ce65b8
+		D245e6: formal_parameter {
ce65b8
+		    {name "msg"}
ce65b8
+		    {type :$D226ca}
ce65b8
+		}
ce65b8
+	    }
ce65b8
+	}
ce65b8
+    }
ce65b8
+
ce65b8
+    cu {} {
ce65b8
+       D41c21: compile_unit {
ce65b8
+           {language @DW_LANG_C99}
ce65b8
+           {name "<artificial>"}
ce65b8
+       } {
ce65b8
+           D42025: subprogram {
ce65b8
+               {abstract_origin %$D245da}
ce65b8
+               {low_pc 0x80b60 addr}
ce65b8
+               {high_pc 0x6c data4}
ce65b8
+           } {
ce65b8
+	       D42038: formal_parameter {
ce65b8
+		   {abstract_origin %$D245e6}
ce65b8
+	       }
ce65b8
+
ce65b8
+	       D42045: inlined_subroutine {
ce65b8
+                   {abstract_origin %$D5ab2}
ce65b8
+                   {low_pc 0x8060 addr}
ce65b8
+                   {high_pc 0xc data4}
ce65b8
+               } {
ce65b8
+                   D420b5: formal_parameter {
ce65b8
+                       {abstract_origin %$D5ac2}
ce65b8
+                   }
ce65b8
+               }
ce65b8
+           }
ce65b8
+       }
ce65b8
+    }
ce65b8
+}
ce65b8
+
ce65b8
+# Build the test executable.
ce65b8
+if {[build_executable $testfile.exp $testfile [list $asm_file $srcfile] {}] \
ce65b8
+	== -1} {
ce65b8
+    return -1
ce65b8
+}
ce65b8
+
ce65b8
+# We force the DIEs above to be read in via "-readnow".
ce65b8
+gdb_spawn_with_cmdline_opts "-readnow"
ce65b8
+gdb_load $binfile
ce65b8
+
ce65b8
+# All we need to do is check whether GDB is alive.  Without
ce65b8
+# multidictionaries, it will either crash, assert, or throw an
ce65b8
+# internal_error.
ce65b8
+gdb_test "p 1" "= 1" "GDB is alive"
ce65b8
+