Beispiel #1
0
def display_function_part(frame, max_lines_before, max_lines_after):
    if frame is None:
        return
    code = frame.getcode()
    if code.co_filename.startswith('<builtin>'):
        return
    first_lineno = code.co_firstlineno
    current_lineno = frame.get_last_lineno()
    final_lineno = get_final_lineno(code)
    #
    ellipsis_after = False
    if first_lineno < current_lineno - max_lines_before - 1:
        first_lineno = current_lineno - max_lines_before
        revdb.send_print("...")
    if final_lineno > current_lineno + max_lines_after + 1:
        final_lineno = current_lineno + max_lines_after
        ellipsis_after = True
    #
    for i in range(first_lineno, final_lineno + 1):
        if i == current_lineno:
            if revdb.current_place() == -2: # <= this is the arg to stop_point()
                prompt = "<< "     # return
            elif revdb.current_place() == -1:
                prompt = "!! "     # exceptional return
            else:
                prompt = " > "     # plain line
            revdb.send_output(prompt)
        else:
            revdb.send_output("   ")
        revdb.send_linecache(code.co_filename, i, strip=False)
    #
    if ellipsis_after:
        revdb.send_print("...")
Beispiel #2
0
 def descr_write(self, w_buffer):
     assert not dbstate.standard_code
     space = self.space
     if space.isinstance_w(w_buffer, space.w_unicode):
         w_buffer = space.call_method(w_buffer, 'encode',
                                      space.newtext('utf-8'))   # safe?
     revdb.send_output(space.bytes_w(w_buffer))
Beispiel #3
0
def show_frame(frame, lineno=0, indent=''):
    if lineno == 0:
        lineno = frame.get_last_lineno()
    revdb.send_output("%s%s\n%s  " % (
        indent,
        file_and_lineno(frame, lineno),
        indent))
    revdb.send_linecache(frame.getcode().co_filename, lineno)
Beispiel #4
0
 def callback_track_obj(gcref):
     revdb.send_output("callback_track_obj\n")
     dbstate.gcref = gcref
Beispiel #5
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