Blame SOURCES/gdb-6.5-bz216711-clone-is-outermost.patch

2c2fa1
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=216711
2c2fa1
2c2fa1
FIXME: This workaround should be dropped and
2c2fa1
glibc/sysdeps/unix/sysv/linux/x86_64/clone.S should get CFI for the child
2c2fa1
instead.
2c2fa1
2c2fa1
2006-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
2c2fa1
	* gdb/amd64-linux-tdep.c (linux_clone_code): New variable.
2c2fa1
	(LINUX_CLONE_LEN): New definition.
2c2fa1
	(amd64_linux_clone_running, amd64_linux_outermost_frame): New function.
2c2fa1
	(amd64_linux_init_abi): Initialize `outermost_frame_p'.
2c2fa1
	* gdb/i386-tdep.c (i386_gdbarch_init): Likewise.
2c2fa1
	* gdb/i386-tdep.h (gdbarch_tdep): Add `outermost_frame_p' member.
2c2fa1
	* gdb/amd64-tdep.c (amd64_frame_this_id): Call `outermost_frame_p'.
2c2fa1
2c2fa1
2006-12-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
2c2fa1
	* gdb.threads/bt-clone-stop.exp, gdb.threads/bt-clone-stop.c:
2c2fa1
	New file.
2c2fa1
2c2fa1
2007-10-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
2c2fa1
2c2fa1
	Port to GDB-6.7.
2c2fa1
2c2fa1
Index: gdb-7.4.50.20120703/gdb/amd64-linux-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.4.50.20120703.orig/gdb/amd64-linux-tdep.c	2012-06-13 22:36:48.000000000 +0200
2c2fa1
+++ gdb-7.4.50.20120703/gdb/amd64-linux-tdep.c	2012-07-03 17:32:46.547563363 +0200
2c2fa1
@@ -271,6 +271,80 @@ amd64_linux_register_reggroup_p (struct
2c2fa1
 
2c2fa1
 /* Set the program counter for process PTID to PC.  */
2c2fa1
 
2c2fa1
+/* Detect the outermost frame; during unwind of
2c2fa1
+   	#5  0x000000305cec68c3 in clone () from /lib64/tls/libc.so.6
2c2fa1
+   avoid the additional bogus frame
2c2fa1
+   	#6  0x0000000000000000 in ??
2c2fa1
+   We compare if the `linux_clone_code' block is _before_ unwound PC.  */
2c2fa1
+
2c2fa1
+static const unsigned char linux_clone_code[] =
2c2fa1
+{
2c2fa1
+/* libc/sysdeps/unix/sysv/linux/x86_64/clone.S */
2c2fa1
+/* #ifdef RESET_PID */
2c2fa1
+/* ... */
2c2fa1
+/* 	mov	$SYS_ify(getpid), %eax */
2c2fa1
+/* 0xb8, 0x27, 0x00, 0x00, 0x00 */
2c2fa1
+/* OR */
2c2fa1
+/* 	mov	$SYS_ify(getpid), %rax */
2c2fa1
+/* 0x48, 0xc7, 0xc0, 0x27, 0x00, 0x00, 0x00 */
2c2fa1
+/* so just: */
2c2fa1
+  0x27, 0x00, 0x00, 0x00,
2c2fa1
+/* 	syscall */
2c2fa1
+  0x0f, 0x05,
2c2fa1
+/* 	movl	%eax, %fs:PID */
2c2fa1
+  0x64, 0x89, 0x04, 0x25, 0x94, 0x00, 0x00, 0x00,
2c2fa1
+/* 	movl	%eax, %fs:TID */
2c2fa1
+  0x64, 0x89, 0x04, 0x25, 0x90, 0x00, 0x00, 0x00,
2c2fa1
+/* #endif */
2c2fa1
+/* 	|* Set up arguments for the function call.  *| */
2c2fa1
+/* 	popq	%rax		|* Function to call.  *| */
2c2fa1
+  0x58,
2c2fa1
+/* 	popq	%rdi		|* Argument.  *| */
2c2fa1
+  0x5f,
2c2fa1
+/* 	call	*%rax$   */
2c2fa1
+  0xff, 0xd0
2c2fa1
+};
2c2fa1
+
2c2fa1
+#define LINUX_CLONE_LEN (sizeof linux_clone_code)
2c2fa1
+
2c2fa1
+static int
2c2fa1
+amd64_linux_clone_running (struct frame_info *this_frame)
2c2fa1
+{
2c2fa1
+  CORE_ADDR pc = get_frame_pc (this_frame);
2c2fa1
+  unsigned char buf[LINUX_CLONE_LEN];
2c2fa1
+
2c2fa1
+  if (!safe_frame_unwind_memory (this_frame, pc - LINUX_CLONE_LEN, buf,
2c2fa1
+				 LINUX_CLONE_LEN))
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  if (memcmp (buf, linux_clone_code, LINUX_CLONE_LEN) != 0)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  return 1;
2c2fa1
+}
2c2fa1
+
2c2fa1
+static int
2c2fa1
+amd64_linux_outermost_frame (struct frame_info *this_frame)
2c2fa1
+{
2c2fa1
+  CORE_ADDR pc = get_frame_pc (this_frame);
2c2fa1
+  const char *name;
2c2fa1
+
2c2fa1
+  find_pc_partial_function (pc, &name, NULL, NULL);
2c2fa1
+
2c2fa1
+  /* If we have NAME, we can optimize the search.
2c2fa1
+     `clone' NAME still needs to have the code checked as its name may be
2c2fa1
+     present in the user code.
2c2fa1
+     `__clone' NAME should not be present in the user code but in the initial
2c2fa1
+     parts of the `__clone' implementation the unwind still makes sense.
2c2fa1
+     More detailed unwinding decision would be too much sensitive to possible
2c2fa1
+     subtle changes in specific glibc revisions.  */
2c2fa1
+  if (name == NULL || strcmp (name, "clone") == 0
2c2fa1
+      || strcmp ("__clone", name) == 0)
2c2fa1
+    return (amd64_linux_clone_running (this_frame) != 0);
2c2fa1
+
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+
2c2fa1
 static void
2c2fa1
 amd64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc)
