1 include("/sys/src/libthread/sched." + objtype + ".acid");
5 if objtype == "386" || objtype == "amd64" then
17 _stk(labpc(l), labsp(l), 0, 1);
22 _stk(labpc(l), labsp(l), 0, 1);
30 s = s + "tag(*" + itoa(A.tag, "%x") + "=" + itoa(*A.tag, "%x") + ") ";
33 while A.op != CHANEND && A.op != CHANNOBLK do{
34 if A.op != CHANNOP then{
35 if yes then s = s + " ";
36 s = s + itoa(i, "%d");
38 if A.op == CHANSND then s = s + "send";
39 if A.op == CHANRCV then s = s + "recv";
41 s = s + itoa(A.c, "%x");
46 A = (Alt)(A + sizeofAlt);
48 if A.op==CHANNOBLK then{
49 if yes then s = s + " ";
57 print(altfmt(A), "\n");
62 "^/sys/src/libthread",
77 return itoa(a\X, "%x");
83 append stkignorelist, s;
86 defn threadstkline(T){
87 local ostk, stk, frame, pc, pc0, file, lastpc0, s, sym, i, stop;
89 if T.state == Running then{
91 stk = strace(*PC, *SP, linkreg(0));
94 stk = strace(labpc(T.sched), labsp(T.sched), 0);
101 while stk && !stop do {
103 if !regexp("^/sys/src/libc/", file)
104 && !regexp("^/sys/src/libthread/", file)
105 && match(file, stkignore)==-1 then
107 else if stk[0][1] == 0xfefefefe then {
115 nextframe = head stk;
121 s = file+":"+itoa(pcline(pc), "%d");
123 s = s + " "+fnname(pc0);
129 local A, yes, i, P, s;
132 s = "t=(Thread)"+itoa(T, "%-10x")+" ";
134 if T.state == Running then
136 else if T.state == Ready then
138 else if T.state == Rendezvous then
141 s = s + "Bad state "+itoa(T.state, "%x")+" ";
145 s = s + threadstkline(T);
146 else if T.chan == Chanalt then
147 s = s + altfmt(T.alt);
148 else if T.chan == Chansend then
149 s = s + "send(Channel("+itoa(A.c, "%x")+"))";
150 else if T.chan == Chanrecv then
151 s = s + "recv(Channel("+itoa(A.c, "%x")+"))";
153 s = s + threadstkline(T);
155 if T.moribund == 1 then
157 if T.cmdname != 0 then
158 s = s + " ["+*(T.cmdname\s)+"]";
163 print(threadfmt(T), "\n");
168 local T, Tq, mainpid;
172 Tq = (Tqueue)P.threads;
173 T = (Thread)Tq.$head;
185 P = (Proc)_threadpq.$head;
187 if P != (Proc)_threadpq.$head then print("\n");
197 P = (Proc)_threadpq.$head;
201 // if P.thread==0 then{
202 // print("=== thread scheduler stack\n");
205 // print("threadstks(", P\X, ")\n");
214 local P, T, Tq, top, sp, mainpid;
217 P = (Proc)_threadpq.$head;
220 Tq = (Tqueue)P.threads;
221 T = (Thread)Tq.$head;
223 top = T.stk+T.stksize;
224 if T.state==Running then {
230 print(top-sp\D, " / ", T.stksize\D, "\n");
245 local T, Tq, mainpid, pref, ign;
249 stkprefix = pref+"\t\t";
252 "^/sys/src/libthread/",
253 "^/sys/src/libc/(386|arm|sparc|power|mips)/"
256 Tq = (Tqueue)P.threads;
257 T = (Thread)Tq.$head;
259 // print("=============================\n");
260 // print(" thread(", T\X, ")\n");
275 print("p=(Proc)", itoa(P, "%-10x"), " pid ", P.pid\D, " ");
286 P = (Proc)_threadpq.$head;
301 if T.state == Running then{
317 if T.state == Running then{
329 print(Q.$head\X, " ");
340 print("channel ", C\X);
342 print(" (moribund)");
345 print("\telementsize=", C.e\D, " buffersize=", C.s, "\n");
347 print("\t", C.n\D, " values in channel:\n");
349 p = C.v+C.e*(C.f%C.s);
354 print("data(", (*p)\X, ") ");
357 if p == C.v+C.s*C.e then {
363 print(C.nentry\D, " queue slots:\n");
367 print("\t", altfmt(C.qentry[i]), "\n");
369 print("\t<empty>\n");
374 print("/sys/lib/acid/thread");