Author: Maciej Fijalkowski <[email protected]>
Branch: vmprof2
Changeset: r76855:cb3455f7a86e
Date: 2015-04-21 13:34 +0200
http://bitbucket.org/pypy/pypy/changeset/cb3455f7a86e/
Log: merge default
diff --git a/pypy/objspace/descroperation.py b/pypy/objspace/descroperation.py
--- a/pypy/objspace/descroperation.py
+++ b/pypy/objspace/descroperation.py
@@ -129,7 +129,8 @@
# This is meant to be a *mixin*.
def is_data_descr(space, w_obj):
- return space.lookup(w_obj, '__set__') is not None
+ return (space.lookup(w_obj, '__set__') is not None or
+ space.lookup(w_obj, '__delete__') is not None)
def get_and_call_args(space, w_descr, w_obj, args):
# a special case for performance and to avoid infinite recursion
diff --git a/pypy/objspace/test/test_descroperation.py
b/pypy/objspace/test/test_descroperation.py
--- a/pypy/objspace/test/test_descroperation.py
+++ b/pypy/objspace/test/test_descroperation.py
@@ -607,6 +607,18 @@
raises(AttributeError, lambda: A().a)
+ def test_delete_descriptor(self):
+ class Prop(object):
+ def __get__(self, obj, cls):
+ return 42
+ def __delete__(self, obj):
+ obj.deleted = True
+ class C(object):
+ x = Prop()
+ obj = C()
+ del obj.x
+ assert obj.deleted
+
def test_non_callable(self):
meth = classmethod(1).__get__(1)
raises(TypeError, meth)
diff --git a/pypy/tool/gdb_pypy.py b/pypy/tool/gdb_pypy.py
--- a/pypy/tool/gdb_pypy.py
+++ b/pypy/tool/gdb_pypy.py
@@ -5,7 +5,7 @@
Or, alternatively:
-(gdb) python execfile('/path/to/gdb_pypy.py')
+(gdb) python exec(open('/path/to/gdb_pypy.py').read())
"""
import re
@@ -55,10 +55,10 @@
class RPyType(Command):
"""
- Prints the RPython type of the expression (remember to dereference it!)
+ Prints the RPython type of the expression.
E.g.:
- (gdb) rpy_type *l_v123
+ (gdb) rpy_type l_v123
GcStruct pypy.foo.Bar { super, inst_xxx, inst_yyy }
"""
@@ -73,21 +73,30 @@
def invoke(self, arg, from_tty):
# some magic code to automatically reload the python file while
developing
- from pypy.tool import gdb_pypy
try:
- reload(gdb_pypy)
+ from pypy.tool import gdb_pypy
+ try:
+ reload(gdb_pypy)
+ except:
+ import imp
+ imp.reload(gdb_pypy)
+ gdb_pypy.RPyType.prog2typeids = self.prog2typeids # persist the
cache
+ self.__class__ = gdb_pypy.RPyType
+ result = self.do_invoke(arg, from_tty)
+ if not isinstance(result, str):
+ result = result.decode('latin-1')
+ print(result)
except:
- import imp
- imp.reload(gdb_pypy)
- gdb_pypy.RPyType.prog2typeids = self.prog2typeids # persist the cache
- self.__class__ = gdb_pypy.RPyType
- print (self.do_invoke(arg, from_tty).decode('latin-1'))
+ import traceback
+ traceback.print_exc()
def do_invoke(self, arg, from_tty):
try:
offset = int(arg)
except ValueError:
obj = self.gdb.parse_and_eval(arg)
+ if obj.type.code == self.gdb.TYPE_CODE_PTR:
+ obj = obj.dereference()
hdr = lookup(obj, '_gcheader')
tid = hdr['h_tid']
if sys.maxsize < 2**32:
@@ -100,7 +109,7 @@
if offset in typeids:
return typeids[offset]
else:
- return 'Cannot find the type with offset %d' % offset
+ return 'Cannot find the type with offset 0x%x' % offset
def get_typeids(self):
try:
@@ -127,7 +136,7 @@
try:
self.gdb.execute('dump binary memory %s %s %s+%d' %
(fname, vstart, vstart, length))
- with open(fname, 'rt') as fobj:
+ with open(fname, 'rb') as fobj:
data = fobj.read()
return TypeIdsMap(zlib.decompress(data).splitlines(True), self.gdb)
finally:
@@ -242,6 +251,8 @@
fields
"""
+ recursive = False
+
def __init__(self, val):
self.val = val
@@ -249,29 +260,47 @@
def lookup(cls, val, gdb=None):
t = val.type
if (is_ptr(t, gdb) and t.target().tag is not None and
- re.match(r'pypy_list\d*', t.target().tag)):
+ re.match(r'pypy_(list|array)\d*', t.target().tag)):
return cls(val)
return None
def to_string(self):
- length = int(self.val['l_length'])
- array = self.val['l_items']
- allocated = int(array['length'])
- items = array['items']
- itemlist = []
- for i in range(length):
- item = items[i]
- itemlist.append(str(item))
- str_items = ', '.join(itemlist)
- return 'r[%s] (len=%d, alloc=%d)' % (str_items, length, allocated)
+ t = self.val.type
+ if t.target().tag.startswith(r'pypy_array'):
+ if not self.val:
+ return 'r(null_array)'
+ length = int(self.val['length'])
+ items = self.val['items']
+ allocstr = ''
+ else:
+ if not self.val:
+ return 'r(null_list)'
+ length = int(self.val['l_length'])
+ array = self.val['l_items']
+ allocated = int(array['length'])
+ items = array['items']
+ allocstr = ', alloc=%d' % allocated
+ if RPyListPrinter.recursive:
+ str_items = '...'
+ else:
+ RPyListPrinter.recursive = True
+ try:
+ itemlist = []
+ for i in range(length):
+ item = items[i]
+ itemlist.append(str(item)) # may recurse here
+ str_items = ', '.join(itemlist)
+ finally:
+ RPyListPrinter.recursive = False
+ return 'r[%s] (len=%d%s)' % (str_items, length, allocstr)
try:
import gdb
RPyType() # side effects
- gdb.pretty_printers += [
+ gdb.pretty_printers = [
RPyStringPrinter.lookup,
RPyListPrinter.lookup
- ]
+ ] + gdb.pretty_printers
except ImportError:
pass
diff --git a/pypy/tool/test/test_gdb_pypy.py b/pypy/tool/test/test_gdb_pypy.py
--- a/pypy/tool/test/test_gdb_pypy.py
+++ b/pypy/tool/test/test_gdb_pypy.py
@@ -204,6 +204,22 @@
mylist.type.target().tag = None
assert gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb) is None
+def test_pprint_array():
+ d = {'_gcheder': {'h_tid': 234}, 'length': 3, 'items': [20, 21, 22]}
+ mylist = PtrValue(d, type_tag='pypy_array1')
+ printer = gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb)
+ assert printer.to_string() == 'r[20, 21, 22] (len=3)'
+
+def test_pprint_null_list():
+ mylist = PtrValue({}, type_tag='pypy_list1')
+ printer = gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb)
+ assert printer.to_string() == 'r(null_list)'
+
+def test_pprint_null_array():
+ mylist = PtrValue({}, type_tag='pypy_array1')
+ printer = gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb)
+ assert printer.to_string() == 'r(null_array)'
+
def test_typeidsmap():
gdb = FakeGdb('', {exprmember(1): 111,
exprmember(2): 222,
diff --git a/rpython/jit/codewriter/jtransform.py
b/rpython/jit/codewriter/jtransform.py
--- a/rpython/jit/codewriter/jtransform.py
+++ b/rpython/jit/codewriter/jtransform.py
@@ -1972,7 +1972,10 @@
def rewrite_op_jit_force_virtualizable(self, op):
# this one is for virtualizables
vinfo = self.get_vinfo(op.args[0])
- assert vinfo is not None
+ assert vinfo is not None, (
+ "%r is a class with _virtualizable_, but no jitdriver was found"
+ " with a 'virtualizable' argument naming a variable of that class"
+ % op.args[0].concretetype)
self.vable_flags[op.args[0]] = op.args[2].value
return []
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit