This is the mail archive of the archer@sourceware.org mailing list for the Archer project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[python] handle display_hint from CLI


This updates the CLI pretty-printer to handle a display_hint of 'map'.
It also fixes a small latent bug in _format_children -- the to_string
method may return a Value.

Tom

2008-10-27  Tom Tromey  <tromey@redhat.com>

	* python/python.c (_initialize_python) <_format_children>: Handle
	display_hint.  Stringize result of to_string.

diff --git a/gdb/python/python.c b/gdb/python/python.c
index 6d280d9..22f85ba 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1056,12 +1056,23 @@ sys.stdout = GdbOutputFile()\n\
 def _format_children(obj, val):\n\
   result = []\n\
   if hasattr(obj, 'to_string'):\n\
-    result.append(obj.to_string(val))\n\
+    result.append(str(obj.to_string(val)))\n\
+  if hasattr(obj, 'display_hint'):\n\
+    is_map = 'map' == obj.display_hint(val)\n\
+  else:\n\
+    is_map = False\n\
   max = gdb.get_parameter('print elements')\n\
   i = 0\n\
+  previous = None\n\
   for elt in obj.children(val):\n\
     (name, val) = elt\n\
-    result.append('%s = %s' % (name, str(val)))\n\
+    if is_map:\n\
+      if i % 2 == 0:\n\
+        previous = val\n\
+      else:\n\
+        result.append('[%s] = %s' % (str (previous), str (val)))\n\
+    else:\n\
+      result.append('%s = %s' % (name, str(val)))\n\
     i = i + 1\n\
     if max != None and i == max:\n\
       break\n\


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]