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

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