|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1986, 1989 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)kdb_trap.c 7.7 (Berkeley) 4/3/90 ! 7: */ ! 8: ! 9: /* ! 10: * Trap handler - command loop entry point. ! 11: */ ! 12: #include "../kdb/defs.h" ! 13: ! 14: char *NOEOR; ! 15: ! 16: int executing; ! 17: char *lp; ! 18: ! 19: char lastc; ! 20: ! 21: ADDR userpc; ! 22: int lastcom; ! 23: ! 24: ADDR maxoff = MAXOFF; ! 25: long maxpos = MAXPOS; ! 26: ! 27: /* ! 28: * Kdb trap handler; entered on all fatal ! 29: * and/or debugger related traps or faults. ! 30: */ ! 31: kdb(type, code, curproc, kstack) ! 32: int type, code; ! 33: struct proc *curproc; ! 34: int kstack; ! 35: { ! 36: ! 37: var[varchk('t')] = type; ! 38: var[varchk('c')] = code; ! 39: var[varchk('p')] = (int)curproc; ! 40: if (executing) ! 41: delbp(); ! 42: executing = 0; ! 43: if (kstack) ! 44: printf("(from kernel stack)\n"); /* after delbp() */ ! 45: printtrap((long)type, (long)code); ! 46: userpc = dot = pcb.pcb_pc; ! 47: switch (setexit()) { ! 48: ! 49: case SINGLE: ! 50: setsstep(); /* hardware single step */ ! 51: /* fall thru... */ ! 52: case CONTIN: ! 53: return (1); ! 54: case PANIC: ! 55: return (0); ! 56: case 0: ! 57: if (nextpcs(type)) ! 58: printf("breakpoint%16t"); ! 59: else ! 60: printf("stopped at%16t"); ! 61: printpc(); ! 62: break; ! 63: } ! 64: if (executing) ! 65: delbp(); ! 66: executing = 0; ! 67: for (;;) { ! 68: flushbuf(); ! 69: if (errflg) { ! 70: printf("%s\n", errflg); ! 71: errflg = 0; ! 72: } ! 73: if (mkfault) { ! 74: mkfault=0; ! 75: printc('\n'); ! 76: printf(DBNAME); ! 77: } ! 78: kdbwrite("kdb> ", 5); ! 79: lp=0; (void) rdc(); lp--; ! 80: (void) command((char *)0, lastcom); ! 81: if (lp && lastc!='\n') ! 82: error(NOEOR); ! 83: } ! 84: } ! 85: ! 86: /* ! 87: * If there has been an error or a fault, take the error. ! 88: */ ! 89: chkerr() ! 90: { ! 91: if (errflg || mkfault) ! 92: error(errflg); ! 93: } ! 94: ! 95: /* ! 96: * An error occurred; save the message for ! 97: * later printing, and reset to main command loop. ! 98: */ ! 99: error(n) ! 100: char *n; ! 101: { ! 102: ! 103: errflg = n; ! 104: reset(ERROR); ! 105: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.