4c2ad1
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
4c2ad1
From: Fedora GDB patches <invalid@email.com>
4c2ad1
Date: Fri, 27 Oct 2017 21:07:50 +0200
4c2ad1
Subject: gdb-bz601887-dwarf4-rh-test.patch
4c2ad1
4c2ad1
;; Backport DWARF-4 support (BZ 601887, Tom Tromey).
4c2ad1
;;=fedoratest
4c2ad1
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.S
4c2ad1
@@ -0,0 +1,167 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2010 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
+	.file	"rh-dwarf4-x86_64.c"
4c2ad1
+	.section	.debug_abbrev,"",@progbits
4c2ad1
+.Ldebug_abbrev0:
4c2ad1
+	.section	.debug_info,"",@progbits
4c2ad1
+.Ldebug_info0:
4c2ad1
+	.section	.debug_line,"",@progbits
4c2ad1
+.Ldebug_line0:
4c2ad1
+	.text
4c2ad1
+.Ltext0:
4c2ad1
+.globl main
4c2ad1
+	.type	main, @function
4c2ad1
+main:
4c2ad1
+.LFB0:
4c2ad1
+	.file 1 "gdb.dwarf2/rh-dwarf4-x86_64.c"
4c2ad1
+	# gdb.dwarf2/rh-dwarf4-x86_64.c:20
4c2ad1
+	.loc 1 20 0
4c2ad1
+	.cfi_startproc
4c2ad1
+	# basic block 2
4c2ad1
+	pushq	%rbp
4c2ad1
+	.cfi_def_cfa_offset 16
4c2ad1
+	movq	%rsp, %rbp
4c2ad1
+	.cfi_offset 6, -16
4c2ad1
+	.cfi_def_cfa_register 6
4c2ad1
+	# gdb.dwarf2/rh-dwarf4-x86_64.c:21
4c2ad1
+	.loc 1 21 0
4c2ad1
+	movl	$0, %eax
4c2ad1
+	# gdb.dwarf2/rh-dwarf4-x86_64.c:22
4c2ad1
+	.loc 1 22 0
4c2ad1
+	leave
4c2ad1
+	.cfi_def_cfa 7, 8
4c2ad1
+	ret
4c2ad1
+	.cfi_endproc
4c2ad1
+.LFE0:
4c2ad1
+	.size	main, .-main
4c2ad1
+.Letext0:
4c2ad1
+	.section	.debug_info
4c2ad1
+	.long	0x4e	# Length of Compilation Unit Info
4c2ad1
+	.value	0x4	# DWARF version number
4c2ad1
+	.long	.Ldebug_abbrev0	# Offset Into Abbrev. Section
4c2ad1
+	.byte	0x8	# Pointer Size (in bytes)
4c2ad1
+	.uleb128 0x1	# (DIE (0xb) DW_TAG_compile_unit)
4c2ad1
+	.long	.LASF0	# DW_AT_producer: "GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)"
4c2ad1
+	.byte	0x1	# DW_AT_language
4c2ad1
+	.long	.LASF1	# DW_AT_name: "gdb.dwarf2/rh-dwarf4-x86_64.c"
4c2ad1
+	.long	.LASF2	# DW_AT_comp_dir
4c2ad1
+	.quad	.Ltext0	# DW_AT_low_pc
4c2ad1
+	.quad	.Letext0	# DW_AT_high_pc
4c2ad1
+	.long	.Ldebug_line0	# DW_AT_stmt_list
4c2ad1
+	.uleb128 0x2	# (DIE (0x2d) DW_TAG_subprogram)
4c2ad1
+			# DW_AT_external
4c2ad1
+	.long	.LASF3	# DW_AT_name: "main"
4c2ad1
+	.byte	0x1	# DW_AT_decl_file (gdb.dwarf2/rh-dwarf4-x86_64.c)
4c2ad1
+	.byte	0x13	# DW_AT_decl_line
4c2ad1
+			# DW_AT_prototyped
4c2ad1
+	.long	0x4a	# DW_AT_type
4c2ad1
+	.quad	.LFB0	# DW_AT_low_pc
4c2ad1
+	.quad	.LFE0	# DW_AT_high_pc
4c2ad1
+	.uleb128 0x1	# DW_AT_frame_base
4c2ad1
+	.byte	0x9c	# DW_OP_call_frame_cfa
4c2ad1
+	.uleb128 0x3	# (DIE (0x4a) DW_TAG_base_type)
4c2ad1
+	.byte	0x4	# DW_AT_byte_size
4c2ad1
+	.byte	0x5	# DW_AT_encoding
4c2ad1
+	.ascii "int\0"	# DW_AT_name
4c2ad1
+	.byte	0x0	# end of children of DIE 0xb
4c2ad1
+	.section	.debug_abbrev
4c2ad1
+	.uleb128 0x1	# (abbrev code)
4c2ad1
+	.uleb128 0x11	# (TAG: DW_TAG_compile_unit)
4c2ad1
+	.byte	0x1	# DW_children_yes
4c2ad1
+	.uleb128 0x25	# (DW_AT_producer)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x13	# (DW_AT_language)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x1b	# (DW_AT_comp_dir)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x11	# (DW_AT_low_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x12	# (DW_AT_high_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x10	# (DW_AT_stmt_list)
4c2ad1
+	.uleb128 0x17	# (DW_FORM_sec_offset)
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x2	# (abbrev code)
4c2ad1
+	.uleb128 0x2e	# (TAG: DW_TAG_subprogram)
4c2ad1
+	.byte	0x0	# DW_children_no
4c2ad1
+	.uleb128 0x3f	# (DW_AT_external)
4c2ad1
+	.uleb128 0x19	# (DW_FORM_flag_present)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0xe	# (DW_FORM_strp)
4c2ad1
+	.uleb128 0x3a	# (DW_AT_decl_file)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3b	# (DW_AT_decl_line)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x27	# (DW_AT_prototyped)
4c2ad1
+	.uleb128 0x19	# (DW_FORM_flag_present)
4c2ad1
+	.uleb128 0x49	# (DW_AT_type)
4c2ad1
+	.uleb128 0x13	# (DW_FORM_ref4)
4c2ad1
+	.uleb128 0x11	# (DW_AT_low_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x12	# (DW_AT_high_pc)
4c2ad1
+	.uleb128 0x1	# (DW_FORM_addr)
4c2ad1
+	.uleb128 0x40	# (DW_AT_frame_base)
4c2ad1
+	.uleb128 0x18	# (DW_FORM_exprloc)
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.uleb128 0x3	# (abbrev code)
4c2ad1
+	.uleb128 0x24	# (TAG: DW_TAG_base_type)
4c2ad1
+	.byte	0x0	# DW_children_no
4c2ad1
+	.uleb128 0xb	# (DW_AT_byte_size)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3e	# (DW_AT_encoding)
4c2ad1
+	.uleb128 0xb	# (DW_FORM_data1)
4c2ad1
+	.uleb128 0x3	# (DW_AT_name)
4c2ad1
+	.uleb128 0x8	# (DW_FORM_string)
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.byte	0x0
4c2ad1
+	.section	.debug_pubnames,"",@progbits
4c2ad1
+	.long	0x17	# Length of Public Names Info
4c2ad1
+	.value	0x2	# DWARF Version
4c2ad1
+	.long	.Ldebug_info0	# Offset of Compilation Unit Info
4c2ad1
+	.long	0x52	# Compilation Unit Length
4c2ad1
+	.long	0x2d	# DIE offset
4c2ad1
+	.ascii "main\0"	# external name
4c2ad1
+	.long	0x0
4c2ad1
+	.section	.debug_aranges,"",@progbits
4c2ad1
+	.long	0x2c	# Length of Address Ranges Info
4c2ad1
+	.value	0x2	# DWARF Version
4c2ad1
+	.long	.Ldebug_info0	# Offset of Compilation Unit Info
4c2ad1
+	.byte	0x8	# Size of Address
4c2ad1
+	.byte	0x0	# Size of Segment Descriptor
4c2ad1
+	.value	0x0	# Pad to 16 byte boundary
4c2ad1
+	.value	0x0
4c2ad1
+	.quad	.Ltext0	# Address
4c2ad1
+	.quad	.Letext0-.Ltext0	# Length
4c2ad1
+	.quad	0x0
4c2ad1
+	.quad	0x0
4c2ad1
+	.section	.debug_str,"MS",@progbits,1
4c2ad1
+.LASF2:
4c2ad1
+	.string	"."
4c2ad1
+.LASF0:
4c2ad1
+	.string	"GNU C 4.4.4 20100503 (Red Hat 4.4.4-2)"
4c2ad1
+.LASF1:
4c2ad1
+	.string	"gdb.dwarf2/rh-dwarf4-x86_64.c"
4c2ad1
+.LASF3:
4c2ad1
+	.string	"main"
4c2ad1
+	.ident	"GCC: (GNU) 4.4.4 20100503 (Red Hat 4.4.4-2)"
4c2ad1
+	.section	.note.GNU-stack,"",@progbits
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.c
4c2ad1
@@ -0,0 +1,22 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2010 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
+int
4c2ad1
+main (void)
4c2ad1
+{
4c2ad1
+  return 0;
4c2ad1
+}
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/rh-dwarf4-x86_64.exp
4c2ad1
@@ -0,0 +1,42 @@
4c2ad1
+# Copyright 2010 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
+# This test can only be run on targets which support DWARF-2 and use gas.
4c2ad1
+# For now pick a sampling of likely targets.
4c2ad1
+if {![istarget *-*-linux*]
4c2ad1
+    && ![istarget *-*-gnu*]
4c2ad1
+    && ![istarget *-*-elf*]
4c2ad1
+    && ![istarget *-*-openbsd*]
4c2ad1
+    && ![istarget arm-*-eabi*]
4c2ad1
+    && ![istarget powerpc-*-eabi*]} {
4c2ad1
+    return 0  
4c2ad1
+}
4c2ad1
+
4c2ad1
+if {![istarget x86_64-*]} {
4c2ad1
+    return 0  
4c2ad1
+}
4c2ad1
+
4c2ad1
+set testfile "rh-dwarf4-x86_64"
4c2ad1
+set srcfile ${testfile}.S
4c2ad1
+set executable ${testfile}.x
4c2ad1
+set binfile [standard_output_file ${executable}]
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+clean_restart $executable
4c2ad1
+
4c2ad1
+gdb_test "ptype main" {type = int \(void\)}