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