From a8f2e34c5f59e32205d867aed0751d8e4172eb28 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Wed, 5 Oct 2011 17:25:41 +0200 Subject: [PATCH] Make struct used by PTRACE_GETREGS arch-dependant Structure used by ptrace in PTRACE_GETREGS mode is unfortunetely arch-dependant. Although pt_regs seems portable, it's only designed to represent the way registers are stored on the stack during system call. The right struct to use is defined in sys/user.h and is user_regs_struct on x86-{32,64} and user_regs on armel. --- pstack.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pstack.c b/pstack.c index c6329d0..dc89d46 100644 --- a/pstack.c +++ b/pstack.c @@ -114,12 +114,14 @@ #endif /* x86-{32,64} */ #define NEXT_FRAME_POINTER_ADDR(fp) (fp) #define NEXT_PROGRAM_COUNTER_ADDR(fp) ((fp) + __SIZEOF_POINTER__) +#define DECLARE_REGS_STRUCT(regs) struct user_regs_struct regs #elif defined(__ARMEL__) /* armel */ #define ELF_MACHINE EM_ARM #define PROGRAM_COUNTER(regs) (regs.ARM_pc) #define FRAME_POINTER(regs) (regs.ARM_fp) #define NEXT_FRAME_POINTER_ADDR(fp) ((fp) - __SIZEOF_POINTER__) #define NEXT_PROGRAM_COUNTER_ADDR(fp) (fp) +#define DECLARE_REGS_STRUCT(regs) struct user_regs regs #elif defined(__ppc64__) || defined(__alpha__) || defined(__ia64__) || defined(s390x__) #error Not (yet) supported architecture, patches welcomes :-) #else @@ -643,7 +645,7 @@ static int crawl(int pid) { unsigned long pc, fp, nextfp, nargs, i, arg; int ret, error_occured = 0; - struct pt_regs regs; + DECLARE_REGS_STRUCT(regs); errno = 0;