forked from torvalds/linux
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use common arch_stack_walk infrastructure to avoid duplicated code and avoid taking care of the stack storage and filtering. Add sra (means __schedule return address) and scfa (means __schedule call frame address) to thread_info and store it in switch_to(). Now we can print the process stack by cat /proc/*/stack and can better support ftrace. Signed-off-by: Qing Zhang <zhangqing@loongson.cn>
- Loading branch information
1 parent
2237d07
commit 102a43b
Showing
9 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* | ||
* Stack trace management functions | ||
* | ||
* Copyright (C) 2022 Loongson Technology Corporation Limited | ||
*/ | ||
#include <linux/sched.h> | ||
#include <linux/stacktrace.h> | ||
|
||
#include <asm/stacktrace.h> | ||
#include <asm/unwind.h> | ||
|
||
void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, | ||
struct task_struct *task, struct pt_regs *regs) | ||
{ | ||
struct pt_regs dummyregs; | ||
struct unwind_state state; | ||
unsigned long addr; | ||
|
||
regs = &dummyregs; | ||
|
||
if (task == current) { | ||
regs->csr_era = (unsigned long)__builtin_return_address(0); | ||
regs->regs[3] = (unsigned long)__builtin_frame_address(0); | ||
} else { | ||
regs->csr_era = thread_saved_ra(task); | ||
regs->regs[3] = thread_saved_fp(task); | ||
} | ||
|
||
regs->regs[1] = 0; | ||
for (unwind_start(&state, task, regs); | ||
!unwind_done(&state); unwind_next_frame(&state)) { | ||
addr = unwind_get_return_address(&state); | ||
if (!addr || !consume_entry(cookie, addr)) | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters