mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-18 02:04:05 +08:00
nds32/stack: Get real return address by using ftrace_graph_ret_addr
Function graph tracer has modified the return address to 'return_to_handler' on stack, and provide the 'ftrace_graph_ret_addr' to get the real return address. Signed-off-by: Zong Li <zong@andestech.com> Acked-by: Greentime Hu <greentime@andestech.com> Signed-off-by: Greentime Hu <greentime@andestech.com>
This commit is contained in:
parent
95cd2f7bce
commit
1e377ae9b0
@ -4,6 +4,7 @@
|
||||
#include <linux/sched/debug.h>
|
||||
#include <linux/sched/task_stack.h>
|
||||
#include <linux/stacktrace.h>
|
||||
#include <linux/ftrace.h>
|
||||
|
||||
void save_stack_trace(struct stack_trace *trace)
|
||||
{
|
||||
@ -16,6 +17,7 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
|
||||
unsigned long *fpn;
|
||||
int skip = trace->skip;
|
||||
int savesched;
|
||||
int graph_idx = 0;
|
||||
|
||||
if (tsk == current) {
|
||||
__asm__ __volatile__("\tori\t%0, $fp, #0\n":"=r"(fpn));
|
||||
@ -33,6 +35,8 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
|
||||
fpp = fpn[FP_OFFSET];
|
||||
if (!__kernel_text_address(lpp))
|
||||
break;
|
||||
else
|
||||
lpp = ftrace_graph_ret_addr(tsk, &graph_idx, lpp, NULL);
|
||||
|
||||
if (savesched || !in_sched_functions(lpp)) {
|
||||
if (skip) {
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <linux/kdebug.h>
|
||||
#include <linux/sched/task_stack.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/ftrace.h>
|
||||
|
||||
#include <asm/proc-fns.h>
|
||||
#include <asm/unistd.h>
|
||||
@ -94,28 +95,6 @@ static void dump_instr(struct pt_regs *regs)
|
||||
set_fs(fs);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
||||
#include <linux/ftrace.h>
|
||||
static void
|
||||
get_real_ret_addr(unsigned long *addr, struct task_struct *tsk, int *graph)
|
||||
{
|
||||
if (*addr == (unsigned long)return_to_handler) {
|
||||
int index = tsk->curr_ret_stack;
|
||||
|
||||
if (tsk->ret_stack && index >= *graph) {
|
||||
index -= *graph;
|
||||
*addr = tsk->ret_stack[index].ret;
|
||||
(*graph)++;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static inline void
|
||||
get_real_ret_addr(unsigned long *addr, struct task_struct *tsk, int *graph)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define LOOP_TIMES (100)
|
||||
static void __dump(struct task_struct *tsk, unsigned long *base_reg)
|
||||
{
|
||||
@ -126,7 +105,8 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)
|
||||
while (!kstack_end(base_reg)) {
|
||||
ret_addr = *base_reg++;
|
||||
if (__kernel_text_address(ret_addr)) {
|
||||
get_real_ret_addr(&ret_addr, tsk, &graph);
|
||||
ret_addr = ftrace_graph_ret_addr(
|
||||
tsk, &graph, ret_addr, NULL);
|
||||
print_ip_sym(ret_addr);
|
||||
}
|
||||
if (--cnt < 0)
|
||||
@ -145,7 +125,9 @@ static void __dump(struct task_struct *tsk, unsigned long *base_reg)
|
||||
next_fp = base_reg[FP_OFFSET];
|
||||
#endif
|
||||
if (__kernel_text_address(ret_addr)) {
|
||||
get_real_ret_addr(&ret_addr, tsk, &graph);
|
||||
|
||||
ret_addr = ftrace_graph_ret_addr(
|
||||
tsk, &graph, ret_addr, NULL);
|
||||
print_ip_sym(ret_addr);
|
||||
}
|
||||
if (--cnt < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user