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] print summary in stack trace


This implements the summary output form from the earlier discussion
with Graydon.

Now a backtrace involving a value that has a pretty-printer with a
children method will print like this:

(gdb) bt
#0  pushtostack (S=
    std::queue wrapping: std::vector of length 1, capacity 1 = {...}, ref="to")
    at r.cc:64

That is, it prints the results of 'to_string', then it may print "= {...}",
depending on the children method.

Tom

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.

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


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