arch/csky/kernel/stacktrace.c
Source file repositories/reference/linux-study-clean/arch/csky/kernel/stacktrace.c
File Facts
- System
- Linux kernel
- Corpus path
arch/csky/kernel/stacktrace.c- Extension
.c- Size
- 3540 bytes
- Lines
- 157
- Domain
- Architecture Layer
- Bucket
- arch/csky
- Inferred role
- Architecture Layer: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched/debug.hlinux/sched/task_stack.hlinux/stacktrace.hlinux/ftrace.hlinux/ptrace.h
Detected Declarations
struct stackframefunction walk_stackframefunction walk_stackframefunction print_trace_addressfunction show_stackfunction save_wchanfunction __get_wchanfunction __save_tracefunction save_tracefunction save_stack_trace_tskfunction save_stack_traceexport save_stack_trace_tskexport save_stack_trace
Annotated Snippet
struct stackframe {
unsigned long fp;
unsigned long ra;
};
void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
bool (*fn)(unsigned long, void *), void *arg)
{
unsigned long fp, sp, pc;
if (regs) {
fp = frame_pointer(regs);
sp = user_stack_pointer(regs);
pc = instruction_pointer(regs);
} else if (task == NULL || task == current) {
const register unsigned long current_fp __asm__ ("r8");
fp = current_fp;
sp = current_stack_pointer;
pc = (unsigned long)walk_stackframe;
} else {
/* task blocked in __switch_to */
fp = thread_saved_fp(task);
sp = thread_saved_sp(task);
pc = thread_saved_lr(task);
}
for (;;) {
unsigned long low, high;
struct stackframe *frame;
if (unlikely(!__kernel_text_address(pc) || fn(pc, arg)))
break;
/* Validate frame pointer */
low = sp;
high = ALIGN(sp, THREAD_SIZE);
if (unlikely(fp < low || fp > high || fp & 0x3))
break;
/* Unwind stack frame */
frame = (struct stackframe *)fp;
sp = fp;
fp = frame->fp;
pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
(unsigned long *)(fp - 8));
}
}
#else /* !CONFIG_FRAME_POINTER */
static void notrace walk_stackframe(struct task_struct *task,
struct pt_regs *regs, bool (*fn)(unsigned long, void *), void *arg)
{
unsigned long sp, pc;
unsigned long *ksp;
if (regs) {
sp = user_stack_pointer(regs);
pc = instruction_pointer(regs);
} else if (task == NULL || task == current) {
sp = current_stack_pointer;
pc = (unsigned long)walk_stackframe;
} else {
/* task blocked in __switch_to */
sp = thread_saved_sp(task);
pc = thread_saved_lr(task);
}
if (unlikely(sp & 0x3))
return;
ksp = (unsigned long *)sp;
while (!kstack_end(ksp)) {
if (__kernel_text_address(pc) && unlikely(fn(pc, arg)))
break;
pc = (*ksp++) - 0x4;
}
}
#endif /* CONFIG_FRAME_POINTER */
static bool print_trace_address(unsigned long pc, void *arg)
{
print_ip_sym((const char *)arg, pc);
return false;
}
void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
{
pr_cont("Call Trace:\n");
walk_stackframe(task, NULL, print_trace_address, (void *)loglvl);
}
Annotation
- Immediate include surface: `linux/sched/debug.h`, `linux/sched/task_stack.h`, `linux/stacktrace.h`, `linux/ftrace.h`, `linux/ptrace.h`.
- Detected declarations: `struct stackframe`, `function walk_stackframe`, `function walk_stackframe`, `function print_trace_address`, `function show_stack`, `function save_wchan`, `function __get_wchan`, `function __save_trace`, `function save_trace`, `function save_stack_trace_tsk`.
- Atlas domain: Architecture Layer / arch/csky.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.