.gdbinitlua 4.1 KB

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