mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
ANDROID: fiq_debugger: Call fiq_debugger_printf through a function pointer from cpu specific code
This allows the output from the register and stack trace code to be sent elsewhere. Change-Id: I41bb0d5a25e1b9ca55feef5dbd675818b2f832d5 Signed-off-by: Arve Hjønnevåg <arve@android.com>
This commit is contained in:
committed by
Dmitry Shmidt
parent
516b14de21
commit
e073df6886
@@ -54,6 +54,7 @@ struct fiq_debugger_state {
|
||||
#ifdef CONFIG_FIQ_GLUE
|
||||
struct fiq_glue_handler handler;
|
||||
#endif
|
||||
struct fiq_debugger_output output;
|
||||
|
||||
int fiq;
|
||||
int uart_irq;
|
||||
@@ -229,18 +230,19 @@ static void fiq_debugger_dump_kernel_log(struct fiq_debugger_state *state)
|
||||
}
|
||||
}
|
||||
|
||||
int fiq_debugger_printf(void *cookie, const char *fmt, ...)
|
||||
static void fiq_debugger_printf(struct fiq_debugger_output *output,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
struct fiq_debugger_state *state = cookie;
|
||||
struct fiq_debugger_state *state;
|
||||
char buf[256];
|
||||
va_list ap;
|
||||
|
||||
state = container_of(output, struct fiq_debugger_state, output);
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fiq_debugger_puts(state, buf);
|
||||
return state->debug_abort;
|
||||
}
|
||||
|
||||
/* Safe outside fiq context */
|
||||
@@ -267,13 +269,13 @@ static void fiq_debugger_dump_irqs(struct fiq_debugger_state *state)
|
||||
int n;
|
||||
struct irq_desc *desc;
|
||||
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
"irqnr total since-last status name\n");
|
||||
for_each_irq_desc(n, desc) {
|
||||
struct irqaction *act = desc->action;
|
||||
if (!act && !kstat_irqs(n))
|
||||
continue;
|
||||
fiq_debugger_printf(state, "%5d: %10u %11u %8x %s\n", n,
|
||||
fiq_debugger_printf(&state->output, "%5d: %10u %11u %8x %s\n", n,
|
||||
kstat_irqs(n),
|
||||
kstat_irqs(n) - state->last_irqs[n],
|
||||
desc->status_use_accessors,
|
||||
@@ -289,18 +291,18 @@ static void fiq_debugger_do_ps(struct fiq_debugger_state *state)
|
||||
unsigned task_state;
|
||||
static const char stat_nam[] = "RSDTtZX";
|
||||
|
||||
fiq_debugger_printf(state, "pid ppid prio task pc\n");
|
||||
fiq_debugger_printf(&state->output, "pid ppid prio task pc\n");
|
||||
read_lock(&tasklist_lock);
|
||||
do_each_thread(g, p) {
|
||||
task_state = p->state ? __ffs(p->state) + 1 : 0;
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
"%5d %5d %4d ", p->pid, p->parent->pid, p->prio);
|
||||
fiq_debugger_printf(state, "%-13.13s %c", p->comm,
|
||||
fiq_debugger_printf(&state->output, "%-13.13s %c", p->comm,
|
||||
task_state >= sizeof(stat_nam) ? '?' : stat_nam[task_state]);
|
||||
if (task_state == TASK_RUNNING)
|
||||
fiq_debugger_printf(state, " running\n");
|
||||
fiq_debugger_printf(&state->output, " running\n");
|
||||
else
|
||||
fiq_debugger_printf(state, " %08lx\n",
|
||||
fiq_debugger_printf(&state->output, " %08lx\n",
|
||||
thread_saved_pc(p));
|
||||
} while_each_thread(g, p);
|
||||
read_unlock(&tasklist_lock);
|
||||
@@ -332,7 +334,7 @@ static void fiq_debugger_end_syslog_dump(struct fiq_debugger_state *state)
|
||||
static void fiq_debugger_do_sysrq(struct fiq_debugger_state *state, char rq)
|
||||
{
|
||||
if ((rq == 'g' || rq == 'G') && !fiq_kgdb_enable) {
|
||||
fiq_debugger_printf(state, "sysrq-g blocked\n");
|
||||
fiq_debugger_printf(&state->output, "sysrq-g blocked\n");
|
||||
return;
|
||||
}
|
||||
fiq_debugger_begin_syslog_dump(state);
|
||||
@@ -344,11 +346,11 @@ static void fiq_debugger_do_sysrq(struct fiq_debugger_state *state, char rq)
|
||||
static void fiq_debugger_do_kgdb(struct fiq_debugger_state *state)
|
||||
{
|
||||
if (!fiq_kgdb_enable) {
|
||||
fiq_debugger_printf(state, "kgdb through fiq debugger not enabled\n");
|
||||
fiq_debugger_printf(&state->output, "kgdb through fiq debugger not enabled\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fiq_debugger_printf(state, "enabling console and triggering kgdb\n");
|
||||
fiq_debugger_printf(&state->output, "enabling console and triggering kgdb\n");
|
||||
state->console_enable = true;
|
||||
handle_sysrq('g');
|
||||
}
|
||||
@@ -361,7 +363,7 @@ static void fiq_debugger_schedule_work(struct fiq_debugger_state *state,
|
||||
|
||||
spin_lock_irqsave(&state->work_lock, flags);
|
||||
if (state->work_cmd[0] != '\0') {
|
||||
fiq_debugger_printf(state, "work command processor busy\n");
|
||||
fiq_debugger_printf(&state->output, "work command processor busy\n");
|
||||
spin_unlock_irqrestore(&state->work_lock, flags);
|
||||
return;
|
||||
}
|
||||
@@ -398,7 +400,7 @@ static void fiq_debugger_work(struct work_struct *work)
|
||||
else
|
||||
kernel_restart(NULL);
|
||||
} else {
|
||||
fiq_debugger_printf(state, "unknown work command '%s'\n",
|
||||
fiq_debugger_printf(&state->output, "unknown work command '%s'\n",
|
||||
work_cmd);
|
||||
}
|
||||
}
|
||||
@@ -422,7 +424,7 @@ static void fiq_debugger_irq_exec(struct fiq_debugger_state *state, char *cmd)
|
||||
|
||||
static void fiq_debugger_help(struct fiq_debugger_state *state)
|
||||
{
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
"FIQ Debugger commands:\n"
|
||||
" pc PC status\n"
|
||||
" regs Register dump\n"
|
||||
@@ -433,18 +435,18 @@ static void fiq_debugger_help(struct fiq_debugger_state *state)
|
||||
" irqs Interupt status\n"
|
||||
" kmsg Kernel log\n"
|
||||
" version Kernel version\n");
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
" sleep Allow sleep while in FIQ\n"
|
||||
" nosleep Disable sleep while in FIQ\n"
|
||||
" console Switch terminal to console\n"
|
||||
" cpu Current CPU\n"
|
||||
" cpu <number> Switch to CPU<number>\n");
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
" ps Process list\n"
|
||||
" sysrq sysrq options\n"
|
||||
" sysrq <param> Execute sysrq with <param>\n");
|
||||
#ifdef CONFIG_KGDB
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
" kgdb Enter kernel debugger\n");
|
||||
#endif
|
||||
}
|
||||
@@ -477,13 +479,13 @@ static bool fiq_debugger_fiq_exec(struct fiq_debugger_state *state,
|
||||
if (!strcmp(cmd, "help") || !strcmp(cmd, "?")) {
|
||||
fiq_debugger_help(state);
|
||||
} else if (!strcmp(cmd, "pc")) {
|
||||
fiq_debugger_dump_pc(state, regs);
|
||||
fiq_debugger_dump_pc(&state->output, regs);
|
||||
} else if (!strcmp(cmd, "regs")) {
|
||||
fiq_debugger_dump_regs(state, regs);
|
||||
fiq_debugger_dump_regs(&state->output, regs);
|
||||
} else if (!strcmp(cmd, "allregs")) {
|
||||
fiq_debugger_dump_allregs(state, regs);
|
||||
fiq_debugger_dump_allregs(&state->output, regs);
|
||||
} else if (!strcmp(cmd, "bt")) {
|
||||
fiq_debugger_dump_stacktrace(state, regs, 100, svc_sp);
|
||||
fiq_debugger_dump_stacktrace(&state->output, regs, 100, svc_sp);
|
||||
} else if (!strncmp(cmd, "reset", 5)) {
|
||||
cmd += 5;
|
||||
while (*cmd == ' ')
|
||||
@@ -500,29 +502,29 @@ static bool fiq_debugger_fiq_exec(struct fiq_debugger_state *state,
|
||||
} else if (!strcmp(cmd, "kmsg")) {
|
||||
fiq_debugger_dump_kernel_log(state);
|
||||
} else if (!strcmp(cmd, "version")) {
|
||||
fiq_debugger_printf(state, "%s\n", linux_banner);
|
||||
fiq_debugger_printf(&state->output, "%s\n", linux_banner);
|
||||
} else if (!strcmp(cmd, "sleep")) {
|
||||
state->no_sleep = false;
|
||||
fiq_debugger_printf(state, "enabling sleep\n");
|
||||
fiq_debugger_printf(&state->output, "enabling sleep\n");
|
||||
} else if (!strcmp(cmd, "nosleep")) {
|
||||
state->no_sleep = true;
|
||||
fiq_debugger_printf(state, "disabling sleep\n");
|
||||
fiq_debugger_printf(&state->output, "disabling sleep\n");
|
||||
} else if (!strcmp(cmd, "console")) {
|
||||
fiq_debugger_printf(state, "console mode\n");
|
||||
fiq_debugger_printf(&state->output, "console mode\n");
|
||||
fiq_debugger_uart_flush(state);
|
||||
state->console_enable = true;
|
||||
} else if (!strcmp(cmd, "cpu")) {
|
||||
fiq_debugger_printf(state, "cpu %d\n", state->current_cpu);
|
||||
fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
|
||||
} else if (!strncmp(cmd, "cpu ", 4)) {
|
||||
unsigned long cpu = 0;
|
||||
if (strict_strtoul(cmd + 4, 10, &cpu) == 0)
|
||||
fiq_debugger_switch_cpu(state, cpu);
|
||||
else
|
||||
fiq_debugger_printf(state, "invalid cpu\n");
|
||||
fiq_debugger_printf(state, "cpu %d\n", state->current_cpu);
|
||||
fiq_debugger_printf(&state->output, "invalid cpu\n");
|
||||
fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
|
||||
} else {
|
||||
if (state->debug_busy) {
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
"command processor busy. trying to abort.\n");
|
||||
state->debug_abort = -1;
|
||||
} else {
|
||||
@@ -645,7 +647,7 @@ static bool fiq_debugger_handle_uart_interrupt(struct fiq_debugger_state *state,
|
||||
MAX_UNHANDLED_FIQ_COUNT)
|
||||
return false;
|
||||
|
||||
fiq_debugger_printf(state,
|
||||
fiq_debugger_printf(&state->output,
|
||||
"fiq_debugger: cpu %d not responding, "
|
||||
"reverting to cpu %d\n", state->current_cpu,
|
||||
this_cpu);
|
||||
@@ -1053,6 +1055,7 @@ static int fiq_debugger_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
|
||||
state = kzalloc(sizeof(*state), GFP_KERNEL);
|
||||
state->output.printf = fiq_debugger_printf;
|
||||
setup_timer(&state->sleep_timer, fiq_debugger_sleep_timer_expired,
|
||||
(unsigned long)state);
|
||||
state->pdata = pdata;
|
||||
|
||||
@@ -34,27 +34,27 @@ static char *mode_name(unsigned cpsr)
|
||||
}
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
fiq_debugger_printf(state, " pc %08x cpsr %08x mode %s\n",
|
||||
output->printf(output, " pc %08x cpsr %08x mode %s\n",
|
||||
regs->ARM_pc, regs->ARM_cpsr, mode_name(regs->ARM_cpsr));
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" r0 %08x r1 %08x r2 %08x r3 %08x\n",
|
||||
regs->ARM_r0, regs->ARM_r1, regs->ARM_r2, regs->ARM_r3);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" r4 %08x r5 %08x r6 %08x r7 %08x\n",
|
||||
regs->ARM_r4, regs->ARM_r5, regs->ARM_r6, regs->ARM_r7);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n",
|
||||
regs->ARM_r8, regs->ARM_r9, regs->ARM_r10, regs->ARM_fp,
|
||||
mode_name(regs->ARM_cpsr));
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" ip %08x sp %08x lr %08x pc %08x cpsr %08x\n",
|
||||
regs->ARM_ip, regs->ARM_sp, regs->ARM_lr, regs->ARM_pc,
|
||||
regs->ARM_cpsr);
|
||||
@@ -112,43 +112,43 @@ static void __naked get_mode_regs(struct mode_regs *regs)
|
||||
}
|
||||
|
||||
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
struct mode_regs mode_regs;
|
||||
unsigned long mode = regs->ARM_cpsr & MODE_MASK;
|
||||
|
||||
fiq_debugger_dump_regs(state, regs);
|
||||
fiq_debugger_dump_regs(output, regs);
|
||||
get_mode_regs(&mode_regs);
|
||||
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
"%csvc: sp %08x lr %08x spsr %08x\n",
|
||||
mode == SVC_MODE ? '*' : ' ',
|
||||
mode_regs.sp_svc, mode_regs.lr_svc, mode_regs.spsr_svc);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
"%cabt: sp %08x lr %08x spsr %08x\n",
|
||||
mode == ABT_MODE ? '*' : ' ',
|
||||
mode_regs.sp_abt, mode_regs.lr_abt, mode_regs.spsr_abt);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
"%cund: sp %08x lr %08x spsr %08x\n",
|
||||
mode == UND_MODE ? '*' : ' ',
|
||||
mode_regs.sp_und, mode_regs.lr_und, mode_regs.spsr_und);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
"%cirq: sp %08x lr %08x spsr %08x\n",
|
||||
mode == IRQ_MODE ? '*' : ' ',
|
||||
mode_regs.sp_irq, mode_regs.lr_irq, mode_regs.spsr_irq);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
"%cfiq: r8 %08x r9 %08x r10 %08x r11 %08x r12 %08x\n",
|
||||
mode == FIQ_MODE ? '*' : ' ',
|
||||
mode_regs.r8_fiq, mode_regs.r9_fiq, mode_regs.r10_fiq,
|
||||
mode_regs.r11_fiq, mode_regs.r12_fiq);
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" fiq: sp %08x lr %08x spsr %08x\n",
|
||||
mode_regs.sp_fiq, mode_regs.lr_fiq, mode_regs.spsr_fiq);
|
||||
}
|
||||
|
||||
struct stacktrace_state {
|
||||
struct fiq_debugger_state *state;
|
||||
struct fiq_debugger_output *output;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
@@ -157,14 +157,14 @@ static int report_trace(struct stackframe *frame, void *d)
|
||||
struct stacktrace_state *sts = d;
|
||||
|
||||
if (sts->depth) {
|
||||
fiq_debugger_printf(sts->state,
|
||||
sts->output->printf(sts->output,
|
||||
" pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
|
||||
frame->pc, frame->pc, frame->lr, frame->lr,
|
||||
frame->sp, frame->fp);
|
||||
sts->depth--;
|
||||
return 0;
|
||||
}
|
||||
fiq_debugger_printf(sts->state, " ...\n");
|
||||
sts->output->printf(sts->output, " ...\n");
|
||||
|
||||
return sts->depth == 0;
|
||||
}
|
||||
@@ -175,24 +175,24 @@ struct frame_tail {
|
||||
unsigned long lr;
|
||||
} __attribute__((packed));
|
||||
|
||||
static struct frame_tail *user_backtrace(struct fiq_debugger_state *state,
|
||||
static struct frame_tail *user_backtrace(struct fiq_debugger_output *output,
|
||||
struct frame_tail *tail)
|
||||
{
|
||||
struct frame_tail buftail[2];
|
||||
|
||||
/* Also check accessibility of one struct frame_tail beyond */
|
||||
if (!access_ok(VERIFY_READ, tail, sizeof(buftail))) {
|
||||
fiq_debugger_printf(state, " invalid frame pointer %p\n",
|
||||
output->printf(output, " invalid frame pointer %p\n",
|
||||
tail);
|
||||
return NULL;
|
||||
}
|
||||
if (__copy_from_user_inatomic(buftail, tail, sizeof(buftail))) {
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" failed to copy frame pointer %p\n", tail);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fiq_debugger_printf(state, " %p\n", buftail[0].lr);
|
||||
output->printf(output, " %p\n", buftail[0].lr);
|
||||
|
||||
/* frame pointers should strictly progress back up the stack
|
||||
* (towards higher addresses) */
|
||||
@@ -202,7 +202,7 @@ static struct frame_tail *user_backtrace(struct fiq_debugger_state *state,
|
||||
return buftail[0].fp-1;
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs, unsigned int depth, void *ssp)
|
||||
{
|
||||
struct frame_tail *tail;
|
||||
@@ -210,15 +210,15 @@ void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
struct stacktrace_state sts;
|
||||
|
||||
sts.depth = depth;
|
||||
sts.state = state;
|
||||
sts.output = output;
|
||||
*current_thread_info() = *real_thread_info;
|
||||
|
||||
if (!current)
|
||||
fiq_debugger_printf(state, "current NULL\n");
|
||||
output->printf(output, "current NULL\n");
|
||||
else
|
||||
fiq_debugger_printf(state, "pid: %d comm: %s\n",
|
||||
output->printf(output, "pid: %d comm: %s\n",
|
||||
current->pid, current->comm);
|
||||
fiq_debugger_dump_regs(state, regs);
|
||||
fiq_debugger_dump_regs(output, regs);
|
||||
|
||||
if (!user_mode(regs)) {
|
||||
struct stackframe frame;
|
||||
@@ -226,7 +226,7 @@ void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
frame.sp = regs->ARM_sp;
|
||||
frame.lr = regs->ARM_lr;
|
||||
frame.pc = regs->ARM_pc;
|
||||
fiq_debugger_printf(state,
|
||||
output->printf(output,
|
||||
" pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
|
||||
regs->ARM_pc, regs->ARM_pc, regs->ARM_lr, regs->ARM_lr,
|
||||
regs->ARM_sp, regs->ARM_fp);
|
||||
@@ -236,5 +236,5 @@ void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
|
||||
tail = ((struct frame_tail *) regs->ARM_fp) - 1;
|
||||
while (depth-- && tail && !((unsigned long) tail & 3))
|
||||
tail = user_backtrace(state, tail);
|
||||
tail = user_backtrace(output, tail);
|
||||
}
|
||||
|
||||
@@ -34,79 +34,79 @@ static char *mode_name(const struct pt_regs *regs)
|
||||
}
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
fiq_debugger_printf(state, " pc %016lx cpsr %08lx mode %s\n",
|
||||
output->printf(output, " pc %016lx cpsr %08lx mode %s\n",
|
||||
regs->pc, regs->pstate, mode_name(regs));
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_regs_aarch32(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_regs_aarch32(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
fiq_debugger_printf(state, " r0 %08x r1 %08x r2 %08x r3 %08x\n",
|
||||
output->printf(output, " r0 %08x r1 %08x r2 %08x r3 %08x\n",
|
||||
regs->compat_usr(0), regs->compat_usr(1),
|
||||
regs->compat_usr(2), regs->compat_usr(3));
|
||||
fiq_debugger_printf(state, " r4 %08x r5 %08x r6 %08x r7 %08x\n",
|
||||
output->printf(output, " r4 %08x r5 %08x r6 %08x r7 %08x\n",
|
||||
regs->compat_usr(4), regs->compat_usr(5),
|
||||
regs->compat_usr(6), regs->compat_usr(7));
|
||||
fiq_debugger_printf(state, " r8 %08x r9 %08x r10 %08x r11 %08x\n",
|
||||
output->printf(output, " r8 %08x r9 %08x r10 %08x r11 %08x\n",
|
||||
regs->compat_usr(8), regs->compat_usr(9),
|
||||
regs->compat_usr(10), regs->compat_usr(11));
|
||||
fiq_debugger_printf(state, " ip %08x sp %08x lr %08x pc %08x\n",
|
||||
output->printf(output, " ip %08x sp %08x lr %08x pc %08x\n",
|
||||
regs->compat_usr(12), regs->compat_sp,
|
||||
regs->compat_lr, regs->pc);
|
||||
fiq_debugger_printf(state, " cpsr %08x (%s)\n",
|
||||
output->printf(output, " cpsr %08x (%s)\n",
|
||||
regs->pstate, mode_name(regs));
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_regs_aarch64(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_regs_aarch64(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
|
||||
fiq_debugger_printf(state, " x0 %016lx x1 %016lx\n",
|
||||
output->printf(output, " x0 %016lx x1 %016lx\n",
|
||||
regs->regs[0], regs->regs[1]);
|
||||
fiq_debugger_printf(state, " x2 %016lx x3 %016lx\n",
|
||||
output->printf(output, " x2 %016lx x3 %016lx\n",
|
||||
regs->regs[2], regs->regs[3]);
|
||||
fiq_debugger_printf(state, " x4 %016lx x5 %016lx\n",
|
||||
output->printf(output, " x4 %016lx x5 %016lx\n",
|
||||
regs->regs[4], regs->regs[5]);
|
||||
fiq_debugger_printf(state, " x6 %016lx x7 %016lx\n",
|
||||
output->printf(output, " x6 %016lx x7 %016lx\n",
|
||||
regs->regs[6], regs->regs[7]);
|
||||
fiq_debugger_printf(state, " x8 %016lx x9 %016lx\n",
|
||||
output->printf(output, " x8 %016lx x9 %016lx\n",
|
||||
regs->regs[8], regs->regs[9]);
|
||||
fiq_debugger_printf(state, " x10 %016lx x11 %016lx\n",
|
||||
output->printf(output, " x10 %016lx x11 %016lx\n",
|
||||
regs->regs[10], regs->regs[11]);
|
||||
fiq_debugger_printf(state, " x12 %016lx x13 %016lx\n",
|
||||
output->printf(output, " x12 %016lx x13 %016lx\n",
|
||||
regs->regs[12], regs->regs[13]);
|
||||
fiq_debugger_printf(state, " x14 %016lx x15 %016lx\n",
|
||||
output->printf(output, " x14 %016lx x15 %016lx\n",
|
||||
regs->regs[14], regs->regs[15]);
|
||||
fiq_debugger_printf(state, " x16 %016lx x17 %016lx\n",
|
||||
output->printf(output, " x16 %016lx x17 %016lx\n",
|
||||
regs->regs[16], regs->regs[17]);
|
||||
fiq_debugger_printf(state, " x18 %016lx x19 %016lx\n",
|
||||
output->printf(output, " x18 %016lx x19 %016lx\n",
|
||||
regs->regs[18], regs->regs[19]);
|
||||
fiq_debugger_printf(state, " x20 %016lx x21 %016lx\n",
|
||||
output->printf(output, " x20 %016lx x21 %016lx\n",
|
||||
regs->regs[20], regs->regs[21]);
|
||||
fiq_debugger_printf(state, " x22 %016lx x23 %016lx\n",
|
||||
output->printf(output, " x22 %016lx x23 %016lx\n",
|
||||
regs->regs[22], regs->regs[23]);
|
||||
fiq_debugger_printf(state, " x24 %016lx x25 %016lx\n",
|
||||
output->printf(output, " x24 %016lx x25 %016lx\n",
|
||||
regs->regs[24], regs->regs[25]);
|
||||
fiq_debugger_printf(state, " x26 %016lx x27 %016lx\n",
|
||||
output->printf(output, " x26 %016lx x27 %016lx\n",
|
||||
regs->regs[26], regs->regs[27]);
|
||||
fiq_debugger_printf(state, " x28 %016lx x29 %016lx\n",
|
||||
output->printf(output, " x28 %016lx x29 %016lx\n",
|
||||
regs->regs[28], regs->regs[29]);
|
||||
fiq_debugger_printf(state, " x30 %016lx sp %016lx\n",
|
||||
output->printf(output, " x30 %016lx sp %016lx\n",
|
||||
regs->regs[30], regs->sp);
|
||||
fiq_debugger_printf(state, " pc %016lx cpsr %08x (%s)\n",
|
||||
output->printf(output, " pc %016lx cpsr %08x (%s)\n",
|
||||
regs->pc, regs->pstate, mode_name(regs));
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
if (compat_user_mode(regs))
|
||||
fiq_debugger_dump_regs_aarch32(state, regs);
|
||||
fiq_debugger_dump_regs_aarch32(output, regs);
|
||||
else
|
||||
fiq_debugger_dump_regs_aarch64(state, regs);
|
||||
fiq_debugger_dump_regs_aarch64(output, regs);
|
||||
}
|
||||
|
||||
#define READ_SPECIAL_REG(x) ({ \
|
||||
@@ -115,45 +115,45 @@ void fiq_debugger_dump_regs(struct fiq_debugger_state *state,
|
||||
val; \
|
||||
})
|
||||
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs)
|
||||
{
|
||||
u32 pstate = READ_SPECIAL_REG(CurrentEl);
|
||||
bool in_el2 = (pstate & PSR_MODE_MASK) >= PSR_MODE_EL2t;
|
||||
|
||||
fiq_debugger_dump_regs(state, regs);
|
||||
fiq_debugger_dump_regs(output, regs);
|
||||
|
||||
fiq_debugger_printf(state, " sp_el0 %016lx\n",
|
||||
output->printf(output, " sp_el0 %016lx\n",
|
||||
READ_SPECIAL_REG(sp_el0));
|
||||
|
||||
if (in_el2)
|
||||
fiq_debugger_printf(state, " sp_el1 %016lx\n",
|
||||
output->printf(output, " sp_el1 %016lx\n",
|
||||
READ_SPECIAL_REG(sp_el1));
|
||||
|
||||
fiq_debugger_printf(state, " elr_el1 %016lx\n",
|
||||
output->printf(output, " elr_el1 %016lx\n",
|
||||
READ_SPECIAL_REG(elr_el1));
|
||||
|
||||
fiq_debugger_printf(state, " spsr_el1 %08lx\n",
|
||||
output->printf(output, " spsr_el1 %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_el1));
|
||||
|
||||
if (in_el2) {
|
||||
fiq_debugger_printf(state, " spsr_irq %08lx\n",
|
||||
output->printf(output, " spsr_irq %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_irq));
|
||||
fiq_debugger_printf(state, " spsr_abt %08lx\n",
|
||||
output->printf(output, " spsr_abt %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_abt));
|
||||
fiq_debugger_printf(state, " spsr_und %08lx\n",
|
||||
output->printf(output, " spsr_und %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_und));
|
||||
fiq_debugger_printf(state, " spsr_fiq %08lx\n",
|
||||
output->printf(output, " spsr_fiq %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_fiq));
|
||||
fiq_debugger_printf(state, " spsr_el2 %08lx\n",
|
||||
output->printf(output, " spsr_el2 %08lx\n",
|
||||
READ_SPECIAL_REG(elr_el2));
|
||||
fiq_debugger_printf(state, " spsr_el2 %08lx\n",
|
||||
output->printf(output, " spsr_el2 %08lx\n",
|
||||
READ_SPECIAL_REG(spsr_el2));
|
||||
}
|
||||
}
|
||||
|
||||
struct stacktrace_state {
|
||||
struct fiq_debugger_state *state;
|
||||
struct fiq_debugger_output *output;
|
||||
unsigned int depth;
|
||||
};
|
||||
|
||||
@@ -162,41 +162,41 @@ static int report_trace(struct stackframe *frame, void *d)
|
||||
struct stacktrace_state *sts = d;
|
||||
|
||||
if (sts->depth) {
|
||||
fiq_debugger_printf(sts->state, "%pF:\n", frame->pc);
|
||||
fiq_debugger_printf(sts->state,
|
||||
sts->output->printf(sts->output, "%pF:\n", frame->pc);
|
||||
sts->output->printf(sts->output,
|
||||
" pc %016lx sp %016lx fp %016lx\n",
|
||||
frame->pc, frame->sp, frame->fp);
|
||||
sts->depth--;
|
||||
return 0;
|
||||
}
|
||||
fiq_debugger_printf(sts->state, " ...\n");
|
||||
sts->output->printf(sts->output, " ...\n");
|
||||
|
||||
return sts->depth == 0;
|
||||
}
|
||||
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs, unsigned int depth, void *ssp)
|
||||
{
|
||||
struct thread_info *real_thread_info = THREAD_INFO(ssp);
|
||||
struct stacktrace_state sts;
|
||||
|
||||
sts.depth = depth;
|
||||
sts.state = state;
|
||||
sts.output = output;
|
||||
*current_thread_info() = *real_thread_info;
|
||||
|
||||
if (!current)
|
||||
fiq_debugger_printf(state, "current NULL\n");
|
||||
output->printf(output, "current NULL\n");
|
||||
else
|
||||
fiq_debugger_printf(state, "pid: %d comm: %s\n",
|
||||
output->printf(output, "pid: %d comm: %s\n",
|
||||
current->pid, current->comm);
|
||||
fiq_debugger_dump_regs(state, regs);
|
||||
fiq_debugger_dump_regs(output, regs);
|
||||
|
||||
if (!user_mode(regs)) {
|
||||
struct stackframe frame;
|
||||
frame.fp = regs->regs[29];
|
||||
frame.sp = regs->sp;
|
||||
frame.pc = regs->pc;
|
||||
fiq_debugger_printf(state, "\n");
|
||||
output->printf(output, "\n");
|
||||
walk_stackframe(&frame, report_trace, &sts);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,19 @@
|
||||
#define THREAD_INFO(sp) ((struct thread_info *) \
|
||||
((unsigned long)(sp) & ~(THREAD_SIZE - 1)))
|
||||
|
||||
struct fiq_debugger_state;
|
||||
struct fiq_debugger_output {
|
||||
void (*printf)(struct fiq_debugger_output *output, const char *fmt, ...);
|
||||
};
|
||||
|
||||
struct pt_regs;
|
||||
|
||||
int fiq_debugger_printf(void *cookie, const char *fmt, ...);
|
||||
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_pc(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs);
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_regs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs);
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_allregs(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs);
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_state *state,
|
||||
void fiq_debugger_dump_stacktrace(struct fiq_debugger_output *output,
|
||||
const struct pt_regs *regs, unsigned int depth, void *ssp);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user