13 if objtype == "386" then
14 return {"PC", l.pc, "BX", l.bx, "SP", l.sp, "BP", l.bp, "SI", l.si, "DI", l.di};
34 s = s + "tag(*" + itoa(A.tag, "%x") + "=" + itoa(*A.tag, "%x") + ") ";
37 while A.op != CHANEND && A.op != CHANNOBLK do{
38 if A.op != CHANNOP then{
39 if yes then s = s + " ";
40 s = s + itoa(i, "%d");
42 if A.op == CHANSND then s = s + "send";
43 if A.op == CHANRCV then s = s + "recv";
45 s = s + itoa(A.c, "%x");
50 A = (Alt)(A + sizeofAlt);
52 if A.op==CHANNOBLK then{
53 if yes then s = s + " ";
61 print(altfmt(A), "\n");
80 append stkignorelist, s;
83 defn threadstkline(T){
84 local stk, frame, pc, pc0, file, s, sym, i, stop, P, mainpid;
86 if T.state == Running then {
89 if mainpid != P.pid then setproc(P.pid);
91 if mainpid != P.pid then setproc(mainpid);
93 stk = strace(label(T.sched));
96 while stk && !stop do {
102 if !regexp("plan9/src/lib9/", file)
103 && !regexp("plan9/src/libthread/", file)
104 && match(file, stkignore)==-1 then
108 s = file+":"+itoa(pcline(pc), "%d");
110 s = s + " "+fnname(pc0);
116 local A, yes, i, P, s;
119 s = "t=(Thread)"+itoa(T, "%-10x")+" // ";
121 if T.state == Running then
123 else if T.state == Ready then
125 else if T.state == Rendezvous then
128 s = s + "Bad state "+itoa(T.state, "%x")+" ";
132 s = s + threadstkline(T);
133 else if T.chan == Chanalt then
134 s = s + altfmt(T.alt);
135 else if T.chan == Chansend then
136 s = s + "send(Channel("+itoa(A.c, "%x")+"))";
137 else if T.chan == Chanrecv then
138 s = s + "recv(Channel("+itoa(A.c, "%x")+"))";
140 s = s + threadstkline(T);
142 if T.moribund == 1 then
144 if T.cmdname != 0 then
145 s = s + " ["+*(T.cmdname\s)+"]";
150 print(threadfmt(T), "\n");
155 local T, Tq, mainpid;
158 Tq = (Tqueue)P.threads;
159 T = (Thread)Tq.$head;
169 complex Pqueue _threadpq;
171 P = (Proc)_threadpq.$head;
173 if P != (Proc)_threadpq.$head then print("\n");
181 complex Pqueue _threadpq;
185 P = (Proc)_threadpq.$head;
188 if mainpid != P.pid then setproc(P.pid);
190 // if P.thread==0 then{
191 // print("=== thread scheduler stack\n");
194 // print("threadstks(", P\X, ")\n");
196 if mainpid != P.pid then setproc(mainpid);
204 local P, T, Tq, top, sp, mainpid;
205 complex Pqueue _threadpq;
208 P = (Proc)_threadpq.$head;
211 if mainpid != P.pid then setproc(P.pid);
212 Tq = (Tqueue)P.threads;
213 T = (Thread)Tq.$head;
215 top = T.stk+T.stksize;
216 if T.state==Running then {
221 print(top-sp\D, " of ", T.stksize\D, " - 0x", top\X, " 0x", sp\X, " ", *T.stk\X, "\n");
224 if mainpid != P.pid then setproc(mainpid);
236 "plan9/src/libthread/",
238 "plan9/src/lib9/(fmt|utf)/",
242 local T, Tq, mainpid, pref, ign;
246 stkprefix = pref+"\t\t";
248 stkignore = threadstkignore;
250 Tq = (Tqueue)P.threads;
251 T = (Thread)Tq.$head;
253 // print("=============================\n");
254 // print(" thread(", T\X, ")\n");
269 print("p=(Proc)", itoa(P, "%-10x"), " pid ", P.pid\D, " ");
279 complex Pqueue _threadpq;
281 P = (Proc)_threadpq.$head;
296 if T.state == Running then{
312 if T.state == Running then{
313 if P.pid != mainpid then
316 if P.pid != mainpid then
328 print(Q.$head\X, " ");
339 print("channel ", C\X);
341 print(" (moribund)");
344 print("\telementsize=", C.e\D, " buffersize=", C.s, "\n");
346 print("\t", C.n\D, " values in channel:\n");
348 p = C.v+C.e*(C.f%C.s);
353 print("data(", (*p)\X, ") ");
356 if p == C.v+C.s*C.e then {
362 print(C.nentry\D, " queue slots:\n");
366 print("\t", altfmt(C.qentry[i]), "\n");
368 print("\t<empty>\n");
374 local i, c, t, p, pf;
376 p=(Poll)polls; pf=(struct_pollfd)pfd; loop 1,*npoll do {
377 print("\tfd ", pf.fd\D, " ");
378 if pf.events & 1 then
380 else if pf.events & 2 then
384 print(" chan Channel(", p.c\X, ")\n");
385 p = (Poll)(p+sizeofPoll);
386 pf = (struct_pollfd)(pf+sizeofstruct_pollfd);
389 c=sleepchan; t=sleeptime; loop 1,*nsleep do {
390 print("\tsleep ", *t\D, " Channel(", *c\X, ")\n");