Blame SOURCES/gdb-test-dw2-aranges.patch

7d6eda
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
7d6eda
From: Fedora GDB patches <invalid@email.com>
7d6eda
Date: Fri, 27 Oct 2017 21:07:50 +0200
7d6eda
Subject: gdb-test-dw2-aranges.patch
7d6eda
7d6eda
;; [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp.
7d6eda
;;=fedoratest
7d6eda
7d6eda
[archer-tromey-delayed-symfile]
7d6eda
7d6eda
commit 77fa7778a37b0d28a7e4e5235f074a10ecf1815d
7d6eda
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
7d6eda
Date:   Sat Aug 15 15:05:54 2009 +0200
7d6eda
7d6eda
    Test for "handle incorrect aranges".
7d6eda
7d6eda
    readelf:
7d6eda
    Contents of the .debug_aranges section:
7d6eda
7d6eda
      Length:                   8
7d6eda
      Version:                  2
7d6eda
      Offset into .debug_info:  0x0
7d6eda
      Pointer Size:             0
7d6eda
      Segment Size:             0
7d6eda
7d6eda
        Address    Length
7d6eda
    Floating point exception
7d6eda
7d6eda
    	* gdb.dwarf2/dw2-aranges.exp, gdb.dwarf2/dw2-aranges.S: New files.
7d6eda
7d6eda
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
7d6eda
new file mode 100644
7d6eda
--- /dev/null
7d6eda
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
7d6eda
@@ -0,0 +1,140 @@
7d6eda
+/* This testcase is part of GDB, the GNU debugger.
7d6eda
+
7d6eda
+   Copyright 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
7d6eda
+
7d6eda
+   This program is free software; you can redistribute it and/or modify
7d6eda
+   it under the terms of the GNU General Public License as published by
7d6eda
+   the Free Software Foundation; either version 3 of the License, or
7d6eda
+   (at your option) any later version.
7d6eda
+
7d6eda
+   This program is distributed in the hope that it will be useful,
7d6eda
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6eda
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d6eda
+   GNU General Public License for more details.
7d6eda
+
7d6eda
+   You should have received a copy of the GNU General Public License
7d6eda
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
7d6eda
+
7d6eda
+/* Test .debug_aranges containing zero address_size.  */
7d6eda
+
7d6eda
+/* Dummy function to provide debug information for.  */
7d6eda
+
7d6eda
+	.text
7d6eda
+.Lbegin_text1:
7d6eda
+	.globl main
7d6eda
+	.type main, %function
7d6eda
+main:
7d6eda
+.Lbegin_main:
7d6eda
+	.int 0
7d6eda
+.Lend_main:
7d6eda
+	.size main, .-main
7d6eda
+.Lend_text1:
7d6eda
+
7d6eda
+/* Debug information */
7d6eda
+
7d6eda
+	.section .debug_info
7d6eda
+.Lcu1_begin:
7d6eda
+	/* CU header */
7d6eda
+	.4byte	.Lcu1_end - .Lcu1_start		/* Length of Compilation Unit */
7d6eda
+.Lcu1_start:
7d6eda
+	.2byte	2				/* DWARF Version */
7d6eda
+	.4byte	.Labbrev1_begin			/* Offset into abbrev section */
7d6eda
+	.byte	4				/* Pointer size */
7d6eda
+
7d6eda
+	/* CU die */
7d6eda
+	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
7d6eda
+	.4byte	.Lend_text1			/* DW_AT_high_pc */
7d6eda
+	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
7d6eda
+	.ascii	"file1.txt\0"			/* DW_AT_name */
7d6eda
+	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
7d6eda
+	.byte	1				/* DW_AT_language (C) */
7d6eda
+
7d6eda
+	/* main */
7d6eda
+	.uleb128	2			/* Abbrev: DW_TAG_subprogram */
7d6eda
+	.byte		1			/* DW_AT_external */
7d6eda
+	.byte		1			/* DW_AT_decl_file */
7d6eda
+	.byte		2			/* DW_AT_decl_line */
7d6eda
+	.ascii		"main\0"		/* DW_AT_name */
7d6eda
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
7d6eda
+	.4byte		.Lbegin_main	/* DW_AT_low_pc */
7d6eda
+	.4byte		.Lend_main		/* DW_AT_high_pc */
7d6eda
+	.byte		1			/* DW_AT_frame_base: length */
7d6eda
+	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
7d6eda
+
7d6eda
+.Ltype_int:
7d6eda
+	.uleb128	3			/* Abbrev: DW_TAG_base_type */
7d6eda
+	.ascii		"int\0"			/* DW_AT_name */
7d6eda
+	.byte		4			/* DW_AT_byte_size */
7d6eda
+	.byte		5			/* DW_AT_encoding */
7d6eda
+
7d6eda
+	.byte		0			/* End of children of CU */
7d6eda
+
7d6eda
+.Lcu1_end:
7d6eda
+
7d6eda
+/* Abbrev table */
7d6eda
+	.section .debug_abbrev
7d6eda
+.Labbrev1_begin:
7d6eda
+	.uleb128	1			/* Abbrev code */
7d6eda
+	.uleb128	0x11			/* DW_TAG_compile_unit */
7d6eda
+	.byte		1			/* has_children */
7d6eda
+	.uleb128	0x12			/* DW_AT_high_pc */
7d6eda
+	.uleb128	0x1			/* DW_FORM_addr */
7d6eda
+	.uleb128	0x11			/* DW_AT_low_pc */
7d6eda
+	.uleb128	0x1			/* DW_FORM_addr */
7d6eda
+	.uleb128	0x3			/* DW_AT_name */
7d6eda
+	.uleb128	0x8			/* DW_FORM_string */
7d6eda
+	.uleb128	0x25			/* DW_AT_producer */
7d6eda
+	.uleb128	0x8			/* DW_FORM_string */
7d6eda
+	.uleb128	0x13			/* DW_AT_language */
7d6eda
+	.uleb128	0xb			/* DW_FORM_data1 */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+
7d6eda
+	.uleb128	2			/* Abbrev code */
7d6eda
+	.uleb128	0x2e			/* DW_TAG_subprogram */
7d6eda
+	.byte		0			/* has_children */
7d6eda
+	.uleb128	0x3f			/* DW_AT_external */
7d6eda
+	.uleb128	0xc			/* DW_FORM_flag */
7d6eda
+	.uleb128	0x3a			/* DW_AT_decl_file */
7d6eda
+	.uleb128	0xb			/* DW_FORM_data1 */
7d6eda
+	.uleb128	0x3b			/* DW_AT_decl_line */
7d6eda
+	.uleb128	0xb			/* DW_FORM_data1 */
7d6eda
+	.uleb128	0x3			/* DW_AT_name */
7d6eda
+	.uleb128	0x8			/* DW_FORM_string */
7d6eda
+	.uleb128	0x49			/* DW_AT_type */
7d6eda
+	.uleb128	0x13			/* DW_FORM_ref4 */
7d6eda
+	.uleb128	0x11			/* DW_AT_low_pc */
7d6eda
+	.uleb128	0x1			/* DW_FORM_addr */
7d6eda
+	.uleb128	0x12			/* DW_AT_high_pc */
7d6eda
+	.uleb128	0x1			/* DW_FORM_addr */
7d6eda
+	.uleb128	0x40			/* DW_AT_frame_base */
7d6eda
+	.uleb128	0xa			/* DW_FORM_block1 */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+
7d6eda
+	.uleb128	3			/* Abbrev code */
7d6eda
+	.uleb128	0x24			/* DW_TAG_base_type */
7d6eda
+	.byte		0			/* has_children */
7d6eda
+	.uleb128	0x3			/* DW_AT_name */
7d6eda
+	.uleb128	0x8			/* DW_FORM_string */
7d6eda
+	.uleb128	0xb			/* DW_AT_byte_size */
7d6eda
+	.uleb128	0xb			/* DW_FORM_data1 */
7d6eda
+	.uleb128	0x3e			/* DW_AT_encoding */
7d6eda
+	.uleb128	0xb			/* DW_FORM_data1 */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+	.byte		0x0			/* Terminator */
7d6eda
+
7d6eda
+/* aranges table */
7d6eda
+	.section .debug_aranges
7d6eda
+	.long	.Laranges_end - 1f
7d6eda
+1:
7d6eda
+	.2byte	2				/* aranges Version */
7d6eda
+	.4byte	.Lcu1_begin - .debug_info	/* Offset into .debug_info section */
7d6eda
+	/* The GDB crasher is this zero value.  */
7d6eda
+	.byte		0			/* aranges address_size */
7d6eda
+	.byte		0			/* aranges segment_size */
7d6eda
+
7d6eda
+.Laranges_end:
7d6eda
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
7d6eda
new file mode 100644
7d6eda
--- /dev/null
7d6eda
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
7d6eda
@@ -0,0 +1,40 @@
7d6eda
+# Copyright 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
7d6eda
+
7d6eda
+# This program is free software; you can redistribute it and/or modify
7d6eda
+# it under the terms of the GNU General Public License as published by
7d6eda
+# the Free Software Foundation; either version 3 of the License, or
7d6eda
+# (at your option) any later version.
7d6eda
+#
7d6eda
+# This program is distributed in the hope that it will be useful,
7d6eda
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
7d6eda
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7d6eda
+# GNU General Public License for more details.
7d6eda
+#
7d6eda
+# You should have received a copy of the GNU General Public License
7d6eda
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
7d6eda
+
7d6eda
+# Test .debug_aranges containing zero address_size.
7d6eda
+
7d6eda
+# This test can only be run on targets which support DWARF-2 and use gas.
7d6eda
+# For now pick a sampling of likely targets.
7d6eda
+if {![istarget *-*-linux*]
7d6eda
+    && ![istarget *-*-gnu*]
7d6eda
+    && ![istarget *-*-elf*]
7d6eda
+    && ![istarget *-*-openbsd*]
7d6eda
+    && ![istarget arm-*-eabi*]
7d6eda
+    && ![istarget powerpc-*-eabi*]} {
7d6eda
+    return 0  
7d6eda
+}
7d6eda
+
7d6eda
+set testfile "dw2-aranges"
7d6eda
+set srcfile ${testfile}.S
7d6eda
+set binfile [standard_output_file ${testfile}]
7d6eda
+
7d6eda
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } {
7d6eda
+    return -1
7d6eda
+}
7d6eda
+
7d6eda
+clean_restart $testfile
7d6eda
+
7d6eda
+# Failed gdb_load would abort the testcase execution earlier.
7d6eda
+pass "file loaded"