| To: | wuzhangjin@gmail.com, ralf@linux-mips.org |
|---|---|
| Subject: | Re: [Bug-fix] backtrace when HAVE_FUNCTION_TRACER is enable |
| From: | Akhilesh Kumar <akhilesh.lxr@gmail.com> |
| Date: | Thu, 9 Aug 2012 22:46:57 +0530 |
| Cc: | linux-mips@linux-mips.org |
| Dkim-signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=/UxgkjcBimowHD03erl1dsewBThdVXdUC4C4LRlJ0tM=; b=IgrS8EexrHbS8UUWvfxwNu2b0pVfH1IUNbApQgZPmAPs5k7F0YI8tINiZ8UoGNRnyX Sxdd6PyBhoTkrV01V9bG1lX9myOCxPn3DxAR6evnV1p9gc2lccxxGCA0dj+t6P2n9H3V L2OjMGtG9p8J10w1+LFsJgmn6lKVTQ2hJRCRcZ/rsAND/fBo72/svaomvX4oA1BbtTvd ZiJ+GRXl6dmp8waH+DN+4CJTSgCMhcPJwN8NT7c4fw5CyGopZw3pbcJo+mQ80b9Wt3Nu N/KTSeu1HJId92vDBVmkMYzy9HVmyRWoDxdoKiA1g2N9z9PDiFV1f1uLBQVhh8yzWzd9 xVyQ== |
| In-reply-to: | <CAD+V5YKZJHKONehvT+-GrKLP2+e0PiLiFTJWEojiDoNyLT3yGQ@mail.gmail.com> |
| List-archive: | <http://www.linux-mips.org/archives/linux-mips/> |
| List-help: | <mailto:ecartis@linux-mips.org?Subject=help> |
| List-id: | linux-mips <linux-mips.eddie.linux-mips.org> |
| List-owner: | <mailto:ralf@linux-mips.org> |
| List-post: | <mailto:linux-mips@linux-mips.org> |
| List-software: | Ecartis version 1.0.0 |
| List-subscribe: | <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips> |
| List-unsubscribe: | <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips> |
| References: | <CADArhcB+N+D4fyVN20f0hu=vfPj1tsn5NHi0cjG4JJcKAhTkeQ@mail.gmail.com> <CAD+V5YKZJHKONehvT+-GrKLP2+e0PiLiFTJWEojiDoNyLT3yGQ@mail.gmail.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
|
yes Zhangin please find the complete patch ==================================================================== diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 7955409..df72738 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c @@ -290,12 +290,45 @@ static inline int is_sp_move_ins(union mips_instruction *ip)
return 0; } +#ifdef CONFIG_DYNAMIC_FTRACE +/* + * To create the jal <> instruction from mcount. + * taken from: + * - arch/mips/kernel/ftrace.c
+ */ +#define ADDR_MASK 0x03ffffff /* op_code|addr : 31...26|25 ....0 */ +#define JAL 0x0c000000 /* jump & link: ip --> ra, jump to target */ +#define INSN_JAL(addr) \
+ ((unsigned int)(JAL | (((addr) >> 2) & ADDR_MASK))) + +/* + * We assume jal <mcount>/<ftrace_caller> to be present in + * first JAL_MAX_OFFSET instructions.
+ * Increment this, if its otherwise + */ +#define JAL_MAX_OFFSET 16U +#define MCOUNT_STACK_INST 0x27bdfff8 /* addiu sp,sp,-8 */ + +/* + * If Dynamic Ftrace is enabled, ftrace_caller is the trace function.
+ * Otherwise its - mcount + */ +extern void ftrace_caller(void); +#endif /* CONFIG_DYNAMIC_FTRACE */ + static int get_frame_info(struct mips_frame_info *info)
{ union mips_instruction *ip = info->func; unsigned max_insns = info->func_size / sizeof(union mips_instruction); unsigned i; +#ifdef CONFIG_DYNAMIC_FTRACE
+ unsigned max_prolog_inst = max_insns; + int jal_found = 0; + /* instruction corresponding to jal <_mcount>/<ftrace_caller> */ + int jal_mcount = 0; +#endif
+ info->pc_offset = -1; info->frame_size = 0; @@ -306,6 +339,28 @@ static int get_frame_info(struct mips_frame_info *info) max_insns = 128U; /* unknown function size */
max_insns = min(128U, max_insns); +#ifdef CONFIG_DYNAMIC_FTRACE + max_prolog_inst = min(JAL_MAX_OFFSET, max_prolog_inst); + jal_mcount = INSN_JAL((unsigned)&ftrace_caller);
+ + for (i = 0; i < max_prolog_inst; i++, ip++) { + if ((*(int *)ip == jal_mcount) || + /* + * for dyn ftrace, the code initially has 0. + * so we check whether the next instruction is
+ * addiu sp,sp,-8 + */ + (!(*(int *)ip) && + (*(int *)(ip + 1) == MCOUNT_STACK_INST)) + ) { + jal_found = 1; + break;
+ } + } + /* restore the ip to start of function */ + ip = info->func; +#endif + for (i = 0; i < max_insns; i++, ip++) { if (is_jal_jalr_jr_ins(ip))
@@ -321,6 +376,18 @@ static int get_frame_info(struct mips_frame_info *info) break; } } +#ifdef CONFIG_DYNAMIC_FTRACE + /* + * to offset the effect of:
+ * addiu sp,sp,-8 + */ + if (jal_found) { + if (info->frame_size) + info->frame_size += 8; + if (info->pc_offset >= 0) + info->pc_offset += 8 / sizeof(long);
+ } +#endif if (info->frame_size && info->pc_offset >= 0) /* nested */ return 0; if (info->pc_offset < 0) /* leaf */ -- 1.7.8.4
====================================================================
On Thu, Aug 9, 2012 at 9:41 PM, Wu Zhangjin <wuzhangjin@gmail.com> wrote: Hi, Akhilesh |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [PATCH v2 6/6] x86: switch the 64bit uncached page clear to SSE/AVX v2, Jan Beulich |
|---|---|
| Next by Date: | Re: Direct I/O bug in kernel, Victor Meyerson |
| Previous by Thread: | [Bug-fix] backtrace when HAVE_FUNCTION_TRACER is enable, Akhilesh Kumar |
| Next by Thread: | Re: [Bug-fix] backtrace when HAVE_FUNCTION_TRACER is enable, John Crispin |
| Indexes: | [Date] [Thread] [Top] [All Lists] |