[Ltrace-devel] [PATCH] Correct fetching arguments beyond eighth arg on ppc/ppc64

Andreas Schwab schwab at linux-m68k.org
Sun May 8 14:25:41 UTC 2011


The parameter save area starts at sp+8 on ppc32 and at sp+112 on ppc64.

Signed-off-by: Andreas Schwab <schwab at linux-m68k.org>
---
 sysdeps/linux-gnu/ppc/trace.c |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
index ee696d8..8642157 100644
--- a/sysdeps/linux-gnu/ppc/trace.c
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -87,10 +87,22 @@ gimme_arg_regset(enum tof type, Process *proc, int arg_num, arg_type_info *info,
 	}
 	else if (greg <= 10)
 		return (*regs)[greg++];
-	else
+	else {
+#ifdef __powerpc64__
+		if (proc->mask_32bit)
+			return ptrace (PTRACE_PEEKDATA, proc->pid,
+				       proc->stack_pointer + 8 +
+				       sizeof (int) * (arg_num - 8), 0) >> 32;
+		else
+			return ptrace (PTRACE_PEEKDATA, proc->pid,
+				       proc->stack_pointer + 112 +
+				       sizeof (long) * (arg_num - 8), 0);
+#else
 		return ptrace (PTRACE_PEEKDATA, proc->pid,
-				proc->stack_pointer + sizeof (long) *
-				(arg_num - 8), 0);
+			       proc->stack_pointer + 8 +
+			       sizeof (long) * (arg_num - 8), 0);
+#endif
+	}
 
 	return 0;
 }
-- 
1.7.5.1


-- 
Andreas Schwab, schwab at linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



More information about the Ltrace-devel mailing list