Exemplo n.º 1
0
    def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) > 1:
            err("Usage: lvmst [L]")

        if len(argv) == 1:
            L = gdbutils.parse_ptr(argv[0], "lua_State*")
            if not L or str(L) == "void":
                raise gdb.GdbError("L empty")
        else:
            L = get_cur_L()

        #print "g: ", hex(int(L['glref']['ptr32']))

        g = G(L)

        vmstate = int(g['vmstate'])
        if vmstate >= 0:
            out("Compiled (trace #%d)\n" % vmstate)

        elif ~vmstate >= LJ_VMST__MAX:
            raise gdb.GdbError("Invalid VM state: ", ~vmstate)

        else:
            #print "vmstate = %d" % vmstate
            out("current VM state: %s\n" % vmstates[~vmstate])
Exemplo n.º 2
0
    def invoke (self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) > 1:
            err("Usage: lvmst [L]")

        if len(argv) == 1:
            L = gdbutils.parse_ptr(argv[0], "lua_State*")
            if not L or str(L) == "void":
                raise gdb.GdbError("L empty")
        else:
            L = get_cur_L()

        #print "g: ", hex(int(L['glref']['ptr32']))

        g = G(L)

        vmstate = int(g['vmstate'])
        if vmstate >= 0:
            out("Compiled (trace #%d)\n" % vmstate)

        elif ~vmstate >= LJ_VMST__MAX:
            raise gdb.GdbError("Invalid VM state: ", ~vmstate)

        else:
            #print "vmstate = %d" % vmstate
            out("current VM state: %s\n" % vmstates[~vmstate])
Exemplo n.º 3
0
    def invoke (self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) != 1:
            raise gdb.GdbError("Usage: luv fn")

        fn = gdbutils.parse_ptr(argv[0], "GCfunc*")
        #print str(fn)
        pt = funcproto(fn)
        dump_upvalues(fn, pt)
Exemplo n.º 4
0
    def invoke (self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) > 1:
            raise gdb.GdbError("Usage: lbt [L]")

        if len(argv) == 1:
            L = gdbutils.parse_ptr(argv[0], "lua_State*")
            if not L or str(L) == "void":
                raise gdb.GdbError("L empty")
        else:
            L = get_cur_L()

        #print "g: ", hex(int(L['glref']['ptr32']))

        g = G(L)

        vmstate = int(g['vmstate'])
        #print "vmstate = %d" % vmstate

        if vmstate >= 0:
            #print "compiled code"
            traceno = vmstate
            J = G2J(g)
            T = traceref(J, traceno)
            base = tvref(g['jit_base'])
            if not base:
                raise gdb.GdbError("jit base is NULL")
            bt = lj_debug_dumpstack(L, T, 30, base)

        else:
            if vmstate == ~LJ_VMST_EXIT:
                base = tvref(g['jit_base'])
                if base:
                    bt = lj_debug_dumpstack(L, 0, 30, base)

                else:
                    base = L['base']
                    bt = lj_debug_dumpstack(L, 0, 30, base)

            else:
                if vmstate == ~LJ_VMST_INTERP and not L['cframe']:
                    out("No Lua code running.\n")
                    return

                if vmstate == ~LJ_VMST_INTERP or \
                       vmstate == ~LJ_VMST_C or \
                       vmstate == ~LJ_VMST_GC:
                    base = L['base']
                    bt = lj_debug_dumpstack(L, 0, 30, base)

                else:
                    out("No Lua code running.\n")
                    return
        if not bt:
            out("Empty backtrace.\n")
        out(bt)
Exemplo n.º 5
0
    def invoke (self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) > 1:
            raise gdb.GdbError("Usage: lglobtab [L]")

        if len(argv) == 1:
            L = gdbutils.parse_ptr(argv[0], "lua_State*")
            if not L or str(L) == "void":
                raise gdb.GdbError("L empty")
        else:
            L = get_cur_L()

        #print "g: ", hex(int(L['glref']['ptr32']))

        out("(GCtab*)0x%x\n" % ptr2int(tabref(L['env'])))
Exemplo n.º 6
0
    def invoke(self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) > 1:
            raise gdb.GdbError("Usage: lbt [L]")

        if len(argv) == 1:
            L = gdbutils.parse_ptr(argv[0], "lua_State*")
            if not L or str(L) == "void":
                raise gdb.GdbError("L empty")
        else:
            L = get_cur_L()

        #print "g: ", hex(int(L['glref']['ptr32']))

        g = G(L)

        vmstate = int(g['vmstate'])
        #print "vmstate = %d" % vmstate

        if vmstate >= 0:
            #print "compiled code"
            traceno = vmstate
            J = G2J(g)
            T = traceref(J, traceno)
            base = tvref(g['jit_base'])
            if not base:
                raise gdb.GdbError("jit base is NULL")
            bt = lj_debug_dumpstack(L, T, 30, base)

        else:
            if vmstate == ~LJ_VMST_INTERP and not L['cframe']:
                out("No Lua code running.\n")
                return

            if vmstate == ~LJ_VMST_INTERP or \
                   vmstate == ~LJ_VMST_C or \
                   vmstate == ~LJ_VMST_GC:
                base = L['base']
                bt = lj_debug_dumpstack(L, 0, 30, base)

            else:
                out("No Lua code running.\n")
                return
        if not bt:
            out("Empty backtrace.\n")
        out(bt)
Exemplo n.º 7
0
    def invoke (self, args, from_tty):
        argv = gdb.string_to_argv(args)
        if len(argv) != 1:
            raise gdb.GdbError("Usage: lfenv tv")

        o = gdbutils.parse_ptr(argv[0], "TValue*")

        typstr = str(o.type)
        #print "type: %s\n" % typstr
        if typstr == "lua_State *":
            tab = tabref(o['env'])
            out("environment table: (GCtab*)0x%x\n" % ptr2int(tab))
            return

        if tvisthread(o):
            o = threadV(o)
            tab = tabref(threadV(o['env']))
            out("environment table: (GCtab*)0x%x\n" % ptr2int(tab))

        else:
            out("TODO")