Beispiel #1
0
 def main(argv):
     lst = [argv[0], 'prebuilt1', 'prebuilt2']
     for op in argv[1:]:
         revdb.stop_point()
         print op
         lst.append(op + '??')  # create a new string here
     for x in lst:
         print revdb.get_unique_id(x)
     return 9
Beispiel #2
0
 def command_print(cmd, extra):
     if extra == 'print-me':
         stuff = dbstate.stuff
     elif extra == '$0':
         stuff = dbstate.metavar
     elif extra == '2.35':
         val = rdtoa.strtod('2.35')
         valx, valy = math.modf(val)
         revdb.send_output(rdtoa.dtoa(valx) + '\n')
         revdb.send_output(rdtoa.dtoa(valy) + '\n')
         xx, yy = math.frexp(val)
         revdb.send_output(rdtoa.dtoa(xx) + '\n')
         revdb.send_output('%d\n' % yy)
         return
     elif extra == 'very-long-loop':
         i = 0
         total = 0
         while i < 2000000000:
             total += revdb.flag_io_disabled()
             i += 1
         revdb.send_output(str(total))
         return
     else:
         assert False
     uid = revdb.get_unique_id(stuff)
     ll_assert(uid > 0, "uid == 0")
     revdb.send_nextnid(uid)  # outputs '$NUM = '
     revdb.send_output('stuff\n')
     dbstate.printed_stuff = stuff
Beispiel #3
0
def enter_call(caller_frame, callee_frame):
    if dbstate.breakpoint_funcnames is not None:
        name = callee_frame.getcode().co_name
        if name in dbstate.breakpoint_funcnames:
            revdb.breakpoint(dbstate.breakpoint_funcnames[name])
    if dbstate.breakpoint_stack_id != 0 and caller_frame is not None:
        if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame):
            revdb.breakpoint(-1)
    #
    code = callee_frame.pycode
    if code.co_revdb_linestarts is None:
        build_co_revdb_linestarts(code)
Beispiel #4
0
def command_stackid(cmd, extra):
    frame = fetch_cur_frame(silent=True)
    if frame is not None and cmd.c_arg1 != 0:     # parent_flag
        frame = dbstate.space.getexecutioncontext().getnextframe_nohidden(frame)
    if frame is None:
        uid = 0
    else:
        uid = revdb.get_unique_id(frame)
    if revdb.current_place() == -2:
        hidden_level = 1      # hide the "<<" events from next/bnext commands
    else:
        hidden_level = 0
    revdb.send_answer(revdb.ANSWER_STACKID, uid, hidden_level)
Beispiel #5
0
def revdb_displayhook(space, w_obj):
    """Modified sys.displayhook() that also outputs '$NUM = ',
    for non-prebuilt objects.  Such objects are then recorded in
    'printed_objects'.
    """
    assert not dbstate.standard_code
    if space.is_w(w_obj, space.w_None):
        return
    uid = revdb.get_unique_id(w_obj)
    if uid > 0:
        dbstate.printed_objects[uid] = w_obj
        revdb.send_nextnid(uid)   # outputs '$NUM = '
    space.setitem(space.builtin.w_dict, space.newtext('_'), w_obj)
    # do repr() after setitem: if w_obj was produced successfully,
    # but its repr crashes because it tries to do I/O, then we already
    # have it recorded in '_' and in '$NUM ='.
    w_repr = space.repr(w_obj)
    if space.isinstance_w(w_repr, space.w_unicode):
        w_repr = space.call_method(w_repr, 'encode',
                                   space.newtext('utf-8'))   # safe?
    revdb.send_print(space.bytes_w(w_repr))
Beispiel #6
0
def leave_call(caller_frame, got_exception):
    if dbstate.breakpoint_stack_id != 0 and caller_frame is not None:
        if dbstate.breakpoint_stack_id == revdb.get_unique_id(caller_frame):
            revdb.breakpoint(-2)
    if we_are_translated():
        stop_point_activate(-2 + got_exception)