Author: Armin Rigo <ar...@tunes.org> Branch: reverse-debugger Changeset: r85453:2070975d17bc Date: 2016-06-29 18:21 +0200 http://bitbucket.org/pypy/pypy/changeset/2070975d17bc/
Log: Starts to work, almost. 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 @@ -670,6 +670,12 @@ OP_CAST_ADR_TO_PTR = OP_CAST_POINTER OP_CAST_OPAQUE_PTR = OP_CAST_POINTER + def OP_CAST_PTR_TO_INT(self, op): + if self.db.reverse_debugger: + from rpython.translator.revdb import gencsupp + return gencsupp.cast_ptr_to_int(self, op) + return self.OP_CAST_POINTER(op) + def OP_LENGTH_OF_SIMPLE_GCARRAY_FROM_OPAQUE(self, op): return ('%s = *(long *)(((char *)%s) + sizeof(struct pypy_header0));' ' /* length_of_simple_gcarray_from_opaque */' diff --git a/rpython/translator/c/src/int.h b/rpython/translator/c/src/int.h --- a/rpython/translator/c/src/int.h +++ b/rpython/translator/c/src/int.h @@ -160,7 +160,6 @@ #define OP_CAST_INT_TO_LONGLONGLONG(x,r) r = (__int128_t)(x) #define OP_CAST_CHAR_TO_INT(x,r) r = (Signed)((unsigned char)(x)) #define OP_CAST_INT_TO_CHAR(x,r) r = (char)(x) -#define OP_CAST_PTR_TO_INT(x,r) r = (Signed)(x) /* XXX */ #define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (Signed)(x) #define OP_TRUNCATE_LONGLONGLONG_TO_INT(x,r) r = (Signed)(x) diff --git a/rpython/translator/revdb/gencsupp.py b/rpython/translator/revdb/gencsupp.py --- a/rpython/translator/revdb/gencsupp.py +++ b/rpython/translator/revdb/gencsupp.py @@ -25,6 +25,10 @@ return 'rpy_reverse_db_register_destructor(%s, %s);' % ( funcgen.expr(op.args[0]), funcgen.expr(op.args[1])) +def cast_ptr_to_int(funcgen, op): + return '%s = RPY_REVDB_CAST_PTR_TO_INT(%s);' % ( + funcgen.expr(op.result), funcgen.expr(op.args[0])) + def prepare_database(db): FUNCPTR = lltype.Ptr(lltype.FuncType([revdb._CMDPTR, lltype.Ptr(rstr.STR)], 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 @@ -1183,6 +1183,9 @@ RPY_EXTERN int rpy_reverse_db_fq_register(void *obj) { + /*fprintf(stderr, "FINALIZER_TREE: %lld -> %p\n", + ((struct pypy_header0 *)obj)->h_uid, obj); + */ if (!RPY_RDB_REPLAY) { return 0; /* recording */ } 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 @@ -29,14 +29,19 @@ RPY_EXTERN void rpy_reverse_db_setup(int *argc_p, char **argv_p[]); RPY_EXTERN void rpy_reverse_db_teardown(void); -#if 1 /* enable to print locations to stderr of all the EMITs */ +#if 0 /* enable to print locations to stderr of all the EMITs */ # define _RPY_REVDB_PRINT(mode) \ fprintf(stderr, \ "%s:%d: %0*llx\n", \ __FILE__, __LINE__, 2 * sizeof(_e), \ ((unsigned long long)_e) & ((2ULL << (8*sizeof(_e)-1)) - 1)) +# define _RPY_REVDB_PRUID() \ + fprintf(stderr, \ + "%s:%d: obj %llu\n", \ + __FILE__, __LINE__, (unsigned long long) uid) #else # define _RPY_REVDB_PRINT(mode) /* nothing */ +# define _RPY_REVDB_PRUID() /* nothing */ #endif @@ -72,6 +77,7 @@ uid = rpy_reverse_db_unique_id_break(expr); \ rpy_revdb.unique_id_seen = uid + 1; \ ((struct pypy_header0 *)expr)->h_uid = uid; \ + _RPY_REVDB_PRUID(); \ } while (0) #define OP_REVDB_STOP_POINT(r) \ @@ -113,6 +119,12 @@ #define OP_REVDB_CALL_DESTRUCTOR(obj, r) \ rpy_reverse_db_call_destructor(obj) +/* Used only for getting a fast hash value that doesn't change too + often (with the minimark GC, it changes at most once). Here, + we'll just return the UID. */ +#define RPY_REVDB_CAST_PTR_TO_INT(obj) (((struct pypy_header0 *)obj)->h_uid) + + 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); _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit