[BACK]Return to db_interface.c CVS log [TXT][DIR] Up to [local] / sys / arch / m68k / m68k

Annotation of sys/arch/m68k/m68k/db_interface.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: db_interface.c,v 1.13 2005/05/01 09:55:49 miod Exp $  */
                      2: /*     $NetBSD: db_interface.c,v 1.24 1997/02/18 22:27:32 gwr Exp $    */
                      3:
                      4: /*
                      5:  * Mach Operating System
                      6:  * Copyright (c) 1992 Carnegie Mellon University
                      7:  * All Rights Reserved.
                      8:  *
                      9:  * Permission to use, copy, modify and distribute this software and its
                     10:  * documentation is hereby granted, provided that both the copyright
                     11:  * notice and this permission notice appear in all copies of the
                     12:  * software, derivative works or modified versions, and any portions
                     13:  * thereof, and that both notices appear in supporting documentation.
                     14:  *
                     15:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
                     16:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
                     17:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
                     18:  *
                     19:  * Carnegie Mellon requests users of this software to return to
                     20:  *
                     21:  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
                     22:  *  School of Computer Science
                     23:  *  Carnegie Mellon University
                     24:  *  Pittsburgh PA 15213-3890
                     25:  *
                     26:  * any improvements or extensions that they make and grant Carnegie Mellon
                     27:  * the rights to redistribute these changes.
                     28:  */
                     29:
                     30: /*
                     31:  * Interface to the "ddb" kernel debugger.
                     32:  */
                     33: #include <sys/param.h>
                     34: #include <sys/proc.h>
                     35: #include <sys/reboot.h>
                     36: #include <sys/systm.h> /* just for boothowto --eichin */
                     37:
                     38: #include <uvm/uvm_extern.h>
                     39:
                     40: #include <dev/cons.h>
                     41:
                     42: #include <machine/trap.h>
                     43: #include <machine/db_machdep.h>
                     44:
                     45: #include <ddb/db_command.h>
                     46: #include <ddb/db_var.h>
                     47: #include <ddb/db_sym.h>
                     48: #include <ddb/db_extern.h>
                     49:
                     50:
                     51: extern label_t *db_recover;
                     52:
                     53: int    db_active = 0;
                     54: db_regs_t      ddb_regs;
                     55:
                     56: static void kdbprinttrap(int, int);
                     57:
                     58: /*
                     59:  * Received keyboard interrupt sequence.
                     60:  */
                     61: void
                     62: kdb_kintr(regs)
                     63:        register db_regs_t *regs;
                     64: {
                     65:        if (db_active == 0 && (boothowto & RB_KDB)) {
                     66:                printf("\n\nkernel: keyboard interrupt\n");
                     67:                kdb_trap(-1, regs);
                     68:        }
                     69: }
                     70:
                     71: /*
                     72:  * kdb_trap - field a TRACE or BPT trap
                     73:  * Return non-zero if we "handled" the trap.
                     74:  */
                     75: int
                     76: kdb_trap(type, regs)
                     77:        int     type;
                     78:        register db_regs_t *regs;
                     79: {
                     80:
                     81:        switch (type) {
                     82:        case T_TRACE:           /* single-step */
                     83:        case T_BREAKPOINT:      /* breakpoint */
                     84: /*      case T_WATCHPOINT:*/
                     85:                break;
                     86:        case -1:
                     87:                break;
                     88:        default:
                     89:                if (!db_panic)
                     90:                        return (0);
                     91:
                     92:                kdbprinttrap(type, 0);
                     93:                if (db_recover != 0) {
                     94:                        /* This will longjmp back to db_command_loop */
                     95:                        db_error("Caught exception in ddb.\n");
                     96:                        /*NOTREACHED*/
                     97:                }
                     98:                /*
                     99:                 * Tell caller "We did NOT handle the trap."
                    100:                 * Caller should panic or whatever.
                    101:                 */
                    102:                return (0);
                    103:        }
                    104:
                    105:        /*
                    106:         * We'd like to be on a separate debug stack here, but
                    107:         * that's easier to do in locore.s before we get here.
                    108:         * See sun3/locore.s:T_TRACE for stack switch code.
                    109:         */
                    110:
                    111:        ddb_regs = *regs;
                    112:
                    113:        db_active++;
                    114:        cnpollc(TRUE);  /* set polling mode, unblank video */
                    115:
                    116:        db_trap(type, 0);       /* where the work happens */
                    117:
                    118:        cnpollc(FALSE); /* resume interrupt mode */
                    119:        db_active--;
                    120:
                    121:        *regs = ddb_regs;
                    122:
                    123:        /*
                    124:         * Indicate that single_step is for KDB.
                    125:         * But lock out interrupts to prevent TRACE_KDB from setting the
                    126:         * trace bit in the current SR (and trapping while exiting KDB).
                    127:         */
                    128:        (void) splhigh();
                    129:
                    130:        /*
                    131:         * Tell caller "We HAVE handled the trap."
                    132:         * Caller will return to locore and rte.
                    133:         */
                    134:        return(1);
                    135: }
                    136:
                    137: extern char *trap_type[];
                    138: extern int trap_types;
                    139:
                    140: /*
                    141:  * Print trap reason.
                    142:  */
                    143: static void
                    144: kdbprinttrap(type, code)
                    145:        int     type, code;
                    146: {
                    147:        printf("kernel: ");
                    148:        if (type >= trap_types || type < 0)
                    149:                printf("type %d", type);
                    150:        else
                    151:                printf("%s", trap_type[type]);
                    152:        printf(" trap\n");
                    153: }
                    154:
                    155: void
                    156: Debugger()
                    157: {
                    158:        __asm ("trap #15");
                    159: }
                    160:

CVSweb