]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/acid/386
acid/kernel: for stacktraces, try to use context from error stack when process is...
[plan9front.git] / sys / lib / acid / 386
1 // 386 support
2
3 defn acidinit()                 // Called after all the init modules are loaded
4 {
5         bplist = {};
6         bpfmt = 'b';
7         wplist = {};
8         wpflush();
9
10         srcpath = {
11                 "./",
12                 "/sys/src/libc/port/",
13                 "/sys/src/libc/9sys/",
14                 "/sys/src/libc/386/"
15         };
16
17         srcfiles = {};                  // list of loaded files
18         srctext = {};                   // the text of the files
19 }
20
21 defn linkreg(addr)
22 {
23         return 0;
24 }
25
26 defn stk()                              // trace
27 {
28         _stk(*PC, *SP, 0, 0);
29 }
30
31 defn lstk()                             // trace with locals
32 {
33         _stk(*PC, *SP, 0, 1);
34 }
35
36 defn gpr()              // print general(hah hah!) purpose registers
37 {
38         print("AX\t", *AX, " BX\t", *BX, " CX\t", *CX, " DX\t", *DX, "\n");
39         print("DI\t", *DI, " SI\t", *SI, " BP\t", *BP, "\n");
40 }
41
42 defn spr()                              // print special processor registers
43 {
44         local pc;
45         local cause;
46
47         pc = *PC;
48         print("PC\t", pc, " ", fmt(pc, 'a'), "  ");
49         pfl(pc);
50         print("SP\t", *SP, " ECODE ", *ECODE, " EFLAG ", *EFLAGS, "\n");
51         print("CS\t", *CS, " DS\t ", *DS, " SS\t", *SS, "\n");
52         print("GS\t", *GS, " FS\t ", *FS, " ES\t", *ES, "\n");
53         
54         cause = *TRAP;
55         print("TRAP\t", cause, " ", reason(cause), "\n");
56 }
57
58 defn regs()                             // print all registers
59 {
60         spr();
61         gpr();
62 }
63
64 defn fpr()
65 {
66         print("F0\t",  *F0, "\n");
67         print("F1\t",  *F1, "\n");
68         print("F2\t",  *F2, "\n");
69         print("F3\t",  *F3, "\n");
70         print("F4\t",  *F4, "\n");
71         print("F5\t",  *F5, "\n");
72         print("F6\t",  *F6, "\n");
73         print("F7\t",  *F7, "\n");
74         print("control\t", *FCW, "\n");
75         print("status\t", *FSW, "\n");
76         print("tag\t", *FTW, "\n");
77         print("ip\t", *FIP, "\n");
78         print("cs selector\t", *FCS, "\n");
79         print("opcode\t", *FOP, "\n");
80         print("data operand\t", *FDP, "\n");
81         print("operand selector\t", *FDS, "\n");
82 }
83
84 defn pstop(pid)
85 {
86         local l;
87         local pc;
88
89         pc = (*PC)\i;
90         
91         if notes && regexp("^sys: watchpoint ", notes[0]) then
92                 pc--;
93
94         print(pid,": ", reason(*TRAP), "\t");
95         print(fmt(pc, 'a'), "\t", pc, "\n");
96
97         if notes then {
98                 if regexp("^sys: watchpoint ", notes[0]) then
99                         wpprocess();
100                 else if notes[0] != "sys: breakpoint" then {
101                         print("Notes pending:\n");
102                         l = notes;
103                         while l do {
104                                 print("\t", head l, "\n");
105                                 l = tail l;
106                         }
107                 }
108         }
109 }
110
111 aggr Ureg
112 {
113         'X' 0 di;
114         'X' 4 si;
115         'X' 8 bp;
116         'X' 12 nsp;
117         'X' 16 bx;
118         'X' 20 dx;
119         'X' 24 cx;
120         'X' 28 ax;
121         'X' 32 gs;
122         'X' 36 fs;
123         'X' 40 es;
124         'X' 44 ds;
125         'X' 48 trap;
126         'X' 52 ecode;
127         'X' 56 pc;
128         'X' 60 cs;
129         'X' 64 flags;
130         {
131         'X' 68 usp;
132         'X' 68 sp;
133         };
134         'X' 72 ss;
135 };
136
137 defn
138 Ureg(addr) {
139         complex Ureg addr;
140         print(" di      ", addr.di, "\n");
141         print(" si      ", addr.si, "\n");
142         print(" bp      ", addr.bp, "\n");
143         print(" nsp     ", addr.nsp, "\n");
144         print(" bx      ", addr.bx, "\n");
145         print(" dx      ", addr.dx, "\n");
146         print(" cx      ", addr.cx, "\n");
147         print(" ax      ", addr.ax, "\n");
148         print(" gs      ", addr.gs, "\n");
149         print(" fs      ", addr.fs, "\n");
150         print(" es      ", addr.es, "\n");
151         print(" ds      ", addr.ds, "\n");
152         print(" trap    ", addr.trap, "\n");
153         print(" ecode   ", addr.ecode, "\n");
154         print(" pc      ", addr.pc, "\n");
155         print(" cs      ", addr.cs, "\n");
156         print(" flags   ", addr.flags, "\n");
157         print(" sp      ", addr.sp, "\n");
158         print(" ss      ", addr.ss, "\n");
159 };
160 sizeofUreg = 76;
161
162 print("/sys/lib/acid/386");