[pypy-commit] pypy reverse-debugger: Tweaks. Can now record and replay duhton.

arigo pypy.commits at gmail.com
Sat Jun 11 06:32:33 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger
Changeset: r85096:0c5d9de93e74
Date: 2016-06-11 12:33 +0200
http://bitbucket.org/pypy/pypy/changeset/0c5d9de93e74/

Log:	Tweaks. Can now record and replay duhton.

diff --git a/rpython/memory/gctransform/boehm.py b/rpython/memory/gctransform/boehm.py
--- a/rpython/memory/gctransform/boehm.py
+++ b/rpython/memory/gctransform/boehm.py
@@ -102,6 +102,9 @@
             destrptr = None
             DESTR_ARG = None
 
+        if self.translator.config.translation.reverse_debugger:
+            destrptr = None    # XXX for now
+
         if destrptr:
             EXC_INSTANCE_TYPE = self.translator.rtyper.exceptiondata.lltype_of_exception_value
             typename = TYPE.__name__
diff --git a/rpython/rlib/rstack.py b/rpython/rlib/rstack.py
--- a/rpython/rlib/rstack.py
+++ b/rpython/rlib/rstack.py
@@ -5,7 +5,7 @@
 
 import py
 
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, fetch_translated_config
 from rpython.rlib.rarithmetic import r_uint
 from rpython.rlib import rgc
 from rpython.rtyper.lltypesystem import lltype, rffi
@@ -42,6 +42,8 @@
 def stack_check():
     if not we_are_translated():
         return
+    if fetch_translated_config().translation.reverse_debugger:
+        return     # XXX for now
     #
     # Load the "current" stack position, or at least some address that
     # points close to the current stack head
diff --git a/rpython/translator/revdb/rdb-src/revdb.c b/rpython/translator/revdb/rdb-src/revdb.c
--- a/rpython/translator/revdb/rdb-src/revdb.c
+++ b/rpython/translator/revdb/rdb-src/revdb.c
@@ -95,7 +95,7 @@
 
 static void setup_record_mode(int argc, char *argv[])
 {
-    char *filename = getenv("PYPYREVDB");
+    char *filename = getenv("PYPYRDB");
     rdb_header_t h;
 
     assert(RPY_RDB_REPLAY == 0);
@@ -103,11 +103,11 @@
     rpy_revdb.buf_limit = rpy_rev_buffer + sizeof(rpy_rev_buffer) - 32;
 
     if (filename && *filename) {
-        putenv("PYPYREVDB=");
+        putenv("PYPYRDB=");
         rpy_rev_fileno = open(filename, O_WRONLY | O_CLOEXEC |
                               O_CREAT | O_NOCTTY | O_TRUNC, 0600);
         if (rpy_rev_fileno < 0) {
-            fprintf(stderr, "Fatal error: can't create PYPYREVDB file '%s'\n",
+            fprintf(stderr, "Fatal error: can't create PYPYRDB file '%s'\n",
                     filename);
             abort();
         }
@@ -473,7 +473,9 @@
         exit(1);
     }
     if (stop_points != rpy_revdb.stop_point_seen) {
-        fprintf(stderr, "Bad number of stop points\n");
+        fprintf(stderr, "Bad number of stop points "
+                "(seen %llu, recorded %llu)\n", rpy_revdb.stop_point_seen,
+                stop_points);
         exit(1);
     }
     if (rpy_revdb.buf_p != rpy_revdb.buf_limit ||
diff --git a/rpython/translator/revdb/rdb-src/revdb_include.h b/rpython/translator/revdb/rdb-src/revdb_include.h
--- a/rpython/translator/revdb/rdb-src/revdb_include.h
+++ b/rpython/translator/revdb/rdb-src/revdb_include.h
@@ -28,12 +28,21 @@
 RPY_EXTERN void rpy_reverse_db_setup(int *argc_p, char **argv_p[]);
 RPY_EXTERN void rpy_reverse_db_teardown(void);
 
+#if 0    /* enable to print locations to stderr of all the EMITs */
+#  define _RPY_REVDB_PRINT(args)  fprintf args
+#else
+#  define _RPY_REVDB_PRINT(args)  /* nothing */
+#endif
+
 
 #define RPY_REVDB_EMIT(normal_code, decl_e, variable)                   \
     if (!RPY_RDB_REPLAY) {                                              \
         normal_code                                                     \
         {                                                               \
             decl_e = variable;                                          \
+            _RPY_REVDB_PRINT((stderr, "%s:%d: write %*llx\n",           \
+                              __FILE__, __LINE__,                       \
+                              2 * sizeof(_e), (unsigned long long)_e)); \
             memcpy(rpy_revdb.buf_p, &_e, sizeof(_e));                   \
             if ((rpy_revdb.buf_p += sizeof(_e)) > rpy_revdb.buf_limit)  \
                 rpy_reverse_db_flush();                                 \
@@ -48,6 +57,9 @@
             }                                                           \
             rpy_revdb.buf_p = _end1;                                    \
             memcpy(&_e, _src, sizeof(_e));                              \
+            _RPY_REVDB_PRINT((stderr, "%s:%d: read %*llx\n",            \
+                              __FILE__, __LINE__,                       \
+                              2 * sizeof(_e), (unsigned long long)_e)); \
             variable = _e;                                              \
     }
 
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
@@ -74,7 +74,7 @@
 
 def run(self, *argv):
     env = os.environ.copy()
-    env['PYPYREVDB'] = self.rdbname
+    env['PYPYRDB'] = self.rdbname
     t = self.t
     stdout, stderr = t.driver.cbuilder.cmdexec(' '.join(argv), env=env,
                                                expect_crash=9)


More information about the pypy-commit mailing list