1 /* kdb_trap.c 7.4 86/11/23 */ 2 3 /* 4 * Trap handler - command loop entry point. 5 */ 6 #include "../kdb/defs.h" 7 8 char *NOEOR; 9 10 int executing; 11 char *lp; 12 13 char lastc; 14 15 ADDR userpc; 16 int lastcom; 17 18 ADDR maxoff = MAXOFF; 19 long maxpos = MAXPOS; 20 21 /* 22 * Kdb trap handler; entered on all fatal 23 * and/or debugger related traps or faults. 24 */ 25 kdb(type, code, curproc) 26 int type, code; 27 struct proc *curproc; 28 { 29 30 var[varchk('t')] = type; 31 var[varchk('c')] = code; 32 var[varchk('p')] = (int)curproc; 33 printtrap(type, code); 34 userpc = dot = pcb.pcb_pc; 35 switch (setexit()) { 36 37 case SINGLE: 38 setsstep(); /* hardware single step */ 39 /* fall thru... */ 40 case CONTIN: 41 return (1); 42 case 0: 43 if (nextpcs(type, 0)) 44 printf("breakpoint%16t"); 45 else 46 printf("stopped at%16t"); 47 printpc(); 48 break; 49 } 50 if (executing) 51 delbp(); 52 executing = 0; 53 for (;;) { 54 flushbuf(); 55 if (errflg) { 56 printf("%s\n", errflg); 57 errflg = 0; 58 } 59 if (mkfault) { 60 mkfault=0; 61 printc('\n'); 62 printf(DBNAME); 63 } 64 kdbwrite("kdb> ", 5); 65 lp=0; rdc(); lp--; 66 command(0, lastcom); 67 if (lp && lastc!='\n') 68 error(NOEOR); 69 } 70 } 71 72 /* 73 * If there has been an error or a fault, take the error. 74 */ 75 chkerr() 76 { 77 if (errflg || mkfault) 78 error(errflg); 79 } 80 81 /* 82 * An error occurred; save the message for 83 * later printing, and reset to main command loop. 84 */ 85 error(n) 86 char *n; 87 { 88 89 errflg = n; 90 reset(ERROR); 91 } 92