2008-02-04 23:31:14 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2013-09-23 09:38:01 -06: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-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
|
2008-02-04 23:31:14 -07:00
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-08 10:51:35 -07:00
|
|
|
#include <linux/sched/debug.h>
|
2017-02-05 06:31:22 -07:00
|
|
|
#include <linux/sched/task_stack.h>
|
2017-02-08 10:51:35 -07:00
|
|
|
|
2012-10-07 20:26:54 -06:00
|
|
|
#include <asm/sysrq.h>
|
2014-08-20 03:56:00 -06:00
|
|
|
#include <asm/stacktrace.h>
|
2013-09-23 09:38:02 -06:00
|
|
|
#include <os.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2014-08-20 03:56:00 -06:00
|
|
|
static void _print_addr(void *data, unsigned long address, int reliable)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2016-12-25 15:11:05 -07:00
|
|
|
pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : "? ",
|
|
|
|
(void *)address);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2014-08-20 03:56:00 -06:00
|
|
|
static const struct stacktrace_ops stackops = {
|
|
|
|
.address = _print_addr
|
|
|
|
};
|
2013-09-23 09:38:02 -06:00
|
|
|
|
2013-09-23 09:38:01 -06:00
|
|
|
void show_stack(struct task_struct *task, unsigned long *stack)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2015-03-18 07:11:04 -06:00
|
|
|
unsigned long *sp = stack;
|
2013-09-23 09:38:02 -06:00
|
|
|
struct pt_regs *segv_regs = current->thread.segv_regs;
|
2005-04-16 16:20:36 -06:00
|
|
|
int i;
|
|
|
|
|
2013-09-23 09:38:02 -06:00
|
|
|
if (!segv_regs && os_is_signal_stack()) {
|
2014-08-20 03:56:00 -06:00
|
|
|
pr_err("Received SIGSEGV in SIGSEGV handler,"
|
2013-09-23 09:38:02 -06:00
|
|
|
" aborting stack trace!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!stack)
|
|
|
|
sp = get_stack_pointer(task, segv_regs);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2014-08-20 03:56:00 -06:00
|
|
|
pr_info("Stack:\n");
|
2013-09-23 09:38:01 -06:00
|
|
|
stack = sp;
|
2013-09-23 09:38:04 -06:00
|
|
|
for (i = 0; i < 3 * STACKSLOTS_PER_LINE; i++) {
|
2005-04-16 16:20:36 -06:00
|
|
|
if (kstack_end(stack))
|
|
|
|
break;
|
2013-09-23 09:38:01 -06:00
|
|
|
if (i && ((i % STACKSLOTS_PER_LINE) == 0))
|
2014-08-20 03:56:00 -06:00
|
|
|
pr_cont("\n");
|
|
|
|
pr_cont(" %08lx", *stack++);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2014-08-20 03:56:00 -06:00
|
|
|
pr_cont("\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2014-08-20 03:56:00 -06:00
|
|
|
pr_info("Call Trace:\n");
|
|
|
|
dump_trace(current, &stackops, NULL);
|
|
|
|
pr_info("\n");
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|