Make arm26 implementation of DDB slightly less gratuitously different from the

ARM one.  Also update for recent undefined-instruction handler changes.
This commit is contained in:
bjh21 2001-03-11 16:31:05 +00:00
parent ce5529eabf
commit b1475781a2
4 changed files with 141 additions and 132 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cons_machdep.c,v 1.2 2001/01/22 13:57:00 jdolecek Exp $ */ /* $NetBSD: cons_machdep.c,v 1.3 2001/03/11 16:31:05 bjh21 Exp $ */
/*- /*-
* Copyright (c) 1998 Ben Harris * Copyright (c) 1998 Ben Harris
* All rights reserved. * All rights reserved.
@ -32,7 +32,7 @@
#include <sys/param.h> #include <sys/param.h>
__RCSID("$NetBSD: cons_machdep.c,v 1.2 2001/01/22 13:57:00 jdolecek Exp $"); __RCSID("$NetBSD: cons_machdep.c,v 1.3 2001/03/11 16:31:05 bjh21 Exp $");
#include <sys/syslog.h> #include <sys/syslog.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -63,6 +63,7 @@ consinit()
/* cninit();*/ /* cninit();*/
#ifdef DDB #ifdef DDB
db_machine_init();
ddb_init(bootconfig.esym - bootconfig.ssym, ddb_init(bootconfig.esym - bootconfig.ssym,
MEMC_PHYS_BASE + bootconfig.ssym, MEMC_PHYS_BASE + bootconfig.ssym,
MEMC_PHYS_BASE + bootconfig.esym); MEMC_PHYS_BASE + bootconfig.esym);

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_interface.c,v 1.7 2001/01/22 13:57:01 jdolecek Exp $ */ /* $NetBSD: db_interface.c,v 1.8 2001/03/11 16:31:05 bjh21 Exp $ */
/* /*
* Copyright (c) 1996 Scott K. Stevens * Copyright (c) 1996 Scott K. Stevens
@ -34,6 +34,7 @@
* Interface to new debugger. * Interface to new debugger.
*/ */
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_progmode.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/proc.h> #include <sys/proc.h>
@ -44,7 +45,7 @@
#include <uvm/uvm_extern.h> #include <uvm/uvm_extern.h>
#include <machine/db_machdep.h> #include <machine/db_machdep.h>
#include <ddb/db_access.h> #include <machine/undefined.h>
#include <ddb/db_command.h> #include <ddb/db_command.h>
#include <ddb/db_output.h> #include <ddb/db_output.h>
#include <ddb/db_interface.h> #include <ddb/db_interface.h>
@ -62,22 +63,30 @@ static int db_validate_address __P((vm_offset_t));
static void db_write_text __P((unsigned char *, int ch)); static void db_write_text __P((unsigned char *, int ch));
const struct db_variable db_regs[] = { const struct db_variable db_regs[] = {
{ "r0", (long *)&DDB_TF->tf_r0, FCN_NULL }, { "spsr", (long *)&DDB_REGS->tf_spsr, FCN_NULL, },
{ "r1", (long *)&DDB_TF->tf_r1, FCN_NULL }, { "r0", (long *)&DDB_REGS->tf_r0, FCN_NULL, },
{ "r2", (long *)&DDB_TF->tf_r2, FCN_NULL }, { "r1", (long *)&DDB_REGS->tf_r1, FCN_NULL, },
{ "r3", (long *)&DDB_TF->tf_r3, FCN_NULL }, { "r2", (long *)&DDB_REGS->tf_r2, FCN_NULL, },
{ "r4", (long *)&DDB_TF->tf_r4, FCN_NULL }, { "r3", (long *)&DDB_REGS->tf_r3, FCN_NULL, },
{ "r5", (long *)&DDB_TF->tf_r5, FCN_NULL }, { "r4", (long *)&DDB_REGS->tf_r4, FCN_NULL, },
{ "r6", (long *)&DDB_TF->tf_r6, FCN_NULL }, { "r5", (long *)&DDB_REGS->tf_r5, FCN_NULL, },
{ "r7", (long *)&DDB_TF->tf_r7, FCN_NULL }, { "r6", (long *)&DDB_REGS->tf_r6, FCN_NULL, },
{ "r8", (long *)&DDB_TF->tf_r8, FCN_NULL }, { "r7", (long *)&DDB_REGS->tf_r7, FCN_NULL, },
{ "r9", (long *)&DDB_TF->tf_r9, FCN_NULL }, { "r8", (long *)&DDB_REGS->tf_r8, FCN_NULL, },
{ "r10", (long *)&DDB_TF->tf_r10, FCN_NULL }, { "r9", (long *)&DDB_REGS->tf_r9, FCN_NULL, },
{ "r11", (long *)&DDB_TF->tf_r11, FCN_NULL }, { "r10", (long *)&DDB_REGS->tf_r10, FCN_NULL, },
{ "r12", (long *)&DDB_TF->tf_r12, FCN_NULL }, { "r11", (long *)&DDB_REGS->tf_r11, FCN_NULL, },
{ "r13", (long *)&DDB_TF->tf_r13, FCN_NULL }, { "r12", (long *)&DDB_REGS->tf_r12, FCN_NULL, },
{ "r14", (long *)&DDB_TF->tf_r14, FCN_NULL }, { "usr_sp", (long *)&DDB_REGS->tf_usr_sp, FCN_NULL, },
{ "r15", (long *)&DDB_TF->tf_r15, FCN_NULL }, { "usr_lr", (long *)&DDB_REGS->tf_usr_lr, FCN_NULL, },
{ "svc_sp", (long *)&DDB_REGS->tf_svc_sp, FCN_NULL, },
{ "svc_lr", (long *)&DDB_REGS->tf_svc_lr, FCN_NULL, },
{ "pc", (long *)&DDB_REGS->tf_pc, FCN_NULL, },
#ifdef PROG32
{ "und_sp", (long *)&nil, db_access_und_sp, },
{ "abt_sp", (long *)&nil, db_access_abt_sp, },
{ "irq_sp", (long *)&nil, db_access_irq_sp, },
#endif
}; };
const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
@ -86,6 +95,38 @@ extern label_t *db_recover;
int db_active = 0; int db_active = 0;
#ifdef PROG32
int db_access_und_sp(vp, valp, rw)
const struct db_variable *vp;
db_expr_t *valp;
int rw;
{
if (rw == DB_VAR_GET)
*valp = get_stackptr(PSR_UND32_MODE);
return(0);
}
int db_access_abt_sp(vp, valp, rw)
const struct db_variable *vp;
db_expr_t *valp;
int rw;
{
if (rw == DB_VAR_GET)
*valp = get_stackptr(PSR_ABT32_MODE);
return(0);
}
int db_access_irq_sp(vp, valp, rw)
const struct db_variable *vp;
db_expr_t *valp;
int rw;
{
if (rw == DB_VAR_GET)
*valp = get_stackptr(PSR_IRQ32_MODE);
return(0);
}
#endif
/* /*
* kdb_trap - field a TRACE or BPT trap * kdb_trap - field a TRACE or BPT trap
*/ */
@ -121,9 +162,24 @@ kdb_trap(type, regs)
*regs = ddb_regs; *regs = ddb_regs;
return 1; return (1);
} }
/*
* Received keyboard interrupt sequence.
*/
void
kdb_kbd_trap(regs)
db_regs_t *regs;
{
if (db_active == 0 && (boothowto & RB_KDB)) {
printf("\n\nkernel: keyboard interrupt\n");
kdb_trap(-1, regs);
}
}
static int static int
db_validate_address(addr) db_validate_address(addr)
vm_offset_t addr; vm_offset_t addr;
@ -216,7 +272,6 @@ const struct db_command db_machine_command_table[] = {
{ NULL, NULL, 0, NULL } { NULL, NULL, 0, NULL }
}; };
#if 0 /* unused? */
int int
db_trapper(addr, inst, frame, fault_code) db_trapper(addr, inst, frame, fault_code)
u_int addr; u_int addr;
@ -225,7 +280,10 @@ db_trapper(addr, inst, frame, fault_code)
int fault_code; int fault_code;
{ {
if (fault_code == 0) { if (fault_code == 0) {
if ((inst & ~0xf0000000) == (BKPT_INST & ~0xf0000000)) #ifndef arm26
frame->tf_pc -= INSN_SIZE;
#endif
if ((inst & ~INSN_COND_MASK) == (BKPT_INST & ~INSN_COND_MASK))
kdb_trap(T_BREAKPOINT, frame); kdb_trap(T_BREAKPOINT, frame);
else else
kdb_trap(-1, frame); kdb_trap(-1, frame);
@ -233,11 +291,46 @@ db_trapper(addr, inst, frame, fault_code)
return 1; return 1;
return 0; return 0;
} }
#endif
extern u_int esym; extern u_int esym;
extern u_int end; extern u_int end;
static struct undefined_handler db_uh;
void
db_machine_init()
{
#ifndef arm26
struct exec *kernexec = (struct exec *)KERNEL_TEXT_BASE;
int len;
/*
* The boot loader currently loads the kernel with the a.out
* header still attached.
*/
if (kernexec->a_syms == 0) {
printf("[No symbol table]\n");
} else {
/* cover the symbols themselves (what is the int for?? XXX) */
esym = (int)&end + kernexec->a_syms + sizeof(int);
/*
* and the string table. (int containing size of string
* table is included in string table size).
*/
len = *((u_int *)esym);
esym += (len + (sizeof(u_int) - 1)) & ~(sizeof(u_int) - 1);
}
#endif
/*
* We get called before malloc() is available, so supply a static
* struct undefined_handler.
*/
db_uh.uh_handler = db_trapper;
install_coproc_handler_static(0, &db_uh);
}
u_int u_int
db_fetch_reg(reg, db_regs) db_fetch_reg(reg, db_regs)
int reg; int reg;
@ -246,37 +339,37 @@ db_fetch_reg(reg, db_regs)
switch (reg) { switch (reg) {
case 0: case 0:
return (db_regs->ddb_tf.tf_r0); return (db_regs->tf_r0);
case 1: case 1:
return (db_regs->ddb_tf.tf_r1); return (db_regs->tf_r1);
case 2: case 2:
return (db_regs->ddb_tf.tf_r2); return (db_regs->tf_r2);
case 3: case 3:
return (db_regs->ddb_tf.tf_r3); return (db_regs->tf_r3);
case 4: case 4:
return (db_regs->ddb_tf.tf_r4); return (db_regs->tf_r4);
case 5: case 5:
return (db_regs->ddb_tf.tf_r5); return (db_regs->tf_r5);
case 6: case 6:
return (db_regs->ddb_tf.tf_r6); return (db_regs->tf_r6);
case 7: case 7:
return (db_regs->ddb_tf.tf_r7); return (db_regs->tf_r7);
case 8: case 8:
return (db_regs->ddb_tf.tf_r8); return (db_regs->tf_r8);
case 9: case 9:
return (db_regs->ddb_tf.tf_r9); return (db_regs->tf_r9);
case 10: case 10:
return (db_regs->ddb_tf.tf_r10); return (db_regs->tf_r10);
case 11: case 11:
return (db_regs->ddb_tf.tf_r11); return (db_regs->tf_r11);
case 12: case 12:
return (db_regs->ddb_tf.tf_r12); return (db_regs->tf_r12);
case 13: case 13:
return (db_regs->ddb_tf.tf_r13); return (db_regs->tf_svc_sp);
case 14: case 14:
return (db_regs->ddb_tf.tf_r14); return (db_regs->tf_svc_lr);
case 15: case 15:
return (db_regs->ddb_tf.tf_r15); return (db_regs->tf_pc);
default: default:
panic("db_fetch_reg: botch"); panic("db_fetch_reg: botch");
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: db_trace.c,v 1.6 2001/01/22 22:10:42 bjh21 Exp $ */ /* $NetBSD: db_trace.c,v 1.7 2001/03/11 16:31:05 bjh21 Exp $ */
/* /*
* Copyright (c) 1996 Scott K. Stevens * Copyright (c) 1996 Scott K. Stevens
@ -30,7 +30,7 @@
#include <sys/param.h> #include <sys/param.h>
__RCSID("$NetBSD: db_trace.c,v 1.6 2001/01/22 22:10:42 bjh21 Exp $"); __RCSID("$NetBSD: db_trace.c,v 1.7 2001/03/11 16:31:05 bjh21 Exp $");
#include <sys/proc.h> #include <sys/proc.h>
#include <sys/user.h> #include <sys/user.h>
@ -98,7 +98,7 @@ db_stack_trace_print(addr, have_addr, count, modif, pr)
} }
if (!have_addr) if (!have_addr)
frame = (u_int32_t *)(DDB_TF->tf_r11); frame = (u_int32_t *)(DDB_REGS->tf_r11);
else { else {
if (trace_thread) { if (trace_thread) {
struct proc *p; struct proc *p;

View File

@ -1,93 +1,8 @@
/* $NetBSD: db_machdep.h,v 1.4 2001/01/22 22:10:45 bjh21 Exp $ */ /* $NetBSD: db_machdep.h,v 1.5 2001/03/11 16:31:06 bjh21 Exp $ */
/* #include <arm/db_machdep.h>
* Copyright (c) 1996 Scott K Stevens
*
* Mach Operating System
* Copyright (c) 1991,1990 Carnegie Mellon University
* All Rights Reserved.
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
#ifndef _ARM26_DB_MACHDEP_H_ /* arm26 uses ELF */
#define _ARM26_DB_MACHDEP_H_ #undef DB_AOUT_SYMBOLS
/*
* Machine-dependent defines for new kernel debugger.
*/
#include <uvm/uvm_extern.h>
#include <arm/armreg.h>
#include <machine/frame.h>
typedef vm_offset_t db_addr_t; /* address - unsigned */
typedef long db_expr_t; /* expression - signed */
typedef struct {
trapframe_t ddb_tf;
} db_regs_t;
db_regs_t ddb_regs; /* register state */
#define DDB_REGS (&ddb_regs)
#define DDB_TF (&ddb_regs.ddb_tf)
#define PC_REGS(regs) ((db_addr_t)(regs)->ddb_tf.tf_r15 & R15_PC)
#define PC_ADVANCE(regs) ((regs)->ddb_tf.tf_r15 += 4)
#define BKPT_INST (0xe7ffffff) /* breakpoint instruction */
#define BKPT_SIZE (INSN_SIZE) /* size of breakpoint inst */
#define BKPT_SET(inst) (BKPT_INST)
/*#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->ddb_tf.tf_pc -= BKPT_SIZE)*/
#define T_BREAKPOINT (1)
#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_BREAKPOINT)
#define IS_WATCHPOINT_TRAP(type, code) (0)
#define inst_trap_return(ins) ((ins)&0)
#define inst_return(ins) ((ins)&0)
#define inst_call(ins) (((ins) & 0x0f000000) == 0x0b000000)
#define inst_branch(ins) (((ins) & 0x0f000000) == 0x0a000000)
#define inst_load(ins) 0
#define inst_store(ins) 0
#define inst_unconditional_flow_transfer(ins) (((ins) & 0xf0000000) == 0xe0000000)
#define getreg_val (0)
#define next_instr_address(pc, bd) (pc + INSN_SIZE)
#define DB_MACHINE_COMMANDS
#define SOFTWARE_SSTEP
u_int branch_taken __P((u_int insn, u_int pc, db_regs_t *db_regs));
/*
* We use ELF symbols in DDB.
*/
#define DB_ELF_SYMBOLS #define DB_ELF_SYMBOLS
#define DB_ELFSIZE 32 #define DB_ELFSIZE 32
/* Entry point from undefined instruction handler */
int kdb_trap __P((int, db_regs_t *));
#endif /* _ARM26_DB_MACHDEP_H_ */