Author: Armin Rigo <ar...@tunes.org>
Branch: reverse-debugger
Changeset: r85316:afd4dd224a4e
Date: 2016-06-21 19:17 +0200
http://bitbucket.org/pypy/pypy/changeset/afd4dd224a4e/

Log:    fixes

diff --git a/rpython/translator/revdb/process.py 
b/rpython/translator/revdb/process.py
--- a/rpython/translator/revdb/process.py
+++ b/rpython/translator/revdb/process.py
@@ -71,7 +71,7 @@
         return ''.join(pieces)
 
     def send(self, msg):
-        print 'SENT:', self.pid, msg
+        #print 'SENT:', self.pid, msg
         binary = struct.pack("iIqqq", msg.cmd, len(msg.extra),
                              msg.arg1, msg.arg2, msg.arg3)
         self.control_socket.sendall(binary + msg.extra)
@@ -81,7 +81,7 @@
         cmd, size, arg1, arg2, arg3 = struct.unpack("iIqqq", binary)
         extra = self._recv_all(size)
         msg = Message(cmd, arg1, arg2, arg3, extra)
-        print 'RECV:', self.pid, msg
+        #print 'RECV:', self.pid, msg
         return msg
 
     def expect(self, cmd, arg1=0, arg2=0, arg3=0, extra=""):
@@ -355,29 +355,27 @@
         """Ensure that all the given unique_ids are loaded in the active
         child, if necessary by forking another child from earlier.
         """
-        import pdb;pdb.set_trace()
         initial_time = self.get_current_time()
-        must_go_forward_again = False
+        child = self.active
         while True:
-            uid_limit = self.get_currently_created_objects()
+            uid_limit = child.currently_created_objects
             missing_uids = [uid for uid in uids
                                 if uid < uid_limit
-                                   and uid not in self.active.printed_objects]
+                                   and uid not in child.printed_objects]
             if not missing_uids:
                 break
-
-            # we need to start with an older fork
-            start_time = self.get_current_time()
+            # pick the earlier fork
+            start_time = child.current_time
             stop_time = max(time for time in self.paused if time < start_time)
-            self._resume(stop_time)
-            must_go_forward_again = True
+            child = self.paused[stop_time]
 
         # No missing_uids left: all uids are either already in
         # self.active.printed_objects, or in the future.
         future_uids = [uid for uid in uids if uid >= uid_limit]
-        if not must_go_forward_again:
+        if child is self.active:
             assert not future_uids
         else:
+            self._resume(stop_time)
             future_uids.sort()
             pack_uids = [struct.pack('q', uid) for uid in future_uids]
             self.active.send(Message(CMD_FUTUREIDS, extra=''.join(pack_uids)))
@@ -391,25 +389,24 @@
     def print_cmd(self, expression, nids=[]):
         """Print an expression.
         """
+        uids = []
         if nids:
-            uids = []
-            for nid in nids:
+            for nid in set(nids):
                 try:
                     uid = self.all_printed_objects_lst[nid]
                 except IndexError:
-                    print >> sys.stderr, ("no print command printed any "
-                                          "value for '$%d'" % nid)
-                    return
+                    continue
                 if uid >= self.get_currently_created_objects():
-                    print >> sys.stderr, ("'$%d' refers to an object that is "
-                                          "only created later in time" % nid)
-                    return
+                    print >> sys.stderr, (
+                        "note: '$%d' refers to an object that is "
+                        "only created later in time" % nid)
+                    continue
                 uids.append(uid)
             self.ensure_printed_objects(uids)
         #
         self.active.tainted = True
-        for nid in nids:
-            uid = self.all_printed_objects_lst[nid]
+        for uid in uids:
+            nid = self.all_printed_objects[uid]
             self.active.send(Message(CMD_ATTACHID, nid, uid))
             self.active.expect_ready()
         self.active.send(Message(CMD_PRINT, extra=expression))
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
@@ -559,6 +559,7 @@
         }
         memcpy(future_ids, extra, cmd->extra_size);
         future_ids[cmd->extra_size / sizeof(uint64_t)] = 0;
+        rpy_revdb.unique_id_break = *future_ids;
     }
     future_next_id = future_ids;
 }
@@ -736,17 +737,22 @@
 RPY_EXTERN
 uint64_t rpy_reverse_db_unique_id_break(void *new_object)
 {
+    uint64_t uid = rpy_revdb.unique_id_seen;
     if (!new_object) {
         fprintf(stderr, "out of memory: allocation failed, cannot continue\n");
         exit(1);
     }
     if (rpy_revdb_commands.rp_alloc) {
+        rpy_revdb_t dinfo;
         save_state();
-        rpy_revdb_commands.rp_alloc(rpy_revdb.unique_id_seen, new_object);
+        disable_io(&dinfo);
+        if (setjmp(jmp_buf_cancel_execution) == 0)
+            rpy_revdb_commands.rp_alloc(uid, new_object);
+        enable_io(&dinfo);
         restore_state();
     }
     rpy_revdb.unique_id_break = *future_next_id++;
-    return rpy_revdb.unique_id_seen;
+    return uid;
 }
 
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to