blarsen / rpms / gdb

Forked from rpms/gdb 2 years ago
Clone
803b8bd
2006-12-30  Jan Kratochvil  <jan.kratochvil@redhat.com>
803b8bd
803b8bd
	* gdb.arch/i386-gnu-cfi.exp, gdb.arch/i386-gnu-cfi.c,
803b8bd
	gdb.arch/i386-gnu-cfi-asm.S: New files.
803b8bd
803b8bd
803b8bd
Index: ./gdb/testsuite/gdb.arch/i386-gnu-cfi-asm.S
803b8bd
===================================================================
803b8bd
RCS file: ./gdb/testsuite/gdb.arch/i386-gnu-cfi-asm.S
803b8bd
diff -N ./gdb/testsuite/gdb.arch/i386-gnu-cfi-asm.S
803b8bd
--- /dev/null	1 Jan 1970 00:00:00 -0000
803b8bd
+++ ./gdb/testsuite/gdb.arch/i386-gnu-cfi-asm.S	30 Dec 2006 18:25:02 -0000
803b8bd
@@ -0,0 +1,357 @@
803b8bd
+/* Copyright 2006 Free Software Foundation, Inc.
803b8bd
+ *
803b8bd
+ * This program is free software; you can redistribute it and/or modify
803b8bd
+ * it under the terms of the GNU General Public License as published by
803b8bd
+ * the Free Software Foundation; either version 2 of the License, or
803b8bd
+ * (at your option) any later version.
803b8bd
+ *
803b8bd
+ * This program is distributed in the hope that it will be useful,
803b8bd
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
803b8bd
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
803b8bd
+ * GNU General Public License for more details.
803b8bd
+ *
803b8bd
+ * You should have received a copy of the GNU General Public License
803b8bd
+ * along with this program; if not, write to the Free Software
803b8bd
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
803b8bd
+ *
803b8bd
+ * Please email any bugs, comments, and/or additions to this file to:
803b8bd
+ * bug-gdb@gnu.org
803b8bd
+ *
803b8bd
+ * This file is part of the gdb testsuite.
803b8bd
+ *
803b8bd
+ * It was generated using
803b8bd
+ * "gcc -g -O9 -S -o gate.s gate.c -fasynchronous-unwind-tables",
803b8bd
+ * using the following source file:
803b8bd
+ *
803b8bd
+ *
803b8bd
+ *	void *gate (void *(*gate) (void *data), void *data)
803b8bd
+ *	{
803b8bd
+ *	  return 1 + (*gate) (data);
803b8bd
+ *	}
803b8bd
+ *
803b8bd
+ * Changes are marked as `CHANGE' below.
803b8bd
+ */
803b8bd
+
803b8bd
+	.file	"gate.c"
803b8bd
+	.section	.debug_abbrev,"",@progbits
803b8bd
+.Ldebug_abbrev0:
803b8bd
+	.section	.debug_info,"",@progbits
803b8bd
+.Ldebug_info0:
803b8bd
+	.section	.debug_line,"",@progbits
803b8bd
+.Ldebug_line0:
803b8bd
+	.text
803b8bd
+.Ltext0:
803b8bd
+	.p2align 4,,15
803b8bd
+.globl gate
803b8bd
+	.type	gate, @function
803b8bd
+gate:
803b8bd
+.LFB2:
803b8bd
+	.file 1 "gate.c"
803b8bd
+	.loc 1 2 0
803b8bd
+.LVL0:
803b8bd
+	pushl	%ebp
803b8bd
+.LCFI0:
803b8bd
+	movl	%esp, %ebp
803b8bd
+.LCFI1:
803b8bd
+	subl	$8, %esp
803b8bd
+.LCFI2:
803b8bd
+	.loc 1 3 0
803b8bd
+	movl	12(%ebp), %eax
803b8bd
+	movl	%eax, (%esp)
803b8bd
+	call	*8(%ebp)
803b8bd
+	.loc 1 4 0
803b8bd
+	leave
803b8bd
+	.loc 1 3 0
803b8bd
+	addl	$1, %eax
803b8bd
+	.loc 1 4 0
803b8bd
+	ret
803b8bd
+.LFE2:
803b8bd
+	.size	gate, .-gate
803b8bd
+	.section	.debug_frame,"",@progbits
803b8bd
+.Lframe0:
803b8bd
+	.long	.LECIE0-.LSCIE0
803b8bd
+.LSCIE0:
803b8bd
+	.long	0xffffffff
803b8bd
+	.byte	0x1
803b8bd
+	.string	""
803b8bd
+	.uleb128 0x1
803b8bd
+	.sleb128 -4
803b8bd
+	.byte	0x8
803b8bd
+	.byte	0xc
803b8bd
+	.uleb128 0x4
803b8bd
+	.uleb128 0x4
803b8bd
+	.byte	0x88
803b8bd
+	.uleb128 0x1
803b8bd
+	.align 4
803b8bd
+.LECIE0:
803b8bd
+.LSFDE0:
803b8bd
+	.long	.LEFDE0-.LASFDE0
803b8bd
+.LASFDE0:
803b8bd
+	.long	.Lframe0
803b8bd
+	.long	.LFB2
803b8bd
+	.long	.LFE2-.LFB2
803b8bd
+	.byte	0x4
803b8bd
+	.long	.LCFI0-.LFB2
803b8bd
+	.byte	0xe
803b8bd
+	.uleb128 0x8
803b8bd
+	.byte	0x85
803b8bd
+	.uleb128 0x2
803b8bd
+
803b8bd
+	/* CHANGE */
803b8bd
+	.byte	0x2f
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x0
803b8bd
+	/* CHANGE */
803b8bd
+
803b8bd
+	.byte	0x4
803b8bd
+	.long	.LCFI1-.LCFI0
803b8bd
+	.byte	0xd
803b8bd
+	.uleb128 0x5
803b8bd
+	.align 4
803b8bd
+.LEFDE0:
803b8bd
+	.section	.eh_frame,"a",@progbits
803b8bd
+.Lframe1:
803b8bd
+	.long	.LECIE1-.LSCIE1
803b8bd
+.LSCIE1:
803b8bd
+	.long	0x0
803b8bd
+	.byte	0x1
803b8bd
+	.string	""
803b8bd
+	.uleb128 0x1
803b8bd
+	.sleb128 -4
803b8bd
+	.byte	0x8
803b8bd
+	.byte	0xc
803b8bd
+	.uleb128 0x4
803b8bd
+	.uleb128 0x4
803b8bd
+	.byte	0x88
803b8bd
+	.uleb128 0x1
803b8bd
+	.align 4
803b8bd
+.LECIE1:
803b8bd
+.LSFDE1:
803b8bd
+	.long	.LEFDE1-.LASFDE1
803b8bd
+.LASFDE1:
803b8bd
+	.long	.LASFDE1-.Lframe1
803b8bd
+	.long	.LFB2
803b8bd
+	.long	.LFE2-.LFB2
803b8bd
+	.byte	0x4
803b8bd
+	.long	.LCFI0-.LFB2
803b8bd
+	.byte	0xe
803b8bd
+	.uleb128 0x8
803b8bd
+	.byte	0x85
803b8bd
+	.uleb128 0x2
803b8bd
+
803b8bd
+	/* CHANGE */
803b8bd
+	.byte	0x2f
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x0
803b8bd
+	/* CHANGE */
803b8bd
+
803b8bd
+	.byte	0x4
803b8bd
+	.long	.LCFI1-.LCFI0
803b8bd
+	.byte	0xd
803b8bd
+	.uleb128 0x5
803b8bd
+	.align 4
803b8bd
+.LEFDE1:
803b8bd
+	.text
803b8bd
+.Letext0:
803b8bd
+	.section	.debug_loc,"",@progbits
803b8bd
+.Ldebug_loc0:
803b8bd
+.LLST0:
803b8bd
+	.long	.LFB2-.Ltext0
803b8bd
+	.long	.LCFI0-.Ltext0
803b8bd
+	.value	0x2
803b8bd
+	.byte	0x74
803b8bd
+	.sleb128 4
803b8bd
+	.long	.LCFI0-.Ltext0
803b8bd
+	.long	.LCFI1-.Ltext0
803b8bd
+	.value	0x2
803b8bd
+	.byte	0x74
803b8bd
+	.sleb128 8
803b8bd
+	.long	.LCFI1-.Ltext0
803b8bd
+	.long	.LFE2-.Ltext0
803b8bd
+	.value	0x2
803b8bd
+	.byte	0x75
803b8bd
+	.sleb128 8
803b8bd
+	.long	0x0
803b8bd
+	.long	0x0
803b8bd
+	.section	.debug_info
803b8bd
+	.long	0x74
803b8bd
+	.value	0x2
803b8bd
+	.long	.Ldebug_abbrev0
803b8bd
+	.byte	0x4
803b8bd
+	.uleb128 0x1
803b8bd
+	.long	.Ldebug_line0
803b8bd
+	.long	.Letext0
803b8bd
+	.long	.Ltext0
803b8bd
+	.long	.LASF2
803b8bd
+	.byte	0x1
803b8bd
+	.long	.LASF3
803b8bd
+	.long	.LASF4
803b8bd
+	.uleb128 0x2
803b8bd
+	.long	0x5f
803b8bd
+	.byte	0x1
803b8bd
+	.long	.LASF0
803b8bd
+	.byte	0x1
803b8bd
+	.byte	0x2
803b8bd
+	.byte	0x1
803b8bd
+	.long	0x5f
803b8bd
+	.long	.LFB2
803b8bd
+	.long	.LFE2
803b8bd
+	.long	.LLST0
803b8bd
+	.uleb128 0x3
803b8bd
+	.long	.LASF0
803b8bd
+	.byte	0x1
803b8bd
+	.byte	0x1
803b8bd
+	.long	0x71
803b8bd
+	.byte	0x2
803b8bd
+	.byte	0x91
803b8bd
+	.sleb128 0
803b8bd
+	.uleb128 0x3
803b8bd
+	.long	.LASF1
803b8bd
+	.byte	0x1
803b8bd
+	.byte	0x1
803b8bd
+	.long	0x5f
803b8bd
+	.byte	0x2
803b8bd
+	.byte	0x91
803b8bd
+	.sleb128 4
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x4
803b8bd
+	.byte	0x4
803b8bd
+	.uleb128 0x5
803b8bd
+	.long	0x71
803b8bd
+	.byte	0x1
803b8bd
+	.long	0x5f
803b8bd
+	.uleb128 0x6
803b8bd
+	.long	0x5f
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x7
803b8bd
+	.byte	0x4
803b8bd
+	.long	0x61
803b8bd
+	.byte	0x0
803b8bd
+	.section	.debug_abbrev
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x11
803b8bd
+	.byte	0x1
803b8bd
+	.uleb128 0x10
803b8bd
+	.uleb128 0x6
803b8bd
+	.uleb128 0x12
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x11
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x25
803b8bd
+	.uleb128 0xe
803b8bd
+	.uleb128 0x13
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x3
803b8bd
+	.uleb128 0xe
803b8bd
+	.uleb128 0x1b
803b8bd
+	.uleb128 0xe
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x2
803b8bd
+	.uleb128 0x2e
803b8bd
+	.byte	0x1
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x13
803b8bd
+	.uleb128 0x3f
803b8bd
+	.uleb128 0xc
803b8bd
+	.uleb128 0x3
803b8bd
+	.uleb128 0xe
803b8bd
+	.uleb128 0x3a
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x3b
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x27
803b8bd
+	.uleb128 0xc
803b8bd
+	.uleb128 0x49
803b8bd
+	.uleb128 0x13
803b8bd
+	.uleb128 0x11
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x12
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x40
803b8bd
+	.uleb128 0x6
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x3
803b8bd
+	.uleb128 0x5
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x3
803b8bd
+	.uleb128 0xe
803b8bd
+	.uleb128 0x3a
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x3b
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x49
803b8bd
+	.uleb128 0x13
803b8bd
+	.uleb128 0x2
803b8bd
+	.uleb128 0xa
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x4
803b8bd
+	.uleb128 0xf
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0xb
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x5
803b8bd
+	.uleb128 0x15
803b8bd
+	.byte	0x1
803b8bd
+	.uleb128 0x1
803b8bd
+	.uleb128 0x13
803b8bd
+	.uleb128 0x27
803b8bd
+	.uleb128 0xc
803b8bd
+	.uleb128 0x49
803b8bd
+	.uleb128 0x13
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x6
803b8bd
+	.uleb128 0x5
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x49
803b8bd
+	.uleb128 0x13
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0x7
803b8bd
+	.uleb128 0xf
803b8bd
+	.byte	0x0
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0xb
803b8bd
+	.uleb128 0x49
803b8bd
+	.uleb128 0x13
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.byte	0x0
803b8bd
+	.section	.debug_pubnames,"",@progbits
803b8bd
+	.long	0x17
803b8bd
+	.value	0x2
803b8bd
+	.long	.Ldebug_info0
803b8bd
+	.long	0x78
803b8bd
+	.long	0x25
803b8bd
+	.string	"gate"
803b8bd
+	.long	0x0
803b8bd
+	.section	.debug_aranges,"",@progbits
803b8bd
+	.long	0x1c
803b8bd
+	.value	0x2
803b8bd
+	.long	.Ldebug_info0
803b8bd
+	.byte	0x4
803b8bd
+	.byte	0x0
803b8bd
+	.value	0x0
803b8bd
+	.value	0x0
803b8bd
+	.long	.Ltext0
803b8bd
+	.long	.Letext0-.Ltext0
803b8bd
+	.long	0x0
803b8bd
+	.long	0x0
803b8bd
+	.section	.debug_str,"MS",@progbits,1
803b8bd
+.LASF1:
803b8bd
+	.string	"data"
803b8bd
+.LASF0:
803b8bd
+	.string	"gate"
803b8bd
+.LASF3:
803b8bd
+	.string	"gate.c"
803b8bd
+.LASF4:
803b8bd
+	.string	"/home/jkratoch/redhat/bz165025"
803b8bd
+.LASF2:
803b8bd
+	.string	"GNU C 4.1.1 20061213 (Red Hat 4.1.1-46)"
803b8bd
+	.ident	"GCC: (GNU) 4.1.1 20061213 (Red Hat 4.1.1-46)"
803b8bd
+	.section	.note.GNU-stack,"",@progbits
803b8bd
Index: ./gdb/testsuite/gdb.arch/i386-gnu-cfi.c
803b8bd
===================================================================
803b8bd
RCS file: ./gdb/testsuite/gdb.arch/i386-gnu-cfi.c
803b8bd
diff -N ./gdb/testsuite/gdb.arch/i386-gnu-cfi.c
803b8bd
--- /dev/null	1 Jan 1970 00:00:00 -0000
803b8bd
+++ ./gdb/testsuite/gdb.arch/i386-gnu-cfi.c	30 Dec 2006 18:25:02 -0000
803b8bd
@@ -0,0 +1,31 @@
803b8bd
+/* Unwinding of DW_CFA_GNU_negative_offset_extended test program.
803b8bd
+
803b8bd
+   Copyright 2006, Free Software Foundation, Inc.
803b8bd
+
803b8bd
+   This file is part of GDB.
803b8bd
+
803b8bd
+   This program is free software; you can redistribute it and/or modify
803b8bd
+   it under the terms of the GNU General Public License as published by
803b8bd
+   the Free Software Foundation; either version 2 of the License, or
803b8bd
+   (at your option) any later version.
803b8bd
+   
803b8bd
+   This program is distributed in the hope that it will be useful,
803b8bd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
803b8bd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
803b8bd
+   GNU General Public License for more details.
803b8bd
+   
803b8bd
+   You should have received a copy of the GNU General Public License
803b8bd
+   along with this program; if not, write to the Free Software
803b8bd
+   Foundation, Inc., 59 Temple Place - Suite 330,
803b8bd
+   Boston, MA 02111-1307, USA.  */
803b8bd
+
803b8bd
+#include <stdlib.h>
803b8bd
+
803b8bd
+/* i386-gnu-cfi-asm.S:  */
803b8bd
+extern void *gate (void *(*gate) (void *data), void *data);
803b8bd
+
803b8bd
+int main (void)
803b8bd
+{
803b8bd
+  gate ((void *(*) (void *data)) abort, NULL);
803b8bd
+  return 0;
803b8bd
+}
803b8bd
Index: ./gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
803b8bd
===================================================================
803b8bd
RCS file: ./gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
803b8bd
diff -N ./gdb/testsuite/gdb.arch/i386-gnu-cfi.exp
803b8bd
--- /dev/null	1 Jan 1970 00:00:00 -0000
803b8bd
+++ ./gdb/testsuite/gdb.arch/i386-gnu-cfi.exp	30 Dec 2006 18:25:02 -0000
803b8bd
@@ -0,0 +1,94 @@
803b8bd
+# Copyright 2006 Free Software Foundation, Inc.
803b8bd
+
803b8bd
+# This program is free software; you can redistribute it and/or modify
803b8bd
+# it under the terms of the GNU General Public License as published by
803b8bd
+# the Free Software Foundation; either version 2 of the License, or
803b8bd
+# (at your option) any later version.
803b8bd
+#
803b8bd
+# This program is distributed in the hope that it will be useful,
803b8bd
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
803b8bd
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
803b8bd
+# GNU General Public License for more details.
803b8bd
+#
803b8bd
+# You should have received a copy of the GNU General Public License
803b8bd
+# along with this program; if not, write to the Free Software
803b8bd
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
803b8bd
+
803b8bd
+# Please email any bugs, comments, and/or additions to this file to:
803b8bd
+# bug-gdb@gnu.org
803b8bd
+
803b8bd
+# This file is part of the gdb testsuite.
803b8bd
+
803b8bd
+# Unwinding of DW_CFA_GNU_negative_offset_extended test program.
803b8bd
+
803b8bd
+if $tracelevel {
803b8bd
+    strace $tracelevel
803b8bd
+}
803b8bd
+
803b8bd
+# Test i386 unwinder.
803b8bd
+
803b8bd
+set prms_id 0
803b8bd
+set bug_id 0
803b8bd
+
803b8bd
+if ![istarget "i?86-*-*"] then {
803b8bd
+    verbose "Skipping i386 unwinder tests."
803b8bd
+    return
803b8bd
+}
803b8bd
+
803b8bd
+set testfile "i386-gnu-cfi"
803b8bd
+set srcfilec ${testfile}.c
803b8bd
+set srcfileasm ${testfile}-asm.S
803b8bd
+set binfile ${objdir}/${subdir}/${testfile}
803b8bd
+
803b8bd
+# some targets have leading underscores on assembly symbols.
803b8bd
+# TODO: detect this automatically
803b8bd
+set additional_flags ""
803b8bd
+if [istarget "i?86-*-cygwin*"] then {
803b8bd
+  set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
803b8bd
+}
803b8bd
+
803b8bd
+if { [gdb_compile "${srcdir}/${subdir}/${srcfilec} ${srcdir}/${subdir}/${srcfileasm}" "${binfile}" executable [list debug $additional_flags]] != "" } {
803b8bd
+    untested i386-gnu-cfi.exp
803b8bd
+    return -1
803b8bd
+}
803b8bd
+
803b8bd
+# Get things started.
803b8bd
+
803b8bd
+gdb_exit
803b8bd
+gdb_start
803b8bd
+gdb_reinitialize_dir $srcdir/$subdir
803b8bd
+gdb_load ${binfile}
803b8bd
+
803b8bd
+# We should stop in abort(3).
803b8bd
+
803b8bd
+gdb_test "run" \
803b8bd
+         "Program received signal SIGABRT,.*" \
803b8bd
+         "run"
803b8bd
+
803b8bd
+# Backtrace would crash before.
803b8bd
+
803b8bd
+gdb_test "bt" \
803b8bd
+         "main \\(\\) at .*${testfile}.c.*" \
803b8bd
+         "backtrace"
803b8bd
+
803b8bd
+# Check we see the inserted `DW_CFA_GNU_negative_offset_extended' CFI.
803b8bd
+# We see there the original CFI-stored filename `gate.c'.
803b8bd
+
803b8bd
+gdb_test "up 3" \
803b8bd
+         "gate \\(\[^()\]*\\) at .*gate.c.*" \
803b8bd
+         "shift up to the modified frame"
803b8bd
+
803b8bd
+send_gdb "info frame\n";
803b8bd
+gdb_expect {
803b8bd
+    -re "Stack level 3, frame at (0x\[0-9a-f\]+):.*Saved registers:.* ecx at (0x\[0-9a-f\]+),.*" {
803b8bd
+	pass "Value of the CFI inserted register"
803b8bd
+	if { [string compare $expect_out(1,string) $expect_out(2,string)] } then {
803b8bd
+	    fail "Value of the CFI inserted register"
803b8bd
+	} else {
803b8bd
+	    pass "Value of the CFI inserted register"
803b8bd
+	}
803b8bd
+    }
803b8bd
+    default {
803b8bd
+	fail "Existence of the CFI inserted register"
803b8bd
+    }
803b8bd
+}