|
|
1.1 root 1: /*
2: * Copyright (c) 1986 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.5 (Berkeley) 12/15/86
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)
32: int type, code;
33: struct proc *curproc;
34: {
35:
36: var[varchk('t')] = type;
37: var[varchk('c')] = code;
38: var[varchk('p')] = (int)curproc;
39: printtrap((long)type, (long)code);
40: userpc = dot = pcb.pcb_pc;
41: switch (setexit()) {
42:
43: case SINGLE:
44: setsstep(); /* hardware single step */
45: /* fall thru... */
46: case CONTIN:
47: return (1);
48: case 0:
49: if (nextpcs(type))
50: printf("breakpoint%16t");
51: else
52: printf("stopped at%16t");
53: printpc();
54: break;
55: }
56: if (executing)
57: delbp();
58: executing = 0;
59: for (;;) {
60: flushbuf();
61: if (errflg) {
62: printf("%s\n", errflg);
63: errflg = 0;
64: }
65: if (mkfault) {
66: mkfault=0;
67: printc('\n');
68: printf(DBNAME);
69: }
70: kdbwrite("kdb> ", 5);
71: lp=0; (void) rdc(); lp--;
72: (void) command((char *)0, lastcom);
73: if (lp && lastc!='\n')
74: error(NOEOR);
75: }
76: }
77:
78: /*
79: * If there has been an error or a fault, take the error.
80: */
81: chkerr()
82: {
83: if (errflg || mkfault)
84: error(errflg);
85: }
86:
87: /*
88: * An error occurred; save the message for
89: * later printing, and reset to main command loop.
90: */
91: error(n)
92: char *n;
93: {
94:
95: errflg = n;
96: reset(ERROR);
97: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.