.gdbinitlua 4.5 KB

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