1
0

amd64 3.6 KB

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