1
0

acme 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // support for acme; acid must be run with /acme/acid/$cputype/Acid
  2. defn w(*code)
  3. {
  4. local dir;
  5. printto("/tmp/acme.acid", eval code);
  6. rc("cat /tmp/acme.acid | wnew -d "+"Acid/-stk'("+itoa(pid)+")'");
  7. }
  8. defn procstk(pid, name)
  9. {
  10. local dir;
  11. printto("/tmp/acme.acid", stk());
  12. rc("cat /tmp/acme.acid | wnew -d "+"Acid/-'"+name+"("+itoa(pid)+")'");
  13. }
  14. defn taskstk(tid, name)
  15. {
  16. local dir;
  17. printto("/tmp/acme.acid", threadstk(tid));
  18. rc("cat /tmp/acme.acid | wnew -d "+"Acid/-"+name+"'("+itoa(pid)+")'");
  19. }
  20. defn _stk(pc, sp, link, dolocals)
  21. {
  22. local stk;
  23. print("At pc:", pc, ":", fmt(pc, 'a'), " ");
  24. pfl(pc);
  25. stk = strace(pc, sp, link);
  26. while stk do {
  27. frame = head stk;
  28. print(fmt(frame[0], 'a'), "(");
  29. params(frame[2], frame[0]);
  30. print(") ");
  31. print("\n\tcalled from ", fmt(frame[1], 'a'), " ");
  32. pfl(frame[1]);
  33. stk = tail stk;
  34. if dolocals then
  35. locals(frame[3], frame[0]);
  36. }
  37. }
  38. //defn _stk(pc, sp, dolocals)
  39. //{
  40. // w(__stk(pc, sp, dolocals));
  41. //}
  42. defn params(param, name)
  43. {
  44. while param do {
  45. sym = head param;
  46. print("*", fmt(name, 'a'), ":", sym[0], "=", sym[1]);
  47. param = tail param;
  48. if param then
  49. print (",");
  50. }
  51. }
  52. defn locals(l, name)
  53. {
  54. local sym;
  55. while l do {
  56. sym = head l;
  57. print("\t*", fmt(name, 'a'), ":", sym[0], "=", sym[1], "\n");
  58. l = tail l;
  59. }
  60. }
  61. defn bptab() // print a table of breakpoints
  62. {
  63. local lst, addr;
  64. lst = bplist;
  65. while lst do {
  66. addr = head lst;
  67. print("\tbpdel(", fmt(addr, 'a'), ")\n");
  68. lst = tail lst;
  69. }
  70. }
  71. defn procs() // print status of processes
  72. {
  73. local c, lst, cpid;
  74. cpid = pid;
  75. lst = proclist;
  76. while lst do {
  77. np = head lst;
  78. setproc(np);
  79. if np == cpid then
  80. print(">");
  81. print("\t", "setproc(", np, ")\t", status(np), " at ", fmt(*PC, 'a'), "\n");
  82. lst = tail lst;
  83. }
  84. pid = cpid;
  85. if pid != 0 then
  86. setproc(pid);
  87. }
  88. defn allstacks() // print stacks of processes and threads
  89. {
  90. complex Proc P;
  91. local T, Tq;
  92. local c, lst, cpid;
  93. cpid = pid;
  94. P = (Proc)pq.$head;
  95. while P != 0 do{
  96. Tq = (Tqueue)P.threads;
  97. T = (Thread)Tq.$head;
  98. setproc(P.pid);
  99. while T != 0 do{
  100. if(T.cmdname == 0) then taskstk(T, "unknown");
  101. else taskstk(T, *(T.cmdname\s));
  102. T = T.nextt;
  103. }
  104. P = P.next;
  105. }
  106. pid = cpid;
  107. if pid != 0 then
  108. setproc(pid);
  109. }
  110. print("/sys/lib/acid/acme");