public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
From: tromey@sourceware.org
To: archer-commits@sourceware.org
Subject: [SCM]  archer-tromey-python: gdb
Date: Sat, 13 Dec 2008 00:37:00 -0000	[thread overview]
Message-ID: <20081213003754.15297.qmail@sourceware.org> (raw)

The branch, archer-tromey-python has been updated
       via  d14f9aff2d79fcf0a60528377c57a33ce6c966e9 (commit)
      from  c02fba96626764b3be627d97f1697e85e76ff6a3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit d14f9aff2d79fcf0a60528377c57a33ce6c966e9
Author: Tom Tromey <tromey@redhat.com>
Date:   Fri Dec 12 17:37:30 2008 -0700

    gdb
    	* python/lib/gdb/libstdcxx/v6/printers.py
    	(StdVectorPrinter.display_hint): Return 'array'.
    	(StdDequePrinter.display_hint): New method.
    	(StdStackOrQueuePrinter.display_hint): Likewise.
    	* python/python.c (print_children): Handle "array" hint.  Respect
    	"print elements".
    gdb/doc
    	* gdb.texinfo (Pretty Printing): Document 'array' hint.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ChangeLog                               |    9 ++++++
 gdb/doc/ChangeLog                           |    4 +++
 gdb/doc/gdb.texinfo                         |    5 +++
 gdb/python/lib/gdb/libstdcxx/v6/printers.py |   10 ++++++-
 gdb/python/python.c                         |   38 ++++++++++++++++++++++++---
 5 files changed, 61 insertions(+), 5 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6b857e5..1e6ddb5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,15 @@
 2008-12-12  Tom Tromey  <tromey@redhat.com>
 
 	* python/lib/gdb/libstdcxx/v6/printers.py
+	(StdVectorPrinter.display_hint): Return 'array'.
+	(StdDequePrinter.display_hint): New method.
+	(StdStackOrQueuePrinter.display_hint): Likewise.
+	* python/python.c (print_children): Handle "array" hint.  Respect
+	"print elements".
+
+2008-12-12  Tom Tromey  <tromey@redhat.com>
+
+	* python/lib/gdb/libstdcxx/v6/printers.py
 	(StdStringPrinter.display_hint): New method.
 	* python/python.c (apply_val_pretty_printer): Compute printer's
 	hint.
diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog
index e194765..651b91d 100644
--- a/gdb/doc/ChangeLog
+++ b/gdb/doc/ChangeLog
@@ -1,5 +1,9 @@
 2008-12-12  Tom Tromey  <tromey@redhat.com>
 
+	* gdb.texinfo (Pretty Printing): Document 'array' hint.
+
+2008-12-12  Tom Tromey  <tromey@redhat.com>
+
 	* gdb.texinfo (Pretty Printing): Document 'string' hint.
 
 2008-12-10  Tom Tromey  <tromey@redhat.com>
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index fd17158..eeaaf61 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -18602,6 +18602,11 @@ being printed.
 Some display hints are predefined by @value{GDBN}:
 
 @table @samp
+@item array
+Indicate that the object being printed is ``array-like''.  The CLI
+uses this to respect parameters such as @code{set print elements} and
+@code{set print array}.
+
 @item map
 Indicate that the object being printed is ``map-like'', and that the
 children of this value can be assumed to alternate between keys and
diff --git a/gdb/python/lib/gdb/libstdcxx/v6/printers.py b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
index 1ea4dd2..c03c682 100644
--- a/gdb/python/lib/gdb/libstdcxx/v6/printers.py
+++ b/gdb/python/lib/gdb/libstdcxx/v6/printers.py
@@ -143,7 +143,7 @@ class StdVectorPrinter:
                 % (int (finish - start), int (end - start)))
 
     def display_hint(self):
-        return 'whatever'
+        return 'array'
 
 class StdStackOrQueuePrinter:
     "Print a std::stack or std::queue"
@@ -159,6 +159,11 @@ class StdStackOrQueuePrinter:
         return '%s wrapping: %s' % (self.typename,
                                     self.visualizer.to_string())
 
+    def display_hint (self):
+        if hasattr (self.visualizer, 'display_hint'):
+            return self.visualizer.display_hint ()
+        return None
+
 class RbtreeIterator:
     def __init__(self, rbtree):
         self.size = rbtree['_M_t']['_M_impl']['_M_node_count']
