| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * stacktrace.c : stacktracing APIs needed by rest of kernel |
|---|
| 3 | 4 | * (wrappers over ARC dwarf based unwinder) |
|---|
| 4 | 5 | * |
|---|
| 5 | 6 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | 7 | * |
|---|
| 11 | 8 | * vineetg: aug 2009 |
|---|
| 12 | 9 | * -Implemented CONFIG_STACKTRACE APIs, primarily save_stack_trace_tsk( ) |
|---|
| .. | .. |
|---|
| 45 | 42 | seed_unwind_frame_info(struct task_struct *tsk, struct pt_regs *regs, |
|---|
| 46 | 43 | struct unwind_frame_info *frame_info) |
|---|
| 47 | 44 | { |
|---|
| 48 | | - /* |
|---|
| 49 | | - * synchronous unwinding (e.g. dump_stack) |
|---|
| 50 | | - * - uses current values of SP and friends |
|---|
| 51 | | - */ |
|---|
| 52 | | - if (regs == NULL && (tsk == NULL || tsk == current)) { |
|---|
| 45 | + if (regs) { |
|---|
| 46 | + /* |
|---|
| 47 | + * Asynchronous unwinding of intr/exception |
|---|
| 48 | + * - Just uses the pt_regs passed |
|---|
| 49 | + */ |
|---|
| 50 | + frame_info->task = tsk; |
|---|
| 51 | + |
|---|
| 52 | + frame_info->regs.r27 = regs->fp; |
|---|
| 53 | + frame_info->regs.r28 = regs->sp; |
|---|
| 54 | + frame_info->regs.r31 = regs->blink; |
|---|
| 55 | + frame_info->regs.r63 = regs->ret; |
|---|
| 56 | + frame_info->call_frame = 0; |
|---|
| 57 | + } else if (tsk == NULL || tsk == current) { |
|---|
| 58 | + /* |
|---|
| 59 | + * synchronous unwinding (e.g. dump_stack) |
|---|
| 60 | + * - uses current values of SP and friends |
|---|
| 61 | + */ |
|---|
| 53 | 62 | unsigned long fp, sp, blink, ret; |
|---|
| 54 | 63 | frame_info->task = current; |
|---|
| 55 | 64 | |
|---|
| .. | .. |
|---|
| 66 | 75 | frame_info->regs.r31 = blink; |
|---|
| 67 | 76 | frame_info->regs.r63 = ret; |
|---|
| 68 | 77 | frame_info->call_frame = 0; |
|---|
| 69 | | - } else if (regs == NULL) { |
|---|
| 78 | + } else { |
|---|
| 70 | 79 | /* |
|---|
| 71 | 80 | * Asynchronous unwinding of a likely sleeping task |
|---|
| 72 | 81 | * - first ensure it is actually sleeping |
|---|
| .. | .. |
|---|
| 97 | 106 | frame_info->regs.r28 += 60; |
|---|
| 98 | 107 | frame_info->call_frame = 0; |
|---|
| 99 | 108 | |
|---|
| 100 | | - } else { |
|---|
| 101 | | - /* |
|---|
| 102 | | - * Asynchronous unwinding of intr/exception |
|---|
| 103 | | - * - Just uses the pt_regs passed |
|---|
| 104 | | - */ |
|---|
| 105 | | - frame_info->task = tsk; |
|---|
| 106 | | - |
|---|
| 107 | | - frame_info->regs.r27 = regs->fp; |
|---|
| 108 | | - frame_info->regs.r28 = regs->sp; |
|---|
| 109 | | - frame_info->regs.r31 = regs->blink; |
|---|
| 110 | | - frame_info->regs.r63 = regs->ret; |
|---|
| 111 | | - frame_info->call_frame = 0; |
|---|
| 112 | 109 | } |
|---|
| 113 | | - |
|---|
| 114 | 110 | return 0; |
|---|
| 115 | 111 | } |
|---|
| 116 | 112 | |
|---|
| .. | .. |
|---|
| 173 | 169 | /* Call-back which plugs into unwinding core to dump the stack in |
|---|
| 174 | 170 | * case of panic/OOPs/BUG etc |
|---|
| 175 | 171 | */ |
|---|
| 176 | | -static int __print_sym(unsigned int address, void *unused) |
|---|
| 172 | +static int __print_sym(unsigned int address, void *arg) |
|---|
| 177 | 173 | { |
|---|
| 178 | | - printk(" %pS\n", (void *)address); |
|---|
| 174 | + const char *loglvl = arg; |
|---|
| 175 | + |
|---|
| 176 | + printk("%s %pS\n", loglvl, (void *)address); |
|---|
| 179 | 177 | return 0; |
|---|
| 180 | 178 | } |
|---|
| 181 | 179 | |
|---|
| .. | .. |
|---|
| 232 | 230 | *------------------------------------------------------------------------- |
|---|
| 233 | 231 | */ |
|---|
| 234 | 232 | |
|---|
| 235 | | -noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs) |
|---|
| 233 | +noinline void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs, |
|---|
| 234 | + const char *loglvl) |
|---|
| 236 | 235 | { |
|---|
| 237 | | - pr_info("\nStack Trace:\n"); |
|---|
| 238 | | - arc_unwind_core(tsk, regs, __print_sym, NULL); |
|---|
| 236 | + printk("%s\nStack Trace:\n", loglvl); |
|---|
| 237 | + arc_unwind_core(tsk, regs, __print_sym, (void *)loglvl); |
|---|
| 239 | 238 | } |
|---|
| 240 | 239 | EXPORT_SYMBOL(show_stacktrace); |
|---|
| 241 | 240 | |
|---|
| 242 | 241 | /* Expected by sched Code */ |
|---|
| 243 | | -void show_stack(struct task_struct *tsk, unsigned long *sp) |
|---|
| 242 | +void show_stack(struct task_struct *tsk, unsigned long *sp, const char *loglvl) |
|---|
| 244 | 243 | { |
|---|
| 245 | | - show_stacktrace(tsk, NULL); |
|---|
| 244 | + show_stacktrace(tsk, NULL, loglvl); |
|---|
| 246 | 245 | } |
|---|
| 247 | 246 | |
|---|
| 248 | 247 | /* Another API expected by schedular, shows up in "ps" as Wait Channel |
|---|