Author: Armin Rigo <[email protected]>
Branch: reverse-debugger
Changeset: r86009:84d843464c68
Date: 2016-08-03 22:04 +0200
http://bitbucket.org/pypy/pypy/changeset/84d843464c68/
Log: Record return from functions as events too
diff --git a/pypy/interpreter/executioncontext.py
b/pypy/interpreter/executioncontext.py
--- a/pypy/interpreter/executioncontext.py
+++ b/pypy/interpreter/executioncontext.py
@@ -87,9 +87,9 @@
# be accessed also later
frame_vref()
jit.virtual_ref_finish(frame_vref, frame)
- if self.space.config.translation.reverse_debugger:
- from pypy.interpreter.reverse_debugging import leave_call
- leave_call(self.topframeref(), frame)
+ if self.space.config.translation.reverse_debugger:
+ from pypy.interpreter.reverse_debugging import leave_call
+ leave_call(self.topframeref(), frame)
# ________________________________________________________________
diff --git a/pypy/interpreter/reverse_debugging.py
b/pypy/interpreter/reverse_debugging.py
--- a/pypy/interpreter/reverse_debugging.py
+++ b/pypy/interpreter/reverse_debugging.py
@@ -78,12 +78,14 @@
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)
def jump_backward(frame, jumpto):
# When we see a jump backward, we set 'f_revdb_nextline_instr' in
# such a way that the next instruction, at 'jumpto', will trigger
- # stop_point_at_start_of_line(). We have to trigger it even if
+ # stop_point_activate(). We have to trigger it even if
# 'jumpto' is not actually a start of line. For example, after a
# 'while foo:', the body ends with a JUMP_ABSOLUTE which
# jumps back to the *second* opcode of the while.
@@ -117,12 +119,12 @@
if ch == 0:
pass # we are at the start of a line now
else:
- # We are not, so don't call stop_point_at_start_of_line().
+ # We are not, so don't call stop_point_activate().
# We still have to fill f_revdb_nextline_instr.
call_stop_point_at_line = False
#
if call_stop_point_at_line:
- stop_point_at_start_of_line()
+ stop_point_activate()
cur += 1
ch = ord(co_revdb_linestarts[cur])
#
@@ -199,7 +201,7 @@
non_standard_code = NonStandardCode()
-def stop_point_at_start_of_line():
+def stop_point_activate(place=0):
if revdb.watch_save_state():
any_watch_point = False
space = dbstate.space
@@ -219,7 +221,7 @@
revdb.watch_restore_state(any_watch_point)
if watch_id != -1:
revdb.breakpoint(watch_id)
- revdb.stop_point()
+ revdb.stop_point(place)
def load_metavar(index):
@@ -382,7 +384,8 @@
indent))
revdb.send_linecache(frame.getcode().co_filename, lineno)
-def display_function_part(frame, max_lines_before, max_lines_after):
+def display_function_part(frame, max_lines_before, max_lines_after,
+ prompt="> "):
code = frame.getcode()
if code.co_filename.startswith('<builtin>'):
return
@@ -400,7 +403,7 @@
#
for i in range(first_lineno, final_lineno + 1):
if i == current_lineno:
- revdb.send_output("> ")
+ revdb.send_output(prompt)
else:
revdb.send_output(" ")
revdb.send_linecache(code.co_filename, i, strip=False)
@@ -415,7 +418,12 @@
if cmd.c_arg1 == 0:
revdb.send_output("%s:\n" % (
file_and_lineno(frame, frame.get_last_lineno()),))
- display_function_part(frame, max_lines_before=8, max_lines_after=5)
+ if revdb.current_place() == -2:
+ prompt = "<<"
+ else:
+ prompt = "> "
+ display_function_part(frame, max_lines_before=8, max_lines_after=5,
+ prompt=prompt)
elif cmd.c_arg1 == 2:
display_function_part(frame,
max_lines_before=1000,max_lines_after=1000)
else:
diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -26,14 +26,14 @@
ANSWER_WATCH = 23
-def stop_point():
+def stop_point(place=0):
"""Indicates a point in the execution of the RPython program where
the reverse-debugger can stop. When reverse-debugging, we see
the "time" as the index of the stop-point that happened.
"""
if we_are_translated():
if fetch_translated_config().translation.reverse_debugger:
- llop.revdb_stop_point(lltype.Void)
+ llop.revdb_stop_point(lltype.Void, place)
def register_debug_command(command, lambda_func):
"""Register the extra RPython-implemented debug command."""
@@ -75,6 +75,12 @@
unique id greater or equal."""
return llop.revdb_get_value(lltype.SignedLongLong, 'u')
+def current_place():
+ """For RPython debug commands: the value of the 'place' argument
+ passed to stop_point().
+ """
+ return llop.revdb_get_value(lltype.Signed, 'p')
+
## @specialize.arg(1)
## def go_forward(time_delta, callback):
## """For RPython debug commands: tells that after this function finishes,
diff --git a/rpython/translator/revdb/src-revdb/revdb.c
b/rpython/translator/revdb/src-revdb/revdb.c
--- a/rpython/translator/revdb/src-revdb/revdb.c
+++ b/rpython/translator/revdb/src-revdb/revdb.c
@@ -145,14 +145,17 @@
static void record_stop_point(void);
static void replay_stop_point(void);
+static long current_place;
RPY_EXTERN
-void rpy_reverse_db_stop_point(void)
+void rpy_reverse_db_stop_point(long place)
{
if (!RPY_RDB_REPLAY)
record_stop_point();
- else
+ else {
+ current_place = place;
replay_stop_point();
+ }
}
@@ -1244,6 +1247,8 @@
return (flag_io_disabled == FID_REGULAR_MODE ?
rpy_revdb.unique_id_seen :
saved_state.unique_id_seen);
+ case 'p': /* current_place() */
+ return current_place;
default:
return -1;
}
diff --git a/rpython/translator/revdb/src-revdb/revdb_include.h
b/rpython/translator/revdb/src-revdb/revdb_include.h
--- a/rpython/translator/revdb/src-revdb/revdb_include.h
+++ b/rpython/translator/revdb/src-revdb/revdb_include.h
@@ -129,9 +129,9 @@
_RPY_REVDB_PRUID(); \
} while (0)
-#define OP_REVDB_STOP_POINT(r) \
+#define OP_REVDB_STOP_POINT(place, r) \
if (++rpy_revdb.stop_point_seen == rpy_revdb.stop_point_break) \
- rpy_reverse_db_stop_point()
+ rpy_reverse_db_stop_point(place)
#define OP_REVDB_SEND_ANSWER(cmd, arg1, arg2, arg3, ll_string, r) \
rpy_reverse_db_send_answer(cmd, arg1, arg2, arg3, ll_string)
@@ -176,7 +176,7 @@
RPY_EXTERN void rpy_reverse_db_flush(void);
RPY_EXTERN void rpy_reverse_db_fetch(const char *file, int line);
-RPY_EXTERN void rpy_reverse_db_stop_point(void);
+RPY_EXTERN void rpy_reverse_db_stop_point(long place);
RPY_EXTERN void rpy_reverse_db_send_answer(int cmd, int64_t arg1, int64_t arg2,
int64_t arg3, RPyString *extra);
RPY_EXTERN Signed rpy_reverse_db_identityhash(struct pypy_header0 *obj);
diff --git a/rpython/translator/revdb/test/test_basic.py
b/rpython/translator/revdb/test/test_basic.py
--- a/rpython/translator/revdb/test/test_basic.py
+++ b/rpython/translator/revdb/test/test_basic.py
@@ -341,6 +341,8 @@
if extra == 'get-value':
revdb.send_answer(100, revdb.current_time(),
revdb.total_time())
+ if extra == 'current-place':
+ revdb.send_answer(200, revdb.current_place())
## if extra == 'go-fw':
## revdb.go_forward(1, went_fw)
## if cmdline == 'set-break-after-0':
@@ -375,7 +377,7 @@
for i, op in enumerate(argv[1:]):
dbstate.stuff = Stuff()
dbstate.stuff.x = i + 1000
- revdb.stop_point()
+ revdb.stop_point(i * 10)
print op
if i == 1:
if os.fork() == 0: # child
@@ -419,6 +421,18 @@
child.send(Message(1, extra='get-value'))
child.expect(100, 1, 3)
+ def test_current_place(self):
+ child = self.replay()
+ child.send(Message(1, extra='current-place'))
+ child.expect(200, 0)
+ child.expect(42, 1, -43, -44, 'current-place')
+ child.expect(ANSWER_READY, 1, Ellipsis)
+ child.send(Message(CMD_FORWARD, 2))
+ child.expect(ANSWER_READY, 3, Ellipsis)
+ child.send(Message(1, extra='current-place'))
+ child.expect(200, 20)
+ child.expect(42, 1, -43, -44, 'current-place')
+
## def test_go_fw(self):
## child = self.replay()
## child.send(Message(1, extra='go-fw'))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit