xref: /plan9/sys/lib/acid/amd64 (revision 23173ec17955c609738f37acefe0c6e72a169a75)
1// amd64
2
3defn acidinit()
4{
5	bplist = {};
6	bpfmt = 'b';
7
8	srcpath = {
9		"./",
10		"/sys/src/libc/port/",
11		"/sys/src/libc/9sys/",
12		"/sys/src/libc/amd64/"
13	};
14
15	srcfiles = {};		// list of loaded files
16	srctext = {};		// the text of the files
17}
18
19defn gpr()
20{
21	print("AX    ", *AX, "\n");
22	print("BX    ", *BX, "\n");
23	print("CX    ", *CX, "\n");
24	print("DX    ", *DX, "\n");
25	print("DI    ", *DI, "\n");
26	print("SI    ", *SI, "\n");
27	print("BP    ", *BP, "\n");
28	print("R8    ", *R8, "\n");
29	print("R9    ", *R9, "\n");
30	print("R10   ", *R10, "\n");
31	print("R11   ", *R11, "\n");
32	print("R12   ", *R12, "\n");
33	print("R13   ", *R13, "\n");
34	print("R14   ", *R14, "\n");
35	print("R15   ", *R15, "\n");
36}
37
38defn spr()
39{
40	print("DS  ", *DS, "  ES  ", *ES, "  FS  ", *FS, "  GS  ", *GS, "\n");
41	print("TYPE  ", *TYPE, "\n");
42	print("ERROR ", *ERROR, "\n");
43	print("PC    ", *PC, "\n");
44	print("CS    ", *CS, "\n");
45	print("FLAGS ", *FLAGS, "\n");
46	print("SP    ", *SP, "\n");
47	print("SS    ", *SS, "\n");
48}
49
50defn x87r()
51{
52	print("FCW  ", *FCW, "  FSW  ", *FSW, "  FTW  ", *FTW, "  FOP  ", *FOP, "\n");
53	print("RIP  ", *RIP, "   RDP  ", *RDP, "\n");
54	print("M0   ", *M0, "\n");
55	print("M1   ", *M1, "\n");
56	print("M2   ", *M2, "\n");
57	print("M3   ", *M3, "\n");
58	print("M4   ", *M4, "\n");
59	print("M5   ", *M5, "\n");
60	print("M6   ", *M6, "\n");
61	print("M7   ", *M7, "\n");
62}
63
64defn xmmr()
65{
66	print("MXCSR  ", *MXCSR, "   MXCSRMASK  ", *MXCSRMASK, "\n");
67	print("X0   ", *X0, "\n");
68	print("X1   ", *X1, "\n");
69	print("X2   ", *X2, "\n");
70	print("X3   ", *X3, "\n");
71	print("X4   ", *X4, "\n");
72	print("X5   ", *X5, "\n");
73	print("X6   ", *X6, "\n");
74	print("X7   ", *X7, "\n");
75	print("X8   ", *X8, "\n");
76	print("X9   ", *X9, "\n");
77	print("X10  ", *X10, "\n");
78	print("X11  ", *X11, "\n");
79	print("X12  ", *X12, "\n");
80	print("X13  ", *X13, "\n");
81	print("X14  ", *X14, "\n");
82	print("X15  ", *X15, "\n");
83}
84
85defn fpr()
86{
87	xmmr();
88}
89
90defn regs()
91{
92	gpr();
93	spr();
94}
95
96defn pstop(pid)
97{
98	local l;
99	local pc;
100
101	pc = *PC;
102
103	print(pid,": ", reason(*TRAP), "\t");
104	print(fmt(pc, 'a'), "\t", fmt(pc, 'i'), "\n");
105
106	if notes then {
107		if notes[0] != "sys: breakpoint" then {
108			print("Notes pending:\n");
109			l = notes;
110			while l do {
111				print("\t", head l, "\n");
112				l = tail l;
113			}
114		}
115	}
116}
117
118defn lstk()				// trace with locals
119{
120	_stk(*PC, *SP, 0, 1);
121}
122
123defn stk()
124{
125	_stk(*PC, *SP, 0, 0);
126}
127
128aggr Ureg
129{
130	'W' 0 ax;
131	'W' 8 bx;
132	'W' 16 cx;
133	'W' 24 dx;
134	'W' 32 si;
135	'W' 40 di;
136	'W' 48 bp;
137	'W' 56 r8;
138	'W' 64 r9;
139	'W' 72 r10;
140	'W' 80 r11;
141	'W' 88 r12;
142	'W' 96 r13;
143	'W' 104 r14;
144	'W' 112 r15;
145	'u' 120 ds;
146	'u' 122 es;
147	'u' 124 fs;
148	'u' 126 gs;
149	'W' 128 type;
150	'W' 136 error;
151	'W' 144 ip;
152	'W' 152 cs;
153	'W' 160 flags;
154	'W' 168 sp;
155	'W' 176 ss;
156};
157
158defn
159Ureg(addr) {
160	complex Ureg addr;
161	print("	ax	", addr.ax, "\n");
162	print("	bx	", addr.bx, "\n");
163	print("	cx	", addr.cx, "\n");
164	print("	dx	", addr.dx, "\n");
165	print("	si	", addr.si, "\n");
166	print("	di	", addr.di, "\n");
167	print("	bp	", addr.bp, "\n");
168	print("	r8	", addr.r8, "\n");
169	print("	r9	", addr.r9, "\n");
170	print("	r10	", addr.r10, "\n");
171	print("	r11	", addr.r11, "\n");
172	print("	r12	", addr.r12, "\n");
173	print("	r13	", addr.r13, "\n");
174	print("	r14	", addr.r14, "\n");
175	print("	r15	", addr.r15, "\n");
176	print("	ds	", addr.ds, "\n");
177	print("	es	", addr.es, "\n");
178	print("	fs	", addr.fs, "\n");
179	print("	gs	", addr.gs, "\n");
180	print("	type	", addr.type, "\n");
181	print("	error	", addr.error, "\n");
182	print("	ip	", addr.ip, "\n");
183	print("	cs	", addr.cs, "\n");
184	print("	flags	", addr.flags, "\n");
185	print("	sp	", addr.sp, "\n");
186	print("	ss	", addr.ss, "\n");
187};
188sizeofUreg = 184;
189
190print("/sys/lib/acid/amd64");
191