From 6b9bd6f6e4315a4413359a479d6bc3c0236600d4 Mon Sep 17 00:00:00 2001 From: Oleg Strikov Date: Mon, 28 Feb 2011 22:19:48 +0300 Subject: arm: oprofile: backtracing support for Android The stack frame for Android is slightly different than that used for vanilla Linux. Bug 935536 Signed-off-by: Ryan V. Bissell Reviewed-on: http://git-master/r/82600 (cherry picked from commit bb6d1e211bdb41c129ee17489814327d7d8d2fb8) Change-Id: Ie0e924d45398c7def58e3722035911d905614b6f Reviewed-on: http://git-master/r/89507 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Oleg Strikov Reviewed-by: Janne Hellsten Tested-by: Ryan Bissell --- arch/arm/oprofile/common.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'arch') diff --git a/arch/arm/oprofile/common.c b/arch/arm/oprofile/common.c index 4e0a371630b3..485e58bf7f49 100644 --- a/arch/arm/oprofile/common.c +++ b/arch/arm/oprofile/common.c @@ -58,6 +58,13 @@ static int report_trace(struct stackframe *frame, void *d) return *depth == 0; } +#ifdef CONFIG_ANDROID +/* Android has a different stack frame than Linux */ +struct frame_tail { + unsigned long fp; + unsigned long lr; +} __attribute__((packed)); +#else /* * The registers we're interested in are at the end of the variable * length saved register structure. The fp points at the end of this @@ -69,6 +76,7 @@ struct frame_tail { unsigned long sp; unsigned long lr; } __attribute__((packed)); +#endif static struct frame_tail* user_backtrace(struct frame_tail *tail) { @@ -84,15 +92,29 @@ static struct frame_tail* user_backtrace(struct frame_tail *tail) /* frame pointers should strictly progress back up the stack * (towards higher addresses) */ +#ifdef CONFIG_ANDROID + if (tail >= (struct frame_tail *) buftail[0].fp) +#else if (tail + 1 >= buftail[0].fp) +#endif return NULL; +#ifdef CONFIG_ANDROID + /* Android has a different stack frame than Linux */ + return (struct frame_tail *) (buftail[0].fp - sizeof(unsigned long)); +#else return buftail[0].fp-1; +#endif } static void arm_backtrace(struct pt_regs * const regs, unsigned int depth) { +#ifdef CONFIG_ANDROID + struct frame_tail *tail = (struct frame_tail *) + (regs->ARM_fp - sizeof(unsigned long)); +#else struct frame_tail *tail = ((struct frame_tail *) regs->ARM_fp) - 1; +#endif if (!user_mode(regs)) { struct stackframe frame; -- cgit v1.2.3