mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
0f659ff362
Currently, show_stack() always dumps the trace of the current task.
However, it should dump the trace of the specified task if one is
provided. Otherwise, things like running "echo t > sysrq-trigger"
won't work as expected.
Fixes: 970e51fead
("um: Add support for CONFIG_STACKTRACE")
Signed-off-by: Tiwei Bie <tiwei.btw@antgroup.com>
Link: https://patch.msgid.link/20241106103933.1132365-1-tiwei.btw@antgroup.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
51 lines
1.2 KiB
C
51 lines
1.2 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
|
* Copyright (C) 2013 Richard Weinberger <richrd@nod.at>
|
|
*/
|
|
|
|
#include <linux/kallsyms.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/sched/debug.h>
|
|
#include <linux/sched/task_stack.h>
|
|
|
|
#include <asm/stacktrace.h>
|
|
#include <os.h>
|
|
|
|
static void _print_addr(void *data, unsigned long address, int reliable)
|
|
{
|
|
const char *loglvl = data;
|
|
|
|
printk("%s [<%08lx>] %s%pS\n", loglvl, address, reliable ? "" : "? ",
|
|
(void *)address);
|
|
}
|
|
|
|
static const struct stacktrace_ops stackops = {
|
|
.address = _print_addr
|
|
};
|
|
|
|
void show_stack(struct task_struct *task, unsigned long *stack,
|
|
const char *loglvl)
|
|
{
|
|
struct pt_regs *segv_regs = current->thread.segv_regs;
|
|
int i;
|
|
|
|
if (!stack)
|
|
stack = get_stack_pointer(task, segv_regs);
|
|
|
|
printk("%sStack:\n", loglvl);
|
|
for (i = 0; i < 3 * STACKSLOTS_PER_LINE; i++) {
|
|
if (kstack_end(stack))
|
|
break;
|
|
if (i && ((i % STACKSLOTS_PER_LINE) == 0))
|
|
pr_cont("\n");
|
|
pr_cont(" %08lx", READ_ONCE_NOCHECK(*stack));
|
|
stack++;
|
|
}
|
|
|
|
printk("%sCall Trace:\n", loglvl);
|
|
dump_trace(task ?: current, &stackops, (void *)loglvl);
|
|
}
|