Blame SOURCES/gdb-6.3-ppc64syscall-20040622.patch

f9426a
2004-06-22  Andrew Cagney  <cagney@gnu.org>
f9426a
f9426a
	* rs6000-tdep.c (struct rs6000_framedata): Add field "func_start".
f9426a
	(skip_prologue): Delete local variable "orig_pc", use
f9426a
	"func_start".  Add local variable "num_skip_linux_syscall_insn",
f9426a
	use to skip over first half of a GNU/Linux syscall and update
f9426a
	"func_start".
f9426a
f9426a
Index: gdb-7.2.50.20110117/gdb/rs6000-tdep.c
f9426a
===================================================================
f9426a
--- gdb-7.2.50.20110117.orig/gdb/rs6000-tdep.c	2011-01-11 20:23:02.000000000 +0100
f9426a
+++ gdb-7.2.50.20110117/gdb/rs6000-tdep.c	2011-01-17 15:48:19.000000000 +0100
f9426a
@@ -126,6 +126,7 @@ static const char *powerpc_vector_abi_st
f9426a
 
f9426a
 struct rs6000_framedata
f9426a
   {
f9426a
+    CORE_ADDR func_start;	/* True function start.  */
f9426a
     int offset;			/* total size of frame --- the distance
f9426a
 				   by which we decrement sp to allocate
f9426a
 				   the frame */
f9426a
@@ -1496,7 +1497,6 @@ static CORE_ADDR
f9426a
 skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
f9426a
 	       struct rs6000_framedata *fdata)
f9426a
 {
f9426a
-  CORE_ADDR orig_pc = pc;
f9426a
   CORE_ADDR last_prologue_pc = pc;
f9426a
   CORE_ADDR li_found_pc = 0;
f9426a
   gdb_byte buf[4];
f9426a
@@ -1514,12 +1514,14 @@ skip_prologue (struct gdbarch *gdbarch, 
f9426a
   int minimal_toc_loaded = 0;
f9426a
   int prev_insn_was_prologue_insn = 1;
f9426a
   int num_skip_non_prologue_insns = 0;
f9426a
+  int num_skip_ppc64_gnu_linux_syscall_insn = 0;
f9426a
   int r0_contains_arg = 0;
f9426a
   const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
f9426a
   struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
f9426a
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
f9426a
 
f9426a
   memset (fdata, 0, sizeof (struct rs6000_framedata));
f9426a
+  fdata->func_start = pc;
f9426a
   fdata->saved_gpr = -1;
f9426a
   fdata->saved_fpr = -1;
f9426a
   fdata->saved_vr = -1;
f9426a
@@ -1553,6 +1555,55 @@ skip_prologue (struct gdbarch *gdbarch, 
f9426a
 	break;
f9426a
       op = extract_unsigned_integer (buf, 4, byte_order);
f9426a
 
f9426a
+      /* A PPC64 GNU/Linux system call function is split into two
f9426a
+	 sub-functions: a non-threaded fast-path (__NAME_nocancel)
f9426a
+	 which does not use a frame; and a threaded slow-path
f9426a
+	 (Lpseudo_cancel) that does create a frame.  Ref:
f9426a
+	 nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
f9426a
+
f9426a
+	 *INDENT-OFF*
f9426a
+	 NAME:
f9426a
+	 	SINGLE_THREAD_P
f9426a
+	 	bne- .Lpseudo_cancel
f9426a
+	 __NAME_nocancel:
f9426a
+	 	li r0,162
f9426a
+	 	sc
f9426a
+	 	bnslr+
f9426a
+	 	b 0x7fe014ef64 <.__syscall_error>
f9426a
+	 Lpseudo_cancel:
f9426a
+	 	stdu r1,-128(r1)
f9426a
+	 	...
f9426a
+	 *INDENT-ON*
f9426a
+
f9426a
+	 Unfortunatly, because the latter case uses a local label (not
f9426a
+	 in the symbol table) a PC in "Lpseudo_cancel" appears to be
f9426a
+	 in "__NAME_nocancel".  The following code recognizes this,
f9426a
+	 adjusting FUNC_START to point to where "Lpseudo_cancel"
f9426a
+	 should be, and parsing the prologue sequence as if
f9426a
+	 "Lpseudo_cancel" was the entry point.  */
f9426a
+
f9426a
+      if (((op & 0xffff0000) == 0x38000000 /* li r0,N */
f9426a
+	   && pc == fdata->func_start + 0
f9426a
+	   && num_skip_ppc64_gnu_linux_syscall_insn == 0)
f9426a
+	  || (op == 0x44000002 /* sc */
f9426a
+	      && pc == fdata->func_start + 4
f9426a
+	      && num_skip_ppc64_gnu_linux_syscall_insn == 1)
f9426a
+	  || (op == 0x4ca30020 /* bnslr+ */
f9426a
+	      && pc == fdata->func_start + 8
f9426a
+	      && num_skip_ppc64_gnu_linux_syscall_insn == 2))
f9426a
+	{
f9426a
+	  num_skip_ppc64_gnu_linux_syscall_insn++;
f9426a
+	  continue;
f9426a
+	}
f9426a
+      else if ((op & 0xfc000003) == 0x48000000 /* b __syscall_error */
f9426a
+	       && pc == fdata->func_start + 12
f9426a
+	       && num_skip_ppc64_gnu_linux_syscall_insn == 3)
f9426a
+	{
f9426a
+	  num_skip_ppc64_gnu_linux_syscall_insn = -1;
f9426a
+	  fdata->func_start = pc;
f9426a
+	  continue;
f9426a
+	}
f9426a
+
f9426a
       if ((op & 0xfc1fffff) == 0x7c0802a6)
f9426a
 	{			/* mflr Rx */
f9426a
 	  /* Since shared library / PIC code, which needs to get its
f9426a
@@ -1734,9 +1785,9 @@ skip_prologue (struct gdbarch *gdbarch, 
f9426a
 	     we have no line table information or the line info tells
f9426a
 	     us that the subroutine call is not part of the line
f9426a
 	     associated with the prologue.  */
f9426a
-	  if ((pc - orig_pc) > 8)
f9426a
+	  if ((pc - fdata->func_start) > 8)
f9426a
 	    {
f9426a
-	      struct symtab_and_line prologue_sal = find_pc_line (orig_pc, 0);
f9426a
+	      struct symtab_and_line prologue_sal = find_pc_line (fdata->func_start, 0);
f9426a
 	      struct symtab_and_line this_sal = find_pc_line (pc, 0);
f9426a
 
f9426a
 	      if ((prologue_sal.line == 0)