arch/arc/kernel/stacktrace.c
Source file repositories/reference/linux-study-clean/arch/arc/kernel/stacktrace.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arc/kernel/stacktrace.c- Extension
.c- Size
- 7366 bytes
- Lines
- 276
- Domain
- Architecture Layer
- Bucket
- arch/arc
- 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/ptrace.hlinux/export.hlinux/stacktrace.hlinux/kallsyms.hlinux/sched/debug.hasm/arcregs.hasm/unwind.hasm/stacktrace.hasm/switch_to.h
Detected Declarations
function Copyrightfunction arc_unwind_corefunction __print_symfunction __collect_allfunction __collect_all_but_schedfunction __get_first_nonschedfunction show_stacktracefunction show_stackfunction schedulefunction save_stack_trace_tskfunction save_stack_traceexport show_stacktraceexport save_stack_trace
Annotated Snippet
if (cnt++ > 128) {
printk("unwinder looping too long, aborting !\n");
return 0;
}
}
return address; /* return the last address it saw */
#else
/* On ARC, only Dward based unwinder works. fp based backtracing is
* not possible (-fno-omit-frame-pointer) because of the way function
* prologue is setup (callee regs saved and then fp set and not other
* way around
*/
pr_warn_once("CONFIG_ARC_DW2_UNWIND needs to be enabled\n");
return 0;
#endif
}
/*-------------------------------------------------------------------------
* callbacks called by unwinder iterator to implement kernel APIs
*
* The callback can return -1 to force the iterator to stop, which by default
* keeps going till the bottom-most frame.
*-------------------------------------------------------------------------
*/
/* Call-back which plugs into unwinding core to dump the stack in
* case of panic/OOPs/BUG etc
*/
static int __print_sym(unsigned int address, void *arg)
{
const char *loglvl = arg;
printk("%s %pS\n", loglvl, (void *)address);
return 0;
}
#ifdef CONFIG_STACKTRACE
/* Call-back which plugs into unwinding core to capture the
* traces needed by kernel on /proc/<pid>/stack
*/
static int __collect_all(unsigned int address, void *arg)
{
struct stack_trace *trace = arg;
if (trace->skip > 0)
trace->skip--;
else
trace->entries[trace->nr_entries++] = address;
if (trace->nr_entries >= trace->max_entries)
return -1;
return 0;
}
static int __collect_all_but_sched(unsigned int address, void *arg)
{
struct stack_trace *trace = arg;
if (in_sched_functions(address))
return 0;
if (trace->skip > 0)
trace->skip--;
else
trace->entries[trace->nr_entries++] = address;
if (trace->nr_entries >= trace->max_entries)
return -1;
return 0;
}
#endif
static int __get_first_nonsched(unsigned int address, void *unused)
{
if (in_sched_functions(address))
return 0;
return -1;
}
/*-------------------------------------------------------------------------
* APIs expected by various kernel sub-systems
*-------------------------------------------------------------------------
*/
Annotation
- Immediate include surface: `linux/ptrace.h`, `linux/export.h`, `linux/stacktrace.h`, `linux/kallsyms.h`, `linux/sched/debug.h`, `asm/arcregs.h`, `asm/unwind.h`, `asm/stacktrace.h`.
- Detected declarations: `function Copyright`, `function arc_unwind_core`, `function __print_sym`, `function __collect_all`, `function __collect_all_but_sched`, `function __get_first_nonsched`, `function show_stacktrace`, `function show_stack`, `function schedule`, `function save_stack_trace_tsk`.
- Atlas domain: Architecture Layer / arch/arc.
- 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.