2019-06-04 10:11:33 +02:00
// SPDX-License-Identifier: GPL-2.0-only
2008-02-04 22:31:14 -08:00
/*
* Copyright ( C ) 2001 - 2007 Jeff Dike ( jdike @ { addtoit , linux . intel } . com )
2013-09-23 17:38:01 +02:00
* Copyright ( C ) 2013 Richard Weinberger < richrd @ nod . at >
2005-04-16 15:20:36 -07:00
*/
2008-02-04 22:31:14 -08:00
# include <linux/kallsyms.h>
# include <linux/kernel.h>
# include <linux/module.h>
# include <linux/sched.h>
2017-02-08 18:51:35 +01:00
# include <linux/sched/debug.h>
2017-02-05 14:31:22 +01:00
# include <linux/sched/task_stack.h>
2017-02-08 18:51:35 +01:00
2012-10-08 03:26:54 +01:00
# include <asm/sysrq.h>
2014-08-20 10:56:00 +01:00
# include <asm/stacktrace.h>
2013-09-23 17:38:02 +02:00
# include <os.h>
2005-04-16 15:20:36 -07:00
2014-08-20 10:56:00 +01:00
static void _print_addr ( void * data , unsigned long address , int reliable )
2005-04-16 15:20:36 -07:00
{
2020-06-08 21:31:45 -07:00
const char * loglvl = data ;
printk ( " %s [<%08lx>] %s%pS \n " , loglvl , address , reliable ? " " : " ? " ,
2016-12-25 23:11:05 +01:00
( void * ) address ) ;
2005-04-16 15:20:36 -07:00
}
2014-08-20 10:56:00 +01:00
static const struct stacktrace_ops stackops = {
. address = _print_addr
} ;
2013-09-23 17:38:02 +02:00
2020-06-08 21:32:29 -07:00
void show_stack ( struct task_struct * task , unsigned long * stack ,
2020-06-08 21:31:45 -07:00
const char * loglvl )
2005-04-16 15:20:36 -07:00
{
2013-09-23 17:38:02 +02:00
struct pt_regs * segv_regs = current - > thread . segv_regs ;
2005-04-16 15:20:36 -07:00
int i ;
2013-09-23 17:38:02 +02:00
if ( ! segv_regs & & os_is_signal_stack ( ) ) {
2014-08-20 10:56:00 +01:00
pr_err ( " Received SIGSEGV in SIGSEGV handler, "
2013-09-23 17:38:02 +02:00
" aborting stack trace! \n " ) ;
return ;
}
if ( ! stack )
2020-06-08 21:31:42 -07:00
stack = get_stack_pointer ( task , segv_regs ) ;
2005-04-16 15:20:36 -07:00
2020-06-08 21:31:45 -07:00
printk ( " %sStack: \n " , loglvl ) ;
2013-09-23 17:38:04 +02:00
for ( i = 0 ; i < 3 * STACKSLOTS_PER_LINE ; i + + ) {
2005-04-16 15:20:36 -07:00
if ( kstack_end ( stack ) )
break ;
2013-09-23 17:38:01 +02:00
if ( i & & ( ( i % STACKSLOTS_PER_LINE ) = = 0 ) )
2020-09-21 13:43:25 +02:00
pr_cont ( " \n " ) ;
2014-08-20 10:56:00 +01:00
pr_cont ( " %08lx " , * stack + + ) ;
2005-04-16 15:20:36 -07:00
}
2020-06-08 21:31:45 -07:00
printk ( " %sCall Trace: \n " , loglvl ) ;
dump_trace ( current , & stackops , ( void * ) loglvl ) ;
}