public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-tromey-python:  * varobj.c (value_get_print_value): Use LA_PRINT_STRING for
@ 2008-12-15 23:35 tromey
  0 siblings, 0 replies; only message in thread
From: tromey @ 2008-12-15 23:35 UTC (permalink / raw)
  To: archer-commits

The branch, archer-tromey-python has been updated
       via  3b1cc43d35bf03cbeeded112972e35ba8f2b5384 (commit)
       via  870e29ccaffccf07e3a7e8936daacfb81ca85574 (commit)
      from  3af011f203616a293e1d709fe074e5eb8e62660d (commit)

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

- Log -----------------------------------------------------------------
commit 3b1cc43d35bf03cbeeded112972e35ba8f2b5384
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Dec 15 16:34:51 2008 -0700

    	* varobj.c (value_get_print_value): Use LA_PRINT_STRING for
    	"string" printers.

commit 870e29ccaffccf07e3a7e8936daacfb81ca85574
Author: Tom Tromey <tromey@redhat.com>
Date:   Mon Dec 15 16:20:53 2008 -0700

    	* python/python.c (print_children): Handle the "summary" field.
    	* stack.c (print_frame_args): Set "summary" flag.
    	* valprint.c (user_print_options): Add new field.
    	* valprint.h (struct value_print_options) <summary>: New field.

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

Summary of changes:
 gdb/ChangeLog       |   12 ++++++++++++
 gdb/python/python.c |   12 ++++++++++++
 gdb/stack.c         |    1 +
 gdb/valprint.c      |    3 ++-
 gdb/valprint.h      |    3 +++
 gdb/varobj.c        |   24 +++++++++++++++++++++---
 6 files changed, 51 insertions(+), 4 deletions(-)

First 500 lines of diff:
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6828a6a..ffccbe4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
 2008-12-15  Tom Tromey  <tromey@redhat.com>
 
+	* varobj.c (value_get_print_value): Use LA_PRINT_STRING for
+	"string" printers.
+
+2008-12-15  Tom Tromey  <tromey@redhat.com>
+
+	* python/python.c (print_children): Handle the "summary" field.
+	* stack.c (print_frame_args): Set "summary" flag.
+	* valprint.c (user_print_options): Add new field.
+	* valprint.h (struct value_print_options) <summary>: New field.
+
+2008-12-15  Tom Tromey  <tromey@redhat.com>
+
 	* python/python.c (gdbpy_new_objfile): Look in
 	debug_file_directory as well.
 
diff --git a/gdb/python/python.c b/gdb/python/python.c
index fd84f60..02e5c61 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -1109,6 +1109,18 @@ print_children (PyObject *printer, const char *hint,
       else if (! is_map || i % 2 == 0)
 	fputs_filtered (pretty ? "," : ", ", stream);
 
+      /* In summary mode, we just want to print "= {...}" if there is
+	 a value.  */
+      if (options->summary)
+	{
+	  /* This increment tricks the post-loop logic to print what
+	     we want.  */
+	  ++i;
+	  /* Likewise.  */
+	  pretty = 0;
+	  break;
+	}
+
       if (! is_map || i % 2 == 0)
 	{
 	  if (pretty)
diff --git a/gdb/stack.c b/gdb/stack.c
index 19c40a0..330932f 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -380,6 +380,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
 
 		  get_raw_print_options (&opts);
 		  opts.deref_ref = 0;
+		  opts.summary = 1;
 		  common_val_print (val, stb->stream, 2,
 				    &opts, language);
 		  ui_out_field_stream (uiout, "value", stb);
diff --git a/gdb/valprint.c b/gdb/valprint.c
index b3e5529..dab39ce 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -82,7 +82,8 @@ struct value_print_options user_print_options =
   0,				/* deref_ref */
   1,				/* static_field_print */
   1,				/* pascal_static_field_print */
-  0				/* raw */
+  0,				/* raw */
+  0				/* summary */
 };
 
 /* Initialize *OPTS to be a copy of the user print options.  */
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 6204ac7..c189c8d 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -87,6 +87,9 @@ struct value_print_options
 
   /* Controls Python pretty-printing.  */
   int raw;
+
+  /* If nonzero, print the value in "summary" form.  */
+  int summary;
 };
 
 /* The global print options set by the user.  In general this should
diff --git a/gdb/varobj.c b/gdb/varobj.c
index d98759f..b33229f 100644
--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2240,7 +2240,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   long dummy;
   struct ui_file *stb;
   struct cleanup *old_chain;
-  char *thevalue;
+  char *thevalue = NULL;
   struct value_print_options opts;
 
   if (value == NULL)
@@ -2252,10 +2252,21 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
     if (value_formatter && PyObject_HasAttr (value_formatter,
 					     gdbpy_to_string_cst))
       {
+	char *hint;
 	struct value *replacement;
+	int string_print = 0;
+
+	hint = gdbpy_get_display_hint (value_formatter);
+	if (hint)
+	  {
+	    if (!strcmp (hint, "string"))
+	      string_print = 1;
+	    xfree (hint);
+	  }
+
 	thevalue = apply_varobj_pretty_printer (value_formatter, value,
 						&replacement);
-	if (thevalue)
+	if (thevalue && !string_print)
 	  {
 	    PyGILState_Release (state);
 	    return thevalue;
@@ -2273,7 +2284,14 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
   get_formatted_print_options (&opts, format_code[(int) format]);
   opts.deref_ref = 0;
   opts.raw = 1;
-  common_val_print (value, stb, 0, &opts, current_language);
+  if (thevalue)
+    {
+      make_cleanup (xfree, thevalue);
+      LA_PRINT_STRING (stb, (gdb_byte *) thevalue, strlen (thevalue),
+		       1, 0, &opts);
+    }
+  else
+    common_val_print (value, stb, 0, &opts, current_language);
   thevalue = ui_file_xstrdup (stb, &dummy);
 
   do_cleanups (old_chain);


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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-15 23:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-15 23:35 [SCM] archer-tromey-python: * varobj.c (value_get_print_value): Use LA_PRINT_STRING for tromey

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).