[pypy-commit] pypy reverse-debugger: first_created_object_uid()
arigo
pypy.commits at gmail.com
Wed Jun 15 13:14:58 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger
Changeset: r85180:91be90845d8d
Date: 2016-06-15 16:27 +0200
http://bitbucket.org/pypy/pypy/changeset/91be90845d8d/
Log: first_created_object_uid()
diff --git a/rpython/rlib/revdb.py b/rpython/rlib/revdb.py
--- a/rpython/rlib/revdb.py
+++ b/rpython/rlib/revdb.py
@@ -71,6 +71,12 @@
unique id greater or equal."""
return llop.revdb_get_value(lltype.SignedLongLong, 'u')
+def first_created_object_uid():
+ """Returns the creation number of the first object dynamically created
+ by the program. Older objects are either prebuilt or created before
+ the first stop point."""
+ return llop.revdb_get_value(lltype.SignedLongLong, '1')
+
@specialize.argtype(0)
def get_unique_id(x):
"""Returns the creation number of the object 'x'. For objects created
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
@@ -227,6 +227,7 @@
static uint64_t total_stop_points;
static uint64_t stopped_time;
static uint64_t stopped_uid;
+static uint64_t first_created_uid;
static void (*invoke_after_forward)(RPyString *);
static RPyString *invoke_argument;
@@ -698,6 +699,8 @@
fprintf(stderr, "stop_point_break overflow?\n");
exit(1);
}
+ if (frozen_num_pipes == 0)
+ first_created_uid = rpy_revdb.unique_id_seen;
fprintf(stderr, "[%llu]",
(unsigned long long)rpy_revdb.stop_point_seen);
@@ -877,6 +880,8 @@
return rpy_revdb.stop_point_break;
case 'u': /* currently_created_objects() */
return stopped_uid ? stopped_uid : rpy_revdb.unique_id_seen;
+ case '1': /* first_created_object_uid() */
+ return first_created_uid;
default:
return -1;
}
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
@@ -350,6 +350,9 @@
obj = revdb.get_tracked_object(Stuff)
revdb.send_output('None\n' if obj is None else
('obj.x=%d\n' % obj.x))
+ if cmdline == 'first-created-uid':
+ revdb.send_output('first-created-uid=%d\n' % (
+ revdb.first_created_object_uid(),))
revdb.send_output('blipped\n')
lambda_blip = lambda: blip
#
@@ -563,3 +566,22 @@
'obj.x=1001\r\n'
'blipped\r\n'
'(2)$ ')
+
+ def test_first_created_uid(self):
+ child = self.replay()
+ child.expectx('(3)$ ')
+ child.sendline('r first-created-uid')
+ child.expectx('<<<first-created-uid>>>\r\n')
+ child.expect('first-created-uid=(\d+)\r\n')
+ first_created_id = int(child.match.group(1))
+ child.expectx('blipped\r\n'
+ '(3)$ ')
+ child.sendline('__go 1')
+ child.expectx('(1)$ ')
+ child.sendline('r print-id')
+ child.expect(re.escape('<<<print-id>>>\r\n')
+ + r'obj.x=1000 (\d+) (\d+)'
+ + re.escape('\r\n'
+ 'blipped\r\n'
+ '(1)$ '))
+ assert int(child.match.group(2)) == first_created_id
More information about the pypy-commit
mailing list