@@ -361,6 +366,9 @@ class StdDequePrinter:
         return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'],
                           end['_M_cur'], self.buffer_size)
 
+    def display_hint (self):
+        return 'array'
+
 class WideEncoding (gdb.Parameter):
     """The target wide character set is the encoding used for wchar_t."""
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index c2d4897..36e8356 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1023,15 +1023,18 @@ print_children (PyObject *printer, const char *hint,
 		const struct value_print_options *options,
 		const struct language_defn *language)
 {
-  int is_map, i;
+  int is_map, is_array, done_flag;
+  unsigned int i;
   PyObject *children, *iter;
   struct cleanup *cleanups;
 
   if (! PyObject_HasAttr (printer, gdbpy_children_cst))
     return;
 
-  /* If we are printing a map, we want some special formatting.  */
+  /* If we are printing a map or an array, we want some special
+     formatting.  */
   is_map = hint && ! strcmp (hint, "map");
+  is_array = hint && ! strcmp (hint, "array");
 
   children = PyObject_CallMethodObjArgs (printer, gdbpy_children_cst,
 					 NULL);
@@ -1051,14 +1054,20 @@ print_children (PyObject *printer, const char *hint,
     }
   make_cleanup_py_decref (iter);
 
-  for (i = 0; ; ++i)
+  done_flag = 0;
+  for (i = 0; i < options->print_max; ++i)
     {
       PyObject *py_v, *item = PyIter_Next (iter);
       char *name;
       struct cleanup *inner_cleanup;
 
       if (! item)
-	break;
+	{
+	  /* Set a flag so we can know whether we printed all the
+	     available elements.  */
+	  done_flag = 1;
+	  break;
+	}
 
       if (! PyArg_ParseTuple (item, "sO", &name, &py_v))
 	{
@@ -1068,6 +1077,11 @@ print_children (PyObject *printer, const char *hint,
 	}
       inner_cleanup = make_cleanup_py_decref (item);
 
+      /* Print initial "{".  For other elements, there are three
+	 cases:
+	 1. Maps.  Print a "," after each value element.
+	 2. Arrays.  Always print a ",".
+	 3. Other.  Always print a ",".  */
       if (i == 0)
 	fputs_filtered (" = {", stream);
       else if (! is_map || i % 2 == 0)
@@ -1081,6 +1095,13 @@ print_children (PyObject *printer, const char *hint,
 
       if (is_map && i % 2 == 0)
 	fputs_filtered ("[", stream);
+      else if (is_array)
+	{
+	  /* We print the index, not whatever the child method
+	     returned as the name.  */
+	  if (options->print_array_indexes)
+	    fprintf_filtered (stream, "[%d] = ", i);
+	}
       else if (! is_map)
 	{
 	  fputs_filtered (name, stream);
@@ -1114,6 +1135,15 @@ print_children (PyObject *printer, const char *hint,
 
   if (i)
     {
+      if (!done_flag)
+	{
+	  if (options->pretty)
+	    {
+	      fputs_filtered ("\n", stream);
+	      print_spaces_filtered (2 + 2 * recurse, stream);
+	    }
+	  fputs_filtered ("...", stream);
+	}
       if (options->pretty)
 	{
 	  fputs_filtered ("\n", stream);


hooks/post-receive
--
Repository for Project Archer.


             reply	other threads:[~2008-12-13  0:37 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-13  0:37 tromey [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-04-07 20:28 tromey
2009-03-24 17:27 tromey
2009-02-05 19:56 tromey
2008-12-17 23:10 tromey
2008-12-15 22:38 tromey
2008-12-12 23:54 tromey
2008-12-10 15:28 tromey
2008-12-09  0:33 tromey
2008-12-02 21:29 tromey
2008-12-01 19:10 tromey
2008-11-25 21:17 tromey
2008-11-21 18:25 tromey
2008-11-18 18:52 tromey
2008-11-18 15:54 tromey
2008-11-17 15:45 tromey
2008-11-16 22:18 tromey
2008-11-16 16:56 tromey
2008-11-12  1:54 tromey
2008-11-10 14:15 tromey
2008-11-06 21:11 tromey
2008-11-06 19:58 tromey
2008-10-23 22:27 tromey
2008-10-23 21:28 tromey
2008-10-22 18:18 tromey
2008-10-21 18:32 tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081213003754.15297.qmail@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=archer-commits@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).