2009-05-27  Tom Tromey  <tromey@redhat.com>
	    Thiago Jung Bauermann  <bauerman@br.ibm.com>
	    Phil Muldoon  <pmuldoon@redhat.com>
	    Paul Pluzhnikov  <ppluzhnikov@google.com>
	    Vladimir Prus  <vladimir@codesourcery.com>

	* python/python-value.c (value_object_to_value): New function.
	* python/python-internal.h: Include frameobject.h.
	(gdbpy_children_cst, gdbpy_to_string_cst, gdbpy_display_hint_cst):
	Declare.
	(value_object_to_value): Declare.
	* printcmd.c (struct format_data) <raw>: New field.
	(last_format): Default to 0.
	(decode_format): Initialize val.raw.  Handle /r flag.
	(print_command_1): Initialize fmt.raw and opts.raw.
	(output_command): Likewise.
	(x_command): Fix initialization of fmt.format.  Initialize
	fmt.raw.
	(display_command): Initialize fmt.raw.
	(do_one_display): Set opts.raw.
	* python/python.c (gdbpy_to_string_cst, gdbpy_children_cst,
	gdbpy_display_hint_cst): New globals.
	(_initialize_python): Initialize them.  Set gdb.pretty_printers.
	* cp-valprint.c: Include python.h.
	(cp_print_value): Call apply_val_pretty_printer.
	* python/python.h (apply_val_pretty_printer): Declare.
	* stack.c (print_this_frame_argument_p): Remove.
	(print_frame_args): Compute summary flag.  Don't use
	print_this_frame_argument_p.
	* valprint.c: Include python.h.
	(user_print_options): Initialize new fields.
	(scalar_type_p): New function.
	(val_print): Handle 'raw' and 'summary' modes.  Call
	apply_val_pretty_printer.
	(value_print): Handle 'raw' mode.
	* valprint.h (struct value_print_options) <raw, summary>: New
	fields.
	* Makefile.in (SUBDIR_PYTHON_OBS): Add python-prettyprint.o
	(SUBDIR_PYTHON_SRCS): Add python-prettyprint.c.
	(python-prettyprint.o): New target.
	* python/python-prettyprint.c: New file.

gdb/doc

2009-05-27  Tom Tromey  <tromey@redhat.com>
	    Thiago Jung Bauermann  <bauerman@br.ibm.com>
	    Phil Muldoon  <pmuldoon@redhat.com>

	* gdb.texinfo (Objfiles In Python): Reference pretty printing.
	(Pretty Printing): New node.
	(Selecting Pretty-Printers): Likewise.
	(Python API): Update.
	(Output Formats): Document /r format.

gdb/testsuite

2009-05-27  Tom Tromey  <tromey@redhat.com>
	    Thiago Jung Bauermann  <bauerman@br.ibm.com>
	    Phil Muldoon  <pmuldoon@redhat.com>
	    Paul Pluzhnikov  <ppluzhnikov@google.com>

	* gdb.python/python-prettyprint.exp: New file.
	* gdb.python/python-prettyprint.c: New file.
	* gdb.python/python-prettyprint.py: New file.
	* gdb.base/display.exp: print/r is now valid.
This commit is contained in:
Tom Tromey 2009-05-28 01:05:14 +00:00
parent 42ae523077
commit a6bac58e84
19 changed files with 1399 additions and 55 deletions

View file

@ -158,46 +158,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
@ -220,6 +180,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);
@ -354,7 +318,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
@ -381,8 +345,8 @@ print_frame_args (struct symbol *func, struct frame_info *frame,
get_raw_print_options (&opts);
opts.deref_ref = 0;
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