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

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