[pypy-commit] pypy reverse-debugger: Fix tests. Improve safety

arigo pypy.commits at gmail.com
Fri Jun 17 11:26:07 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger
Changeset: r85213:10e58efcb71e
Date: 2016-06-17 16:22 +0200
http://bitbucket.org/pypy/pypy/changeset/10e58efcb71e/

Log:	Fix tests. Improve safety

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
@@ -364,6 +364,10 @@
 static void disable_io(rpy_revdb_t *dinfo)
 {
     *dinfo = rpy_revdb;   /* save the complete struct */
+    dinfo->saved_exc[0] = pypy_g_ExcData.ed_exc_type;
+    dinfo->saved_exc[1] = pypy_g_ExcData.ed_exc_value;
+    pypy_g_ExcData.ed_exc_type = NULL;
+    pypy_g_ExcData.ed_exc_value = NULL;
     rpy_revdb.buf_p = NULL;
     rpy_revdb.buf_limit = NULL;
     flag_io_disabled = 1;
@@ -374,12 +378,19 @@
     uint64_t v1, v2;
     flag_io_disabled = 0;
 
+    if (pypy_g_ExcData.ed_exc_type != NULL) {
+        printf("Command crashed with %.*s\n",
+               (int)(pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.length),
+               pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.items);
+    }
     /* restore the complete struct, with the exception of '*_break' */
     v1 = rpy_revdb.stop_point_break;
     v2 = rpy_revdb.unique_id_break;
     rpy_revdb = *dinfo;
     rpy_revdb.stop_point_break = v1;
     rpy_revdb.unique_id_break = v2;
+    pypy_g_ExcData.ed_exc_type = dinfo->saved_exc[0];
+    pypy_g_ExcData.ed_exc_value = dinfo->saved_exc[1];
 }
 
 /* generated by RPython */
@@ -418,27 +429,12 @@
 static void execute_rpy_function(void func(RPyString *), RPyString *arg)
 {
     rpy_revdb_t dinfo;
-    void *saved_t = pypy_g_ExcData.ed_exc_type;
-    void *saved_v = pypy_g_ExcData.ed_exc_value;
-    pypy_g_ExcData.ed_exc_type = NULL;
-    pypy_g_ExcData.ed_exc_value = NULL;
     disable_io(&dinfo);
     invoke_after_forward = NULL;
     invoke_argument = NULL;
-
-    if (setjmp(jmp_buf_cancel_execution) == 0) {
-
+    if (setjmp(jmp_buf_cancel_execution) == 0)
         func(arg);
-
-        if (pypy_g_ExcData.ed_exc_type != NULL) {
-            printf("Command crashed with %.*s\n",
-                   (int)(pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.length),
-                   pypy_g_ExcData.ed_exc_type->ov_name->rs_chars.items);
-        }
-    }
     enable_io(&dinfo);
-    pypy_g_ExcData.ed_exc_type = saved_t;
-    pypy_g_ExcData.ed_exc_value = saved_v;
 }
 
 struct action_s {
@@ -905,8 +901,12 @@
 RPY_EXTERN
 uint64_t rpy_reverse_db_unique_id_break(void *new_object)
 {
+    rpy_revdb_t dinfo;
     rpy_revdb.unique_id_break = 0;
-    unique_id_callback(new_object);
+    disable_io(&dinfo);
+    if (setjmp(jmp_buf_cancel_execution) == 0)
+        unique_id_callback(new_object);
+    enable_io(&dinfo);
     return rpy_revdb.unique_id_seen;
 }
 
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
@@ -19,6 +19,7 @@
     char *buf_p, *buf_limit;
     uint64_t stop_point_seen, stop_point_break;
     uint64_t unique_id_seen, unique_id_break;
+    void *saved_exc[2];
 } rpy_revdb_t;
 
 RPY_EXTERN rpy_revdb_t rpy_revdb;
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
@@ -236,10 +236,11 @@
                 print op
                 lst.append(op + '??')   # create a new string here
             for x in lst:
-                print revdb.creation_time_of(x)
+                print revdb.get_unique_id(x)
             return 9
         compile(cls, main, [], backendopt=False)
-        assert run(cls, 'abc d ef') == 'abc\nd\nef\n0\n0\n1\n2\n3\n'
+        assert run(cls, 'abc d ef') == ('abc\nd\nef\n'
+                                        '3\n0\n12\n15\n17\n')
         rdb = fetch_rdb(cls, [cls.exename, 'abc', 'd', 'ef'])
         assert rdb.number_of_stop_points() == 3
 


More information about the pypy-commit mailing list