diff --git a/sys/arch/m68k/include/db_machdep.h b/sys/arch/m68k/include/db_machdep.h index 2337ae77593b..de080bb121d6 100644 --- a/sys/arch/m68k/include/db_machdep.h +++ b/sys/arch/m68k/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.h,v 1.30 2011/05/26 15:34:13 joerg Exp $ */ +/* $NetBSD: db_machdep.h,v 1.31 2012/01/31 21:17:57 mlelstv Exp $ */ /* * Mach Operating System @@ -32,6 +32,12 @@ #ifndef _M68K_DB_MACHDEP_H_ #define _M68K_DB_MACHDEP_H_ +#if !defined(_KERNEL) && !defined(_STANDALONE) +#include +#include +#include +#endif /* _KERNEL || _STANDALONE */ + #include /* diff --git a/sys/arch/m68k/m68k/db_disasm.c b/sys/arch/m68k/m68k/db_disasm.c index 43298d1e69d1..8645761170e8 100644 --- a/sys/arch/m68k/m68k/db_disasm.c +++ b/sys/arch/m68k/m68k/db_disasm.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_disasm.c,v 1.38 2007/02/21 22:59:46 thorpej Exp $ */ +/* $NetBSD: db_disasm.c,v 1.39 2012/01/31 21:17:57 mlelstv Exp $ */ /* * Copyright (c) 1994 Christian E. Hopps @@ -63,10 +63,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.38 2007/02/21 22:59:46 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_disasm.c,v 1.39 2012/01/31 21:17:57 mlelstv Exp $"); #include +#ifdef _KERNEL #include +#endif #include @@ -168,6 +170,9 @@ static const char *const dregs[8] = {"d0","d1","d2","d3","d4","d5","d6","d7"}; static const char *const fpregs[8] = { "fp0","fp1","fp2","fp3","fp4","fp5","fp6","fp7" }; static const char *const fpcregs[3] = { "fpiar", "fpsr", "fpcr" }; +#ifndef _KERNEL +static const char hexdigits[] = "0123456789abcdef"; +#endif /* * Disassemble intruction at location ``loc''. diff --git a/sys/arch/m68k/m68k/db_interface.c b/sys/arch/m68k/m68k/db_interface.c index 0fd87e572d37..2f9d8631c844 100644 --- a/sys/arch/m68k/m68k/db_interface.c +++ b/sys/arch/m68k/m68k/db_interface.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.34 2007/02/22 17:09:44 thorpej Exp $ */ +/* $NetBSD: db_interface.c,v 1.35 2012/01/31 21:17:57 mlelstv Exp $ */ /* * Mach Operating System @@ -31,9 +31,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.34 2007/02/22 17:09:44 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.35 2012/01/31 21:17:57 mlelstv Exp $"); +#ifdef _KERNEL_OPT #include "opt_ddb.h" +#endif #include #include @@ -49,12 +51,14 @@ __KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.34 2007/02/22 17:09:44 thorpej Ex #include #include +#ifdef _KERNEL #include - +#endif int db_active = 0; db_regs_t ddb_regs; +#ifdef _KERNEL static void kdbprinttrap(int, int); /* @@ -155,3 +159,4 @@ cpu_Debugger(void) __asm ("trap #15"); } +#endif diff --git a/sys/arch/m68k/m68k/db_trace.c b/sys/arch/m68k/m68k/db_trace.c index 35b389d4f05b..007d18af9797 100644 --- a/sys/arch/m68k/m68k/db_trace.c +++ b/sys/arch/m68k/m68k/db_trace.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_trace.c,v 1.56 2010/07/01 02:38:27 rmind Exp $ */ +/* $NetBSD: db_trace.c,v 1.57 2012/01/31 21:17:57 mlelstv Exp $ */ /* * Mach Operating System @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.56 2010/07/01 02:38:27 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.57 2012/01/31 21:17:57 mlelstv Exp $"); #include #include @@ -39,7 +39,6 @@ __KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.56 2010/07/01 02:38:27 rmind Exp $"); #include #include #include -#include #include /* @@ -49,26 +48,26 @@ static int db_var_short(const struct db_variable *, db_expr_t *, int); const struct db_variable db_regs[] = { /* D0-D7 */ - { "d0", (long *)&ddb_regs.tf_regs[0], FCN_NULL }, - { "d1", (long *)&ddb_regs.tf_regs[1], FCN_NULL }, - { "d2", (long *)&ddb_regs.tf_regs[2], FCN_NULL }, - { "d3", (long *)&ddb_regs.tf_regs[3], FCN_NULL }, - { "d4", (long *)&ddb_regs.tf_regs[4], FCN_NULL }, - { "d5", (long *)&ddb_regs.tf_regs[5], FCN_NULL }, - { "d6", (long *)&ddb_regs.tf_regs[6], FCN_NULL }, - { "d7", (long *)&ddb_regs.tf_regs[7], FCN_NULL }, + { "d0", (long *)&ddb_regs.tf_regs[0], FCN_NULL, NULL }, + { "d1", (long *)&ddb_regs.tf_regs[1], FCN_NULL, NULL }, + { "d2", (long *)&ddb_regs.tf_regs[2], FCN_NULL, NULL }, + { "d3", (long *)&ddb_regs.tf_regs[3], FCN_NULL, NULL }, + { "d4", (long *)&ddb_regs.tf_regs[4], FCN_NULL, NULL }, + { "d5", (long *)&ddb_regs.tf_regs[5], FCN_NULL, NULL }, + { "d6", (long *)&ddb_regs.tf_regs[6], FCN_NULL, NULL }, + { "d7", (long *)&ddb_regs.tf_regs[7], FCN_NULL, NULL }, /* A0-A7 */ - { "a0", (long *)&ddb_regs.tf_regs[8+0], FCN_NULL }, - { "a1", (long *)&ddb_regs.tf_regs[8+1], FCN_NULL }, - { "a2", (long *)&ddb_regs.tf_regs[8+2], FCN_NULL }, - { "a3", (long *)&ddb_regs.tf_regs[8+3], FCN_NULL }, - { "a4", (long *)&ddb_regs.tf_regs[8+4], FCN_NULL }, - { "a5", (long *)&ddb_regs.tf_regs[8+5], FCN_NULL }, - { "a6", (long *)&ddb_regs.tf_regs[8+6], FCN_NULL }, - { "sp", (long *)&ddb_regs.tf_regs[8+7], FCN_NULL }, + { "a0", (long *)&ddb_regs.tf_regs[8+0], FCN_NULL, NULL }, + { "a1", (long *)&ddb_regs.tf_regs[8+1], FCN_NULL, NULL }, + { "a2", (long *)&ddb_regs.tf_regs[8+2], FCN_NULL, NULL }, + { "a3", (long *)&ddb_regs.tf_regs[8+3], FCN_NULL, NULL }, + { "a4", (long *)&ddb_regs.tf_regs[8+4], FCN_NULL, NULL }, + { "a5", (long *)&ddb_regs.tf_regs[8+5], FCN_NULL, NULL }, + { "a6", (long *)&ddb_regs.tf_regs[8+6], FCN_NULL, NULL }, + { "sp", (long *)&ddb_regs.tf_regs[8+7], FCN_NULL, NULL }, /* misc. */ - { "pc", (long *)&ddb_regs.tf_pc, FCN_NULL }, - { "sr", (long *)&ddb_regs.tf_sr, db_var_short } + { "pc", (long *)&ddb_regs.tf_pc, FCN_NULL, NULL }, + { "sr", (long *)&ddb_regs.tf_sr, db_var_short, NULL } }; const struct db_variable * const db_eregs = db_regs + sizeof(db_regs)/sizeof(db_regs[0]); @@ -107,9 +106,11 @@ struct stackpos { }; static void findentry(struct stackpos *, void (*)(const char *, ...)); +#ifdef _KERNEL static void findregs(struct stackpos *, db_addr_t); static int nextframe(struct stackpos *, struct pcb *, int, void (*)(const char *, ...)); +#endif static void stacktop(db_regs_t *, struct stackpos *, void (*)(const char *, ...)); @@ -174,6 +175,7 @@ static struct nlist * trampsym = 0; static struct nlist * funcsym = 0; #endif +#ifdef _KERNEL static int nextframe(struct stackpos *sp, struct pcb *pcb, int kerneltrace, void (*pr)(const char *, ...)) @@ -222,10 +224,11 @@ nextframe(struct stackpos *sp, struct pcb *pcb, int kerneltrace, } else findentry(sp, pr); - if (sp->k_fp == 0 || oldfp == sp->k_fp) + if (sp->k_fp == 0 || oldfp == (db_addr_t)sp->k_fp) return 0; return sp->k_fp; } +#endif static void findentry(struct stackpos *sp, void (*pr)(const char *, ...)) @@ -239,19 +242,6 @@ findentry(struct stackpos *sp, void (*pr)(const char *, ...)) int instruc; int val; db_addr_t addr, nextword; - label_t db_jmpbuf; - label_t *savejmp; - - savejmp = db_recover; - db_recover = &db_jmpbuf; - if (setjmp(&db_jmpbuf)) { - /* oops -- we touched something we ought not to have */ - /* cannot trace caller of "start" */ - sp->k_entry = MAXINT; - sp->k_nargs = 0; - db_recover = savejmp; - return; - } addr = get(sp->k_fp + FR_SAVPC, DSP); if (addr == 0) { @@ -259,14 +249,11 @@ findentry(struct stackpos *sp, void (*pr)(const char *, ...)) /* cannot trace caller of "start" */ sp->k_entry = MAXINT; sp->k_nargs = 0; - db_recover = savejmp; return; } instruc = get(addr - 6, ISP); nextword = get(addr - 4, ISP); - db_recover = savejmp; - if ((instruc & HIWORD) == (JSR | LONGBIT)) { /* longword offset here */ sp->k_caller = addr - 6; @@ -328,6 +315,7 @@ findentry(struct stackpos *sp, void (*pr)(const char *, ...)) sp->k_nargs = val / 4; } +#ifdef _KERNEL /* * Look at the procedure prolog of the current called procedure. * Figure out which registers we saved, and where they are @@ -390,6 +378,7 @@ findregs(struct stackpos *sp, db_addr_t addr) } /* else no registers saved */ } +#endif /* * Frame tracing. @@ -436,6 +425,7 @@ db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count, (*pr)("trace: pid %d ", p->p_pid); } else { (*pr)("trace: pid %d ", (int)addr); +#ifdef _KERNEL p = proc_find_raw(addr); if (p == NULL) { (*pr)("not found\n"); @@ -443,6 +433,10 @@ db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count, } l = LIST_FIRST(&p->p_lwps); KASSERT(l != NULL); +#else + (*pr)("no proc_find_raw() in crash\n"); + return; +#endif } (*pr)("lid %d ", l->l_lid); pcb = lwp_getpcb(l); @@ -550,6 +544,7 @@ db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count, else (*pr)(") + %lx\n", val); +#if _KERNEL /* * Stop tracing if frame ptr no longer points into kernel * stack. @@ -559,5 +554,6 @@ db_stack_trace_print(db_expr_t addr, bool have_addr, db_expr_t count, break; if (nextframe(&pos, pcb, kernel_only, pr) == 0) break; +#endif } } diff --git a/usr.sbin/crash/Makefile b/usr.sbin/crash/Makefile index 3951b41419bd..4359b8235cc8 100644 --- a/usr.sbin/crash/Makefile +++ b/usr.sbin/crash/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.15 2012/01/18 09:35:48 skrll Exp $ +# $NetBSD: Makefile,v 1.16 2012/01/31 21:17:57 mlelstv Exp $ PROG= crash MAN= crash.8 @@ -14,7 +14,8 @@ DPADD+= ${LIBUTIL} ${LIBKVM} ${LIBEDIT} ${LIBTERMINFO} .if ${MACHINE} == "amd64" \ || ${MACHINE} == "hp700" \ || ${MACHINE} == "i386" \ - || ${MACHINE} == "sparc64" + || ${MACHINE} == "sparc64" \ + || ${MACHINE_ARCH} == "m68k" REALCRASH=yes .else REALCRASH=no @@ -57,6 +58,13 @@ SRCS+= db_trace.c db_machdep.c SRCS+= db_trace.c db_interface.c . endif +. if ${MACHINE_ARCH} == "m68k" +MACHINE_FAMILY = m68k +.PATH: ${S}/arch/m68k/m68k +CPPFLAGS+= -I${S}/arch +SRCS+= db_trace.c db_interface.c +. endif + # crash main source SRCS+= crash.c