mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 08:52:27 +00:00
Terminating the last trace entry with ULONG_MAX is a completely pointless exercise and none of the consumers can rely on it because it's inconsistently implemented across architectures. In fact quite some of the callers remove the entry and adjust stack_trace.nr_entries afterwards. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Steven Rostedt <[email protected]> Cc: Alexander Potapenko <[email protected]> Cc: "James E.J. Bottomley" <[email protected]> Cc: Helge Deller <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
46 lines
1.1 KiB
C
46 lines
1.1 KiB
C
/*
|
|
* Stack trace management functions
|
|
*
|
|
* Copyright (C) 2009 Helge Deller <[email protected]>
|
|
* based on arch/x86/kernel/stacktrace.c by Ingo Molnar <[email protected]>
|
|
* and parisc unwind functions by Randolph Chung <[email protected]>
|
|
*
|
|
* TODO: Userspace stacktrace (CONFIG_USER_STACKTRACE_SUPPORT)
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/stacktrace.h>
|
|
|
|
#include <asm/unwind.h>
|
|
|
|
static void dump_trace(struct task_struct *task, struct stack_trace *trace)
|
|
{
|
|
struct unwind_frame_info info;
|
|
|
|
unwind_frame_init_task(&info, task, NULL);
|
|
|
|
/* unwind stack and save entries in stack_trace struct */
|
|
trace->nr_entries = 0;
|
|
while (trace->nr_entries < trace->max_entries) {
|
|
if (unwind_once(&info) < 0 || info.ip == 0)
|
|
break;
|
|
|
|
if (__kernel_text_address(info.ip))
|
|
trace->entries[trace->nr_entries++] = info.ip;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Save stack-backtrace addresses into a stack_trace buffer.
|
|
*/
|
|
void save_stack_trace(struct stack_trace *trace)
|
|
{
|
|
dump_trace(current, trace);
|
|
}
|
|
EXPORT_SYMBOL_GPL(save_stack_trace);
|
|
|
|
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
|
|
{
|
|
dump_trace(tsk, trace);
|
|
}
|
|
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
|