This is the mail archive of the
archer@sourceware.org
mailing list for the Archer project.
[python] integrate summary mode and print frame-arguments
- From: Tom Tromey <tromey at redhat dot com>
- To: Project Archer <archer at sourceware dot org>
- Date: Wed, 25 Mar 2009 11:09:28 -0600
- Subject: [python] integrate summary mode and print frame-arguments
- Reply-to: tromey at redhat dot com
I'm checking this in on the python branch.
When I implemented "summary" mode, I did not realize that gdb already
had "set print frame-arguments". This patch integrates the two and
incorporates Joel's change to the default.
It also fixes a lurking bug -- print_this_frame_argument_p might
change the type of a symbol via CHECK_TYPEDEF. I think this is
incorrect, though I don't have a test case.
Tom
2009-03-25 Tom Tromey <tromey@redhat.com>
* stack.c (print_frame_args): Handle print_frame_arguments
directly.
(print_this_frame_argument_p): Remove.
(print_frame_arguments): Change default.
* valprint.c (scalar_type_p): New function.
(val_print): Handle summary mode.
diff --git a/gdb/stack.c b/gdb/stack.c
index c6f58db..0216391 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -57,7 +57,7 @@ void (*deprecated_selected_frame_level_changed_hook) (int);
static const char *print_frame_arguments_choices[] =
{"all", "scalars", "none", NULL};
-static const char *print_frame_arguments = "all";
+static const char *print_frame_arguments = "scalars";
/* Prototypes for local functions. */
@@ -157,46 +157,6 @@ print_frame_nameless_args (struct frame_info *frame, long start, int num,
}
}
-/* Return non-zero if the debugger should print the value of the provided
- symbol parameter (SYM). */
-
-static int
-print_this_frame_argument_p (struct symbol *sym)
-{
- struct type *type;
-
- /* If the user asked to print no argument at all, then obviously
- do not print this argument. */
-
- if (strcmp (print_frame_arguments, "none") == 0)
- return 0;
-
- /* If the user asked to print all arguments, then we should print
- that one. */
-
- if (strcmp (print_frame_arguments, "all") == 0)
- return 1;
-
- /* The user asked to print only the scalar arguments, so do not
- print the non-scalar ones. */
-
- type = CHECK_TYPEDEF (SYMBOL_TYPE (sym));
- while (TYPE_CODE (type) == TYPE_CODE_REF)
- type = CHECK_TYPEDEF (TYPE_TARGET_TYPE (type));
- switch (TYPE_CODE (type))
- {
- case TYPE_CODE_ARRAY:
- case TYPE_CODE_STRUCT:
- case TYPE_CODE_UNION:
- case TYPE_CODE_SET:
- case TYPE_CODE_STRING:
- case TYPE_CODE_BITSTRING:
- return 0;
- default:
- return 1;
- }
-}
-
/* Print the arguments of frame FRAME on STREAM, given the function
FUNC running in that frame (as a symbol), where NUM is the number
of arguments according to the stack frame (or -1 if the number of
@@ -219,6 +179,10 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
int args_printed = 0;
struct cleanup *old_chain, *list_chain;
struct ui_stream *stb;
+ /* True if we should print arguments, false otherwise. */
+ int print_args = strcmp (print_frame_arguments, "none");
+ /* True in "summary" mode, false otherwise. */
+ int summary = !strcmp (print_frame_arguments, "scalars");
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
@@ -353,7 +317,7 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
annotate_arg_name_end ();
ui_out_text (uiout, "=");
- if (print_this_frame_argument_p (sym))
+ if (print_args)
{
/* Avoid value_print because it will deref ref parameters.
We just want to print their addresses. Print ??? for
@@ -380,9 +344,8 @@ 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);
+ opts.summary = summary;
+ common_val_print (val, stb->stream, 2, &opts, language);
ui_out_field_stream (uiout, "value", stb);
}
else
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 2f84cc0..997fc3d 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -217,6 +217,33 @@ show_addressprint (struct ui_file *file, int from_tty,
}
+/* A helper function for val_print. When printing in "summary" mode,
+ we want to print scalar arguments, but not aggregate arguments.
+ This function distinguishes between the two. */
+
+static int
+scalar_type_p (struct type *type)
+{
+ CHECK_TYPEDEF (type);
+ while (TYPE_CODE (type) == TYPE_CODE_REF)
+ {
+ type = TYPE_TARGET_TYPE (type);
+ CHECK_TYPEDEF (type);
+ }
+ switch (TYPE_CODE (type))
+ {
+ case TYPE_CODE_ARRAY:
+ case TYPE_CODE_STRUCT:
+ case TYPE_CODE_UNION:
+ case TYPE_CODE_SET:
+ case TYPE_CODE_STRING:
+ case TYPE_CODE_BITSTRING:
+ return 0;
+ default:
+ return 1;
+ }
+}
+
/* Print using the given LANGUAGE the data of type TYPE located at VALADDR
(within GDB), which came from the inferior at address ADDRESS, onto
stdio stream STREAM according to OPTIONS.
@@ -269,6 +296,14 @@ val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
return ret;
}
+ /* Handle summary mode. If the value is a scalar, print it;
+ otherwise, print an ellipsis. */
+ if (options->summary && !scalar_type_p (type))
+ {
+ fprintf_filtered (stream, "...");
+ return 0;
+ }
+
TRY_CATCH (except, RETURN_MASK_ERROR)
{
ret = language->la_val_print (type, valaddr, embedded_offset, address,