.gdbinitlua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. set pagination off
  2. set print null-stop
  3. define prTS
  4. set $o = &(((TString *)(($arg0).value))->tsv)
  5. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  6. printf "String: hash = 0x%08x, len = %u : %s\n", $o->hash, $o->len, (char *)($o+1)
  7. end
  8. define prTnodes
  9. set $o = (Table *)($arg0)
  10. set $n = 1<<($o->lsizenode)
  11. set $i = 0
  12. while $i < $n
  13. set $nd = ($o->node) + $i
  14. if $nd->i_key.nk.tt && $nd->i_val.tt
  15. if $nd->i_key.nk.tt == 6
  16. printf "%4u: %s %2i\n", $i, $nd->i_key.nk.tt , $nd->i_val.tt
  17. else
  18. printf "%4u: %2i %2i\n", $i, $nd->i_key.nk.tt , $nd->i_val.tt
  19. end
  20. end
  21. set $i = $i +1
  22. end
  23. end
  24. define prTarray
  25. set $o = (Table *)($arg0)
  26. set $n = $o->sizearray
  27. set $i = 0
  28. while $i < $n
  29. set $nd = ($o->array) + $i
  30. prTV $nd
  31. set $i = $i +1
  32. end
  33. end
  34. define prTV
  35. if $arg0
  36. set $type = ($arg0).tt
  37. set $val = ($arg0).value
  38. if $type == 0
  39. # NIL
  40. printf "Nil\n"
  41. end
  42. if $type == 1
  43. # Boolean
  44. printf "Boolean: %u\n", $val.n
  45. end
  46. if $type == 2
  47. # Light User Data
  48. printf "Light Udata: %p\n", $val.p
  49. end
  50. if $type == 3
  51. # Number
  52. printf "Number: %u\n", $val.n
  53. end
  54. if $type == 4
  55. # String
  56. printf "String: %s\n", (char *)($val.p)+16
  57. end
  58. if $type == 5
  59. # Table
  60. set $o = &($val->gc.h)
  61. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  62. printf "Nodes: %4i %p\n", 2<<($o->lsizenode), $o->node
  63. printf "Arry: %4i %p\n", $o->sizearray, $o->array
  64. end
  65. if $type == 6
  66. # Function
  67. set $o = &($val->gc.cl.c)
  68. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  69. if $o->isC == 0
  70. set $o = &($val->gc.cl.l)
  71. printf "LClosure: nupvalues = %u, gclist = %p, env = %p, p = %p\n", \
  72. $o->nupvalues, $o->gclist, $o->env, $o->p
  73. else
  74. printf "CClosure: nupvalues = %u, gclist = %p, env = %p, f = %p\np", \
  75. $o->nupvalues, $o->gclist, $o->env, $o->f
  76. end
  77. end
  78. if $type == 7
  79. # UserData
  80. set $o = &($val->gc.u.uv)
  81. printf "Common header: next = %p, marked = 0x%01x\n", $o->next, $o->marked
  82. printf "UD = %p Userdata: metatable = ", ($o+1))
  83. print ($o)->metatable
  84. end
  85. if $type == 8
  86. # Thread
  87. end
  88. if $type == 21
  89. # ROTable
  90. printf "ROTable: %p\n", $val.p
  91. end
  92. if $type == 38
  93. # Light Function
  94. printf "Light Func: %p\n", $val.p
  95. end
  96. end
  97. end
  98. define prT
  99. print *(Table*)($arg0)
  100. end
  101. define prL
  102. if L > 0
  103. printf " stack: %u\n", L->top-L->base
  104. printf " hooking: %u, %u, %u, %u, %p\n", L->hookmask, L->allowhook, L->basehookcount, L->hookcount, L->hook
  105. end
  106. end
  107. define dumpstrt
  108. set $st = $arg0
  109. set $i = 0
  110. while $i< $st->size
  111. set $o = &(((TString *)($st->hash[$i]))->tsv)
  112. while $o
  113. if $o->next
  114. printf "Slot: %5i %p %p %08x %02x %4u", \
  115. $i, $o, $o->next, $o->hash, $o->marked, $o->len
  116. else
  117. printf "Slot: %5i %p %08x %02x %4u", \
  118. $i, $o, $o->hash, $o->marked, $o->len
  119. end
  120. if $o->marked & 0x80
  121. printf "* %s\n", *(char **)($o+1)
  122. else
  123. printf " %s\n", (char *)($o+1)
  124. end
  125. set $o = &(((TString *)($o->next))->tsv)
  126. end
  127. set $i = $i + 1
  128. end
  129. end
  130. define dumpRAMstrt
  131. dumpstrt &(L->l_G->strt)
  132. end
  133. define dumpROstrt
  134. dumpstrt &(L->l_G->ROstrt)
  135. end
  136. define graylist
  137. set $n = $arg0
  138. while $n
  139. printf "%p %2u %02X\n",$n, $n->gch.tt, $n->gch.marked
  140. set $n=$n->gch.next
  141. end
  142. end
  143. define prPC
  144. printf "Excuting instruction %i: %08x\n", (pc - cl->p->code)+1-1, i
  145. end
  146. define where
  147. set $f=cl->p
  148. printf "<%s:%u,%u>, opcode %u\n",\
  149. (char *)$f->source+17, $f->linedefined, $f->lastlinedefined, pc - $f->code
  150. end
  151. define callinfo
  152. printf "%p: ", L->ci
  153. print *L->ci
  154. end
  155. define luastack
  156. set $i = 0
  157. set $ci = L->base_ci
  158. set $s = L->stack
  159. set $last = L->stack_last - L->stack
  160. printf "stack = %p, last: %i, size: %i, " , $s, $last, L->stacksize
  161. if $last+6==L->stacksize
  162. printf "(OK)\n"
  163. else
  164. printf "(MISMATCH)\n"
  165. end
  166. printf " Ndx top base func\n"
  167. while $ci <= L->ci
  168. printf "%3u %6i %6i %6i\n", $i++, $ci->top-$s, $ci->base-$s, ($ci++)->func-$s
  169. end
  170. end
  171. define stacklen
  172. printf "%i top: %p, base: %p\n", \
  173. L->ci->top - L->base, L->ci->top, L->base
  174. end
  175. define stackcheck
  176. set $ci = L->ci
  177. printf "Used: %i, Headroom: %i, Total: %i\n", \
  178. L->top-$ci->base-1, $ci->top-L->top+1, $ci->top-$ci->base
  179. end