[pypy-commit] pypy default: Fix for the gdb hooks when the tag of a something you try to print is None, not sure what exactly this means, but it happened to me.

alex_gaynor noreply at buildbot.pypy.org
Tue Aug 9 05:53:21 CEST 2011


Author: Alex Gaynor <alex.gaynor at gmail.com>
Branch: 
Changeset: r46384:19cfd2182cc1
Date: 2011-08-08 20:53 -0700
http://bitbucket.org/pypy/pypy/changeset/19cfd2182cc1/

Log:	Fix for the gdb hooks when the tag of a something you try to print
	is None, not sure what exactly this means, but it happened to me.

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
@@ -65,7 +65,7 @@
     """
 
     prog2typeids = {}
- 
+
     def __init__(self, gdb=None):
         # dependency injection, for tests
         if gdb is None:
@@ -137,7 +137,7 @@
     val" and see the nice string, and "p *val" to see the underyling struct
     fields
     """
-    
+
     def __init__(self, val):
         self.val = val
 
@@ -172,7 +172,8 @@
     @classmethod
     def lookup(cls, val, gdb=None):
         t = val.type
-        if is_ptr(t, gdb) and re.match(r'pypy_list\d*', t.target().tag):
+        if (is_ptr(t, gdb) and t.target().tag is not None and
+            re.match(r'pypy_list\d*', t.target().tag)):
             return cls(val)
         return None
 
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
@@ -29,7 +29,7 @@
 
 class Struct(object):
     code = FakeGdb.TYPE_CODE_STRUCT
-    
+
     def __init__(self, fieldnames, tag):
         self._fields = [Field(name=name) for name in fieldnames]
         self.tag = tag
@@ -178,3 +178,6 @@
     mylist.type.target().tag = 'pypy_list1234'
     printer = gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb)
     assert printer.to_string() == 'r[40, 41, 42] (len=3, alloc=5)'
+
+    mylist.type.target().tag = None
+    assert gdb_pypy.RPyListPrinter.lookup(mylist, FakeGdb) is None
\ No newline at end of file


More information about the pypy-commit mailing list