2008-02-05 13:31:14 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2013-09-23 22:38:01 +07:00
|
|
|
* Copyright (C) 2013 Richard Weinberger <richrd@nod.at>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2008-02-05 13:31:14 +07:00
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-09 00:51:35 +07:00
|
|
|
#include <linux/sched/debug.h>
|
2017-02-05 20:31:22 +07:00
|
|
|
#include <linux/sched/task_stack.h>
|
2017-02-09 00:51:35 +07:00
|
|
|
|
2012-10-08 09:26:54 +07:00
|
|
|
#include <asm/sysrq.h>
|
2014-08-20 16:56:00 +07:00
|
|
|
#include <asm/stacktrace.h>
|
2013-09-23 22:38:02 +07:00
|
|
|
#include <os.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-08-20 16:56:00 +07:00
|
|
|
static void _print_addr(void *data, unsigned long address, int reliable)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2016-12-26 05:11:05 +07:00
|
|
|
pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : "? ",
|
|
|
|
(void *)address);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2014-08-20 16:56:00 +07:00
|
|
|
static const struct stacktrace_ops stackops = {
|
|
|
|
.address = _print_addr
|
|
|
|
};
|
2013-09-23 22:38:02 +07:00
|
|
|
|
2013-09-23 22:38:01 +07:00
|
|
|
void show_stack(struct task_struct *task, unsigned long *stack)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2015-03-18 20:11:04 +07:00
|
|
|
unsigned long *sp = stack;
|
2013-09-23 22:38:02 +07:00
|
|
|
struct pt_regs *segv_regs = current->thread.segv_regs;
|
2005-04-17 05:20:36 +07:00
|
|
|
int i;
|
|
|
|
|
2013-09-23 22:38:02 +07:00
|
|
|
if (!segv_regs && os_is_signal_stack()) {
|
2014-08-20 16:56:00 +07:00
|
|
|
pr_err("Received SIGSEGV in SIGSEGV handler,"
|
2013-09-23 22:38:02 +07:00
|
|
|
" aborting stack trace!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stack)
|
|
|
|
sp = get_stack_pointer(task, segv_regs);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-08-20 16:56:00 +07:00
|
|
|
pr_info("Stack:\n");
|
2013-09-23 22:38:01 +07:00
|
|
|
stack = sp;
|
2013-09-23 22:38:04 +07:00
|
|
|
for (i = 0; i < 3 * STACKSLOTS_PER_LINE; i++) {
|
2005-04-17 05:20:36 +07:00
|
|
|
if (kstack_end(stack))
|
|
|
|
break;
|
2013-09-23 22:38:01 +07:00
|
|
|
if (i && ((i % STACKSLOTS_PER_LINE) == 0))
|
2014-08-20 16:56:00 +07:00
|
|
|
pr_cont("\n");
|
|
|
|
pr_cont(" %08lx", *stack++);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2014-08-20 16:56:00 +07:00
|
|
|
pr_cont("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2014-08-20 16:56:00 +07:00
|
|
|
pr_info("Call Trace:\n");
|
|
|
|
dump_trace(current, &stackops, NULL);
|
|
|
|
pr_info("\n");
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|