Module Name: src
Committed By: skrll
Date: Wed Jan 18 09:35:48 UTC 2012
Modified Files:
src/sys/arch/hppa/hppa: db_disasm.c db_interface.c db_machdep.c
db_trace.c
src/sys/arch/hppa/include: db_machdep.h types.h
src/usr.sbin/crash: Makefile
Log Message:
Support crash(8) on hppa.
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/hppa/hppa/db_disasm.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/hppa/hppa/db_interface.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/hppa/db_machdep.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hppa/hppa/db_trace.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/hppa/include/db_machdep.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/hppa/include/types.h
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/crash/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/hppa/hppa/db_disasm.c
diff -u src/sys/arch/hppa/hppa/db_disasm.c:1.15 src/sys/arch/hppa/hppa/db_disasm.c:1.16
--- src/sys/arch/hppa/hppa/db_disasm.c:1.15 Tue Jan 17 12:32:52 2012
+++ src/sys/arch/hppa/hppa/db_disasm.c Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: db_disasm.c,v 1.15 2012/01/17 12:32:52 skrll Exp $ */
+/* $NetBSD: db_disasm.c,v 1.16 2012/01/18 09:35:48 skrll Exp $ */
/* $OpenBSD: db_disasm.c,v 1.9 2000/04/18 20:02:45 mickey Exp $ */
@@ -38,17 +38,21 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.15 2012/01/17 12:32:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.16 2012/01/18 09:35:48 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/db_machdep.h>
+
#include <ddb/db_access.h>
#include <ddb/db_sym.h>
#include <ddb/db_output.h>
#include <ddb/db_interface.h>
+#ifndef _KERNEL
+#include <string.h>
+#endif
/* IMPORTANT NOTE:
* All modules using this header may assume that the datatype "int" is a
@@ -1138,7 +1142,7 @@ static const struct inst instrs[] = {
{ FMPYADD,0, "fmpy", fmpyaddDasm },
{ FSTQX, 0, "fstqx", lpkDasm },
{ FSTQS, 0, "fstqs", lpkDasm },
- {0}
+ { 0, 0, 0, 0, 0, "", NULL}
};
@@ -1160,70 +1164,70 @@ static const struct inst *so_deps [0x08]
#define ILLEG NULL
#define NENTS(a) (sizeof(a)/sizeof(a[0])-1)
static struct majoropcode majopcs[NMAJOPCS] = {
- { so_sysop, NENTS(so_sysop) }, /* 00 */
- { so_mmuop, NENTS(so_mmuop) }, /* 01 */
- { so_arith, NENTS(so_arith) }, /* 02 */
- { so_loads, NENTS(so_loads) }, /* 03 */
- { ILLEG, 1 }, /* 04 */
- { ILLEG, 1 }, /* 05 */
- { ILLEG, 1 }, /* 06 */
- { ILLEG, 1 }, /* 07 */
- { ILLEG, 1 }, /* 08 */
- { so_cldw , NENTS(so_cldw ) }, /* 09 */
- { ILLEG, 1 }, /* 0A */
- { so_cldd , NENTS(so_cldd ) }, /* 0B */
- { ILLEG, 1 }, /* 0C */
- { ILLEG, 1 }, /* 0D */
- { so_float, NENTS(so_float) }, /* 0E */
- { so_fstq , NENTS(so_fstq ) }, /* 0F */
- { ILLEG, 1 }, /* 10 */
- { ILLEG, 1 }, /* 11 */
- { ILLEG, 1 }, /* 12 */
- { ILLEG, 1 }, /* 13 */
- { ILLEG, 1 }, /* 14 */
- { ILLEG, 1 }, /* 15 */
- { ILLEG, 1 }, /* 16 */
- { ILLEG, 1 }, /* 17 */
- { ILLEG, 1 }, /* 18 */
- { ILLEG, 1 }, /* 19 */
- { ILLEG, 1 }, /* 1A */
- { ILLEG, 1 }, /* 1B */
- { ILLEG, 1 }, /* 1C */
- { ILLEG, 1 }, /* 1D */
- { ILLEG, 1 }, /* 1E */
- { ILLEG, 1 }, /* 1F */
- { ILLEG, 1 }, /* 20 */
- { ILLEG, 1 }, /* 21 */
- { ILLEG, 1 }, /* 22 */
- { ILLEG, 1 }, /* 23 */
- { ILLEG, 1 }, /* 24 */
- { so_subi , NENTS(so_subi ) }, /* 25 */
- { ILLEG, 1 }, /* 26 */
- { ILLEG, 1 }, /* 27 */
- { ILLEG, 1 }, /* 28 */
- { ILLEG, 1 }, /* 29 */
- { ILLEG, 1 }, /* 2A */
- { ILLEG, 1 }, /* 2B */
- { so_addit, NENTS(so_addit) }, /* 2C */
- { so_addi , NENTS(so_addi ) }, /* 2D */
- { ILLEG, 1 }, /* 2E */
- { ILLEG, 1 }, /* 2F */
- { ILLEG, 1 }, /* 30 */
- { ILLEG, 1 }, /* 31 */
- { ILLEG, 1 }, /* 32 */
- { ILLEG, 1 }, /* 33 */
- { so_shext, NENTS(so_shext) }, /* 34 */
- { so_deps , NENTS(so_deps ) }, /* 35 */
- { ILLEG, 1 }, /* 36 */
- { ILLEG, 1 }, /* 37 */
- { ILLEG, 1 }, /* 38 */
- { ILLEG, 1 }, /* 39 */
- { so_ebran, NENTS(so_ebran) }, /* 3A */
- { ILLEG, 1 }, /* 3B */
- { ILLEG, 1 }, /* 3C */
- { ILLEG, 1 }, /* 3D */
- { ILLEG, 1 }, /* 3E */
- { ILLEG, 1 }, /* 3F */
+ { so_sysop, NENTS(so_sysop), 0, 0 }, /* 00 */
+ { so_mmuop, NENTS(so_mmuop), 0, 0 }, /* 01 */
+ { so_arith, NENTS(so_arith), 0, 0 }, /* 02 */
+ { so_loads, NENTS(so_loads), 0, 0 }, /* 03 */
+ { ILLEG, 1, 0, 0 }, /* 04 */
+ { ILLEG, 1, 0, 0 }, /* 05 */
+ { ILLEG, 1, 0, 0 }, /* 06 */
+ { ILLEG, 1, 0, 0 }, /* 07 */
+ { ILLEG, 1, 0, 0 }, /* 08 */
+ { so_cldw , NENTS(so_cldw ), 0, 0 }, /* 09 */
+ { ILLEG, 1, 0, 0 }, /* 0A */
+ { so_cldd , NENTS(so_cldd ), 0, 0 }, /* 0B */
+ { ILLEG, 1, 0, 0 }, /* 0C */
+ { ILLEG, 1, 0, 0 }, /* 0D */
+ { so_float, NENTS(so_float), 0, 0 }, /* 0E */
+ { so_fstq , NENTS(so_fstq ), 0, 0 }, /* 0F */
+ { ILLEG, 1, 0, 0 }, /* 10 */
+ { ILLEG, 1, 0, 0 }, /* 11 */
+ { ILLEG, 1, 0, 0 }, /* 12 */
+ { ILLEG, 1, 0, 0 }, /* 13 */
+ { ILLEG, 1, 0, 0 }, /* 14 */
+ { ILLEG, 1, 0, 0 }, /* 15 */
+ { ILLEG, 1, 0, 0 }, /* 16 */
+ { ILLEG, 1, 0, 0 }, /* 17 */
+ { ILLEG, 1, 0, 0 }, /* 18 */
+ { ILLEG, 1, 0, 0 }, /* 19 */
+ { ILLEG, 1, 0, 0 }, /* 1A */
+ { ILLEG, 1, 0, 0 }, /* 1B */
+ { ILLEG, 1, 0, 0 }, /* 1C */
+ { ILLEG, 1, 0, 0 }, /* 1D */
+ { ILLEG, 1, 0, 0 }, /* 1E */
+ { ILLEG, 1, 0, 0 }, /* 1F */
+ { ILLEG, 1, 0, 0 }, /* 20 */
+ { ILLEG, 1, 0, 0 }, /* 21 */
+ { ILLEG, 1, 0, 0 }, /* 22 */
+ { ILLEG, 1, 0, 0 }, /* 23 */
+ { ILLEG, 1, 0, 0 }, /* 24 */
+ { so_subi , NENTS(so_subi ), 0, 0 }, /* 25 */
+ { ILLEG, 1, 0, 0 }, /* 26 */
+ { ILLEG, 1, 0, 0 }, /* 27 */
+ { ILLEG, 1, 0, 0 }, /* 28 */
+ { ILLEG, 1, 0, 0 }, /* 29 */
+ { ILLEG, 1, 0, 0 }, /* 2A */
+ { ILLEG, 1, 0, 0 }, /* 2B */
+ { so_addit, NENTS(so_addit), 0, 0 }, /* 2C */
+ { so_addi , NENTS(so_addi ), 0, 0 }, /* 2D */
+ { ILLEG, 1, 0, 0 }, /* 2E */
+ { ILLEG, 1, 0, 0 }, /* 2F */
+ { ILLEG, 1, 0, 0 }, /* 30 */
+ { ILLEG, 1, 0, 0 }, /* 31 */
+ { ILLEG, 1, 0, 0 }, /* 32 */
+ { ILLEG, 1, 0, 0 }, /* 33 */
+ { so_shext, NENTS(so_shext), 0, 0 }, /* 34 */
+ { so_deps , NENTS(so_deps ), 0, 0 }, /* 35 */
+ { ILLEG, 1, 0, 0 }, /* 36 */
+ { ILLEG, 1, 0, 0 }, /* 37 */
+ { ILLEG, 1, 0, 0 }, /* 38 */
+ { ILLEG, 1, 0, 0 }, /* 39 */
+ { so_ebran, NENTS(so_ebran), 0, 0 }, /* 3A */
+ { ILLEG, 1, 0, 0 }, /* 3B */
+ { ILLEG, 1, 0, 0 }, /* 3C */
+ { ILLEG, 1, 0, 0 }, /* 3D */
+ { ILLEG, 1, 0, 0 }, /* 3E */
+ { ILLEG, 1, 0, 0 }, /* 3F */
};
#undef NENTS
#undef ILLEG
@@ -1253,9 +1257,11 @@ iExInit(void)
*/
for (i = &instrs[0]; *i->mnem; i++) {
m = &majopcs[i->majopc];
- if (m->maxsubop < i->opcext)
- panic("iExInit not enough space for opcode %d",
+ if (m->maxsubop < i->opcext) {
+ db_printf("iExInit not enough space for opcode %d",
i->majopc);
+ return 0;
+ }
shft = 32 - i->extbs - i->extbl;
mask = (1 << i->extbl) - 1;
if (m->extshft || m->extmask) {
@@ -1305,7 +1311,7 @@ addDasm(const struct inst *i, OFS ofs, u
int
unitDasm(const struct inst *i, OFS ofs, union insn w)
{
- db_printf(unitDCond(Cond4(w)));
+ db_printf("%s", unitDCond(Cond4(w)));
if (Match("dcor") || Match("idcor"))
db_printf("\t%%r%d, %%r%d",Rsb(w),Rtc(w));
else
@@ -1422,7 +1428,7 @@ subDCond(u_int cond)
case TR: return(",tr");
case NEV: return("");
default:
- panic("subDCond: unknown condition");
+ return("subDCond: unknown condition");
}
}
@@ -1453,7 +1459,7 @@ addDCond(u_int cond)
case TR: return(",tr");
case NEV: return("");
default:
- panic("addDCond: unknown condition");
+ return ("addDCond: unknown condition");
}
}
@@ -1474,7 +1480,7 @@ unitDCond(u_int cond)
case TR: return(",tr");
case NEV: return("");
default:
- panic("unitDCond: unknown condition");
+ return("unitDCond: unknown condition");
}
}
@@ -1491,7 +1497,7 @@ edDCond(u_int cond)
case XEV: return(",ev");
case NEV: return("");
default:
- panic("edDCond: unknown condition");
+ return("edDCond: unknown condition");
}
}
@@ -1617,7 +1623,7 @@ stbysDasm(const struct inst *i, OFS ofs,
{
const char *p;
- db_printf(ModBefore(w)? ",e":",b");
+ db_printf("%s", ModBefore(w)? ",e":",b");
if (Modify(w))
db_printf(",m");
switch (CacheCtrl(w)) {
@@ -1710,12 +1716,12 @@ cbDasm(const struct inst *i, OFS ofs, un
OFS tgtofs = ofs + 8 + Cbdisp(w);
if (Match("movb"))
- db_printf(edDCond(Cond(w)));
+ db_printf("%s", edDCond(Cond(w)));
else if (Match("addb"))
- db_printf(addDCond(Cond(w) << 1));
+ db_printf("%s", addDCond(Cond(w) << 1));
else
- db_printf(subDCond(Cond(w) << 1));
- db_printf("%s\t%%r%d, %%r%d,", Nu(w)?",n":"", Rsa(w), Rsb(w));
+ db_printf("%s", subDCond(Cond(w) << 1));
+ db_printf("%s\t%%r%d, %%r%d, ", Nu(w)?",n":"", Rsa(w), Rsb(w));
db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
return (1);
}
@@ -1727,11 +1733,11 @@ cbiDasm(const struct inst *i, OFS ofs, u
OFS tgtofs = ofs + 8 + Cbdisp(w);
if (Match("movib"))
- db_printf(edDCond(Cond(w)));
+ db_printf("%s", edDCond(Cond(w)));
else if (Match("addib"))
- db_printf(addDCond(Cond(w) << 1));
+ db_printf("%s", addDCond(Cond(w) << 1));
else
- db_printf(subDCond(Cond(w) << 1));
+ db_printf("%s", subDCond(Cond(w) << 1));
db_printf("%s\t%d, %%r%d, ", Nu(w)? ",n":"", Ima5(w), Rsb(w));
db_printsym((db_addr_t)tgtofs, DB_STGY_ANY, db_printf);
return (1);
@@ -1744,7 +1750,7 @@ bbDasm(const struct inst *i, OFS ofs, un
OFS tgtofs = ofs + 8 + Cbdisp(w);
const char *p;
- db_printf(edDCond(Cond(w)));
+ db_printf("%s", edDCond(Cond(w)));
p = Nu(w)? ",n":"";
if (Match("bvb"))
db_printf("%s\t%%r%d, ", p, Rta(w));
@@ -1780,7 +1786,7 @@ scDasm(const struct inst *i, OFS ofs, un
db_printf("mtctl\t%%r%d, %%cr%d",Rsa(w),Rtb(w));
return (1);
}
- db_printf(i->mnem);
+ db_printf("%s", i->mnem);
if (Match("ssm") || Match("rsm"))
db_printf("\t%d, %%r%d",Ima5A(w),Rtc(w));
else if (Match("mtsm")) db_printf("\t%%r%d",Rsa(w));
@@ -1900,7 +1906,7 @@ floatDasm(const struct inst *i, OFS ofs,
p = "cmp";
break;
default:
- db_printf(fcoprUndef);
+ db_printf("%s", fcoprUndef);
return(0);
}
db_printf("%s,%s",p,fmtStrTbl[fmt]);
@@ -1921,7 +1927,7 @@ floatDasm(const struct inst *i, OFS ofs,
case 2: p = (Fpi(w)) ? "mpyi" : "mpy"; break;
case 3: p = "div"; break;
case 4: p = "rem"; break;
- default: db_printf(fcoprUndef); return (0);
+ default: db_printf("%s", fcoprUndef); return (0);
}
db_printf("%s,%s", p, fmtStrTbl[fmt]);
db_printf("\t%%f%s, %%f%s, %%f%s",ST(r1),ST(r2),ST(t));
@@ -1962,7 +1968,7 @@ floatDasm(const struct inst *i, OFS ofs,
case 3: p = "abs"; break;
case 4: p = "sqrt"; break;
case 5: p = "rnd"; break;
- default: db_printf(fcoprUndef); return (0);
+ default: db_printf("%s", fcoprUndef); return (0);
}
db_printf("%s,%s",p,fmtStrTbl[fmt]);
db_printf("\t%%f%s, %%f%s",ST(r1),ST(t));
@@ -2000,7 +2006,7 @@ fcoprDasm(union insn w, u_int op1, u_int
case 3: p = "abs"; break;
case 4: p = "sqrt"; break;
case 5: p = "rnd"; break;
- default: db_printf(fcoprUndef); return(0);
+ default: db_printf("%s", fcoprUndef); return(0);
}
db_printf("f%s,%s\t%%fr%d, %%fr%d", p, fmtStrTbl[fmt], r1, t);
break;
@@ -2026,7 +2032,7 @@ fcoprDasm(union insn w, u_int op1, u_int
fmt = (op1 >> 2) & 3;
switch((op1 >> 4) & 7) {
case 0: p = "fcmp"; break;
- default: db_printf(fcoprUndef); return (0);
+ default: db_printf("%s", fcoprUndef); return (0);
}
db_printf("%s,%s,%s\t%%fr%d, %%fr%d",
p,fmtStrTbl[fmt],condStrTbl[op2],r1,r2);
@@ -2041,13 +2047,13 @@ fcoprDasm(union insn w, u_int op1, u_int
case 2: p = "mpy"; break;
case 3: p = "div"; break;
case 4: p = "rem"; break;
- default: db_printf(fcoprUndef); return (0);
+ default: db_printf("%s", fcoprUndef); return (0);
}
db_printf("f%s,%s\t%%fr%d, %%fr%d, %%fr%d",
p, fmtStrTbl[fmt], r1, r2, t);
break;
default:
- db_printf(fcoprUndef);
+ db_printf("%s", fcoprUndef);
return(0);
}
return (1);
@@ -2181,7 +2187,7 @@ diagDasm(const struct inst *i, OFS ofs,
else if (0x0d0 == BitfR(w,19,8,_b198)) /* mfcpu */
db_printf("mfcpu\t%%dr%d, %%r%d", Rsb(w), Rta(w));
else {
- db_printf(i->mnem);
+ db_printf("%s", i->mnem);
if (Match("diag"))
db_printf("\t0x%X",w.w & 0x03ffffff);
else {
@@ -2237,11 +2243,13 @@ db_disasm(vaddr_t loc, bool flag)
iExInit();
+#ifdef _KERNEL
if (USERMODE(loc)) {
if (copyin((void *)(loc &~ HPPA_PC_PRIV_MASK),
&instruct, sizeof(instruct)))
instruct.w = 0;
} else
+#endif
instruct.w = *(int *)loc;
m = &majopcs[Opcode(instruct)];
Index: src/sys/arch/hppa/hppa/db_interface.c
diff -u src/sys/arch/hppa/hppa/db_interface.c:1.26 src/sys/arch/hppa/hppa/db_interface.c:1.27
--- src/sys/arch/hppa/hppa/db_interface.c:1.26 Sat Jan 22 20:24:48 2011
+++ src/sys/arch/hppa/hppa/db_interface.c Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.26 2011/01/22 20:24:48 skrll Exp $ */
+/* $NetBSD: db_interface.c,v 1.27 2012/01/18 09:35:48 skrll Exp $ */
/* $OpenBSD: db_interface.c,v 1.16 2001/03/22 23:31:45 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.26 2011/01/22 20:24:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.27 2012/01/18 09:35:48 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -53,82 +53,10 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface
void kdbprinttrap(int, int);
-extern label_t *db_recover;
extern int db_active;
extern const char *trap_type[];
extern int trap_types;
-db_regs_t ddb_regs;
-const struct db_variable db_regs[] = {
- { "flags", (long *)&ddb_regs.tf_flags, FCN_NULL },
- { "r1", (long *)&ddb_regs.tf_r1, FCN_NULL },
- { "r2(rp)", (long *)&ddb_regs.tf_rp, FCN_NULL },
- { "r3(fp)", (long *)&ddb_regs.tf_r3, FCN_NULL },
- { "r4", (long *)&ddb_regs.tf_r4, FCN_NULL },
- { "r5", (long *)&ddb_regs.tf_r5, FCN_NULL },
- { "r6", (long *)&ddb_regs.tf_r6, FCN_NULL },
- { "r7", (long *)&ddb_regs.tf_r7, FCN_NULL },
- { "r8", (long *)&ddb_regs.tf_r8, FCN_NULL },
- { "r9", (long *)&ddb_regs.tf_r9, FCN_NULL },
- { "r10", (long *)&ddb_regs.tf_r10, FCN_NULL },
- { "r11", (long *)&ddb_regs.tf_r11, FCN_NULL },
- { "r12", (long *)&ddb_regs.tf_r12, FCN_NULL },
- { "r13", (long *)&ddb_regs.tf_r13, FCN_NULL },
- { "r14", (long *)&ddb_regs.tf_r14, FCN_NULL },
- { "r15", (long *)&ddb_regs.tf_r15, FCN_NULL },
- { "r16", (long *)&ddb_regs.tf_r16, FCN_NULL },
- { "r17", (long *)&ddb_regs.tf_r17, FCN_NULL },
- { "r18", (long *)&ddb_regs.tf_r18, FCN_NULL },
- { "r19(t4)", (long *)&ddb_regs.tf_t4, FCN_NULL },
- { "r20(t3)", (long *)&ddb_regs.tf_t3, FCN_NULL },
- { "r21(t2)", (long *)&ddb_regs.tf_t2, FCN_NULL },
- { "r22(t1)", (long *)&ddb_regs.tf_t1, FCN_NULL },
- { "r23(arg3)", (long *)&ddb_regs.tf_arg3, FCN_NULL },
- { "r24(arg2)", (long *)&ddb_regs.tf_arg2, FCN_NULL },
- { "r25(arg1)", (long *)&ddb_regs.tf_arg1, FCN_NULL },
- { "r26(arg0)", (long *)&ddb_regs.tf_arg0, FCN_NULL },
- { "r27(dp)", (long *)&ddb_regs.tf_dp, FCN_NULL },
- { "r28(ret0)", (long *)&ddb_regs.tf_ret0, FCN_NULL },
- { "r29(ret1)", (long *)&ddb_regs.tf_ret1, FCN_NULL },
- { "r30(sp)", (long *)&ddb_regs.tf_sp, FCN_NULL },
- { "r31", (long *)&ddb_regs.tf_r31, FCN_NULL },
-
- { "sar", (long *)&ddb_regs.tf_sar, FCN_NULL },
-
- { "eirr", (long *)&ddb_regs.tf_eirr, FCN_NULL },
- { "eiem", (long *)&ddb_regs.tf_eiem, FCN_NULL },
- { "iir", (long *)&ddb_regs.tf_iir, FCN_NULL },
- { "isr", (long *)&ddb_regs.tf_isr, FCN_NULL },
- { "ior", (long *)&ddb_regs.tf_ior, FCN_NULL },
- { "ipsw", (long *)&ddb_regs.tf_ipsw, FCN_NULL },
- { "iisqh", (long *)&ddb_regs.tf_iisq_head, FCN_NULL },
- { "iioqh", (long *)&ddb_regs.tf_iioq_head, FCN_NULL },
- { "iisqt", (long *)&ddb_regs.tf_iisq_tail, FCN_NULL },
- { "iioqt", (long *)&ddb_regs.tf_iioq_tail, FCN_NULL },
-
- { "sr0", (long *)&ddb_regs.tf_sr0, FCN_NULL },
- { "sr1", (long *)&ddb_regs.tf_sr1, FCN_NULL },
- { "sr2", (long *)&ddb_regs.tf_sr2, FCN_NULL },
- { "sr3", (long *)&ddb_regs.tf_sr3, FCN_NULL },
- { "sr4", (long *)&ddb_regs.tf_sr4, FCN_NULL },
- { "sr5", (long *)&ddb_regs.tf_sr5, FCN_NULL },
- { "sr6", (long *)&ddb_regs.tf_sr6, FCN_NULL },
- { "sr7", (long *)&ddb_regs.tf_sr7, FCN_NULL },
-
- { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL },
- { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL },
-#ifdef pbably_not_worth_it
- { "pidr3", (long *)&ddb_regs.tf_pidr3, FCN_NULL },
- { "pidr4", (long *)&ddb_regs.tf_pidr4, FCN_NULL },
-#endif
-
- { "vtop", (long *)&ddb_regs.tf_vtop, FCN_NULL },
- { "cr24", (long *)&ddb_regs.tf_cr24, FCN_NULL },
- { "cr27", (long *)&ddb_regs.tf_cr27, FCN_NULL },
- { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL },
- { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL },
-};
-const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
int db_active = 0;
void
Index: src/sys/arch/hppa/hppa/db_machdep.c
diff -u src/sys/arch/hppa/hppa/db_machdep.c:1.4 src/sys/arch/hppa/hppa/db_machdep.c:1.5
--- src/sys/arch/hppa/hppa/db_machdep.c:1.4 Sat Dec 31 08:34:49 2011
+++ src/sys/arch/hppa/hppa/db_machdep.c Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.c,v 1.4 2011/12/31 08:34:49 skrll Exp $ */
+/* $NetBSD: db_machdep.c,v 1.5 2012/01/18 09:35:48 skrll Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.4 2011/12/31 08:34:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_machdep.c,v 1.5 2012/01/18 09:35:48 skrll Exp $");
#include <sys/param.h>
#include <sys/lwp.h>
@@ -39,6 +39,80 @@ __KERNEL_RCSID(0, "$NetBSD: db_machdep.c
#include <ddb/db_command.h>
#include <ddb/db_output.h>
+#include <ddb/db_variables.h>
+#include <ddb/db_access.h>
+
+db_regs_t ddb_regs;
+const struct db_variable db_regs[] = {
+ { "flags", (long *)&ddb_regs.tf_flags, FCN_NULL, NULL },
+ { "r1", (long *)&ddb_regs.tf_r1, FCN_NULL, NULL },
+ { "r2(rp)", (long *)&ddb_regs.tf_rp, FCN_NULL, NULL },
+ { "r3(fp)", (long *)&ddb_regs.tf_r3, FCN_NULL, NULL },
+ { "r4", (long *)&ddb_regs.tf_r4, FCN_NULL, NULL },
+ { "r5", (long *)&ddb_regs.tf_r5, FCN_NULL, NULL },
+ { "r6", (long *)&ddb_regs.tf_r6, FCN_NULL, NULL },
+ { "r7", (long *)&ddb_regs.tf_r7, FCN_NULL, NULL },
+ { "r8", (long *)&ddb_regs.tf_r8, FCN_NULL, NULL },
+ { "r9", (long *)&ddb_regs.tf_r9, FCN_NULL, NULL },
+ { "r10", (long *)&ddb_regs.tf_r10, FCN_NULL, NULL },
+ { "r11", (long *)&ddb_regs.tf_r11, FCN_NULL, NULL },
+ { "r12", (long *)&ddb_regs.tf_r12, FCN_NULL, NULL },
+ { "r13", (long *)&ddb_regs.tf_r13, FCN_NULL, NULL },
+ { "r14", (long *)&ddb_regs.tf_r14, FCN_NULL, NULL },
+ { "r15", (long *)&ddb_regs.tf_r15, FCN_NULL, NULL },
+ { "r16", (long *)&ddb_regs.tf_r16, FCN_NULL, NULL },
+ { "r17", (long *)&ddb_regs.tf_r17, FCN_NULL, NULL },
+ { "r18", (long *)&ddb_regs.tf_r18, FCN_NULL, NULL },
+ { "r19(t4)", (long *)&ddb_regs.tf_t4, FCN_NULL, NULL },
+ { "r20(t3)", (long *)&ddb_regs.tf_t3, FCN_NULL, NULL },
+ { "r21(t2)", (long *)&ddb_regs.tf_t2, FCN_NULL, NULL },
+ { "r22(t1)", (long *)&ddb_regs.tf_t1, FCN_NULL, NULL },
+ { "r23(arg3)", (long *)&ddb_regs.tf_arg3, FCN_NULL, NULL },
+ { "r24(arg2)", (long *)&ddb_regs.tf_arg2, FCN_NULL, NULL },
+ { "r25(arg1)", (long *)&ddb_regs.tf_arg1, FCN_NULL, NULL },
+ { "r26(arg0)", (long *)&ddb_regs.tf_arg0, FCN_NULL, NULL },
+ { "r27(dp)", (long *)&ddb_regs.tf_dp, FCN_NULL, NULL },
+ { "r28(ret0)", (long *)&ddb_regs.tf_ret0, FCN_NULL, NULL },
+ { "r29(ret1)", (long *)&ddb_regs.tf_ret1, FCN_NULL, NULL },
+ { "r30(sp)", (long *)&ddb_regs.tf_sp, FCN_NULL, NULL },
+ { "r31", (long *)&ddb_regs.tf_r31, FCN_NULL, NULL },
+
+ { "sar", (long *)&ddb_regs.tf_sar, FCN_NULL, NULL },
+
+ { "eirr", (long *)&ddb_regs.tf_eirr, FCN_NULL, NULL },
+ { "eiem", (long *)&ddb_regs.tf_eiem, FCN_NULL, NULL },
+ { "iir", (long *)&ddb_regs.tf_iir, FCN_NULL, NULL },
+ { "isr", (long *)&ddb_regs.tf_isr, FCN_NULL, NULL },
+ { "ior", (long *)&ddb_regs.tf_ior, FCN_NULL, NULL },
+ { "ipsw", (long *)&ddb_regs.tf_ipsw, FCN_NULL, NULL },
+ { "iisqh", (long *)&ddb_regs.tf_iisq_head, FCN_NULL, NULL },
+ { "iioqh", (long *)&ddb_regs.tf_iioq_head, FCN_NULL, NULL },
+ { "iisqt", (long *)&ddb_regs.tf_iisq_tail, FCN_NULL, NULL },
+ { "iioqt", (long *)&ddb_regs.tf_iioq_tail, FCN_NULL, NULL },
+
+ { "sr0", (long *)&ddb_regs.tf_sr0, FCN_NULL, NULL },
+ { "sr1", (long *)&ddb_regs.tf_sr1, FCN_NULL, NULL },
+ { "sr2", (long *)&ddb_regs.tf_sr2, FCN_NULL, NULL },
+ { "sr3", (long *)&ddb_regs.tf_sr3, FCN_NULL, NULL },
+ { "sr4", (long *)&ddb_regs.tf_sr4, FCN_NULL, NULL },
+ { "sr5", (long *)&ddb_regs.tf_sr5, FCN_NULL, NULL },
+ { "sr6", (long *)&ddb_regs.tf_sr6, FCN_NULL, NULL },
+ { "sr7", (long *)&ddb_regs.tf_sr7, FCN_NULL, NULL },
+
+ { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL, NULL },
+ { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL, NULL },
+#ifdef pbably_not_worth_it
+ { "pidr3", (long *)&ddb_regs.tf_pidr3, FCN_NULL, NULL },
+ { "pidr4", (long *)&ddb_regs.tf_pidr4, FCN_NULL, NULL },
+#endif
+
+ { "vtop", (long *)&ddb_regs.tf_vtop, FCN_NULL, NULL },
+ { "cr24", (long *)&ddb_regs.tf_cr24, FCN_NULL, NULL },
+ { "cr27", (long *)&ddb_regs.tf_cr27, FCN_NULL, NULL },
+ { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL, NULL },
+ { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL, NULL },
+};
+const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]);
const struct db_command db_machine_command_table[] = {
{ DDB_ADD_CMD("frame", db_dump_trap, 0,
@@ -52,7 +126,7 @@ const struct db_command db_machine_comma
void
db_dump_trap(db_expr_t addr, bool have_addr, db_expr_t count, const char *modif)
{
- struct trapframe *tf;
+ struct trapframe *tf, *ktf, ltf;
const char *cp = modif;
bool lwpaddr = false;
char c;
@@ -66,13 +140,15 @@ db_dump_trap(db_expr_t addr, bool have_a
/* Or an arbitrary trapframe */
if (have_addr) {
if (lwpaddr) {
- struct lwp *l;
-
- l = (struct lwp *)addr;
- tf = (struct trapframe *)l->l_md.md_regs;
+ lwp_t l;
+
+ db_read_bytes(addr, sizeof(l), (char *)&l);
+ ktf = (struct trapframe *)l.l_md.md_regs;
} else {
- tf = (struct trapframe *)addr;
+ ktf = (struct trapframe *)addr;
}
+ db_read_bytes((db_addr_t)ktf, sizeof(ltf), (char *)<f);
+ tf = <f;
}
db_printf("General registers\n");
Index: src/sys/arch/hppa/hppa/db_trace.c
diff -u src/sys/arch/hppa/hppa/db_trace.c:1.11 src/sys/arch/hppa/hppa/db_trace.c:1.12
--- src/sys/arch/hppa/hppa/db_trace.c:1.11 Tue Jan 17 10:56:56 2012
+++ src/sys/arch/hppa/hppa/db_trace.c Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.11 2012/01/17 10:56:56 skrll Exp $ */
+/* $NetBSD: db_trace.c,v 1.12 2012/01/18 09:35:48 skrll Exp $ */
/* $OpenBSD: db_interface.c,v 1.16 2001/03/22 23:31:45 mickey Exp $ */
@@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.11 2012/01/17 10:56:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.12 2012/01/18 09:35:48 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v
#include <ddb/db_access.h>
#include <ddb/db_sym.h>
#include <ddb/db_interface.h>
+#include <ddb/db_proc.h>
void
db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count,
@@ -75,46 +76,62 @@ db_stack_trace_print(db_expr_t addr, boo
rp = ddb_regs.tf_rp;
} else {
if (trace_thread) {
- struct proc *p;
- struct lwp *l;
+ proc_t p;
+ lwp_t l;
+ pid_t pid;
if (lwpaddr) {
- l = (struct lwp *)addr;
- p = l->l_proc;
- (*pr)("trace: pid %d ", p->p_pid);
+ db_read_bytes(addr, sizeof(l), (char *)&l);
+ db_read_bytes((db_addr_t)l.l_proc, sizeof(p),
+ (char *)&p);
+ (*pr)("trace: pid %d ", p.p_pid);
} else {
- (*pr)("trace: pid %d ", (int)addr);
- p = proc_find_raw(addr);
- if (p == NULL) {
+ proc_t *pp;
+
+ pid = (pid_t)addr;
+ (*pr)("trace: pid %d ", pid);
+ pp = db_proc_find(pid);
+ if (pp == NULL) {
(*pr)("not found\n");
return;
}
- l = LIST_FIRST(&p->p_lwps);
- KASSERT(l != NULL);
+ db_read_bytes((db_addr_t)pp, sizeof(p),
+ (char *)&p);
+ addr = (db_addr_t)p.p_lwps.lh_first;
+ db_read_bytes(addr, sizeof(l), (char *)&l);
}
- (*pr)("lid %d ", l->l_lid);
- if (p == curproc && l == curlwp) {
+ (*pr)("lid %d ", l.l_lid);
+#ifdef _KERNEL
+ if (l.l_proc == curproc && (lwp_t *)addr == curlwp) {
fp = (int *)ddb_regs.tf_r3;
pc = ddb_regs.tf_iioq_head;
rp = ddb_regs.tf_rp;
- } else {
- struct pcb *pcb = lwp_getpcb(l);
+ } else
+#endif
+ {
+ struct pcb *pcb = lwp_getpcb(&l);
+ register_t sp;
/* cpu_switchto fp, and return point */
- fp = (int *)(pcb->pcb_ksp -
+ db_read_bytes((db_addr_t)&pcb->pcb_ksp,
+ sizeof(sp), (char *)&sp);
+ fp = (register_t *)(sp -
(HPPA_FRAME_SIZE + 16*4));
pc = 0;
- rp = fp[-5];
+
+ db_read_bytes((db_addr_t)&fp[-5], sizeof(rp),
+ (char *)&rp);
}
(*pr)("at %p\n", fp);
} else {
pc = 0;
fp = (register_t *)addr;
- rp = fp[-5];
+ db_read_bytes((db_addr_t)&fp[-5], sizeof(rp),
+ (char *)&rp);
}
}
while (fp && count--) {
-
+ register_t *newfp;
#ifdef DDB_DEBUG
pr(">> %08x %08x %08x\t", fp, pc, rp);
#endif
@@ -122,50 +139,59 @@ db_stack_trace_print(db_expr_t addr, boo
if (USERMODE(pc))
return;
- sym = db_search_symbol(pc, DB_STGY_ANY, &off);
- db_symbol_values (sym, &name, NULL);
+ if (pc) {
+ sym = db_search_symbol(pc, DB_STGY_ANY, &off);
+ db_symbol_values (sym, &name, NULL);
+
+ pr("%s() at ", name);
+ db_printsym(pc, DB_STGY_PROC, pr);
+ pr("\n");
+ }
- pr("%s() at ", name);
- db_printsym(pc, DB_STGY_PROC, pr);
- pr("\n");
+ db_read_bytes((db_addr_t)&fp[0], sizeof(newfp), (char *)&newfp);
/*
* if a terminal frame then report the trapframe and continue
* after it (if not the last one).
*/
- if (!fp[0]) {
- register_t *scargs;
- struct trapframe *tf;
+ if (!newfp) {
+ register_t scargs[5];
+ struct trapframe tf, *ktf;
int scoff;
/* Stack space for syscall args */
- scoff = HPPA_FRAME_ROUND(HPPA_FRAME_SIZE + HPPA_FRAME_MAXARGS);
-
- scargs = (register_t *)((char *)fp - scoff);
- tf = (struct trapframe *)((char *)scargs - sizeof(*tf));
+ scoff = HPPA_FRAME_ROUND(HPPA_FRAME_SIZE +
+ HPPA_FRAME_MAXARGS);
+ ktf = (struct trapframe *)((char *)fp - scoff -
+ sizeof(tf));
+
+ db_read_bytes((db_addr_t)((char *)fp - scoff),
+ sizeof(scargs), (char *)&scargs);
+ db_read_bytes((db_addr_t)ktf, sizeof(tf), (char *)&tf);
- if (tf->tf_flags & TFF_SYS)
+ if (tf.tf_flags & TFF_SYS)
pr("-- syscall #%d(%x, %x, %x, %x, ...) (%p)\n",
- tf->tf_t1, scargs[1], scargs[2],
- scargs[3], scargs[4], tf);
+ tf.tf_t1, scargs[1], scargs[2],
+ scargs[3], scargs[4], ktf);
else
- pr("-- trap #%d (%p) %s\n", tf->tf_flags & 0x3f,
- tf, (tf->tf_flags & T_USER)? " from user" :
+ pr("-- trap #%d (%p) %s\n", tf.tf_flags & 0x3f,
+ ktf, (tf.tf_flags & T_USER)? " from user" :
"");
- if (!(tf->tf_flags & TFF_LAST)) {
- fp = (register_t *)tf->tf_r3;
- pc = tf->tf_iioq_head;
- rp = tf->tf_rp;
+ if (!(tf.tf_flags & TFF_LAST)) {
+ fp = (register_t *)tf.tf_r3;
+ pc = tf.tf_iioq_head;
+ rp = tf.tf_rp;
} else {
pc = 0;
fp = 0;
}
} else {
/* next frame */
- fp = (register_t *)fp[0];
+ fp = newfp;
pc = rp;
- rp = fp[-5];
+ db_read_bytes((db_addr_t)&fp[-5], sizeof(rp),
+ (char *)&rp);
}
}
Index: src/sys/arch/hppa/include/db_machdep.h
diff -u src/sys/arch/hppa/include/db_machdep.h:1.11 src/sys/arch/hppa/include/db_machdep.h:1.12
--- src/sys/arch/hppa/include/db_machdep.h:1.11 Thu May 26 15:34:12 2011
+++ src/sys/arch/hppa/include/db_machdep.h Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: db_machdep.h,v 1.11 2011/05/26 15:34:12 joerg Exp $ */
+/* $NetBSD: db_machdep.h,v 1.12 2012/01/18 09:35:48 skrll Exp $ */
/* $OpenBSD: db_machdep.h,v 1.5 2001/02/16 19:20:13 mickey Exp $ */
@@ -31,8 +31,12 @@
#ifndef _HPPA_DB_MACHDEP_H_
#define _HPPA_DB_MACHDEP_H_
+#include <sys/param.h>
+
#include <uvm/uvm_extern.h>
+
#include <machine/pcb.h>
+#include <machine/frame.h>
#define DB_ELF_SYMBOLS
#define DB_ELFSIZE 32
Index: src/sys/arch/hppa/include/types.h
diff -u src/sys/arch/hppa/include/types.h:1.21 src/sys/arch/hppa/include/types.h:1.22
--- src/sys/arch/hppa/include/types.h:1.21 Tue Jan 10 16:26:43 2012
+++ src/sys/arch/hppa/include/types.h Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: types.h,v 1.21 2012/01/10 16:26:43 skrll Exp $ */
+/* $NetBSD: types.h,v 1.22 2012/01/18 09:35:48 skrll Exp $ */
/* $OpenBSD: types.h,v 1.6 2001/08/11 01:58:34 art Exp $ */
@@ -40,6 +40,7 @@
#include <sys/featuretest.h>
#if defined(_NETBSD_SOURCE)
+#if defined(_KERNEL)
typedef struct label_t {
int lbl_rp;
int lbl_sp;
@@ -47,6 +48,7 @@ typedef struct label_t {
int lbl_ss[1];
double lbl_sf[10]; /* hp800:fr12-fr15, hp700:fr12-fr21 */
} label_t;
+#endif
typedef unsigned long hppa_hpa_t;
typedef unsigned long hppa_spa_t;
Index: src/usr.sbin/crash/Makefile
diff -u src/usr.sbin/crash/Makefile:1.14 src/usr.sbin/crash/Makefile:1.15
--- src/usr.sbin/crash/Makefile:1.14 Tue Jan 17 18:44:24 2012
+++ src/usr.sbin/crash/Makefile Wed Jan 18 09:35:48 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.14 2012/01/17 18:44:24 skrll Exp $
+# $NetBSD: Makefile,v 1.15 2012/01/18 09:35:48 skrll Exp $
PROG= crash
MAN= crash.8
@@ -12,6 +12,7 @@ DPADD+= ${LIBUTIL} ${LIBKVM} ${LIBEDIT}
# some ddb kernel components need limited modifications. for now,
# punt if not noted as implemented here.
.if ${MACHINE} == "amd64" \
+ || ${MACHINE} == "hp700" \
|| ${MACHINE} == "i386" \
|| ${MACHINE} == "sparc64"
REALCRASH=yes
@@ -35,6 +36,7 @@ SRCS+= db_expr.c db_lex.c db_output.c db
SRCS+= db_sym.c db_variables.c db_write_cmd.c
.PATH: ${S}/arch/${MACHINE}/${MACHINE}
+.PATH: ${S}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
SRCS+= db_disasm.c
. if ${MACHINE} == "amd64" \
@@ -47,6 +49,10 @@ SRCS+= db_machdep.c
MACHINE_FAMILY = ${MACHINE}
. endif
+. if ${MACHINE} == "hp700"
+SRCS+= db_trace.c db_machdep.c
+. endif
+
. if ${MACHINE} == "sparc64"
SRCS+= db_trace.c db_interface.c
. endif