This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch RFC] Re: Notes on a frame_unwind_address_in_block problem


On Mon, Jan 01, 2007 at 03:35:33PM -0500, Daniel Jacobowitz wrote:
> > Hmm, sorry yes, a test that would work on all i386 or x86-64 target
> > was what I actually meant.
> 
> I can probably do that.  I'll try this evening.

Here you go.  It requires binutils 2.17 or later; before committing it
I would have to make sure it's quiet with an older version.  I could
write it without the binutils dependency, but it's a lot bigger and
messier that way.

This testcase should be roughly OS independent, fails without the
patch, and passes with it.

-- 
Daniel Jacobowitz
CodeSourcery

2007-01-01  Daniel Jacobowitz  <dan@codesourcery.com>

	* gdb.arch/i386-signal.c, gdb.arch/i386-signal.exp: New files.

Index: testsuite/gdb.arch/i386-signal.c
===================================================================
RCS file: testsuite/gdb.arch/i386-signal.c
diff -N testsuite/gdb.arch/i386-signal.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.arch/i386-signal.c	2 Jan 2007 00:48:36 -0000
@@ -0,0 +1,55 @@
+/* Unwinder test program for signal frames.
+
+   Copyright 2007 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+void sigframe (void);
+void setup (void);
+
+void
+func (void)
+{
+}
+
+int
+main (void)
+{
+  setup ();
+}
+
+/* Create an imitation signal frame.  This will work on any x86 or
+   x86-64 target which uses a version of GAS recent enough for
+   .cfi_signal_frame (added 2006-02-27 and included in binutils 2.17).
+   The default CIE created by gas suffices to unwind from an empty
+   function.  */
+
+asm(".text\n"
+    "    .align 8\n"
+    "    .globl setup\n"
+    "setup:\n"
+    "    push $sigframe\n"
+    "    jmp func\n"
+    "\n"
+    "    .cfi_startproc\n"
+    "    .cfi_signal_frame\n"
+    "    nop\n"
+    "    .globl sigframe\n"
+    "sigframe:\n"
+    "    ret\n"
+    "    .cfi_endproc");
Index: testsuite/gdb.arch/i386-signal.exp
===================================================================
RCS file: testsuite/gdb.arch/i386-signal.exp
diff -N testsuite/gdb.arch/i386-signal.exp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gdb.arch/i386-signal.exp	2 Jan 2007 00:48:36 -0000
@@ -0,0 +1,43 @@
+# Copyright 2007 Free Software Foundation, Inc.
+
+# This file is part of the GDB testsuite.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
+
+if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
+    verbose "Skipping i386 unwinder tests."
+    return
+}
+
+set testfile "i386-signal"
+set srcfile ${testfile}.c
+set binfile ${objdir}/${subdir}/${testfile}
+
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
+	  executable { debug }] != "" } {
+    untested i386-sigframe.exp
+    return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+gdb_load ${binfile}
+
+runto func
+gdb_test "backtrace 10" \
+    "#0  ($hex in )?func.*\r\n#1  <signal handler called>\r\n#2  ($hex in)?main.*"
+
+gdb_test "finish" "Run till exit from \#0  func.*<signal handler called>"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]