Author: Armin Rigo <[email protected]>
Branch: reverse-debugger
Changeset: r85406:060881a88f57
Date: 2016-06-27 18:07 +0200
http://bitbucket.org/pypy/pypy/changeset/060881a88f57/

Log:    Replaying old-style finalizers

diff --git a/rpython/memory/gctransform/support.py 
b/rpython/memory/gctransform/support.py
--- a/rpython/memory/gctransform/support.py
+++ b/rpython/memory/gctransform/support.py
@@ -77,18 +77,23 @@
     from rpython.rlib.rposix import c_write
     return c_write(fd, string, len(string))
 
+def destructor_failed(typename, e):
+    try:
+        write(2, "a destructor of type ")
+        write(2, typename)
+        write(2, " raised an exception ")
+        write(2, str(e))
+        write(2, " ignoring it\n")
+    except:
+        pass
+destructor_failed._dont_inline_ = True
+
 def ll_call_destructor(destrptr, destr_v, typename):
     try:
         destrptr(destr_v)
     except Exception as e:
-        try:
-            write(2, "a destructor of type ")
-            write(2, typename)
-            write(2, " raised an exception ")
-            write(2, str(e))
-            write(2, " ignoring it\n")
-        except:
-            pass
+        destructor_failed(typename, e)
+ll_call_destructor._revdb_do_all_calls_ = True
 
 def ll_report_finalizer_error(e):
     try:
diff --git a/rpython/translator/c/funcgen.py b/rpython/translator/c/funcgen.py
--- a/rpython/translator/c/funcgen.py
+++ b/rpython/translator/c/funcgen.py
@@ -399,8 +399,13 @@
                     line += '\nPYPY_INHIBIT_TAIL_CALL();'
                     break
         elif self.db.reverse_debugger:
-            from rpython.translator.revdb import gencsupp
-            line = gencsupp.emit(line, self.lltypename(v_result), r)
+            if getattr(getattr(self.graph, 'func', None),
+                       '_revdb_do_all_calls_', False):
+                pass   # a hack for ll_call_destructor() to mean
+                       # that the calls should really be done
+            else:
+                from rpython.translator.revdb import gencsupp
+                line = gencsupp.emit(line, self.lltypename(v_result), r)
         return line
 
     def OP_DIRECT_CALL(self, op):
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
@@ -1226,14 +1226,15 @@
     finalizer_trigger_saved_break = 0;
     fq_trigger();
 
-    /* Re-enable fetching more, and fetch the uid's of objects
-       with old-style destructors that die now. 
+    /* Re-enable fetching (disabled when we saw ASYNC_FINALIZER_TRIGGER),
+       and fetch the uid's of dying objects with old-style destructors.
     */
     rpy_reverse_db_fetch(__FILE__, __LINE__);
     while (1) {
         int64_t uid;
         struct destructor_s d_dummy, *entry, **item;
         struct pypy_header0 o_dummy;
+
         RPY_REVDB_EMIT(abort();, int64_t _e, uid);
         if (uid == -1)
             break;
@@ -1242,7 +1243,7 @@
         o_dummy.h_uid = uid;
         item = tfind(&d_dummy, &destructor_tree, _dtree_compare);
         if (item == NULL) {
-            fprintf(stderr, "next_dead: object not found\n");
+            fprintf(stderr, "replay_call_destructors: object not found\n");
             exit(1);
         }
         entry = *item;
diff --git a/rpython/translator/revdb/test/test_weak.py 
b/rpython/translator/revdb/test/test_weak.py
--- a/rpython/translator/revdb/test/test_weak.py
+++ b/rpython/translator/revdb/test/test_weak.py
@@ -308,3 +308,18 @@
         child = self.replay()
         child.send(Message(CMD_FORWARD, 3001))
         child.expect(ANSWER_AT_END)
+
+
+class TestReplayingOldStyleFinalizer(InteractiveTests):
+    expected_stop_points = 3000
+
+    def setup_class(cls):
+        from rpython.translator.revdb.test.test_basic import compile, run
+        main = get_old_style_finalizer_main()
+        compile(cls, main, backendopt=False)
+        run(cls, '')
+
+    def test_replaying_old_style_finalizer(self):
+        child = self.replay()
+        child.send(Message(CMD_FORWARD, 3001))
+        child.expect(ANSWER_AT_END)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to