static int kdb_show_stack(struct task_struct *p, void *addr, int argcount) { /* Use KDB arch-specific backtraces for ia64 */ #ifdef CONFIG_IA64 return kdba_bt_process(p, argcount); #else /* Use the in-kernel backtraces */ int old_lvl = console_loglevel; console_loglevel = 15; kdba_set_current_task(p); if (addr) { show_stack((struct task_struct *)p, addr); } else if (kdb_current_regs) { #ifdef CONFIG_X86 show_stack(p, &kdb_current_regs->sp); #else show_stack(p, NULL); #endif } else { show_stack(p, NULL); } console_loglevel = old_lvl; return 0; #endif /* CONFIG_IA64 */ }
void do_print_all (stack *stack) { DEBUGS ('m', show_stack (stack)); int size = size_stack (stack); for (int index = 0; index < size; ++index) { print_bigint (peek_stack (stack, index)); } }
static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages, unsigned long uaddr, enum dma_data_direction direction) { u64 rc; union tce_entry tce; tcenum <<= TCE_PAGE_FACTOR; npages <<= TCE_PAGE_FACTOR; tce.te_word = 0; tce.te_rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; tce.te_rdwr = 1; if (direction != DMA_TO_DEVICE) tce.te_pciwr = 1; while (npages--) { rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, tce.te_word ); if (rc && printk_ratelimit()) { printk("tce_build_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); printk("\tindex = 0x%lx\n", (u64)tbl->it_index); printk("\ttcenum = 0x%lx\n", (u64)tcenum); printk("\ttce val = 0x%lx\n", tce.te_word ); show_stack(current, (unsigned long *)__get_SP()); } tcenum++; tce.te_rpn++; } }
static void showacpu(void *info) { spin_lock(&show_lock); printk("CPU%d:\n", smp_processor_id()); show_stack(NULL, NULL); spin_unlock(&show_lock); }
static void show_stack(lua_State* st, int n) { lua_Debug ar; if(lua_getstack(st, n, &ar) == 1) { lua_getinfo(st, "nSlu", &ar); const char* indent; if(n == 0) { indent = "->\t"; print_error(st, "\t<call stack>"); } else { indent = "\t"; } if(ar.name) print_error(st, "%s%s(): line %d [%s: line %d]", indent, ar.name, ar.currentline, ar.source, ar.linedefined); else print_error(st, "%sunknown: line %d [%s: line %d]", indent, ar.currentline, ar.source, ar.linedefined); show_stack(st, n + 1); } }
static void raise_backtrace_ipi(cpumask_t *mask) { unsigned int cpu; for_each_cpu(cpu, mask) { if (cpu == smp_processor_id()) handle_backtrace_ipi(NULL); else smp_send_safe_nmi_ipi(cpu, handle_backtrace_ipi, 5 * USEC_PER_SEC); } for_each_cpu(cpu, mask) { struct paca_struct *p = paca_ptrs[cpu]; cpumask_clear_cpu(cpu, mask); pr_warn("CPU %d didn't respond to backtrace IPI, inspecting paca.\n", cpu); if (!virt_addr_valid(p)) { pr_warn("paca pointer appears corrupt? (%px)\n", p); continue; } pr_warn("irq_soft_mask: 0x%02x in_mce: %d in_nmi: %d", p->irq_soft_mask, p->in_mce, p->in_nmi); if (virt_addr_valid(p->__current)) pr_cont(" current: %d (%s)\n", p->__current->pid, p->__current->comm); else pr_cont(" current pointer corrupt? (%px)\n", p->__current); pr_warn("Back trace of paca->saved_r1 (0x%016llx) (possibly stale):\n", p->saved_r1); show_stack(p->__current, (unsigned long *)p->saved_r1); } }
static void tce_free_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages) { u64 rc; union tce_entry tce; tcenum <<= TCE_PAGE_FACTOR; npages <<= TCE_PAGE_FACTOR; tce.te_word = 0; while (npages--) { rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, tce.te_word); if (rc && printk_ratelimit()) { printk("tce_free_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); printk("\tindex = 0x%lx\n", (u64)tbl->it_index); printk("\ttcenum = 0x%lx\n", (u64)tcenum); printk("\ttce val = 0x%lx\n", tce.te_word ); show_stack(current, (unsigned long *)__get_SP()); } tcenum++; } }
static void ShowStatus (void) { struct task_struct * task ; for_each_process(task) { printk_deferred("[Hang_Detect] %s found:%d.,RT[%lld]\n", task->comm, task->pid, sched_clock()); show_stack(task,NULL) ; } }
/* * f: bit0: show kernel , bit1: dump user. */ int tstack( int pid , int f) { struct pt_regs * preg; struct task_struct *t = FIND_TASK_BY_PID( pid ); if( !t ){ printk("NO task found for pid %d\n" ,pid ); t = current ; } preg = unwind_get_regs( t ); if( f& 1 ) { show_stack( t , NULL ); } if( !preg ) { printk("NO user stack found for task %s(%d)\n" , t->comm , t->pid ); } else { //printk("user stack found for task %s(%d):\n" , t->comm , t->pid ); __show_regs( preg ); if( f & 2 ) { #define SHOW_STACK_SIZE (2*1024) int len; unsigned int *ps = (unsigned int*)kmalloc( SHOW_STACK_SIZE , GFP_KERNEL); if( ps ) { len = access_process_vm( t , preg->ARM_sp , ps , SHOW_STACK_SIZE, 0 ); rk28_printk_mem( ps , len/4 , (unsigned int* )preg->ARM_sp ); kfree( ps ); } } } return pid; }
void print_backtrace_and_die(int sig, siginfo_t *info, void *secret) { ucontext_t *uc = secret; unsigned long ip, bp, sp, addr; ip = uc->uc_mcontext.gregs[IP_REG]; bp = uc->uc_mcontext.gregs[BP_REG]; sp = uc->uc_mcontext.gregs[SP_REG]; addr = (unsigned long) info->si_addr; switch (sig) { case SIGSEGV: trace_printf("SIGSEGV at %s %08lx while accessing memory address %08lx.\n", IP_REG_NAME, ip, addr); break; case SIGILL: trace_printf("SIGILL at %s %08lx\n", sig, IP_REG_NAME, ip); break; default: trace_printf("Signal %d at %s %08lx\n", sig, IP_REG_NAME, ip); break; }; show_registers(uc->uc_mcontext.gregs); show_stack((void *) sp); show_code((void *) ip); print_trace_from(ip, (void *) bp); trace_flush(); abort(); }
void snapdog_service(struct pt_regs *regs) { int the_dog_is_alive = 0; if (snapdog_kernel) { the_dog_is_alive = 1; } else if (!snapdog_service_required) { the_dog_is_alive = 1; } else if (snapdog_next < snapdog_last) { if (jiffies < snapdog_next || jiffies > snapdog_last) the_dog_is_alive = 1; } else if (jiffies >= snapdog_last && jiffies < snapdog_next) { the_dog_is_alive = 1; } if (the_dog_is_alive) poke_the_dog(); else if (!snapdog_warned) { snapdog_warned = 1; printk(KERN_CRIT "snapdog: expired, allowing system reboot.\n"); if (regs) { show_regs(regs); show_stack(regs); } the_dog_is_dead(); } }
void print_buffer_trace(struct buffer_head *bh) { #ifdef CONFIG_X86 extern void show_stack(unsigned long * esp); #endif unsigned long idx, count; unsigned long flags; printk("buffer trace for buffer at 0x%p (I am CPU %d)\n", bh, smp_processor_id()); BUFFER_TRACE(bh, ""); /* Record state now */ spin_lock_irqsave(&trace_lock, flags); for ( idx = bh->b_history.b_history_tail, count = 0; idx < bh->b_history.b_history_head && count < BUFFER_HISTORY_SIZE; idx++, count++) print_one_hist(bh->b_history.b + (idx & (BUFFER_HISTORY_SIZE - 1))); print_buffer_fields(bh); spin_unlock_irqrestore(&trace_lock, flags); #ifdef CONFIG_X86 show_stack(NULL); #endif printk("\n"); }
/* For user mode or the case KDB is not enabled, print basic debug messages */ void aee_dumpbasic(void) { struct task_struct *p = current; int orig_log_level = console_loglevel; preempt_disable(); console_loglevel = 7; LOGI("kernel : %s-%s\n", init_uts_ns.name.sysname, init_uts_ns.name.release); LOGI("version : %s\n", init_uts_ns.name.version); LOGI("machine : %s\n\n", init_uts_ns.name.machine); #ifdef CONFIG_SCHED_DEBUG sysrq_sched_debug_show(); #endif LOGI("\n%-*s Pid Parent Command\n", (int)(2 * sizeof(void *)) + 2, "Task Addr"); LOGI("0x%p %8d %8d %s\n\n", (void *)p, p->pid, p->parent->pid, p->comm); LOGI("Stack traceback for current pid %d\n", p->pid); show_stack(p, NULL); #ifdef CONFIG_MTK_AEE_IPANIC_64 aee_dumpnative(); #endif console_loglevel = orig_log_level; preempt_enable(); }
static void print_task(struct seq_file *m, struct rq *rq, struct task_struct *p) { if (rq->curr == p) SEQ_printf(m, "R"); else SEQ_printf(m, " "); SEQ_printf(m, "%15s %5d %9Ld.%06ld %9Ld %5d ", p->comm, p->pid, SPLIT_NS(p->se.vruntime), (long long)(p->nvcsw + p->nivcsw), p->prio); #ifdef CONFIG_SCHEDSTATS SEQ_printf(m, "%9Ld.%06ld %9Ld.%06ld %9Ld.%06ld", SPLIT_NS(p->se.vruntime), SPLIT_NS(p->se.sum_exec_runtime), SPLIT_NS(p->se.statistics.sum_sleep_runtime)); #else SEQ_printf(m, "%15Ld %15Ld %15Ld.%06ld %15Ld.%06ld %15Ld.%06ld", 0LL, 0LL, 0LL, 0L, 0LL, 0L, 0LL, 0L); #endif #ifdef CONFIG_CGROUP_SCHED SEQ_printf(m, " %s", task_group_path(task_group(p))); #endif SEQ_printf(m, "\n"); if (!m) show_stack(p, NULL); }
int check_bug_trap(struct pt_regs *regs) { struct bug_entry *bug; unsigned long addr; if (regs->msr & MSR_PR) return 0; /* not in kernel */ addr = regs->nip; /* address of trap instruction */ if (addr < PAGE_OFFSET) return 0; bug = find_bug(regs->nip); if (bug == NULL) return 0; if (bug->line & BUG_WARNING_TRAP) { /* this is a WARN_ON rather than BUG/BUG_ON */ printk(KERN_ERR "Badness in %s at %s:%d\n", bug->function, bug->file, (unsigned int)bug->line & ~BUG_WARNING_TRAP); show_stack(current, (void *)regs->gpr[1]); return 1; } printk(KERN_CRIT "kernel BUG in %s at %s:%d!\n", bug->function, bug->file, (unsigned int)bug->line); return 0; }
static void tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages, unsigned long uaddr, enum dma_data_direction direction) { u64 rc; u64 proto_tce, tce; u64 rpn; rpn = (virt_to_abs(uaddr)) >> TCE_SHIFT; proto_tce = TCE_PCI_READ; if (direction != DMA_TO_DEVICE) proto_tce |= TCE_PCI_WRITE; while (npages--) { tce = proto_tce | (rpn & TCE_RPN_MASK) << TCE_RPN_SHIFT; rc = plpar_tce_put((u64)tbl->it_index, (u64)tcenum << 12, tce); if (rc && printk_ratelimit()) { printk("tce_build_pSeriesLP: plpar_tce_put failed. rc=%ld\n", rc); printk("\tindex = 0x%lx\n", (u64)tbl->it_index); printk("\ttcenum = 0x%lx\n", (u64)tcenum); printk("\ttce val = 0x%lx\n", tce ); show_stack(current, (unsigned long *)__get_SP()); } tcenum++; rpn++; } }
void sched_show_task_local(struct task_struct *p) { unsigned long free = 0; int ppid; unsigned state; char stat_nam[] = TASK_STATE_TO_CHAR_STR; state = p->state ? __ffs(p->state) + 1 : 0; LOGE("%-15.15s %c", p->comm, state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?'); #if BITS_PER_LONG == 32 if (state == TASK_RUNNING) LOGE(" running "); else LOGE(" %08lx ", thread_saved_pc(p)); #else if (state == TASK_RUNNING) LOGE(" running task "); else LOGE(" %016lx ", thread_saved_pc(p)); #endif #ifdef CONFIG_DEBUG_STACK_USAGE free = stack_not_used(p); #endif rcu_read_lock(); ppid = task_pid_nr(rcu_dereference(p->real_parent)); rcu_read_unlock(); LOGE("%5lu %5d %6d 0x%08lx\n", free, task_pid_nr(p), ppid, (unsigned long)task_thread_info(p)->flags); print_worker_info(KERN_INFO, p); show_stack(p, NULL); }
static void dump_blocking_callstack(unsigned long nr) { struct blocking_monitor *bl_monitor = (struct blocking_monitor *)nr; pr_err("Start blocking callstack dump\n"); pr_err("Blocking callstack name is %s\n", bl_monitor->name); show_stack(bl_monitor->task, NULL); pr_err("End blocking callstack dump\n"); }
void show_regs(struct pt_regs *regs) { show_regs_print_info(KERN_DEFAULT); show_registers(regs); /* Show stack backtrace if pt_regs is from kernel mode */ if (!user_mode(regs)) show_stack(NULL, (unsigned long *) regs->gprs[15]); show_last_breaking_event(regs); }
static void ShowStatus(void) { struct task_struct * task ; show_free_areas_minimum () ; for_each_process(task) { LOGE("[Hang_Detect] %s found:%d.,RT[%lld]\n", task->comm, task->pid, sched_clock()); show_stack(task,NULL) ; } }
void do_print (stack *stack) { DEBUGS ('m', show_stack (stack)); if (empty_stack(stack)) { fprintf(stderr, "mydc: stack empty\n"); } else { print_bigint (peek_stack (stack, 0), stdout); } }
void do_binop (stack *stack, bigint_binop binop) { DEBUGS ('m', show_stack (stack)); bigint *right = pop_stack (stack); bigint *left = pop_stack (stack); bigint *answer = binop (left, right); push_stack (stack, answer); free_bigint (left); free_bigint (right); }
void do_binop (stack *stack, bigint_binop binop) { DEBUGS ('m', show_stack (stack)); bigint *right = pop_stack (stack); // bigint *left = pop_stack (stack); // take the two variables bigint *answer = binop (left, right); //do the binop passed push_stack (stack, answer); free_bigint (left); free_bigint (right); }
static void show_registers(struct pt_regs *regs) { show_regs(regs); printk(KERN_NOTICE "Process %s (pid: %d, stackpage=%08lx)\n", current->comm, current->pid, (unsigned long) current); show_stack(current_thread_info()->task, (long *) regs->regs[0]); show_trace((long *) regs->regs[0]); show_code((unsigned int *) regs->cp0_epc); printk(KERN_NOTICE "\n"); }
static void kdb_show_stack(struct task_struct *p, void *addr) { int old_lvl = console_loglevel; console_loglevel = 15; kdb_trap_printk++; kdb_set_current_task(p); if (addr) { show_stack((struct task_struct *)p, addr); } else if (kdb_current_regs) { #ifdef CONFIG_X86 show_stack(p, &kdb_current_regs->sp); #else show_stack(p, NULL); #endif } else { show_stack(p, NULL); } console_loglevel = old_lvl; kdb_trap_printk--; }
void dump_stack(void) { unsigned long stack; #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON int tflags; #endif trace_buffer_save(tflags); dump_bfin_trace_buffer(); show_stack(current, &stack); trace_buffer_restore(tflags); }
static void timeout_warning(unsigned long data) { struct timeout_data* d = (struct timeout_data*) data; pr_warn("suspend: %s stuck for %lu sec(s), dump call stack:\n", d->fname, d->timeout); show_stack(d->tsk, NULL); mod_timer(d->timer, jiffies + msecs_to_jiffies(1000 * d->timeout)); }
static void showacpu(void *dummy) { unsigned long flags; /* Idle CPUs have no interesting backtrace. */ if (idle_cpu(smp_processor_id())) return; spin_lock_irqsave(&show_lock, flags); printk(KERN_INFO "CPU%d:\n", smp_processor_id()); show_stack(NULL, NULL); spin_unlock_irqrestore(&show_lock, flags); }
void pm_wd_timeout(unsigned long data) { struct pm_wd_data *wd_data = (void *)data; struct task_struct *tsk = wd_data->tsk; pr_emerg("%s: PM watchdog timeout: %d seconds\n", __func__, wd_data->timeout); pr_emerg("stack:\n"); show_stack(tsk, NULL); BUG(); }
void debug_rt_mutex_print_deadlock(struct rt_mutex_waiter *waiter) { struct task_struct *task; if (!waiter->deadlock_lock || !debug_locks) return; rcu_read_lock(); task = pid_task(waiter->deadlock_task_pid, PIDTYPE_PID); if (!task) { rcu_read_unlock(); return; } if (!debug_locks_off()) { rcu_read_unlock(); return; } pr_warn("\n"); pr_warn("============================================\n"); pr_warn("WARNING: circular locking deadlock detected!\n"); pr_warn("%s\n", print_tainted()); pr_warn("--------------------------------------------\n"); printk("%s/%d is deadlocking current task %s/%d\n\n", task->comm, task_pid_nr(task), current->comm, task_pid_nr(current)); printk("\n1) %s/%d is trying to acquire this lock:\n", current->comm, task_pid_nr(current)); printk_lock(waiter->lock, 1); printk("\n2) %s/%d is blocked on this lock:\n", task->comm, task_pid_nr(task)); printk_lock(waiter->deadlock_lock, 1); debug_show_held_locks(current); debug_show_held_locks(task); printk("\n%s/%d's [blocked] stackdump:\n\n", task->comm, task_pid_nr(task)); show_stack(task, NULL); printk("\n%s/%d's [current] stackdump:\n\n", current->comm, task_pid_nr(current)); dump_stack(); debug_show_all_locks(); rcu_read_unlock(); printk("[ turning off deadlock detection." "Please report this trace. ]\n\n"); }