aboutsummaryrefslogtreecommitdiff
path: root/acid/acme
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-04-19 18:18:37 +0000
committerrsc <devnull@localhost>2004-04-19 18:18:37 +0000
commit0a61c07d591273b76da21fb8386b669989da3707 (patch)
tree1dd9832f7d646f12c0ff5cf7ff64d1fddc6bd361 /acid/acme
parentc8af1ab17b72f500c27688598dbb893f09f62c53 (diff)
downloadplan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.gz
plan9port-0a61c07d591273b76da21fb8386b669989da3707.tar.bz2
plan9port-0a61c07d591273b76da21fb8386b669989da3707.zip
acid files
Diffstat (limited to 'acid/acme')
-rw-r--r--acid/acme133
1 files changed, 133 insertions, 0 deletions
diff --git a/acid/acme b/acid/acme
new file mode 100644
index 00000000..1cce6eb8
--- /dev/null
+++ b/acid/acme
@@ -0,0 +1,133 @@
+// support for acme; acid must be run with /acme/acid/$cputype/Acid
+
+
+defn w(*code)
+{
+ local dir;
+
+ printto("/tmp/acme.acid", eval code);
+ rc("cat /tmp/acme.acid | wnew -d "+"Acid/-stk'("+itoa(pid)+")'");
+}
+
+defn procstk(pid, name)
+{
+ local dir;
+
+ printto("/tmp/acme.acid", stk());
+ rc("cat /tmp/acme.acid | wnew -d "+"Acid/-'"+name+"("+itoa(pid)+")'");
+}
+
+defn taskstk(tid, name)
+{
+ local dir;
+
+ printto("/tmp/acme.acid", threadstk(tid));
+ rc("cat /tmp/acme.acid | wnew -d "+"Acid/-"+name+"'("+itoa(pid)+")'");
+}
+
+defn _stk(pc, sp, link, dolocals)
+{
+ local stk;
+
+ print("At pc:", pc, ":", fmt(pc, 'a'), " ");
+ pfl(pc);
+
+ stk = strace(pc, sp, link);
+
+ while stk do {
+ frame = head stk;
+ print(fmt(frame[0], 'a'), "(");
+ params(frame[2], frame[0]);
+ print(") ");
+ print("\n\tcalled from ", fmt(frame[1], 'a'), " ");
+ pfl(frame[1]);
+ stk = tail stk;
+ if dolocals then
+ locals(frame[3], frame[0]);
+ }
+}
+
+//defn _stk(pc, sp, dolocals)
+//{
+// w(__stk(pc, sp, dolocals));
+//}
+
+
+defn params(param, name)
+{
+ while param do {
+ sym = head param;
+ print("*", fmt(name, 'a'), ":", sym[0], "=", sym[1]);
+ param = tail param;
+ if param then
+ print (",");
+ }
+}
+
+defn locals(l, name)
+{
+ local sym;
+
+ while l do {
+ sym = head l;
+ print("\t*", fmt(name, 'a'), ":", sym[0], "=", sym[1], "\n");
+ l = tail l;
+ }
+}
+
+defn bptab() // print a table of breakpoints
+{
+ local lst, addr;
+
+ lst = bplist;
+ while lst do {
+ addr = head lst;
+ print("\tbpdel(", fmt(addr, 'a'), ")\n");
+ lst = tail lst;
+ }
+}
+
+defn procs() // print status of processes
+{
+ local c, lst, cpid;
+
+ cpid = pid;
+ lst = proclist;
+ while lst do {
+ np = head lst;
+ setproc(np);
+ if np == cpid then
+ print(">");
+ print("\t", "setproc(", np, ")\t", status(np), " at ", fmt(*PC, 'a'), "\n");
+ lst = tail lst;
+ }
+ pid = cpid;
+ if pid != 0 then
+ setproc(pid);
+}
+
+defn allstacks() // print stacks of processes and threads
+{
+ complex Proc P;
+ local T, Tq;
+ local c, lst, cpid;
+
+ cpid = pid;
+ P = (Proc)pq.$head;
+ while P != 0 do{
+ Tq = (Tqueue)P.threads;
+ T = (Thread)Tq.$head;
+ setproc(P.pid);
+ while T != 0 do{
+ if(T.cmdname == 0) then taskstk(T, "unknown");
+ else taskstk(T, *(T.cmdname\s));
+ T = T.nextt;
+ }
+ P = P.next;
+ }
+ pid = cpid;
+ if pid != 0 then
+ setproc(pid);
+}
+
+print(acidfile);