2c2fa1
 {
2c2fa1
@@ -1547,6 +1621,8 @@ amd64_linux_init_abi (struct gdbarch_inf
2c2fa1
 
2c2fa1
   amd64_linux_init_abi_common (info, gdbarch);
2c2fa1
 
2c2fa1
+  tdep->outermost_frame_p = amd64_linux_outermost_frame;
2c2fa1
+
2c2fa1
   /* GNU/Linux uses SVR4-style shared libraries.  */
2c2fa1
   set_solib_svr4_fetch_link_map_offsets
2c2fa1
     (gdbarch, svr4_lp64_fetch_link_map_offsets);
2c2fa1
Index: gdb-7.4.50.20120703/gdb/amd64-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.4.50.20120703.orig/gdb/amd64-tdep.c	2012-06-16 17:20:22.000000000 +0200
2c2fa1
+++ gdb-7.4.50.20120703/gdb/amd64-tdep.c	2012-07-03 17:32:12.335604415 +0200
2c2fa1
@@ -2324,6 +2324,7 @@ amd64_frame_unwind_stop_reason (struct f
2c2fa1
 {
2c2fa1
   struct amd64_frame_cache *cache =
2c2fa1
     amd64_frame_cache (this_frame, this_cache);
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
2c2fa1
 
2c2fa1
   if (!cache->base_p)
2c2fa1
     return UNWIND_UNAVAILABLE;
2c2fa1
@@ -2332,6 +2333,10 @@ amd64_frame_unwind_stop_reason (struct f
2c2fa1
   if (cache->base == 0)
2c2fa1
     return UNWIND_OUTERMOST;
2c2fa1
 
2c2fa1
+  /* Detect OS dependent outermost frames; such as `clone'.  */
2c2fa1
+  if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame))
2c2fa1
+    return UNWIND_OUTERMOST;
2c2fa1
+
2c2fa1
   return UNWIND_NO_REASON;
2c2fa1
 }
2c2fa1
 
2c2fa1
@@ -2341,6 +2346,7 @@ amd64_frame_this_id (struct frame_info *
2c2fa1
 {
2c2fa1
   struct amd64_frame_cache *cache =
2c2fa1
     amd64_frame_cache (this_frame, this_cache);
2c2fa1
+  struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
2c2fa1
 
2c2fa1
   if (!cache->base_p)
2c2fa1
     return;
2c2fa1
@@ -2349,6 +2355,10 @@ amd64_frame_this_id (struct frame_info *
2c2fa1
   if (cache->base == 0)
2c2fa1
     return;
2c2fa1
 
2c2fa1
+  /* Detect OS dependent outermost frames; such as `clone'.  */
2c2fa1
+  if (tdep->outermost_frame_p && tdep->outermost_frame_p (this_frame))
2c2fa1
+    return;
2c2fa1
+
2c2fa1
   (*this_id) = frame_id_build (cache->base + 16, cache->pc);
2c2fa1
 }
2c2fa1
 
2c2fa1
Index: gdb-7.4.50.20120703/gdb/i386-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.4.50.20120703.orig/gdb/i386-tdep.c	2012-06-18 19:31:34.000000000 +0200
2c2fa1
+++ gdb-7.4.50.20120703/gdb/i386-tdep.c	2012-07-03 17:32:12.339604409 +0200
2c2fa1
@@ -7655,6 +7655,9 @@ i386_gdbarch_init (struct gdbarch_info i
2c2fa1
 
2c2fa1
   tdep->xsave_xcr0_offset = -1;
2c2fa1
 
2c2fa1
+  /* Unwinding stops on i386 automatically.  */
2c2fa1
+  tdep->outermost_frame_p = NULL;
2c2fa1
+
2c2fa1
   tdep->record_regmap = i386_record_regmap;
2c2fa1
 
2c2fa1
   set_gdbarch_long_long_align_bit (gdbarch, 32);
2c2fa1
Index: gdb-7.4.50.20120703/gdb/i386-tdep.h
2c2fa1
===================================================================
2c2fa1
--- gdb-7.4.50.20120703.orig/gdb/i386-tdep.h	2012-06-13 22:29:15.000000000 +0200
2c2fa1
+++ gdb-7.4.50.20120703/gdb/i386-tdep.h	2012-07-03 17:32:12.340604408 +0200
2c2fa1
@@ -219,6 +219,9 @@ struct gdbarch_tdep
2c2fa1
   int (*i386_sysenter_record) (struct regcache *regcache);
2c2fa1
   /* Parse syscall args.  */
2c2fa1
   int (*i386_syscall_record) (struct regcache *regcache);
2c2fa1
+
2c2fa1
+  /* Detect OS dependent outermost frames; such as `clone'.  */
2c2fa1
+  int (*outermost_frame_p) (struct frame_info *this_frame);
2c2fa1
 };
2c2fa1
 
2c2fa1
 /* Floating-point registers.  */
2c2fa1
Index: gdb-7.4.50.20120703/gdb/ia64-tdep.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.4.50.20120703.orig/gdb/ia64-tdep.c	2012-07-03 17:30:09.000000000 +0200
2c2fa1
+++ gdb-7.4.50.20120703/gdb/ia64-tdep.c	2012-07-03 17:32:12.343604405 +0200
2c2fa1
@@ -2176,6 +2176,138 @@ static const struct frame_unwind ia64_fr
2c2fa1
   default_frame_sniffer
2c2fa1
 };
2c2fa1
 
2c2fa1
+/* Detect the outermost frame; during unwind of
2c2fa1
+   	#6  0x2000000000347100 in __clone2 () from /lib/libc.so.6.1
2c2fa1
+   avoid the additional bogus frame
2c2fa1
+   	#7  0x0000000000000000 in ?? ()  */
2c2fa1
+
2c2fa1
+static char linux_clone2_code[] =
2c2fa1
+{
2c2fa1
+/* libc/sysdeps/unix/sysv/linux/ia64/clone2.S */
2c2fa1
+  0x09, 0x00, 0x20, 0x12, 0x90, 0x11, 0x00, 0x40,
2c2fa1
+  0x28, 0x20, 0x23, 0x00, 0x00, 0x00, 0x04, 0x00,
2c2fa1
+/*         st4 [r9]=r8 */
2c2fa1
+/*         st4 [r10]=r8 */
2c2fa1
+/*         ;; */
2c2fa1
+/* #endif */
2c2fa1
+  0x02, 0x50, 0x21, 0x40, 0x18, 0x14, 0x90, 0x02,
2c2fa1
+  0x90, 0x00, 0x42, 0x00, 0x00, 0x00, 0x04, 0x00,
2c2fa1
+/* 1:      ld8 out1=[in0],8        |* Retrieve code pointer.       *| */
2c2fa1
+/*         mov out0=in4            |* Pass proper argument to fn *| */
2c2fa1
+/*         ;; */
2c2fa1
+  0x11, 0x08, 0x00, 0x40, 0x18, 0x10, 0x60, 0x50,
2c2fa1
+  0x05, 0x80, 0x03, 0x00, 0x68, 0x00, 0x80, 0x12,
2c2fa1
+/*         ld8 gp=[in0]            |* Load function gp.            *| */
2c2fa1
+/*         mov b6=out1 */
2c2fa1
+/*         br.call.dptk.many rp=b6 |* Call fn(arg) in the child    *| */
2c2fa1
+/*         ;; */
2c2fa1
+  0x10, 0x48, 0x01, 0x10, 0x00, 0x21, 0x10, 0x00,
2c2fa1
+  0xa0, 0x00, 0x42, 0x00, 0x98, 0xdf, 0xf7, 0x5b,
2c2fa1
+/*         mov out0=r8             |* Argument to _exit            *| */
2c2fa1
+/*         mov gp=loc0 */
2c2fa1
+/*         .globl HIDDEN_JUMPTARGET(_exit) */
2c2fa1
+/*         br.call.dpnt.many rp=HIDDEN_JUMPTARGET(_exit) */
2c2fa1
+/*                                 |* call _exit with result from fn.      *| */
2c2fa1
+  0x11, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
2c2fa1
+  0x00, 0x02, 0x00, 0x80, 0x00, 0x00, 0x84, 0x00
2c2fa1
+/*         ret                     |* Not reached.         *| */
2c2fa1
+};
2c2fa1
+
2c2fa1
+#define LINUX_CLONE_PRE_SLOTS 3	/* Number of slots before PC.  */
2c2fa1
+#define LINUX_CLONE_LEN (sizeof linux_clone2_code)
2c2fa1
+
2c2fa1
+static int
2c2fa1
+ia64_linux_clone2_running (struct frame_info *this_frame)
2c2fa1
+{
2c2fa1
+  CORE_ADDR pc = get_frame_pc (this_frame);
2c2fa1
+  char buf[LINUX_CLONE_LEN];
2c2fa1
+  struct minimal_symbol *minsym;
2c2fa1
+  long long instr;
2c2fa1
+
2c2fa1
+  if (!safe_frame_unwind_memory (this_frame, pc - LINUX_CLONE_PRE_SLOTS * 16,
2c2fa1
+				 buf, LINUX_CLONE_LEN))
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  if (memcmp (buf, linux_clone2_code, LINUX_CLONE_PRE_SLOTS * 16) != 0)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  /* Adjust the expected "_exit" address.  */
2c2fa1
+  minsym = lookup_minimal_symbol_text ("_exit", NULL);
2c2fa1
+  if (minsym == NULL)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  instr = slotN_contents (&linux_clone2_code[LINUX_CLONE_PRE_SLOTS * 16], 2);
2c2fa1
+  instr &= ~(((1L << 20) - 1) << 13);
2c2fa1
+  /* Address is relative to the jump instruction slot, not the next one.  */
2c2fa1
+  instr |= (((SYMBOL_VALUE_ADDRESS (minsym) - (pc & ~0xfL)) >> 4)
2c2fa1
+	    & ((1L << 20) - 1)) << 13;
2c2fa1
+  replace_slotN_contents (&linux_clone2_code[LINUX_CLONE_PRE_SLOTS * 16], instr,
2c2fa1
+			  2);
2c2fa1
+
2c2fa1
+  if (memcmp (&buf[LINUX_CLONE_PRE_SLOTS * 16],
2c2fa1
+              &linux_clone2_code[LINUX_CLONE_PRE_SLOTS * 16],
2c2fa1
+	      LINUX_CLONE_LEN - (LINUX_CLONE_PRE_SLOTS * 16)) != 0)
2c2fa1
+    return 0;
2c2fa1
+
2c2fa1
+  return 1;
2c2fa1
+}
2c2fa1
+
2c2fa1
+static int
2c2fa1
+ia64_outermost_frame (struct frame_info *this_frame)
2c2fa1
+{
2c2fa1
+  CORE_ADDR pc = get_frame_pc (this_frame);
2c2fa1
+  char *name;
2c2fa1
+
2c2fa1
+  find_pc_partial_function (pc, &name, NULL, NULL);
2c2fa1
+
2c2fa1
+  /* If we have NAME, we can optimize the search.
2c2fa1
+     `clone' NAME still needs to have the code checked as its name may be
2c2fa1
+     present in the user code.
2c2fa1
+     `__clone' NAME should not be present in the user code but in the initial
2c2fa1
+     parts of the `__clone' implementation the unwind still makes sense.
2c2fa1
+     More detailed unwinding decision would be too much sensitive to possible
2c2fa1
+     subtle changes in specific glibc revisions.  */
2c2fa1
+  if (name == NULL || strcmp (name, "clone2") == 0
2c2fa1
+      || strcmp ("__clone2", name) == 0)
2c2fa1
+    return (ia64_linux_clone2_running (this_frame) != 0);
2c2fa1
+
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+
2c2fa1
+static void
2c2fa1
+ia64_clone2_frame_this_id (struct frame_info *this_frame, void **this_cache,
2c2fa1
+			   struct frame_id *this_id)
2c2fa1
+{
2c2fa1
+  /* Leave the default outermost frame at *THIS_ID.  */
2c2fa1
+}
2c2fa1
+
2c2fa1
+static struct value *
2c2fa1
+ia64_clone2_frame_prev_register (struct frame_info *this_frame,
2c2fa1
+				 void **this_cache, int regnum)
2c2fa1
+{
2c2fa1
+  return frame_unwind_got_register (this_frame, regnum, regnum);
2c2fa1
+}
2c2fa1
+
2c2fa1
+static int
2c2fa1
+ia64_clone2_frame_sniffer (const struct frame_unwind *self,
2c2fa1
+			   struct frame_info *this_frame,
2c2fa1
+			   void **this_prologue_cache)
2c2fa1
+{
2c2fa1
+  if (ia64_outermost_frame (this_frame))
2c2fa1
+    return 1;
2c2fa1
+
2c2fa1
+  return 0;
2c2fa1
+}
2c2fa1
+
2c2fa1
+static const struct frame_unwind ia64_clone2_frame_unwind =
2c2fa1
+{
2c2fa1
+  NORMAL_FRAME,
2c2fa1
+  &ia64_clone2_frame_this_id,
2c2fa1
+  &ia64_clone2_frame_prev_register,
2c2fa1
+  NULL,
2c2fa1
+  &ia64_clone2_frame_sniffer
2c2fa1
+};
2c2fa1
+
2c2fa1
 /* Signal trampolines.  */
2c2fa1
 
2c2fa1
 static void
2c2fa1
@@ -4146,6 +4278,7 @@ ia64_gdbarch_init (struct gdbarch_info i
2c2fa1
   set_gdbarch_dummy_id (gdbarch, ia64_dummy_id);
2c2fa1
 
2c2fa1
   set_gdbarch_unwind_pc (gdbarch, ia64_unwind_pc);
2c2fa1
+  frame_unwind_append_unwinder (gdbarch, &ia64_clone2_frame_unwind);
2c2fa1
 #ifdef HAVE_LIBUNWIND_IA64_H
2c2fa1
   frame_unwind_append_unwinder (gdbarch,
2c2fa1
                                 &ia64_libunwind_sigtramp_frame_unwind);
2c2fa1
Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.c
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.c	2012-07-03 17:32:12.344604404 +0200
2c2fa1
@@ -0,0 +1,39 @@
2c2fa1
+/* This testcase is part of GDB, the GNU debugger.
2c2fa1
+
2c2fa1
+   Copyright 2006 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+   This program is free software; you can redistribute it and/or modify
2c2fa1
+   it under the terms of the GNU General Public License as published by
2c2fa1
+   the Free Software Foundation; either version 2 of the License, or
2c2fa1
+   (at your option) any later version.
2c2fa1
+
2c2fa1
+   This program is distributed in the hope that it will be useful,
2c2fa1
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+   GNU General Public License for more details.
2c2fa1
+ 
2c2fa1
+   You should have received a copy of the GNU General Public License
2c2fa1
+   along with this program; if not, write to the Free Software
2c2fa1
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
2c2fa1
+   MA 02110-1301, USA.  */
2c2fa1
+
2c2fa1
+
2c2fa1
+#include <pthread.h>
2c2fa1
+#include <unistd.h>
2c2fa1
+#include <assert.h>
2c2fa1
+
2c2fa1
+
2c2fa1
+void *threader (void *arg)
2c2fa1
+{
2c2fa1
+	assert (0);
2c2fa1
+	return NULL;
2c2fa1
+}
2c2fa1
+
2c2fa1
+int main (void)
2c2fa1
+{
2c2fa1
+	pthread_t t1;
2c2fa1
+
2c2fa1
+	pthread_create (&t1, NULL, threader, (void *) NULL);
2c2fa1
+	for (;;)
2c2fa1
+		pause();
2c2fa1
+}
2c2fa1
Index: gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.exp
2c2fa1
===================================================================
2c2fa1
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
2c2fa1
+++ gdb-7.4.50.20120703/gdb/testsuite/gdb.threads/bt-clone-stop.exp	2012-07-03 17:32:12.344604404 +0200
2c2fa1
@@ -0,0 +1,61 @@
2c2fa1
+# Copyright 2006 Free Software Foundation, Inc.
2c2fa1
+
2c2fa1
+# This program is free software; you can redistribute it and/or modify
2c2fa1
+# it under the terms of the GNU General Public License as published by
2c2fa1
+# the Free Software Foundation; either version 2 of the License, or
2c2fa1
+# (at your option) any later version.
2c2fa1
+# 
2c2fa1
+# This program is distributed in the hope that it will be useful,
2c2fa1
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2c2fa1
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
2c2fa1
+# GNU General Public License for more details.
2c2fa1
+# 
2c2fa1
+# You should have received a copy of the GNU General Public License
2c2fa1
+# along with this program; if not, write to the Free Software
2c2fa1
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
2c2fa1
+
2c2fa1
+# Backtraced `clone' must not have `PC == 0' as its previous frame.
2c2fa1
+
2c2fa1
+if $tracelevel then {
2c2fa1
+    strace $tracelevel
2c2fa1
+}
2c2fa1
+
2c2fa1
+set testfile bt-clone-stop
2c2fa1
+set srcfile ${testfile}.c
2c2fa1
+set binfile ${objdir}/${subdir}/${testfile}
2c2fa1
+if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
2c2fa1
+    untested "Couldn't compile test program"
2c2fa1
+    return -1
2c2fa1
+}
2c2fa1
+
2c2fa1
+# Get things started.
2c2fa1
+
2c2fa1
+gdb_exit
2c2fa1
+gdb_start
2c2fa1
+gdb_reinitialize_dir $srcdir/$subdir
2c2fa1
+gdb_load ${binfile}
2c2fa1
+
2c2fa1
+# threader: threader.c:8: threader: Assertion `0' failed.
2c2fa1
+# Program received signal SIGABRT, Aborted.
2c2fa1
+
2c2fa1
+gdb_test "run" \
2c2fa1
+     "Program received signal SIGABRT.*" \
2c2fa1
+     "run"
2c2fa1
+
2c2fa1
+# Former gdb unwind (the first function is `clone'):
2c2fa1
+# #5  0x0000003421ecd62d in ?? () from /lib64/libc.so.6
2c2fa1
+# #6  0x0000000000000000 in ?? ()
2c2fa1
+# (gdb)
2c2fa1
+# Tested `amd64_linux_outermost_frame' functionality should omit the line `#6'.
2c2fa1
+# 
2c2fa1
+# Two `-re' cases below must be in this order (1st is a subset of the 2nd one).
2c2fa1
+# Unhandled case below should not happen and it is fortunately handled by
2c2fa1
+# `amd64_linux_outermost_frame' as FAIL (and result `0x0 entry output invalid').
2c2fa1
+gdb_test_multiple "bt" "0x0 entry output invalid" {
2c2fa1
+    -re "in threader \\(.*\n#\[0-9\]* *0x0* in .*$gdb_prompt $" {
2c2fa1
+    	fail "0x0 entry found"
2c2fa1
+    }
2c2fa1
+    -re "in threader \\(.*$gdb_prompt $" {
2c2fa1
+    	pass "0x0 entry not found"
2c2fa1
+    }
2c2fa1
+}