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

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-test-dw2-aranges.patch
4c2ad1
4c2ad1
;; [archer-tromey-delayed-symfile] New test gdb.dwarf2/dw2-aranges.exp.
4c2ad1
;;=fedoratest
4c2ad1
4c2ad1
[archer-tromey-delayed-symfile]
4c2ad1
4c2ad1
commit 77fa7778a37b0d28a7e4e5235f074a10ecf1815d
4c2ad1
Author: Jan Kratochvil <jkratoch@host1.dyn.jankratochvil.net>
4c2ad1
Date:   Sat Aug 15 15:05:54 2009 +0200
4c2ad1
4c2ad1
    Test for "handle incorrect aranges".
4c2ad1
4c2ad1
    readelf:
4c2ad1
    Contents of the .debug_aranges section:
4c2ad1
4c2ad1
      Length:                   8
4c2ad1
      Version:                  2
4c2ad1
      Offset into .debug_info:  0x0
4c2ad1
      Pointer Size:             0
4c2ad1
      Segment Size:             0
4c2ad1
4c2ad1
        Address    Length
4c2ad1
    Floating point exception
4c2ad1
4c2ad1
    	* gdb.dwarf2/dw2-aranges.exp, gdb.dwarf2/dw2-aranges.S: New files.
4c2ad1
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.S b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.S
4c2ad1
@@ -0,0 +1,140 @@
4c2ad1
+/* This testcase is part of GDB, the GNU debugger.
4c2ad1
+
4c2ad1
+   Copyright 2004, 2007, 2008, 2009 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
+/* Test .debug_aranges containing zero address_size.  */
4c2ad1
+
4c2ad1
+/* Dummy function to provide debug information for.  */
4c2ad1
+
4c2ad1
+	.text
4c2ad1
+.Lbegin_text1:
4c2ad1
+	.globl main
4c2ad1
+	.type main, %function
4c2ad1
+main:
4c2ad1
+.Lbegin_main:
4c2ad1
+	.int 0
4c2ad1
+.Lend_main:
4c2ad1
+	.size main, .-main
4c2ad1
+.Lend_text1:
4c2ad1
+
4c2ad1
+/* Debug information */
4c2ad1
+
4c2ad1
+	.section .debug_info
4c2ad1
+.Lcu1_begin:
4c2ad1
+	/* CU header */
4c2ad1
+	.4byte	.Lcu1_end - .Lcu1_start		/* Length of Compilation Unit */
4c2ad1
+.Lcu1_start:
4c2ad1
+	.2byte	2				/* DWARF Version */
4c2ad1
+	.4byte	.Labbrev1_begin			/* Offset into abbrev section */
4c2ad1
+	.byte	4				/* Pointer size */
4c2ad1
+
4c2ad1
+	/* CU die */
4c2ad1
+	.uleb128 1				/* Abbrev: DW_TAG_compile_unit */
4c2ad1
+	.4byte	.Lend_text1			/* DW_AT_high_pc */
4c2ad1
+	.4byte	.Lbegin_text1			/* DW_AT_low_pc */
4c2ad1
+	.ascii	"file1.txt\0"			/* DW_AT_name */
4c2ad1
+	.ascii	"GNU C 3.3.3\0"			/* DW_AT_producer */
4c2ad1
+	.byte	1				/* DW_AT_language (C) */
4c2ad1
+
4c2ad1
+	/* main */
4c2ad1
+	.uleb128	2			/* Abbrev: DW_TAG_subprogram */
4c2ad1
+	.byte		1			/* DW_AT_external */
4c2ad1
+	.byte		1			/* DW_AT_decl_file */
4c2ad1
+	.byte		2			/* DW_AT_decl_line */
4c2ad1
+	.ascii		"main\0"		/* DW_AT_name */
4c2ad1
+	.4byte		.Ltype_int-.Lcu1_begin	/* DW_AT_type */
4c2ad1
+	.4byte		.Lbegin_main	/* DW_AT_low_pc */
4c2ad1
+	.4byte		.Lend_main		/* DW_AT_high_pc */
4c2ad1
+	.byte		1			/* DW_AT_frame_base: length */
4c2ad1
+	.byte		0x55			/* DW_AT_frame_base: DW_OP_reg5 */
4c2ad1
+
4c2ad1
+.Ltype_int:
4c2ad1
+	.uleb128	3			/* Abbrev: DW_TAG_base_type */
4c2ad1
+	.ascii		"int\0"			/* DW_AT_name */
4c2ad1
+	.byte		4			/* DW_AT_byte_size */
4c2ad1
+	.byte		5			/* DW_AT_encoding */
4c2ad1
+
4c2ad1
+	.byte		0			/* End of children of CU */
4c2ad1
+
4c2ad1
+.Lcu1_end:
4c2ad1
+
4c2ad1
+/* Abbrev table */
4c2ad1
+	.section .debug_abbrev
4c2ad1
+.Labbrev1_begin:
4c2ad1
+	.uleb128	1			/* Abbrev code */
4c2ad1
+	.uleb128	0x11			/* DW_TAG_compile_unit */
4c2ad1
+	.byte		1			/* has_children */
4c2ad1
+	.uleb128	0x12			/* DW_AT_high_pc */
4c2ad1
+	.uleb128	0x1			/* DW_FORM_addr */
4c2ad1
+	.uleb128	0x11			/* DW_AT_low_pc */
4c2ad1
+	.uleb128	0x1			/* DW_FORM_addr */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x25			/* DW_AT_producer */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
4c2ad1
+	.uleb128	0x13			/* DW_AT_language */
4c2ad1
+	.uleb128	0xb			/* DW_FORM_data1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	2			/* Abbrev code */
4c2ad1
+	.uleb128	0x2e			/* DW_TAG_subprogram */
4c2ad1
+	.byte		0			/* has_children */
4c2ad1
+	.uleb128	0x3f			/* DW_AT_external */
4c2ad1
+	.uleb128	0xc			/* DW_FORM_flag */
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	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
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	0xa			/* DW_FORM_block1 */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.uleb128	3			/* Abbrev code */
4c2ad1
+	.uleb128	0x24			/* DW_TAG_base_type */
4c2ad1
+	.byte		0			/* has_children */
4c2ad1
+	.uleb128	0x3			/* DW_AT_name */
4c2ad1
+	.uleb128	0x8			/* DW_FORM_string */
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
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+	.byte		0x0			/* Terminator */
4c2ad1
+
4c2ad1
+/* aranges table */
4c2ad1
+	.section .debug_aranges
4c2ad1
+	.long	.Laranges_end - 1f
4c2ad1
+1:
4c2ad1
+	.2byte	2				/* aranges Version */
4c2ad1
+	.4byte	.Lcu1_begin - .debug_info	/* Offset into .debug_info section */
4c2ad1
+	/* The GDB crasher is this zero value.  */
4c2ad1
+	.byte		0			/* aranges address_size */
4c2ad1
+	.byte		0			/* aranges segment_size */
4c2ad1
+
4c2ad1
+.Laranges_end:
4c2ad1
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
4c2ad1
new file mode 100644
4c2ad1
--- /dev/null
4c2ad1
+++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
4c2ad1
@@ -0,0 +1,40 @@
4c2ad1
+# Copyright 2004, 2005, 2007, 2008, 2009 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
+# Test .debug_aranges containing zero address_size.
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
+set testfile "dw2-aranges"
4c2ad1
+set srcfile ${testfile}.S
4c2ad1
+set binfile [standard_output_file ${testfile}]
4c2ad1
+
4c2ad1
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {nodebug}] != "" } {
4c2ad1
+    return -1
4c2ad1
+}
4c2ad1
+
4c2ad1
+clean_restart $testfile
4c2ad1
+
4c2ad1
+# Failed gdb_load would abort the testcase execution earlier.
4c2ad1
+pass "file loaded"