You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2012/06/18 15:31:56 UTC

svn commit: r1351336 - /subversion/trunk/tools/dev/gdb-py/svndbg/printers.py

Author: julianfoad
Date: Mon Jun 18 13:31:56 2012
New Revision: 1351336

URL: http://svn.apache.org/viewvc?rev=1351336&view=rev
Log:
Improve the GDB pretty-printer's handling of null arrays and hashes.

* tools/dev/gdb-py/svndbg/printers.py
  (AprHashPrinter): Bring to_string() into line with the other methods in
    handling null here ...
  (PtrAprHashPrinter, PtrAprArrayPrinter): ... and make these classes foward
    all of their methods directly to their non-Ptr base classes.
  (SvnMergeinfoCatalogPrinter): Tweak the children() method to avoid GDB
    throwing an error when the object is null.

Modified:
    subversion/trunk/tools/dev/gdb-py/svndbg/printers.py

Modified: subversion/trunk/tools/dev/gdb-py/svndbg/printers.py
URL: http://svn.apache.org/viewvc/subversion/trunk/tools/dev/gdb-py/svndbg/printers.py?rev=1351336&r1=1351335&r2=1351336&view=diff
==============================================================================
--- subversion/trunk/tools/dev/gdb-py/svndbg/printers.py (original)
+++ subversion/trunk/tools/dev/gdb-py/svndbg/printers.py Mon Jun 18 13:31:56 2012
@@ -120,6 +120,8 @@ class AprHashPrinter:
     def to_string(self):
         """Return a string to be displayed before children are displayed, or
            return None if we don't want any such."""
+        if not self.hash_p:
+            return 'NULL'
         return 'hash of ' + str(apr_hash_count(self.hash_p)) + ' items'
 
     def children(self):
@@ -135,16 +137,6 @@ class PtrAprHashPrinter(AprHashPrinter):
     def __init__(self, val):
         self.hash_p = val
 
-    def to_string(self):
-        if not self.hash_p:
-            return 'NULL'
-        return AprHashPrinter.to_string(self)
-
-    def children(self):
-        if not self.hash_p:
-            return []
-        return AprHashPrinter.children(self)
-
 class AprArrayPrinter:
     """for 'apr_array_header_t' of unknown elements"""
     def __init__(self, val):
@@ -171,16 +163,6 @@ class PtrAprArrayPrinter(AprArrayPrinter
         else:
             self.array = val.dereference()
 
-    def to_string(self):
-        if not self.array:
-            return 'NULL'
-        return AprArrayPrinter.to_string(self)
-
-    def children(self):
-        if not self.array:
-            return []
-        return AprArrayPrinter.children(self)
-
 
 ########################################################################
 
@@ -214,7 +196,10 @@ class SvnMergeinfoCatalogPrinter:
 
     def children(self):
         if self.hash_p == 0:
-            return None
+            # Return an empty list so GDB prints only the 'NULL' that is
+            # returned by to_string().  If instead we were to return None
+            # here, GDB would issue a 'not iterable' error message.
+            return []
         mergeinfoType = gdb.lookup_type('svn_mergeinfo_t')
         return children_as_map(children_of_apr_hash(self.hash_p, mergeinfoType))