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

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