[Crash-utility] [PATCH] crash: bt: Introduce -p option

Dave Anderson anderson at redhat.com
Wed Jun 19 18:13:22 UTC 2019



----- Original Message -----
> The purpose of this patch is to provide a -p option to generate a stack
> trace of the panic task, if available. It might be useful if the current
> context is changed with the 'set' command.
> 
> This option is not supported under a live system or live dump.

Good idea -- queued for crash-7.2.7:

  https://github.com/crash-utility/crash/commit/a000947e9258c60f7c13beb5d8b32d2ae090bdf3

Thanks,
  Dave


> 
> Signed-off-by: Aaron Tomlin <atomlin at redhat.com>
> ---
>  help.c   |  4 +++-
>  kernel.c | 19 +++++++++++++++----
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/help.c b/help.c
> index c0c750f..581e616 100644
> --- a/help.c
> +++ b/help.c
> @@ -1789,13 +1789,15 @@ NULL
>  char *help_bt[] = {
>  "bt",
>  "backtrace",
> -"[-a|-c cpu(s)|-g|-r|-t|-T|-l|-e|-E|-f|-F|-o|-O|-v] [-R ref] [-s [-x|d]]"
> +"[-a|-c cpu(s)|-g|-r|-t|-T|-l|-e|-E|-f|-F|-o|-O|-v|-p] [-R ref] [-s [-x|d]]"
>  "\n     [-I ip] [-S sp] [pid | task]",
>  "  Display a kernel stack backtrace.  If no arguments are given, the stack",
>  "  trace of the current context will be displayed.\n",
>  "       -a  displays the stack traces of the active task on each CPU.",
>  "           (only applicable to crash dumps)",
>  "       -A  same as -a, but also displays vector registers (S390X only).",
> +"       -p  display the stack trace of the panic task only.",
> +"           (only applicable to crash dumps)",
>  "   -c cpu  display the stack trace of the active task on one or more
>  CPUs,",
>  "           which can be specified using the format \"3\", \"1,8,9\",
>  \"1-23\",",
>  "           or \"1,8,9-14\". (only applicable to crash dumps)",
> diff --git a/kernel.c b/kernel.c
> index f5960fc..e1f0b7e 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -2402,7 +2402,7 @@ cmd_bt(void)
>  	int i, c;
>  	ulong value, *cpus;
>          struct task_context *tc;
> -	int subsequent, active;
> +	int subsequent, active, panic;
>  	struct stack_hook hook;
>  	struct bt_info bt_info, bt_setup, *bt;
>  	struct reference reference;
> @@ -2412,7 +2412,7 @@ cmd_bt(void)
>  
>  	tc = NULL;
>  	cpus = NULL;
> -	subsequent = active = 0;
> +	subsequent = active = panic = 0;
>  	hook.eip = hook.esp = 0;
>  	refptr = 0;
>  	bt = &bt_info;
> @@ -2421,7 +2421,7 @@ cmd_bt(void)
>  	if (kt->flags & USE_OPT_BT)
>  		bt->flags |= BT_OPT_BACK_TRACE;
>  
> -	while ((c = getopt(argcnt, args, "D:fFI:S:c:aAloreEgstTdxR:Ov")) != EOF) {
> +	while ((c = getopt(argcnt, args, "D:fFI:S:c:aAloreEgstTdxR:Ovp")) != EOF) {
>                  switch (c)
>  		{
>  		case 'f':
> @@ -2609,6 +2609,14 @@ cmd_bt(void)
>  				option_not_supported(c);
>  			check_stack_overflow();
>  			return;
> +		case 'p':
> +			if (LIVE())
> +				error(FATAL,
> +				    "-p option not supported on a live system or live dump\n");
> +			if (!tt->panic_task)
> +				error(FATAL, "no panic task found!\n");
> +			panic++;
> +			break;
>  
>  		default:
>  			argerrs++;
> @@ -2748,7 +2756,10 @@ cmd_bt(void)
>  			tgid = task_tgid(CURRENT_TASK());
>  			DO_THREAD_GROUP_BACKTRACE();
>  		} else {
> -			tc = CURRENT_CONTEXT();
> +			if (panic)
> +				tc = task_to_context(tt->panic_task);
> +			else
> +				tc = CURRENT_CONTEXT();
>  			DO_TASK_BACKTRACE();
>  		}
>  		return;
> --
> 2.20.1
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
> 




More information about the Crash-utility mailing list