* varobj.c (value_get_print_value): Include valprint.h.
(value_get_print_value): Use get_formatted_print_options.
* value.h (struct value_print_options): Declare.
(value_print, val_print, common_val_print, val_print_string):
Update.
* value.c: Include valprint.h.
(show_values): Use get_user_print_options.
(show_convenience): Likewise.
* valprint.h (prettyprint_arrays, prettyprint_structs): Don't
declare.
(struct value_print_options): New type.
(vtblprint, unionprint, addressprint, objectprint, print_max,
inspect_it, repeat_count_threshold, output_format,
stop_print_at_null): Don't declare.
(user_print_options, get_user_print_options,
get_raw_print_options, get_formatted_print_options): Declare.
(print_array_indexes_p): Don't declare.
(maybe_print_array_index, val_print_array_elements): Update.
* valprint.c (print_max): Remove.
(user_print_options): New global.
(get_user_print_options, get_raw_print_options,
get_formatted_print_options): New functions.
(print_array_indexes, repeat_count_threshold, stop_print_at_null,
prettyprint_structs, prettyprint_arrays, unionprint,
addressprint): Remove.
(val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(common_val_print): Likewise.
(print_array_indexes_p): Remove.
(maybe_print_array_index): Remove format, pretty arguments; add
options. Update.
(val_print_array_elements): Remove format, deref_ref, pretty
arguments; add options. Update.
(val_print_string): Add options argument. Update.
(_initialize_valprint): Use user_print_options.
(output_format): Remove.
(set_output_radix_1): Use user_print_options.
* typeprint.c: Include valprint.h.
(objectprint): Don't declare.
(whatis_exp): Use get_user_print_options.
* tui/tui-regs.c: Include valprint.h.
(tui_register_format): Use get_formatted_print_options.
* tracepoint.c: Include valprint.h.
(addressprint): Don't declare.
(trace_mention): Use get_user_print_options.
(tracepoints_info): Likewise.
* stack.c (print_frame_args): Use get_raw_print_options.
(print_frame_info): Use get_user_print_options.
(print_frame): Likewise.
* sh64-tdep.c: Include valprint.h
(sh64_do_register): Use get_formatted_print_options.
* scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
pretty arguments; add options.
(scm_scmlist_print): Likewise. Update.
(scm_scmval_print): Likewise.
(scm_val_print): Likewise.
(scm_value_print): Remove format, pretty arguments; add options.
Update.
* scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
Update.
* scm-lang.c (scm_printstr): Add options argument.
* python/python-value.c: Include valprint.h.
(valpy_str): Use get_user_print_options.
* printcmd.c: Include valprint.h.
(addressprint): Don't declare.
(inspect_it): Remove.
(print_formatted): Remove format option; add options. Update.
(print_scalar_formatted): Likewise.
(print_address_demangle): Use get_user_print_options.
(do_examine): Use get_formatted_print_options.
(print_command_1): Likewise.
(output_command): Use get_formatted_print_options.
(do_one_display): Likewise.
(print_variable_value): Use get_user_print_options.
* p-valprint.c (pascal_val_print): Remove format, deref_ref,
pretty arguments; add options. Update.
(pascal_value_print): Remove format, pretty arguments; add
options. Update.
(vtblprint, objectprint): Don't declare.
(pascal_static_field_print): Remove.
(pascal_object_print_value_fields): Remove format, pretty
arguments; add options. Update.
(pascal_object_print_static_field): Likewise.
(_initialize_pascal_valprint): Use user_print_options. Update.
* p-lang.h (pascal_val_print, pascal_value_print,
pascal_printstr, pascal_object_print_value_fields): Update.
(vtblprint, static_field_print): Don't declare.
* p-lang.c (pascal_printstr): Add options argument. Update.
* objc-lang.c (objc_printstr): Add options argument. Update.
* mt-tdep.c: Include valprint.h.
(mt_registers_info): Use get_raw_print_options.
* mips-tdep.c: Include valprint.h.
(mips_print_fp_register): Use get_formatted_print_options.
(mips_print_register): Likewise.
* mi/mi-main.c: Include valprint.h.
(get_register): Use get_user_print_options.
(mi_cmd_data_evaluate_expression): Likewise.
(mi_cmd_data_read_memory): Use get_formatted_print_options.
* mi/mi-cmd-stack.c: Include valprint.h.
(list_args_or_locals): Use get_raw_print_options.
* m2-valprint.c (print_function_pointer_address): Add addressprint
argument.
(m2_print_long_set): Remove format, pretty arguments.
(m2_print_unbounded_array): Remove format, deref_ref, pretty
arguments; add options. Update.
(print_unpacked_pointer): Remove format argument; add options.
Now static. Update.
(print_variable_at_address): Remove format, deref_ref, pretty
arguments; add options. Update.
(m2_print_array_contents): Likewise.
(m2_val_print): Likewise.
* m2-lang.h (m2_val_print): Update.
* m2-lang.c (m2_printstr): Add options argument. Update.
* language.h (struct value_print_options): Declare.
(struct language_defn) <la_printstr>: Add options argument.
<la_val_print>: Remove format, deref_ref, pretty argument; add
options.
<la_value_print>: Remove format, pretty arguments; add options.
<la_print_array_index>: Likewise.
(LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Update.
* language.c (default_print_array_index): Remove format, pretty
arguments; add options. Update.
(unk_lang_printstr): Add options argument.
(unk_lang_val_print): Remove format, deref_ref, pretty arguments;
add options.
(unk_lang_value_print): Remove format, pretty arguments; add
options.
* jv-valprint.c (java_value_print): Remove format, pretty
arguments; add options. Update.
(java_print_value_fields): Likewise.
(java_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
* jv-lang.h (java_val_print, java_value_print): Declare.
* infcmd.c: Include valprint.h.
(print_return_value): Use get_raw_print_options.
(default_print_registers_info): Use get_user_print_options,
get_formatted_print_options.
(registers_info): Use get_formatted_print_options.
* gdbtypes.h (struct value_print_options): Declare.
(print_scalar_formatted): Update.
* f-valprint.c (f77_print_array_1): Remove format, deref_ref,
pretty arguments; add options. Update.
(f77_print_array): Likewise.
(f_val_print): Likewise.
* f-lang.h (f_val_print): Update.
* f-lang.c (f_printstr): Add options argument. Update.
(c_value_print): Update declaration.
* expprint.c: Include valprint.h.
(print_subexp_standard): Use get_raw_print_options,
get_user_print_options.
* eval.c: Include valprint.h.
(objectprint): Don't declare.
(evaluate_subexp_standard): Use get_user_print_options.
* cp-valprint.c (vtblprint, objectprint, static_field_print):
Remove.
(cp_print_value_fields): Remove format, pretty arguments; add
options. Update.
(cp_print_value): Likewise.
(cp_print_static_field): Likewise.
(_initialize_cp_valprint): Use user_print_options. Update.
* c-valprint.c (print_function_pointer_address): Add addressprint
argument.
(c_val_print): Remove format, deref_ref, pretty arguments; add
options. Update.
(c_value_print): Add options argument. Update.
* c-lang.h (c_val_print, c_value_print, c_printstr): Update.
(vtblprint, static_field_print): Don't declare.
(cp_print_value_fields): Update.
* c-lang.c (c_printstr): Add options argument. Update.
* breakpoint.c: Include valprint.h.
(addressprint): Don't declare.
(watchpoint_value_print): Use get_user_print_options.
(print_one_breakpoint_location): Likewise.
(breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
print_exception_catchpoint): Likewise.
* auxv.c (fprint_target_auxv): Don't declare addressprint. Use
get_user_print_options.
* ada-valprint.c (struct ada_val_print_args): Remove format,
deref_ref, and pretty; add options.
(print_optional_low_bound): Add options argument.
(val_print_packed_array_elements): Remove format and pretty
arguments; add options. Update.
(printstr): Add options argument. Update.
(ada_printstr): Likewise.
(ada_val_print): Remove format, deref_ref, pretty arguments; add
options argument. Update.
(ada_val_print_stub): Update.
(ada_val_print_array): Remove format, deref_ref, pretty arguments;
add options. Update.
(ada_val_print_1): Likewise.
(print_variant_part): Likewise.
(ada_value_print): Remove format, pretty arguments; add options.
Update.
(print_record): Likewise.
(print_field_values): Likewise.
* ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
Update.
* ada-lang.c (ada_print_array_index): Add options argument; remove
format and pretty arguments.
(print_one_exception): Use get_user_print_options.
gdb/testsuite
* gdb.base/exprs.exp (test_expr): Add enum formatting tests.
+2008-10-28 Tom Tromey <tromey@redhat.com>
+
+ * varobj.c (value_get_print_value): Include valprint.h.
+ (value_get_print_value): Use get_formatted_print_options.
+ * value.h (struct value_print_options): Declare.
+ (value_print, val_print, common_val_print, val_print_string):
+ Update.
+ * value.c: Include valprint.h.
+ (show_values): Use get_user_print_options.
+ (show_convenience): Likewise.
+ * valprint.h (prettyprint_arrays, prettyprint_structs): Don't
+ declare.
+ (struct value_print_options): New type.
+ (vtblprint, unionprint, addressprint, objectprint, print_max,
+ inspect_it, repeat_count_threshold, output_format,
+ stop_print_at_null): Don't declare.
+ (user_print_options, get_user_print_options,
+ get_raw_print_options, get_formatted_print_options): Declare.
+ (print_array_indexes_p): Don't declare.
+ (maybe_print_array_index, val_print_array_elements): Update.
+ * valprint.c (print_max): Remove.
+ (user_print_options): New global.
+ (get_user_print_options, get_raw_print_options,
+ get_formatted_print_options): New functions.
+ (print_array_indexes, repeat_count_threshold, stop_print_at_null,
+ prettyprint_structs, prettyprint_arrays, unionprint,
+ addressprint): Remove.
+ (val_print): Remove format, deref_ref, pretty arguments; add
+ options. Update.
+ (common_val_print): Likewise.
+ (print_array_indexes_p): Remove.
+ (maybe_print_array_index): Remove format, pretty arguments; add
+ options. Update.
+ (val_print_array_elements): Remove format, deref_ref, pretty
+ arguments; add options. Update.
+ (val_print_string): Add options argument. Update.
+ (_initialize_valprint): Use user_print_options.
+ (output_format): Remove.
+ (set_output_radix_1): Use user_print_options.
+ * typeprint.c: Include valprint.h.
+ (objectprint): Don't declare.
+ (whatis_exp): Use get_user_print_options.
+ * tui/tui-regs.c: Include valprint.h.
+ (tui_register_format): Use get_formatted_print_options.
+ * tracepoint.c: Include valprint.h.
+ (addressprint): Don't declare.
+ (trace_mention): Use get_user_print_options.
+ (tracepoints_info): Likewise.
+ * stack.c (print_frame_args): Use get_raw_print_options.
+ (print_frame_info): Use get_user_print_options.
+ (print_frame): Likewise.
+ * sh64-tdep.c: Include valprint.h
+ (sh64_do_register): Use get_formatted_print_options.
+ * scm-valprint.c (scm_inferior_print): Remove format, deref_ref,
+ pretty arguments; add options.
+ (scm_scmlist_print): Likewise. Update.
+ (scm_scmval_print): Likewise.
+ (scm_val_print): Likewise.
+ (scm_value_print): Remove format, pretty arguments; add options.
+ Update.
+ * scm-lang.h (scm_value_print, scm_val_print, scm_scmval_print):
+ Update.
+ * scm-lang.c (scm_printstr): Add options argument.
+ * python/python-value.c: Include valprint.h.
+ (valpy_str): Use get_user_print_options.
+ * printcmd.c: Include valprint.h.
+ (addressprint): Don't declare.
+ (inspect_it): Remove.
+ (print_formatted): Remove format option; add options. Update.
+ (print_scalar_formatted): Likewise.
+ (print_address_demangle): Use get_user_print_options.
+ (do_examine): Use get_formatted_print_options.
+ (print_command_1): Likewise.
+ (output_command): Use get_formatted_print_options.
+ (do_one_display): Likewise.
+ (print_variable_value): Use get_user_print_options.
+ * p-valprint.c (pascal_val_print): Remove format, deref_ref,
+ pretty arguments; add options. Update.
+ (pascal_value_print): Remove format, pretty arguments; add
+ options. Update.
+ (vtblprint, objectprint): Don't declare.
+ (pascal_static_field_print): Remove.
+ (pascal_object_print_value_fields): Remove format, pretty
+ arguments; add options. Update.
+ (pascal_object_print_static_field): Likewise.
+ (_initialize_pascal_valprint): Use user_print_options. Update.
+ * p-lang.h (pascal_val_print, pascal_value_print,
+ pascal_printstr, pascal_object_print_value_fields): Update.
+ (vtblprint, static_field_print): Don't declare.
+ * p-lang.c (pascal_printstr): Add options argument. Update.
+ * objc-lang.c (objc_printstr): Add options argument. Update.
+ * mt-tdep.c: Include valprint.h.
+ (mt_registers_info): Use get_raw_print_options.
+ * mips-tdep.c: Include valprint.h.
+ (mips_print_fp_register): Use get_formatted_print_options.
+ (mips_print_register): Likewise.
+ * mi/mi-main.c: Include valprint.h.
+ (get_register): Use get_user_print_options.
+ (mi_cmd_data_evaluate_expression): Likewise.
+ (mi_cmd_data_read_memory): Use get_formatted_print_options.
+ * mi/mi-cmd-stack.c: Include valprint.h.
+ (list_args_or_locals): Use get_raw_print_options.
+ * m2-valprint.c (print_function_pointer_address): Add addressprint
+ argument.
+ (m2_print_long_set): Remove format, pretty arguments.
+ (m2_print_unbounded_array): Remove format, deref_ref, pretty
+ arguments; add options. Update.
+ (print_unpacked_pointer): Remove format argument; add options.
+ Now static. Update.
+ (print_variable_at_address): Remove format, deref_ref, pretty
+ arguments; add options. Update.
+ (m2_print_array_contents): Likewise.
+ (m2_val_print): Likewise.
+ * m2-lang.h (m2_val_print): Update.
+ * m2-lang.c (m2_printstr): Add options argument. Update.
+ * language.h (struct value_print_options): Declare.
+ (struct language_defn) <la_printstr>: Add options argument.
+ <la_val_print>: Remove format, deref_ref, pretty argument; add
+ options.
+ <la_value_print>: Remove format, pretty arguments; add options.
+ <la_print_array_index>: Likewise.
+ (LA_VAL_PRINT, LA_VALUE_PRINT, LA_PRINT_STRING,
+ LA_PRINT_ARRAY_INDEX): Update.
+ (default_print_array_index): Update.
+ * language.c (default_print_array_index): Remove format, pretty
+ arguments; add options. Update.
+ (unk_lang_printstr): Add options argument.
+ (unk_lang_val_print): Remove format, deref_ref, pretty arguments;
+ add options.
+ (unk_lang_value_print): Remove format, pretty arguments; add
+ options.
+ * jv-valprint.c (java_value_print): Remove format, pretty
+ arguments; add options. Update.
+ (java_print_value_fields): Likewise.
+ (java_val_print): Remove format, deref_ref, pretty arguments; add
+ options. Update.
+ * jv-lang.h (java_val_print, java_value_print): Declare.
+ * infcmd.c: Include valprint.h.
+ (print_return_value): Use get_raw_print_options.
+ (default_print_registers_info): Use get_user_print_options,
+ get_formatted_print_options.
+ (registers_info): Use get_formatted_print_options.
+ * gdbtypes.h (struct value_print_options): Declare.
+ (print_scalar_formatted): Update.
+ * f-valprint.c (f77_print_array_1): Remove format, deref_ref,
+ pretty arguments; add options. Update.
+ (f77_print_array): Likewise.
+ (f_val_print): Likewise.
+ * f-lang.h (f_val_print): Update.
+ * f-lang.c (f_printstr): Add options argument. Update.
+ (c_value_print): Update declaration.
+ * expprint.c: Include valprint.h.
+ (print_subexp_standard): Use get_raw_print_options,
+ get_user_print_options.
+ * eval.c: Include valprint.h.
+ (objectprint): Don't declare.
+ (evaluate_subexp_standard): Use get_user_print_options.
+ * cp-valprint.c (vtblprint, objectprint, static_field_print):
+ Remove.
+ (cp_print_value_fields): Remove format, pretty arguments; add
+ options. Update.
+ (cp_print_value): Likewise.
+ (cp_print_static_field): Likewise.
+ (_initialize_cp_valprint): Use user_print_options. Update.
+ * c-valprint.c (print_function_pointer_address): Add addressprint
+ argument.
+ (c_val_print): Remove format, deref_ref, pretty arguments; add
+ options. Update.
+ (c_value_print): Add options argument. Update.
+ * c-lang.h (c_val_print, c_value_print, c_printstr): Update.
+ (vtblprint, static_field_print): Don't declare.
+ (cp_print_value_fields): Update.
+ * c-lang.c (c_printstr): Add options argument. Update.
+ * breakpoint.c: Include valprint.h.
+ (addressprint): Don't declare.
+ (watchpoint_value_print): Use get_user_print_options.
+ (print_one_breakpoint_location): Likewise.
+ (breakpoint_1, print_it_catch_fork, print_it_catch_vfork, mention,
+ print_exception_catchpoint): Likewise.
+ * auxv.c (fprint_target_auxv): Don't declare addressprint. Use
+ get_user_print_options.
+ * ada-valprint.c (struct ada_val_print_args): Remove format,
+ deref_ref, and pretty; add options.
+ (print_optional_low_bound): Add options argument.
+ (val_print_packed_array_elements): Remove format and pretty
+ arguments; add options. Update.
+ (printstr): Add options argument. Update.
+ (ada_printstr): Likewise.
+ (ada_val_print): Remove format, deref_ref, pretty arguments; add
+ options argument. Update.
+ (ada_val_print_stub): Update.
+ (ada_val_print_array): Remove format, deref_ref, pretty arguments;
+ add options. Update.
+ (ada_val_print_1): Likewise.
+ (print_variant_part): Likewise.
+ (ada_value_print): Remove format, pretty arguments; add options.
+ Update.
+ (print_record): Likewise.
+ (print_field_values): Likewise.
+ * ada-lang.h (ada_val_print, ada_value_print, ada_printstr):
+ Update.
+ * ada-lang.c (ada_print_array_index): Add options argument; remove
+ format and pretty arguments.
+ (print_one_exception): Use get_user_print_options.
+
2008-10-28 Tom Tromey <tromey@redhat.com>
* cli/cli-script.c (do_fclose_cleanup): Remove.
static void
ada_print_array_index (struct value *index_value, struct ui_file *stream,
- int format, enum val_prettyprint pretty)
+ const struct value_print_options *options)
{
- LA_VALUE_PRINT (index_value, stream, format, pretty);
+ LA_VALUE_PRINT (index_value, stream, options);
fprintf_filtered (stream, " => ");
}
print_one_exception (enum exception_catchpoint_kind ex,
struct breakpoint *b, CORE_ADDR *last_addr)
{
- if (addressprint)
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
+ if (opts.addressprint)
{
annotate_field (4);
ui_out_field_core_addr (uiout, "addr", b->loc->address);
int);
extern int ada_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
-extern int ada_value_print (struct value *, struct ui_file *, int,
- enum val_prettyprint);
+extern int ada_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
/* Defined in ada-lang.c */
extern void ada_printchar (int, struct ui_file *);
extern void ada_printstr (struct ui_file *, const gdb_byte *,
- unsigned int, int, int);
+ unsigned int, int, int,
+ const struct value_print_options *);
struct value *ada_convert_actual (struct value *actual,
struct type *formal_type0,
int embedded_offset;
CORE_ADDR address;
struct ui_file *stream;
- int format;
- int deref_ref;
int recurse;
- enum val_prettyprint pretty;
+ const struct value_print_options *options;
};
static void print_record (struct type *, const gdb_byte *, struct ui_file *,
- int, int, enum val_prettyprint);
+ int, const struct value_print_options *);
static int print_field_values (struct type *, const gdb_byte *,
- struct ui_file *, int, int,
- enum val_prettyprint, int, struct type *,
+ struct ui_file *, int,
+ const struct value_print_options *,
+ int, struct type *,
const gdb_byte *);
static void adjust_type_signedness (struct type *);
static int ada_val_print_stub (void *args0);
static int ada_val_print_1 (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
\f
/* Make TYPE unsigned if its range of values includes no negatives. */
otherwise 0. */
static int
-print_optional_low_bound (struct ui_file *stream, struct type *type)
+print_optional_low_bound (struct ui_file *stream, struct type *type,
+ const struct value_print_options *options)
{
struct type *index_type;
long low_bound;
long high_bound;
- if (print_array_indexes_p ())
+ if (options->print_array_indexes)
return 0;
if (!get_array_bounds (type, &low_bound, &high_bound))
/* Version of val_print_array_elements for GNAT-style packed arrays.
Prints elements of packed array of type TYPE at bit offset
- BITOFFSET from VALADDR on STREAM. Formats according to FORMAT and
+ BITOFFSET from VALADDR on STREAM. Formats according to OPTIONS and
separates with commas. RECURSE is the recursion (nesting) level.
- If PRETTY, uses "prettier" format. TYPE must have been decoded (as
- by ada_coerce_to_simple_array). */
+ TYPE must have been decoded (as by ada_coerce_to_simple_array). */
static void
val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
int bitoffset, struct ui_file *stream,
- int format, int recurse,
- enum val_prettyprint pretty)
+ int recurse,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
i = 0;
annotate_array_section_begin (i, elttype);
- while (i < len && things_printed < print_max)
+ while (i < len && things_printed < options->print_max)
{
struct value *v0, *v1;
int i0;
if (i != 0)
{
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
{
fprintf_filtered (stream, ",\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
}
wrap_here (n_spaces (2 + 2 * recurse));
- maybe_print_array_index (index_type, i + low, stream, format, pretty);
+ maybe_print_array_index (index_type, i + low, stream, options);
i0 = i;
v0 = ada_value_primitive_packed_val (NULL, valaddr,
break;
}
- if (i - i0 > repeat_count_threshold)
+ if (i - i0 > options->repeat_count_threshold)
{
- val_print (elttype, value_contents (v0), 0, 0, stream, format,
- 0, recurse + 1, pretty, current_language);
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
+ val_print (elttype, value_contents (v0), 0, 0, stream,
+ recurse + 1, &opts, current_language);
annotate_elt_rep (i - i0);
fprintf_filtered (stream, _(" <repeats %u times>"), i - i0);
annotate_elt_rep_end ();
else
{
int j;
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
for (j = i0; j < i; j += 1)
{
if (j > i0)
{
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
{
fprintf_filtered (stream, ",\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
wrap_here (n_spaces (2 + 2 * recurse));
maybe_print_array_index (index_type, j + low,
- stream, format, pretty);
+ stream, options);
}
- val_print (elttype, value_contents (v0), 0, 0, stream, format,
- 0, recurse + 1, pretty, current_language);
+ val_print (elttype, value_contents (v0), 0, 0, stream,
+ recurse + 1, &opts, current_language);
annotate_elt ();
}
}
static void
printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int force_ellipses, int type_len)
+ unsigned int length, int force_ellipses, int type_len,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; i += 1)
+ for (i = 0; i < length && things_printed < options->print_max; i += 1)
{
/* Position of the character we are examining
to see whether it is repeated. */
reps += 1;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
fputs_filtered ("'", stream);
fprintf_filtered (stream, _(" <repeats %u times>"), reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
void
ada_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
- printstr (stream, string, length, force_ellipses, width);
+ printstr (stream, string, length, force_ellipses, width, options);
}
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter as for the printf % codes or 0 for natural format).
- The data at VALADDR is in target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data is printed as a string, returns the number of string characters
printed.
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
RECURSE indicates the amount of indentation to supply before
- continuation lines; this amount is roughly twice the value of RECURSE.
-
- When PRETTY is non-zero, prints record fields on separate lines.
- (For some reason, the current version of gdb instead uses a global
- variable---prettyprint_arrays--- to causes a similar effect on
- arrays.) */
+ continuation lines; this amount is roughly twice the value of RECURSE. */
int
ada_val_print (struct type *type, const gdb_byte *valaddr0,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format, int deref_ref,
- int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
struct ada_val_print_args args;
args.type = type;
args.embedded_offset = embedded_offset;
args.address = address;
args.stream = stream;
- args.format = format;
- args.deref_ref = deref_ref;
args.recurse = recurse;
- args.pretty = pretty;
+ args.options = options;
return catch_errors (ada_val_print_stub, &args, NULL, RETURN_MASK_ALL);
}
struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
return ada_val_print_1 (argsp->type, argsp->valaddr0,
argsp->embedded_offset, argsp->address,
- argsp->stream, argsp->format, argsp->deref_ref,
- argsp->recurse, argsp->pretty);
+ argsp->stream, argsp->recurse, argsp->options);
}
/* Assuming TYPE is a simple array, print the value of this array located
static int
ada_val_print_array (struct type *type, const gdb_byte *valaddr,
- CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
struct type *elttype = TYPE_TARGET_TYPE (type);
unsigned int eltlen;
len = TYPE_LENGTH (type) / eltlen;
/* For an array of chars, print with string syntax. */
- if (ada_is_string_type (type) && (format == 0 || format == 's'))
+ if (ada_is_string_type (type)
+ && (options->format == 0 || options->format == 's'))
{
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
/* If requested, look for the first null char and only print
elements up to it. */
- if (stop_print_at_null)
+ if (options->stop_print_at_null)
{
int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(temp_len < len
- && temp_len < print_max
+ && temp_len < options->print_max
&& char_at (valaddr, temp_len, eltlen) != 0);
temp_len += 1);
len = temp_len;
}
- printstr (stream, valaddr, len, 0, eltlen);
+ printstr (stream, valaddr, len, 0, eltlen, options);
result = len;
}
else
{
fprintf_filtered (stream, "(");
- print_optional_low_bound (stream, type);
+ print_optional_low_bound (stream, type, options);
if (TYPE_FIELD_BITSIZE (type, 0) > 0)
val_print_packed_array_elements (type, valaddr, 0, stream,
- format, recurse, pretty);
+ recurse, options);
else
val_print_array_elements (type, valaddr, address, stream,
- format, deref_ref, recurse,
- pretty, 0);
+ recurse, options, 0);
fprintf_filtered (stream, ")");
}
static int
ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int len;
int i;
}
else
retn = ada_val_print_1 (value_type (val), value_contents (val), 0,
- VALUE_ADDRESS (val), stream, format,
- deref_ref, recurse, pretty);
+ VALUE_ADDRESS (val), stream, recurse, options);
value_free_to_mark (mark);
return retn;
}
{
default:
return c_val_print (type, valaddr0, embedded_offset, address, stream,
- format, deref_ref, recurse, pretty);
+ recurse, options);
case TYPE_CODE_PTR:
{
int ret = c_val_print (type, valaddr0, embedded_offset, address,
- stream, format, deref_ref, recurse, pretty);
+ stream, recurse, options);
if (ada_is_tag_type (type))
{
struct value *val =
value_from_contents_and_address
(type, valaddr, 0));
return ada_val_print_1 (target_type, value_contents (v), 0, 0,
- stream, format, 0, recurse + 1, pretty);
+ stream, recurse + 1, options);
}
else
return ada_val_print_1 (TYPE_TARGET_TYPE (type),
valaddr0, embedded_offset,
- address, stream, format, deref_ref,
- recurse, pretty);
+ address, stream, recurse, options);
}
else
{
- format = format ? format : output_format;
+ int format = (options->format ? options->format
+ : options->output_format);
if (format)
{
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ struct value_print_options opts = *options;
+ opts.format = format;
+ print_scalar_formatted (valaddr, type, &opts, 0, stream);
}
else if (ada_is_system_address_type (type)
&& TYPE_OBJFILE (type) != NULL)
}
case TYPE_CODE_ENUM:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ print_scalar_formatted (valaddr, type, options, 0, stream);
break;
}
len = TYPE_NFIELDS (type);
break;
case TYPE_CODE_FLAGS:
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr, type, options, 0, stream);
else
val_print_type_code_flags (type, valaddr, stream);
break;
case TYPE_CODE_FLT:
- if (format)
+ if (options->format)
return c_val_print (type, valaddr0, embedded_offset, address, stream,
- format, deref_ref, recurse, pretty);
+ recurse, options);
else
ada_print_floating (valaddr0 + embedded_offset, type, stream);
break;
}
else
{
- print_record (type, valaddr, stream, format, recurse, pretty);
+ print_record (type, valaddr, stream, recurse, options);
return 0;
}
case TYPE_CODE_ARRAY:
- return ada_val_print_array (type, valaddr, address, stream, format,
- deref_ref, recurse, pretty);
+ return ada_val_print_array (type, valaddr, address, stream,
+ recurse, options);
case TYPE_CODE_REF:
/* For references, the debugger is expected to print the value as
deref_val_int));
val_print (value_type (deref_val),
value_contents (deref_val), 0,
- VALUE_ADDRESS (deref_val), stream, format,
- deref_ref, recurse + 1, pretty, current_language);
+ VALUE_ADDRESS (deref_val), stream, recurse + 1,
+ options, current_language);
}
else
fputs_filtered ("(null)", stream);
static int
print_variant_part (struct type *type, int field_num, const gdb_byte *valaddr,
- struct ui_file *stream, int format, int recurse,
- enum val_prettyprint pretty, int comma_needed,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options, int comma_needed,
struct type *outer_type, const gdb_byte *outer_valaddr)
{
struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
(TYPE_FIELD_TYPE (var_type, which),
valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
+ TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
- stream, format, recurse, pretty,
+ stream, recurse, options,
comma_needed, outer_type, outer_valaddr);
}
int
-ada_value_print (struct value *val0, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+ada_value_print (struct value *val0, struct ui_file *stream,
+ const struct value_print_options *options)
{
const gdb_byte *valaddr = value_contents (val0);
CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
struct value *val =
value_from_contents_and_address (type, valaddr, address);
+ struct value_print_options opts;
/* If it is a pointer, indicate what it points to. */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
return 0;
}
+ opts = *options;
+ opts.deref_ref = 1;
return (val_print (type, value_contents (val), 0, address,
- stream, format, 1, 0, pretty, current_language));
+ stream, 0, &opts, current_language));
}
static void
print_record (struct type *type, const gdb_byte *valaddr,
- struct ui_file *stream, int format, int recurse,
- enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
type = ada_check_typedef (type);
fprintf_filtered (stream, "(");
- if (print_field_values (type, valaddr, stream, format, recurse, pretty,
- 0, type, valaddr) != 0 && pretty)
+ if (print_field_values (type, valaddr, stream, recurse, options,
+ 0, type, valaddr) != 0 && options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
/* Print out fields of value at VALADDR having structure type TYPE.
- TYPE, VALADDR, STREAM, FORMAT, RECURSE, and PRETTY have the
+ TYPE, VALADDR, STREAM, RECURSE, and OPTIONS have the
same meanings as in ada_print_value and ada_val_print.
OUTER_TYPE and OUTER_VALADDR give type and address of enclosing record
static int
print_field_values (struct type *type, const gdb_byte *valaddr,
- struct ui_file *stream, int format, int recurse,
- enum val_prettyprint pretty, int comma_needed,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
+ int comma_needed,
struct type *outer_type, const gdb_byte *outer_valaddr)
{
int i, len;
print_field_values (TYPE_FIELD_TYPE (type, i),
valaddr
+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
- stream, format, recurse, pretty,
+ stream, recurse, options,
comma_needed, type, valaddr);
continue;
}
{
comma_needed =
print_variant_part (type, i, valaddr,
- stream, format, recurse, pretty, comma_needed,
+ stream, recurse, options, comma_needed,
outer_type, outer_valaddr);
continue;
}
fprintf_filtered (stream, ", ");
comma_needed = 1;
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
{
wrap_here (n_spaces (2 + 2 * recurse));
}
- if (inspect_it)
+ if (options->inspect_it)
{
if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
fputs_filtered ("\"( ptr \"", stream);
{
int bit_pos = TYPE_FIELD_BITPOS (type, i);
int bit_size = TYPE_FIELD_BITSIZE (type, i);
+ struct value_print_options opts;
adjust_type_signedness (TYPE_FIELD_TYPE (type, i));
v = ada_value_primitive_packed_val (NULL, valaddr,
bit_pos % HOST_CHAR_BIT,
bit_size,
TYPE_FIELD_TYPE (type, i));
+ opts = *options;
+ opts.deref_ref = 0;
val_print (TYPE_FIELD_TYPE (type, i), value_contents (v), 0, 0,
- stream, format, 0, recurse + 1, pretty,
- current_language);
+ stream, recurse + 1, &opts, current_language);
}
}
else
- ada_val_print (TYPE_FIELD_TYPE (type, i),
- valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
- 0, 0, stream, format, 0, recurse + 1, pretty);
+ {
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
+ ada_val_print (TYPE_FIELD_TYPE (type, i),
+ valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
+ 0, 0, stream, recurse + 1, &opts);
+ }
annotate_field_end ();
}
while (target_auxv_parse (ops, &ptr, data + len, &type, &val) > 0)
{
- extern int addressprint;
const char *name = "???";
const char *description = "";
enum { dec, hex, str } flavor = hex;
fprintf_filtered (file, "0x%s\n", paddr_nz (val));
break;
case str:
- if (addressprint)
- fprintf_filtered (file, "0x%s", paddr_nz (val));
- val_print_string (val, -1, 1, file);
- fprintf_filtered (file, "\n");
+ {
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ if (opts.addressprint)
+ fprintf_filtered (file, "0x%s", paddr_nz (val));
+ val_print_string (val, -1, 1, file, &opts);
+ fprintf_filtered (file, "\n");
+ }
break;
}
++ents;
#include "ada-lang.h"
#include "top.h"
#include "wrapper.h"
+#include "valprint.h"
#include "mi/mi-common.h"
void _initialize_breakpoint (void);
-extern int addressprint; /* Print machine addresses? */
-
/* Are we executing breakpoint commands? */
static int executing_breakpoint_commands;
if (val == NULL)
fprintf_unfiltered (stream, _("<unreadable>"));
else
- value_print (val, stream, 0, Val_pretty_default);
+ {
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ value_print (val, stream, &opts);
+ }
}
/* This is the normal print function for a bpstat. In the future,
int header_of_multiple = 0;
int part_of_multiple = (loc != NULL);
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
gdb_assert (!loc || loc_number != 0);
/* See comment in print_one_breakpoint concerning
/* 5 and 6 */
strcpy (wrap_indent, " ");
- if (addressprint)
+ if (opts.addressprint)
{
if (gdbarch_addr_bit (current_gdbarch) <= 32)
strcat (wrap_indent, " ");
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (addressprint)
+ if (opts.addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
print_expression (b->exp, stb->stream);
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (addressprint)
+ if (opts.addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
if (b->dll_pathname == NULL)
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (addressprint)
+ if (opts.addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
if (b->exec_pathname != NULL)
case bp_shlib_event:
case bp_thread_event:
case bp_overlay_event:
- if (addressprint)
+ if (opts.addressprint)
{
annotate_field (4);
if (header_of_multiple)
CORE_ADDR last_addr = (CORE_ADDR) -1;
int nr_printable_breakpoints;
struct cleanup *bkpttbl_chain;
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+
/* Compute the number of rows in the table. */
nr_printable_breakpoints = 0;
ALL_BREAKPOINTS (b)
nr_printable_breakpoints++;
}
- if (addressprint)
+ if (opts.addressprint)
bkpttbl_chain
= make_cleanup_ui_out_table_begin_end (uiout, 6, nr_printable_breakpoints,
"BreakpointTable");
if (nr_printable_breakpoints > 0)
annotate_field (3);
ui_out_table_header (uiout, 3, ui_left, "enabled", "Enb"); /* 4 */
- if (addressprint)
+ if (opts.addressprint)
{
if (nr_printable_breakpoints > 0)
annotate_field (4);
static void
print_one_catch_fork (struct breakpoint *b, CORE_ADDR *last_addr)
{
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
+
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (addressprint)
+ if (opts.addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
ui_out_text (uiout, "fork");
static void
print_one_catch_vfork (struct breakpoint *b, CORE_ADDR *last_addr)
{
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns
not line up too nicely with the headers, but the effect
is relatively readable). */
- if (addressprint)
+ if (opts.addressprint)
ui_out_field_skip (uiout, "addr");
annotate_field (5);
ui_out_text (uiout, "vfork");
int say_where = 0;
struct cleanup *old_chain, *ui_out_chain;
struct ui_stream *stb;
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
}
else
{
- if (addressprint || b->source_file == NULL)
+ if (opts.addressprint || b->source_file == NULL)
{
printf_filtered (" at ");
fputs_filtered (paddress (b->loc->address), gdb_stdout);
static void
print_one_exception_catchpoint (struct breakpoint *b, CORE_ADDR *last_addr)
{
- if (addressprint)
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ if (opts.addressprint)
{
annotate_field (4);
if (b->loc == NULL || b->loc->shlib_disabled)
void
c_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining
to see whether it is repeated. */
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
LA_PRINT_CHAR (current_char, stream);
fprintf_filtered (stream, _(" <repeats %u times>"), reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
extern void c_print_typedef (struct type *, struct symbol *, struct ui_file *);
extern int c_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
-extern int c_value_print (struct value *, struct ui_file *, int,
- enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
/* These are in c-lang.c: */
extern void c_printstr (struct ui_file * stream, const gdb_byte *string,
unsigned int length, int width,
- int force_ellipses);
+ int force_ellipses,
+ const struct value_print_options *options);
extern void scan_macro_expansion (char *expansion);
extern int scanning_macro_expansion (void);
/* These are in cp-valprint.c */
-extern int vtblprint; /* Controls printing of vtbl's */
-
-extern int static_field_print;
-
extern void cp_print_class_member (const gdb_byte *, struct type *,
struct ui_file *, char *);
extern void cp_print_value_fields (struct type *, struct type *,
const gdb_byte *, int, CORE_ADDR,
struct ui_file *, int,
- int, enum val_prettyprint,
+ const struct value_print_options *,
struct type **, int);
extern int cp_is_vtbl_ptr_type (struct type *);
stream STREAM. */
static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+ int addressprint)
{
CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
address,
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter or 0 for natural format). The data at VALADDR is in
- target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data are a string pointer, returns the number of string characters
- printed.
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
+ printed. */
int
c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
- CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int i = 0; /* Number of characters printed */
unsigned len;
{
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
{
print_spaces_filtered (2 + 2 * recurse, stream);
}
/* Print arrays of textual chars with a string syntax. */
- if (textual_element_type (elttype, format))
+ if (textual_element_type (elttype, options->format))
{
/* If requested, look for the first null char and only print
elements up to it. */
- if (stop_print_at_null)
+ if (options->stop_print_at_null)
{
unsigned int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(valaddr + embedded_offset)[temp_len]
- && temp_len < len && temp_len < print_max;
+ && temp_len < len && temp_len < options->print_max;
temp_len++);
len = temp_len;
}
- LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0);
+ LA_PRINT_STRING (stream, valaddr + embedded_offset, len, eltlen, 0, options);
i = len;
}
else
i = 0;
}
val_print_array_elements (type, valaddr + embedded_offset, address, stream,
- format, deref_ref, recurse, pretty, i);
+ recurse, options, i);
fprintf_filtered (stream, "}");
}
break;
goto print_unpacked_pointer;
case TYPE_CODE_MEMBERPTR:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
cp_print_class_member (valaddr + embedded_offset, type, stream, "&");
break;
case TYPE_CODE_PTR:
- if (format && format != 's')
+ if (options->format && options->format != 's')
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
- if (vtblprint && cp_is_vtbl_ptr_type (type))
+ if (options->vtblprint && cp_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if we ARE using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
- print_function_pointer_address (addr, stream);
+ print_function_pointer_address (addr, stream, options->addressprint);
break;
}
elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
/* Try to print what function it points to. */
- print_function_pointer_address (addr, stream);
+ print_function_pointer_address (addr, stream,
+ options->addressprint);
/* Return value is irrelevant except for string pointers. */
return (0);
}
- if (addressprint)
+ if (options->addressprint)
fputs_filtered (paddress (addr), stream);
/* For a pointer to a textual type, also print the string
pointed to, unless pointer is null. */
/* FIXME: need to handle wchar_t here... */
- if (textual_element_type (elttype, format) && addr != 0)
+ if (textual_element_type (elttype, options->format)
+ && addr != 0)
{
- i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+ i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+ options);
}
else if (cp_is_vtbl_member (type))
{
fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
fputs_filtered (">", stream);
}
- if (vt_address && vtblprint)
+ if (vt_address && options->vtblprint)
{
struct value *vt_val;
struct symbol *wsym = (struct symbol *) NULL;
wtype = TYPE_TARGET_TYPE (type);
}
vt_val = value_at (wtype, vt_address);
- common_val_print (vt_val, stream, format,
- deref_ref, recurse + 1, pretty,
+ common_val_print (vt_val, stream, recurse + 1, options,
current_language);
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
case TYPE_CODE_REF:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (addressprint)
+ if (options->addressprint)
{
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
fprintf_filtered (stream, "@");
fputs_filtered (paddress (addr), stream);
- if (deref_ref)
+ if (options->deref_ref)
fputs_filtered (": ", stream);
}
/* De-reference the reference. */
- if (deref_ref)
+ if (options->deref_ref)
{
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
value_at
(TYPE_TARGET_TYPE (type),
unpack_pointer (type, valaddr + embedded_offset));
- common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty, current_language);
+ common_val_print (deref_val, stream, recurse, options,
+ current_language);
}
else
fputs_filtered ("???", stream);
break;
case TYPE_CODE_UNION:
- if (recurse && !unionprint)
+ if (recurse && !options->unionprint)
{
fprintf_filtered (stream, "{...}");
break;
/* Fall through. */
case TYPE_CODE_STRUCT:
/*FIXME: Abstract this away */
- if (vtblprint && cp_is_vtbl_ptr_type (type))
+ if (options->vtblprint && cp_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if NOT using
CORE_ADDR addr
= extract_typed_address (valaddr + offset, field_type);
- print_function_pointer_address (addr, stream);
+ print_function_pointer_address (addr, stream, options->addressprint);
}
else
- cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream, format,
- recurse, pretty, NULL, 0);
+ cp_print_value_fields (type, type, valaddr, embedded_offset, address, stream,
+ recurse, options, NULL, 0);
break;
case TYPE_CODE_ENUM:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
len = TYPE_NFIELDS (type);
break;
case TYPE_CODE_FLAGS:
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
else
val_print_type_code_flags (type, valaddr + embedded_offset, stream);
break;
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
/* FIXME, we should consider, at least for ANSI C language, eliminating
break;
case TYPE_CODE_BOOL:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
+ }
else
{
val = unpack_long (type, valaddr + embedded_offset);
/* FALLTHROUGH */
case TYPE_CODE_INT:
- format = format ? format : output_format;
- if (format)
+ if (options->format || options->output_format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
}
else
{
Since we don't know whether the value is really intended to
be used as an integer or a character, print the character
equivalent as well. */
- if (textual_element_type (type, format))
+ if (textual_element_type (type, options->format))
{
fputs_filtered (" ", stream);
LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr + embedded_offset),
break;
case TYPE_CODE_CHAR:
- format = format ? format : output_format;
- if (format)
+ if (options->format || options->output_format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
}
else
{
break;
case TYPE_CODE_FLT:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
}
else
{
break;
case TYPE_CODE_DECFLOAT:
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
else
print_decimal_floating (valaddr + embedded_offset, type, stream);
break;
break;
case TYPE_CODE_COMPLEX:
- if (format)
+ if (options->format)
print_scalar_formatted (valaddr + embedded_offset,
TYPE_TARGET_TYPE (type),
- format, 0, stream);
+ options, 0, stream);
else
print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
stream);
fprintf_filtered (stream, " + ");
- if (format)
+ if (options->format)
print_scalar_formatted (valaddr + embedded_offset
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
TYPE_TARGET_TYPE (type),
- format, 0, stream);
+ options, 0, stream);
else
print_floating (valaddr + embedded_offset
+ TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
}
\f
int
-c_value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+c_value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
struct type *type, *real_type;
int full, top, using_enc;
+ struct value_print_options opts = *options;
+
+ opts.deref_ref = 1;
/* If it is a pointer, indicate what it points to.
{
/* Print nothing */
}
- else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
+ else if (options->objectprint
+ && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
{
if (TYPE_CODE(type) == TYPE_CODE_REF)
if (!value_initialized (val))
fprintf_filtered (stream, " [uninitialized] ");
- if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
+ if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
{
/* Attempt to determine real type of object */
real_type = value_rtti_type (val, &full, &top, &using_enc);
/* Print out object: enclosing type is same as real_type if full */
return val_print (value_enclosing_type (val),
value_contents_all (val), 0,
- VALUE_ADDRESS (val), stream, format, 1, 0,
- pretty, current_language);
+ VALUE_ADDRESS (val), stream, 0,
+ &opts, current_language);
/* Note: When we look up RTTI entries, we don't get any information on
const or volatile attributes */
}
TYPE_NAME (value_enclosing_type (val)));
return val_print (value_enclosing_type (val),
value_contents_all (val), 0,
- VALUE_ADDRESS (val), stream, format, 1, 0,
- pretty, current_language);
+ VALUE_ADDRESS (val), stream, 0,
+ &opts, current_language);
}
/* Otherwise, we end up at the return outside this "if" */
}
return val_print (type, value_contents_all (val),
value_embedded_offset (val),
VALUE_ADDRESS (val) + value_offset (val),
- stream, format, 1, 0, pretty, current_language);
+ stream, 0, &opts, current_language);
}
#include "language.h"
/* Controls printing of vtbl's */
-int vtblprint;
static void
show_vtblprint (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* Controls looking up an object's derived type using what we find in
its vtables. */
-int objectprint;
static void
show_objectprint (struct ui_file *file, int from_tty,
struct cmd_list_element *c,
value);
}
-int static_field_print; /* Controls printing of static fields. */
static void
show_static_field_print (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
extern void _initialize_cp_valprint (void);
static void cp_print_static_field (struct type *, struct value *,
- struct ui_file *, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
static void cp_print_value (struct type *, struct type *, const gdb_byte *,
- int, CORE_ADDR, struct ui_file *, int, int,
- enum val_prettyprint, struct type **);
+ int, CORE_ADDR, struct ui_file *, int,
+ const struct value_print_options *, struct type **);
/* GCC versions after 2.4.5 use this. */
/* Mutually recursive subroutines of cp_print_value and c_val_print to
print out a structure's fields: cp_print_value_fields and cp_print_value.
- TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+ TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
same meanings as in cp_print_value and c_val_print.
2nd argument REAL_TYPE is used to carry over the type of the derived
void
cp_print_value_fields (struct type *type, struct type *real_type,
const gdb_byte *valaddr, int offset, CORE_ADDR address,
- struct ui_file *stream, int format, int recurse,
- enum val_prettyprint pretty,
- struct type **dont_print_vb,int dont_print_statmem)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
+ struct type **dont_print_vb, int dont_print_statmem)
{
int i, len, n_baseclasses;
char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
if (n_baseclasses > 0)
cp_print_value (type, real_type, valaddr, offset, address, stream,
- format, recurse + 1, pretty, dont_print_vb);
+ recurse + 1, options, dont_print_vb);
/* Second, print out data fields */
for (i = n_baseclasses; i < len; i++)
{
/* If requested, skip printing of static fields. */
- if (!static_field_print
+ if (!options->static_field_print
&& field_is_static (&TYPE_FIELD (type, i)))
continue;
fprintf_filtered (stream, ", ");
else if (n_baseclasses > 0)
{
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
fields_seen = 1;
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
{
wrap_here (n_spaces (2 + 2 * recurse));
}
- if (inspect_it)
+ if (options->inspect_it)
{
if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
fputs_filtered ("\"( ptr \"", stream);
}
else
{
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
v = value_from_longest
(TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr + offset, i));
- common_val_print (v, stream, format, 0, recurse + 1, pretty,
+ common_val_print (v, stream, recurse + 1, &opts,
current_language);
}
}
fputs_filtered ("<optimized out>", stream);
else
cp_print_static_field (TYPE_FIELD_TYPE (type, i), v,
- stream, format, recurse + 1,
- pretty);
+ stream, recurse + 1, options);
}
else
{
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
val_print (TYPE_FIELD_TYPE (type, i),
valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty,
+ stream, recurse + 1, &opts,
current_language);
}
}
dont_print_statmem_obstack = tmp_obstack;
}
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
static void
cp_print_value (struct type *type, struct type *real_type,
const gdb_byte *valaddr, int offset, CORE_ADDR address,
- struct ui_file *stream, int format, int recurse,
- enum val_prettyprint pretty, struct type **dont_print_vb)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
+ struct type **dont_print_vb)
{
struct type **last_dont_print
= (struct type **) obstack_next_free (&dont_print_vb_obstack);
base_valaddr = valaddr;
/* now do the printing */
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
else
cp_print_value_fields (baseclass, thistype, base_valaddr,
thisoffset + boffset, address + boffset,
- stream, format,
- recurse, pretty,
+ stream, recurse, options,
((struct type **)
obstack_base (&dont_print_vb_obstack)),
0);
static member classes in an obstack and refuse to print them more
than once.
- VAL contains the value to print, TYPE, STREAM, RECURSE, and PRETTY
+ VAL contains the value to print, TYPE, STREAM, RECURSE, and OPTIONS
have the same meanings as in c_val_print. */
static void
cp_print_static_field (struct type *type,
struct value *val,
struct ui_file *stream,
- int format,
int recurse,
- enum val_prettyprint pretty)
+ const struct value_print_options *options)
{
+ struct value_print_options opts;
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
CORE_ADDR *first_dont_print;
CHECK_TYPEDEF (type);
cp_print_value_fields (type, type, value_contents_all (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stream, format, recurse, pretty, NULL, 1);
+ stream, recurse, options, NULL, 1);
return;
}
+
+ opts = *options;
+ opts.deref_ref = 0;
val_print (type, value_contents_all (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stream, format, 0, recurse, pretty, current_language);
+ stream, recurse, &opts, current_language);
}
_initialize_cp_valprint (void)
{
add_setshow_boolean_cmd ("static-members", class_support,
- &static_field_print, _("\
+ &user_print_options.static_field_print, _("\
Set printing of C++ static members."), _("\
Show printing of C++ static members."), NULL,
NULL,
show_static_field_print,
&setprintlist, &showprintlist);
- /* Turn on printing of static fields. */
- static_field_print = 1;
- add_setshow_boolean_cmd ("vtbl", class_support, &vtblprint, _("\
+ add_setshow_boolean_cmd ("vtbl", class_support,
+ &user_print_options.vtblprint, _("\
Set printing of C++ virtual function tables."), _("\
Show printing of C++ virtual function tables."), NULL,
NULL,
show_vtblprint,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("object", class_support, &objectprint, _("\
+ add_setshow_boolean_cmd ("object", class_support,
+ &user_print_options.objectprint, _("\
Set printing of object's derived type based on vtable info."), _("\
Show printing of object's derived type based on vtable info."), NULL,
NULL,
show_objectprint,
&setprintlist, &showprintlist);
- /* Give people the defaults which they are used to. */
- objectprint = 0;
- vtblprint = 0;
obstack_begin (&dont_print_vb_obstack, 32 * sizeof (struct type *));
obstack_specify_allocation (&dont_print_statmem_obstack,
32 * sizeof (CORE_ADDR), sizeof (CORE_ADDR),
#include "exceptions.h"
#include "regcache.h"
#include "user-regs.h"
+#include "valprint.h"
#include "gdb_assert.h"
/* This is defined in valops.c */
extern int overload_resolution;
-/* JYG: lookup rtti type of STRUCTOP_PTR when this is set to continue
- on with successful lookup for member/method of the rtti type. */
-extern int objectprint;
-
/* Prototypes for local functions. */
static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
struct type *type = value_type (arg1);
struct type *real_type;
int full, top, using_enc;
-
- if (objectprint && TYPE_TARGET_TYPE(type) &&
+ struct value_print_options opts;
+
+ get_user_print_options (&opts);
+ if (opts.objectprint && TYPE_TARGET_TYPE(type) &&
(TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS))
{
real_type = value_rtti_target_type (arg1, &full, &top, &using_enc);
#include "block.h"
#include "objfiles.h"
#include "gdb_assert.h"
+#include "valprint.h"
#ifdef HAVE_CTYPE_H
#include <ctype.h>
return;
case OP_LONG:
- (*pos) += 3;
- value_print (value_from_longest (exp->elts[pc + 1].type,
- exp->elts[pc + 2].longconst),
- stream, 0, Val_no_prettyprint);
+ {
+ struct value_print_options opts;
+ get_raw_print_options (&opts);
+ (*pos) += 3;
+ value_print (value_from_longest (exp->elts[pc + 1].type,
+ exp->elts[pc + 2].longconst),
+ stream, &opts);
+ }
return;
case OP_DOUBLE:
- (*pos) += 3;
- value_print (value_from_double (exp->elts[pc + 1].type,
- exp->elts[pc + 2].doubleconst),
- stream, 0, Val_no_prettyprint);
+ {
+ struct value_print_options opts;
+ get_raw_print_options (&opts);
+ (*pos) += 3;
+ value_print (value_from_double (exp->elts[pc + 1].type,
+ exp->elts[pc + 2].doubleconst),
+ stream, &opts);
+ }
return;
case OP_VAR_VALUE:
return;
case OP_STRING:
- nargs = longest_to_int (exp->elts[pc + 1].longconst);
- (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
- /* LA_PRINT_STRING will print using the current repeat count threshold.
- If necessary, we can temporarily set it to zero, or pass it as an
- additional parameter to LA_PRINT_STRING. -fnf */
- LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
+ {
+ struct value_print_options opts;
+ nargs = longest_to_int (exp->elts[pc + 1].longconst);
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+ /* LA_PRINT_STRING will print using the current repeat count threshold.
+ If necessary, we can temporarily set it to zero, or pass it as an
+ additional parameter to LA_PRINT_STRING. -fnf */
+ get_user_print_options (&opts);
+ LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+ &opts);
+ }
return;
case OP_BITSTRING:
return;
case OP_OBJC_NSSTRING: /* Objective-C Foundation Class NSString constant. */
- nargs = longest_to_int (exp->elts[pc + 1].longconst);
- (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
- fputs_filtered ("@\"", stream);
- LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0);
- fputs_filtered ("\"", stream);
+ {
+ struct value_print_options opts;
+ nargs = longest_to_int (exp->elts[pc + 1].longconst);
+ (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1);
+ fputs_filtered ("@\"", stream);
+ get_user_print_options (&opts);
+ LA_PRINT_STRING (stream, &exp->elts[pc + 2].string, nargs, 1, 0,
+ &opts);
+ fputs_filtered ("\"", stream);
+ }
return;
case OP_OBJC_MSGCALL:
}
if (tem > 0)
{
- LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0);
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ LA_PRINT_STRING (stream, tempstr, nargs - 1, 1, 0,
+ &opts);
(*pos) = pc;
}
else
if (TYPE_CODE (exp->elts[pc + 1].type) == TYPE_CODE_FUNC &&
exp->elts[pc + 3].opcode == OP_LONG)
{
+ struct value_print_options opts;
+
/* We have a minimal symbol fn, probably. It's encoded
as a UNOP_MEMVAL (function-type) of an OP_LONG (int, address).
Swallow the OP_LONG (including both its opcodes); ignore
(*pos) += 4;
val = value_at_lazy (exp->elts[pc + 1].type,
(CORE_ADDR) exp->elts[pc + 5].longconst);
- value_print (val, stream, 0, Val_no_prettyprint);
+ get_raw_print_options (&opts);
+ value_print (val, stream, &opts);
}
else
{
static void
f_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining
to see whether it is repeated. */
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\', ", stream);
else
fputs_filtered ("', ", stream);
f_printchar (string[i], stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\'", stream);
else
fputs_filtered ("'", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\'", stream);
else
fputs_filtered ("'", stream);
/* This is declared in c-lang.h but it is silly to import that file for what
is already just a hack. */
-extern int c_value_print (struct value *, struct ui_file *, int,
- enum val_prettyprint);
+extern int c_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
const struct language_defn f_language_defn =
{
int);
extern int f_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
/* Language-specific data structures */
static void
f77_print_array_1 (int nss, int ndimensions, struct type *type,
const gdb_byte *valaddr, CORE_ADDR address,
- struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
int *elts)
{
int i;
if (nss != ndimensions)
{
- for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++)
+ for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++)
{
fprintf_filtered (stream, "( ");
f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type),
valaddr + i * F77_DIM_OFFSET (nss),
address + i * F77_DIM_OFFSET (nss),
- stream, format, deref_ref, recurse, pretty, elts);
+ stream, recurse, options, elts);
fprintf_filtered (stream, ") ");
}
- if (*elts >= print_max && i < F77_DIM_SIZE (nss))
+ if (*elts >= options->print_max && i < F77_DIM_SIZE (nss))
fprintf_filtered (stream, "...");
}
else
{
- for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max;
+ for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max;
i++, (*elts)++)
{
val_print (TYPE_TARGET_TYPE (type),
valaddr + i * F77_DIM_OFFSET (ndimensions),
0,
address + i * F77_DIM_OFFSET (ndimensions),
- stream, format, deref_ref, recurse, pretty,
- current_language);
+ stream, recurse, options, current_language);
if (i != (F77_DIM_SIZE (nss) - 1))
fprintf_filtered (stream, ", ");
- if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1)))
+ if ((*elts == options->print_max - 1)
+ && (i != (F77_DIM_SIZE (nss) - 1)))
fprintf_filtered (stream, "...");
}
}
static void
f77_print_array (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
- int format, int deref_ref, int recurse,
- enum val_prettyprint pretty)
+ int recurse, const struct value_print_options *options)
{
int ndimensions;
int elts = 0;
f77_create_arrayprint_offset_tbl (type, stream);
- f77_print_array_1 (1, ndimensions, type, valaddr, address, stream, format,
- deref_ref, recurse, pretty, &elts);
+ f77_print_array_1 (1, ndimensions, type, valaddr, address, stream,
+ recurse, options, &elts);
}
\f
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter or 0 for natural format). The data at VALADDR is in
- target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data are a string pointer, returns the number of string characters
- printed.
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
+ printed. */
int
f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
- CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int i = 0; /* Number of characters printed */
struct type *elttype;
{
case TYPE_CODE_STRING:
f77_get_dynamic_length_of_aggregate (type);
- LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0);
+ LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0, options);
break;
case TYPE_CODE_ARRAY:
fprintf_filtered (stream, "(");
- f77_print_array (type, valaddr, address, stream, format,
- deref_ref, recurse, pretty);
+ f77_print_array (type, valaddr, address, stream, recurse, options);
fprintf_filtered (stream, ")");
break;
case TYPE_CODE_PTR:
- if (format && format != 's')
+ if (options->format && options->format != 's')
{
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ print_scalar_formatted (valaddr, type, options, 0, stream);
break;
}
else
return 0;
}
- if (addressprint && format != 's')
+ if (options->addressprint && options->format != 's')
fputs_filtered (paddress (addr), stream);
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
if (TYPE_LENGTH (elttype) == 1
&& TYPE_CODE (elttype) == TYPE_CODE_INT
- && (format == 0 || format == 's')
+ && (options->format == 0 || options->format == 's')
&& addr != 0)
- i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+ i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream,
+ options);
/* Return number of characters printed, including the terminating
'\0' if we reached the end. val_print_string takes care including
case TYPE_CODE_REF:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (addressprint)
+ if (options->addressprint)
{
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
fprintf_filtered (stream, "@");
fputs_filtered (paddress (addr), stream);
- if (deref_ref)
+ if (options->deref_ref)
fputs_filtered (": ", stream);
}
/* De-reference the reference. */
- if (deref_ref)
+ if (options->deref_ref)
{
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
value_at
(TYPE_TARGET_TYPE (type),
unpack_pointer (type, valaddr + embedded_offset));
- common_val_print (deref_val, stream, format, deref_ref, recurse,
- pretty, current_language);
+ common_val_print (deref_val, stream, recurse,
+ options, current_language);
}
else
fputs_filtered ("???", stream);
break;
case TYPE_CODE_FUNC:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ print_scalar_formatted (valaddr, type, options, 0, stream);
break;
}
/* FIXME, we should consider, at least for ANSI C language, eliminating
break;
case TYPE_CODE_INT:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr, type, &opts, 0, stream);
+ }
else
{
val_print_type_code_int (type, valaddr, stream);
break;
case TYPE_CODE_FLAGS:
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr, type, options, 0, stream);
else
val_print_type_code_flags (type, valaddr, stream);
break;
case TYPE_CODE_FLT:
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr, type, options, 0, stream);
else
print_floating (valaddr, type, stream);
break;
break;
case TYPE_CODE_BOOL:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr, type, &opts, 0, stream);
+ }
else
{
val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
{
/* Bash the type code temporarily. */
TYPE_CODE (type) = TYPE_CODE_INT;
- f_val_print (type, valaddr, 0, address, stream, format,
- deref_ref, recurse, pretty);
+ f_val_print (type, valaddr, 0, address, stream, recurse, options);
/* Restore the type code so later uses work as intended. */
TYPE_CODE (type) = TYPE_CODE_BOOL;
}
{
int offset = TYPE_FIELD_BITPOS (type, index) / 8;
f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
- embedded_offset, address, stream,
- format, deref_ref, recurse, pretty);
+ embedded_offset, address, stream, recurse, options);
if (index != TYPE_NFIELDS (type) - 1)
fputs_filtered (", ", stream);
}
/* Forward declarations for prototypes. */
struct field;
struct block;
+struct value_print_options;
/* Some macros for char-based bitfields. */
/* printcmd.c */
-extern void print_scalar_formatted (const void *, struct type *, int, int,
- struct ui_file *);
+extern void print_scalar_formatted (const void *, struct type *,
+ const struct value_print_options *,
+ int, struct ui_file *);
extern int can_dereference (struct type *);
#include "exceptions.h"
#include "cli/cli-decode.h"
#include "gdbthread.h"
+#include "valprint.h"
/* Functions exported for general use, in inferior.h: */
if (value)
{
+ struct value_print_options opts;
+
/* Print it. */
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
ui_out_field_fmt (uiout, "gdb-result-var", "$%d",
record_latest_value (value));
ui_out_text (uiout, " = ");
- value_print (value, stb->stream, 0, Val_no_prettyprint);
+ get_raw_print_options (&opts);
+ value_print (value, stb->stream, &opts);
ui_out_field_stream (uiout, "return-value", stb);
ui_out_text (uiout, "\n");
do_cleanups (old_chain);
|| TYPE_CODE (register_type (gdbarch, i)) == TYPE_CODE_DECFLOAT)
{
int j;
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ opts.deref_ref = 1;
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default, current_language);
+ file, 0, &opts, current_language);
fprintf_filtered (file, "\t(raw 0x");
for (j = 0; j < register_size (gdbarch, i); j++)
}
else
{
+ struct value_print_options opts;
+
/* Print the register in hex. */
+ get_formatted_print_options (&opts, 'x');
+ opts.deref_ref = 1;
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 'x', 1, 0, Val_pretty_default, current_language);
+ file, 0, &opts,
+ current_language);
/* If not a vector register, print it also according to its
natural format. */
if (TYPE_VECTOR (register_type (gdbarch, i)) == 0)
{
+ get_user_print_options (&opts);
+ opts.deref_ref = 1;
fprintf_filtered (file, "\t");
val_print (register_type (gdbarch, i), buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default, current_language);
+ file, 0, &opts, current_language);
}
}
if (regnum >= gdbarch_num_regs (gdbarch)
+ gdbarch_num_pseudo_regs (gdbarch))
{
+ struct value_print_options opts;
struct value *val = value_of_user_reg (regnum, frame);
printf_filtered ("%s: ", start);
+ get_formatted_print_options (&opts, 'x');
print_scalar_formatted (value_contents (val),
check_typedef (value_type (val)),
- 'x', 0, gdb_stdout);
+ &opts, 0, gdb_stdout);
printf_filtered ("\n");
}
else
extern struct type *java_void_type;
extern int java_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
-extern int java_value_print (struct value *, struct ui_file *, int,
- enum val_prettyprint);
+extern int java_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
extern struct value *java_class_from_object (struct value *);
/* Local functions */
int
-java_value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+java_value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
struct type *type;
CORE_ADDR address;
int i;
char *name;
+ struct value_print_options opts;
type = value_type (val);
address = VALUE_ADDRESS (val) + value_offset (val);
address += JAVA_OBJECT_SIZE + 4; /* Skip object header and length. */
- while (i < length && things_printed < print_max)
+ while (i < length && things_printed < options->print_max)
{
gdb_byte *buf;
VALUE_ADDRESS (v) = address + JAVA_OBJECT_SIZE + 4;
VALUE_ADDRESS (next_v) = VALUE_ADDRESS (v);
- while (i < length && things_printed < print_max)
+ while (i < length && things_printed < options->print_max)
{
fputs_filtered (", ", stream);
wrap_here (n_spaces (2));
else
fprintf_filtered (stream, "%d..%d: ", i, i + reps - 1);
- common_val_print (v, stream, format, 2, 1, pretty,
- current_language);
+ opts = *options;
+ opts.deref_ref = 1;
+ common_val_print (v, stream, 1, &opts, current_language);
things_printed++;
i += reps;
&& TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
&& strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
"java.lang.String") == 0
- && (format == 0 || format == 's')
+ && (options->format == 0 || options->format == 's')
&& address != 0
&& value_as_address (val) != 0)
{
value_free_to_mark (mark); /* Release unnecessary values */
- val_print_string (data + boffset, count, 2, stream);
+ val_print_string (data + boffset, count, 2, stream, options);
return 0;
}
- return common_val_print (val, stream, format, 1, 0, pretty,
- current_language);
+ opts = *options;
+ opts.deref_ref = 1;
+ return common_val_print (val, stream, 0, &opts, current_language);
}
-/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+/* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
same meanings as in cp_print_value and c_val_print.
DONT_PRINT is an array of baseclass types that we
static void
java_print_value_fields (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
- int format, int recurse, enum val_prettyprint pretty)
+ int recurse,
+ const struct value_print_options *options)
{
int i, len, n_baseclasses;
boffset = 0;
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * (recurse + 1), stream);
base_valaddr = valaddr;
java_print_value_fields (baseclass, base_valaddr, address + boffset,
- stream, format, recurse + 1, pretty);
+ stream, recurse + 1, options);
fputs_filtered (", ", stream);
}
if (field_is_static (&TYPE_FIELD (type, i)))
{
char *name = TYPE_FIELD_NAME (type, i);
- if (!static_field_print)
+ if (!options->static_field_print)
continue;
if (name != NULL && strcmp (name, "class") == 0)
continue;
fprintf_filtered (stream, ", ");
else if (n_baseclasses > 0)
{
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
fields_seen = 1;
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
{
wrap_here (n_spaces (2 + 2 * recurse));
}
- if (inspect_it)
+ if (options->inspect_it)
{
if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
fputs_filtered ("\"( ptr \"", stream);
}
else
{
+ struct value_print_options opts;
+
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- common_val_print (v, stream, format, 0, recurse + 1,
- pretty, current_language);
+ opts = *options;
+ opts.deref_ref = 0;
+ common_val_print (v, stream, recurse + 1,
+ &opts, current_language);
}
}
else
fputs_filtered ("<optimized out>", stream);
else
{
+ struct value_print_options opts;
struct type *t = check_typedef (value_type (v));
if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
v = value_addr (v);
- common_val_print (v, stream, format, 0, recurse + 1,
- pretty, current_language);
+ opts = *options;
+ opts.deref_ref = 0;
+ common_val_print (v, stream, recurse + 1,
+ &opts, current_language);
}
}
else if (TYPE_FIELD_TYPE (type, i) == NULL)
fputs_filtered ("<unknown type>", stream);
else
{
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
val_print (TYPE_FIELD_TYPE (type, i),
valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty,
+ stream, recurse + 1, &opts,
current_language);
}
}
annotate_field_end ();
}
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter or 0 for natural format). The data at VALADDR is in
- target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data are a string pointer, returns the number of string characters
- printed.
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
+ printed. */
int
java_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format, int deref_ref,
- int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int i = 0; /* Number of characters printed */
struct type *target_type;
switch (TYPE_CODE (type))
{
case TYPE_CODE_PTR:
- if (format && format != 's')
+ if (options->format && options->format != 's')
{
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ print_scalar_formatted (valaddr, type, options, 0, stream);
break;
}
#if 0
- if (vtblprint && cp_is_vtbl_ptr_type (type))
+ if (options->vtblprint && cp_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if we ARE using
return (0);
}
- if (addressprint && format != 's')
+ if (options->addressprint && options->format != 's')
{
fputs_filtered ("@", stream);
print_longest (stream, 'x', 0, (ULONGEST) addr);
case TYPE_CODE_INT:
/* Can't just call c_val_print because that prints bytes as C
chars. */
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr, type, format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr, type, &opts, 0, stream);
+ }
else if (TYPE_CODE (type) == TYPE_CODE_CHAR
|| (TYPE_CODE (type) == TYPE_CODE_INT
&& TYPE_LENGTH (type) == 2
break;
case TYPE_CODE_STRUCT:
- java_print_value_fields (type, valaddr, address, stream, format,
- recurse, pretty);
+ java_print_value_fields (type, valaddr, address, stream, recurse,
+ options);
break;
default:
return c_val_print (type, valaddr, embedded_offset, address, stream,
- format, deref_ref, recurse, pretty);
+ recurse, options);
}
return 0;
static void unk_lang_print_type (struct type *, char *, struct ui_file *,
int, int);
-static int unk_lang_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+static int unk_lang_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
static CORE_ADDR unk_lang_trampoline (struct frame_info *, CORE_ADDR pc);
void
default_print_array_index (struct value *index_value, struct ui_file *stream,
- int format, enum val_prettyprint pretty)
+ const struct value_print_options *options)
{
fprintf_filtered (stream, "[");
- LA_VALUE_PRINT (index_value, stream, format, pretty);
+ LA_VALUE_PRINT (index_value, stream, options);
fprintf_filtered (stream, "] = ");
}
static void
unk_lang_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
error (_("internal error - unimplemented function unk_lang_printstr called."));
}
static int
unk_lang_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
error (_("internal error - unimplemented function unk_lang_val_print called."));
}
static int
-unk_lang_value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+unk_lang_value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
error (_("internal error - unimplemented function unk_lang_value_print called."));
}
struct frame_info;
struct expression;
struct ui_file;
+struct value_print_options;
#define MAX_FORTRAN_DIMS 7 /* Maximum number of F77 array dims */
void (*la_printstr) (struct ui_file * stream, const gdb_byte *string,
unsigned int length, int width,
- int force_ellipses);
+ int force_ellipses,
+ const struct value_print_options *);
void (*la_emitchar) (int ch, struct ui_file * stream, int quoter);
/* Print a value using syntax appropriate for this language. */
int (*la_val_print) (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
/* Print a top-level value using syntax appropriate for this language. */
int (*la_value_print) (struct value *, struct ui_file *,
- int, enum val_prettyprint);
+ const struct value_print_options *);
/* PC is possibly an unknown languages trampoline.
If that PC falls in a trampoline belonging to this language,
/* Print the index of an element of an array. */
void (*la_print_array_index) (struct value *index_value,
struct ui_file *stream,
- int format,
- enum val_prettyprint pretty);
+ const struct value_print_options *options);
/* Return non-zero if TYPE should be passed (and returned) by
reference at the language level. */
#define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
(current_language->la_print_typedef(type,new_symbol,stream))
-#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,fmt,deref,recurse,pretty) \
- (current_language->la_val_print(type,valaddr,offset,addr,stream,fmt,deref, \
- recurse,pretty))
-#define LA_VALUE_PRINT(val,stream,fmt,pretty) \
- (current_language->la_value_print(val,stream,fmt,pretty))
+#define LA_VAL_PRINT(type,valaddr,offset,addr,stream,recurse,options) \
+ (current_language->la_val_print(type,valaddr,offset,addr,stream, \
+ recurse,options))
+#define LA_VALUE_PRINT(val,stream,options) \
+ (current_language->la_value_print(val,stream,options))
#define LA_PRINT_CHAR(ch, stream) \
(current_language->la_printchar(ch, stream))
-#define LA_PRINT_STRING(stream, string, length, width, force_ellipses) \
- (current_language->la_printstr(stream, string, length, width, force_ellipses))
+#define LA_PRINT_STRING(stream, string, length, width, force_ellipses,options) \
+ (current_language->la_printstr(stream, string, length, width, \
+ force_ellipses,options))
#define LA_EMIT_CHAR(ch, stream, quoter) \
(current_language->la_emitchar(ch, stream, quoter))
-#define LA_PRINT_ARRAY_INDEX(index_value, stream, format, pretty) \
- (current_language->la_print_array_index(index_value, stream, format, pretty))
+#define LA_PRINT_ARRAY_INDEX(index_value, stream, optins) \
+ (current_language->la_print_array_index(index_value, stream, options))
/* Test a character to decide whether it can be printed in literal form
or needs to be printed in another representation. For example,
/* Print the index of an array element using the C99 syntax. */
extern void default_print_array_index (struct value *index_value,
struct ui_file *stream,
- int format,
- enum val_prettyprint pretty);
+ const struct value_print_options *options);
/* Return non-zero if TYPE should be passed (and returned) by
reference at the language level. */
static void
m2_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining
to see whether it is repeated. */
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
m2_printchar (string[i], stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
extern int m2_is_unbounded_array (struct type *type);
extern int m2_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
extern int get_long_set_bounds (struct type *type, LONGEST *low,
LONGEST *high);
#include "m2-lang.h"
#include "target.h"
-int print_unpacked_pointer (struct type *type,
- CORE_ADDR address, CORE_ADDR addr,
- int format, struct ui_file *stream);
+static int print_unpacked_pointer (struct type *type,
+ CORE_ADDR address, CORE_ADDR addr,
+ const struct value_print_options *options,
+ struct ui_file *stream);
static void
m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- enum val_prettyprint pretty,
- int deref_ref, int recurse, int len);
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
+ int len);
/* Print function pointer with inferior address ADDRESS onto stdio
stream STREAM. */
static void
-print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
+print_function_pointer_address (CORE_ADDR address, struct ui_file *stream,
+ int addressprint)
{
CORE_ADDR func_addr = gdbarch_convert_from_func_ptr_addr (current_gdbarch,
address,
static void
m2_print_long_set (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+ struct ui_file *stream)
{
int empty_set = 1;
int element_seen = 0;
static void
m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- int deref_ref, enum val_prettyprint pretty,
- int recurse)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
struct type *content_type;
CORE_ADDR addr;
fprintf_filtered (stream, "{");
m2_print_array_contents (value_type (val), value_contents(val),
value_embedded_offset (val), addr, stream,
- format, deref_ref, pretty, recurse, len);
+ recurse, options, len);
fprintf_filtered (stream, ", HIGH = %d}", (int) len);
}
-int
+static int
print_unpacked_pointer (struct type *type,
CORE_ADDR address, CORE_ADDR addr,
- int format, struct ui_file *stream)
+ const struct value_print_options *options,
+ struct ui_file *stream)
{
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
{
/* Try to print what function it points to. */
- print_function_pointer_address (addr, stream);
+ print_function_pointer_address (addr, stream, options->addressprint);
/* Return value is irrelevant except for string pointers. */
return 0;
}
- if (addressprint && format != 's')
+ if (options->addressprint && options->format != 's')
fputs_filtered (paddress (address), stream);
/* For a pointer to char or unsigned char, also print the string
if (TYPE_LENGTH (elttype) == 1
&& TYPE_CODE (elttype) == TYPE_CODE_INT
- && (format == 0 || format == 's')
+ && (options->format == 0 || options->format == 's')
&& addr != 0)
- return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
+ return val_print_string (addr, -1, TYPE_LENGTH (elttype), stream, options);
return 0;
}
static void
print_variable_at_address (struct type *type,
const gdb_byte *valaddr,
- struct ui_file *stream, int format,
- int deref_ref, int recurse,
- enum val_prettyprint pretty)
+ struct ui_file *stream,
+ int recurse,
+ const struct value_print_options *options)
{
CORE_ADDR addr = unpack_pointer (type, valaddr);
struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
{
struct value *deref_val =
value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr));
- common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty, current_language);
+ common_val_print (deref_val, stream, recurse, options, current_language);
}
else
fputs_filtered ("???", stream);
static void
m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- enum val_prettyprint pretty,
- int deref_ref, int recurse, int len)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
+ int len)
{
int eltlen;
CHECK_TYPEDEF (type);
if (TYPE_LENGTH (type) > 0)
{
eltlen = TYPE_LENGTH (type);
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
/* For an array of chars, print with string syntax. */
if (eltlen == 1 &&
((TYPE_CODE (type) == TYPE_CODE_INT)
|| ((current_language->la_language == language_m2)
&& (TYPE_CODE (type) == TYPE_CODE_CHAR)))
- && (format == 0 || format == 's'))
- val_print_string (address, len+1, eltlen, stream);
+ && (options->format == 0 || options->format == 's'))
+ val_print_string (address, len+1, eltlen, stream, options);
else
{
fprintf_filtered (stream, "{");
val_print_array_elements (type, valaddr + embedded_offset,
- address, stream, format,
- deref_ref, recurse, pretty, 0);
+ address, stream, recurse, options, 0);
fprintf_filtered (stream, "}");
}
}
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter or 0 for natural format). The data at VALADDR is in
- target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data are a string pointer, returns the number of string characters
- printed.
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
+ printed. */
int
m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
- CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int i = 0; /* Number of characters printed */
unsigned len;
elttype = check_typedef (TYPE_TARGET_TYPE (type));
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
/* For an array of chars, print with string syntax. */
if (eltlen == 1 &&
((TYPE_CODE (elttype) == TYPE_CODE_INT)
|| ((current_language->la_language == language_m2)
&& (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
- && (format == 0 || format == 's'))
+ && (options->format == 0 || options->format == 's'))
{
/* If requested, look for the first null char and only print
elements up to it. */
- if (stop_print_at_null)
+ if (options->stop_print_at_null)
{
unsigned int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(valaddr + embedded_offset)[temp_len]
- && temp_len < len && temp_len < print_max;
+ && temp_len < len && temp_len < options->print_max;
temp_len++);
len = temp_len;
}
- LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+ LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+ options);
i = len;
}
else
{
fprintf_filtered (stream, "{");
val_print_array_elements (type, valaddr + embedded_offset,
- address, stream, format, deref_ref,
- recurse, pretty, 0);
+ address, stream, recurse, options, 0);
fprintf_filtered (stream, "}");
}
break;
}
/* Array of unspecified length: treat like pointer to first elt. */
- print_unpacked_pointer (type, address, address, format, stream);
+ print_unpacked_pointer (type, address, address, options, stream);
break;
case TYPE_CODE_PTR:
if (TYPE_CONST (type))
print_variable_at_address (type, valaddr + embedded_offset,
- stream, format, deref_ref, recurse,
- pretty);
- else if (format && format != 's')
- print_scalar_formatted (valaddr + embedded_offset, type, format,
- 0, stream);
+ stream, recurse, options);
+ else if (options->format && options->format != 's')
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
else
{
addr = unpack_pointer (type, valaddr + embedded_offset);
- print_unpacked_pointer (type, addr, address, format, stream);
+ print_unpacked_pointer (type, addr, address, options, stream);
}
break;
case TYPE_CODE_REF:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (addressprint)
+ if (options->addressprint)
{
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
fprintf_filtered (stream, "@");
fputs_filtered (paddress (addr), stream);
- if (deref_ref)
+ if (options->deref_ref)
fputs_filtered (": ", stream);
}
/* De-reference the reference. */
- if (deref_ref)
+ if (options->deref_ref)
{
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
value_at
(TYPE_TARGET_TYPE (type),
unpack_pointer (type, valaddr + embedded_offset));
- common_val_print (deref_val, stream, format, deref_ref,
- recurse, pretty, current_language);
+ common_val_print (deref_val, stream, recurse, options,
+ current_language);
}
else
fputs_filtered ("???", stream);
break;
case TYPE_CODE_UNION:
- if (recurse && !unionprint)
+ if (recurse && !options->unionprint)
{
fprintf_filtered (stream, "{...}");
break;
case TYPE_CODE_STRUCT:
if (m2_is_long_set (type))
m2_print_long_set (type, valaddr, embedded_offset, address,
- stream, format, pretty);
+ stream);
else if (m2_is_unbounded_array (type))
m2_print_unbounded_array (type, valaddr, embedded_offset,
- address, stream, format, deref_ref,
- pretty, recurse);
+ address, stream, recurse, options);
else
cp_print_value_fields (type, type, valaddr, embedded_offset,
- address, stream, format,
- recurse, pretty, NULL, 0);
+ address, stream, recurse, options, NULL, 0);
break;
case TYPE_CODE_ENUM:
- if (format)
+ if (options->format)
{
print_scalar_formatted (valaddr + embedded_offset, type,
- format, 0, stream);
+ options, 0, stream);
break;
}
len = TYPE_NFIELDS (type);
break;
case TYPE_CODE_FUNC:
- if (format)
+ if (options->format)
{
print_scalar_formatted (valaddr + embedded_offset, type,
- format, 0, stream);
+ options, 0, stream);
break;
}
/* FIXME, we should consider, at least for ANSI C language, eliminating
break;
case TYPE_CODE_BOOL:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type,
- format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
+ }
else
{
val = unpack_long (type, valaddr + embedded_offset);
if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
{
m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
- address, stream, format, deref_ref, recurse, pretty);
+ address, stream, recurse, options);
break;
}
/* FIXME: create_range_type does not set the unsigned bit in a
/* FALLTHROUGH */
case TYPE_CODE_INT:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format,
- 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
+ }
else
val_print_type_code_int (type, valaddr + embedded_offset, stream);
break;
case TYPE_CODE_CHAR:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type,
- format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
+ }
else
{
val = unpack_long (type, valaddr + embedded_offset);
break;
case TYPE_CODE_FLT:
- if (format)
+ if (options->format)
print_scalar_formatted (valaddr + embedded_offset, type,
- format, 0, stream);
+ options, 0, stream);
else
print_floating (valaddr + embedded_offset, type, stream);
break;
#include "dictionary.h"
#include "gdb_string.h"
#include "language.h"
+#include "valprint.h"
static void list_args_or_locals (int locals, int values, struct frame_info *fi);
&& TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION)
{
+ struct value_print_options opts;
val = read_var_value (sym2, fi);
+ get_raw_print_options (&opts);
+ opts.deref_ref = 1;
common_val_print
- (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
+ (val, stb->stream, 0, &opts,
language_def (SYMBOL_LANGUAGE (sym2)));
ui_out_field_stream (uiout, "value", stb);
}
do_cleanups (cleanup_tuple);
break;
case PRINT_ALL_VALUES:
- val = read_var_value (sym2, fi);
- common_val_print
- (val, stb->stream, 0, 1, 0, Val_no_prettyprint,
- language_def (SYMBOL_LANGUAGE (sym2)));
- ui_out_field_stream (uiout, "value", stb);
- do_cleanups (cleanup_tuple);
+ {
+ struct value_print_options opts;
+ val = read_var_value (sym2, fi);
+ get_raw_print_options (&opts);
+ opts.deref_ref = 1;
+ common_val_print
+ (val, stb->stream, 0, &opts,
+ language_def (SYMBOL_LANGUAGE (sym2)));
+ ui_out_field_stream (uiout, "value", stb);
+ do_cleanups (cleanup_tuple);
+ }
break;
}
}
#include "frame.h"
#include "mi-main.h"
#include "language.h"
+#include "valprint.h"
#include <ctype.h>
#include <sys/time.h>
}
else
{
+ struct value_print_options opts;
+ get_user_print_options (&opts);
+ opts.deref_ref = 1;
val_print (register_type (current_gdbarch, regnum), buffer, 0, 0,
- stb->stream, format, 1, 0, Val_pretty_default,
- current_language);
+ stb->stream, 0, &opts, current_language);
ui_out_field_stream (uiout, "value", stb);
ui_out_stream_delete (stb);
}
struct cleanup *old_chain = NULL;
struct value *val;
struct ui_stream *stb = NULL;
+ struct value_print_options opts;
stb = ui_out_stream_new (uiout);
val = evaluate_expression (expr);
/* Print the result of the expression evaluation. */
+ get_user_print_options (&opts);
+ opts.deref_ref = 0;
val_print (value_type (val), value_contents (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stb->stream, 0, 0, 0, 0, current_language);
+ stb->stream, 0, &opts, current_language);
ui_out_field_stream (uiout, "value", stb);
ui_out_stream_delete (stb);
int col_byte;
struct cleanup *cleanup_tuple;
struct cleanup *cleanup_list_data;
+ struct value_print_options opts;
+
cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL);
ui_out_field_core_addr (uiout, "addr", addr + row_byte);
/* ui_out_field_core_addr_symbolic (uiout, "saddr", addr + row_byte); */
cleanup_list_data = make_cleanup_ui_out_list_begin_end (uiout, "data");
+ get_formatted_print_options (&opts, word_format);
for (col = 0, col_byte = row_byte;
col < nr_cols;
col++, col_byte += word_size)
else
{
ui_file_rewind (stream->stream);
- print_scalar_formatted (mbuf + col_byte, word_type, word_format,
+ print_scalar_formatted (mbuf + col_byte, word_type, &opts,
word_asize, stream->stream);
ui_out_field_stream (uiout, NULL, stream);
}
#include "target-descriptions.h"
#include "dwarf2-frame.h"
#include "user-regs.h"
+#include "valprint.h"
static const struct objfile_data *mips_pdr_data;
if (register_size (gdbarch, regnum) == 4 || mips2_fp_compat (frame))
{
+ struct value_print_options opts;
+
/* 4-byte registers: Print hex and floating. Also print even
numbered registers as doubles. */
mips_read_fp_register_single (frame, regnum, raw_buffer);
flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
- print_scalar_formatted (raw_buffer, builtin_type_uint32, 'x', 'w',
+ get_formatted_print_options (&opts, 'x');
+ print_scalar_formatted (raw_buffer, builtin_type_uint32, &opts, 'w',
file);
fprintf_filtered (file, " flt: ");
}
else
{
+ struct value_print_options opts;
+
/* Eight byte registers: print each one as hex, float and double. */
mips_read_fp_register_single (frame, regnum, raw_buffer);
flt1 = unpack_double (mips_float_register_type (), raw_buffer, &inv1);
mips_read_fp_register_double (frame, regnum, raw_buffer);
doub = unpack_double (mips_double_register_type (), raw_buffer, &inv2);
-
- print_scalar_formatted (raw_buffer, builtin_type_uint64, 'x', 'g',
+ get_formatted_print_options (&opts, 'x');
+ print_scalar_formatted (raw_buffer, builtin_type_uint64, &opts, 'g',
file);
fprintf_filtered (file, " flt: ");
struct gdbarch *gdbarch = get_frame_arch (frame);
gdb_byte raw_buffer[MAX_REGISTER_SIZE];
int offset;
+ struct value_print_options opts;
if (TYPE_CODE (register_type (gdbarch, regnum)) == TYPE_CODE_FLT)
{
else
offset = 0;
+ get_formatted_print_options (&opts, 'x');
print_scalar_formatted (raw_buffer + offset,
- register_type (gdbarch, regnum), 'x', 0,
+ register_type (gdbarch, regnum), &opts, 0,
file);
}
#include "infcall.h"
#include "gdb_assert.h"
#include "language.h"
+#include "valprint.h"
enum mt_arch_constants
{
{
/* Special output handling for the 'coprocessor' register. */
gdb_byte *buf;
+ struct value_print_options opts;
buf = alloca (register_size (gdbarch, MT_COPRO_REGNUM));
frame_register_read (frame, MT_COPRO_REGNUM, buf);
print_spaces_filtered (15 - strlen (gdbarch_register_name
(gdbarch, regnum)),
file);
+ get_raw_print_options (&opts);
+ opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum), buf,
- 0, 0, file, 0, 1, 0, Val_no_prettyprint,
+ 0, 0, file, 0, &opts,
current_language);
fputs_filtered ("\n", file);
}
static void
objc_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining to see whether it
is repeated. */
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\", ", stream);
else
fputs_filtered ("\", ", stream);
objc_printchar (string[i], stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
{
if (!in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\\"", stream);
else
fputs_filtered ("\"", stream);
void
pascal_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
unsigned int i;
unsigned int things_printed = 0;
return;
}
- for (i = 0; i < length && things_printed < print_max; ++i)
+ for (i = 0; i < length && things_printed < options->print_max; ++i)
{
/* Position of the character we are examining
to see whether it is repeated. */
++reps;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\', ", stream);
else
fputs_filtered ("', ", stream);
pascal_printchar (string[i], stream);
fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
need_comma = 1;
}
else
int c = string[i];
if ((!in_quotes) && (PRINT_LITERAL_FORM (c)))
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\'", stream);
else
fputs_filtered ("'", stream);
/* Terminate the quotes if necessary. */
if (in_quotes)
{
- if (inspect_it)
+ if (options->inspect_it)
fputs_filtered ("\\'", stream);
else
fputs_filtered ("'", stream);
struct ui_file *);
extern int pascal_val_print (struct type *, const gdb_byte *, int,
- CORE_ADDR, struct ui_file *, int, int,
- int, enum val_prettyprint);
+ CORE_ADDR, struct ui_file *, int,
+ const struct value_print_options *);
-extern int pascal_value_print (struct value *, struct ui_file *, int, enum val_prettyprint);
+extern int pascal_value_print (struct value *, struct ui_file *,
+ const struct value_print_options *);
extern void pascal_type_print_method_args (char *, char *,
struct ui_file *);
extern void pascal_printchar (int, struct ui_file *);
extern void pascal_printstr (struct ui_file *, const gdb_byte *,
- unsigned int, int, int);
+ unsigned int, int, int,
+ const struct value_print_options *);
extern struct type **const (pascal_builtin_types[]);
extern void
pascal_type_print_varspec_prefix (struct type *, struct ui_file *, int, int);
-/* These are in cp-valprint.c */
-
-extern int vtblprint; /* Controls printing of vtbl's */
-
-extern int static_field_print;
-
extern void pascal_object_print_value_fields (struct type *, const gdb_byte *,
CORE_ADDR, struct ui_file *,
- int, int, enum val_prettyprint,
+ int,
+ const struct value_print_options *,
struct type **, int);
extern int pascal_object_is_vtbl_ptr_type (struct type *);
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
- FORMAT (a letter or 0 for natural format). The data at VALADDR is in
- target byte order.
+ OPTIONS. The data at VALADDR is in target byte order.
If the data are a string pointer, returns the number of string characters
- printed.
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting. */
+ printed. */
int
pascal_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format, int deref_ref,
- int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
unsigned int i = 0; /* Number of characters printed */
unsigned len;
elttype = check_typedef (TYPE_TARGET_TYPE (type));
eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen;
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
{
print_spaces_filtered (2 + 2 * recurse, stream);
}
&& ((TYPE_CODE (elttype) == TYPE_CODE_INT)
|| ((current_language->la_language == language_pascal)
&& (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
- && (format == 0 || format == 's'))
+ && (options->format == 0 || options->format == 's'))
{
/* If requested, look for the first null char and only print
elements up to it. */
- if (stop_print_at_null)
+ if (options->stop_print_at_null)
{
unsigned int temp_len;
/* Look for a NULL char. */
for (temp_len = 0;
(valaddr + embedded_offset)[temp_len]
- && temp_len < len && temp_len < print_max;
+ && temp_len < len && temp_len < options->print_max;
temp_len++);
len = temp_len;
}
- LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0);
+ LA_PRINT_STRING (stream, valaddr + embedded_offset, len, 1, 0,
+ options);
i = len;
}
else
i = 0;
}
val_print_array_elements (type, valaddr + embedded_offset, address, stream,
- format, deref_ref, recurse, pretty, i);
+ recurse, options, i);
fprintf_filtered (stream, "}");
}
break;
goto print_unpacked_pointer;
case TYPE_CODE_PTR:
- if (format && format != 's')
+ if (options->format && options->format != 's')
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
- if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+ if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if we ARE using
return (0);
}
- if (addressprint && format != 's')
+ if (options->addressprint && options->format != 's')
{
fputs_filtered (paddress (addr), stream);
}
if (TYPE_LENGTH (elttype) == 1
&& (TYPE_CODE (elttype) == TYPE_CODE_INT
|| TYPE_CODE(elttype) == TYPE_CODE_CHAR)
- && (format == 0 || format == 's')
+ && (options->format == 0 || options->format == 's')
&& addr != 0)
{
/* no wide string yet */
- i = val_print_string (addr, -1, 1, stream);
+ i = val_print_string (addr, -1, 1, stream, options);
}
/* also for pointers to pascal strings */
/* Note: this is Free Pascal specific:
read_memory (addr + length_pos, buffer, length_size);
string_length = extract_unsigned_integer (buffer, length_size);
xfree (buffer);
- i = val_print_string (addr + string_pos, string_length, char_size, stream);
+ i = val_print_string (addr + string_pos, string_length, char_size, stream, options);
}
else if (pascal_object_is_vtbl_member (type))
{
fputs_filtered (SYMBOL_PRINT_NAME (msymbol), stream);
fputs_filtered (">", stream);
}
- if (vt_address && vtblprint)
+ if (vt_address && options->vtblprint)
{
struct value *vt_val;
struct symbol *wsym = (struct symbol *) NULL;
wtype = TYPE_TARGET_TYPE (type);
}
vt_val = value_at (wtype, vt_address);
- common_val_print (vt_val, stream, format, deref_ref,
- recurse + 1, pretty, current_language);
- if (pretty)
+ common_val_print (vt_val, stream, recurse + 1, options,
+ current_language);
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
case TYPE_CODE_REF:
elttype = check_typedef (TYPE_TARGET_TYPE (type));
- if (addressprint)
+ if (options->addressprint)
{
fprintf_filtered (stream, "@");
/* Extract the address, assume that it is unsigned. */
fputs_filtered (paddress (
extract_unsigned_integer (valaddr + embedded_offset,
gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT)), stream);
- if (deref_ref)
+ if (options->deref_ref)
fputs_filtered (": ", stream);
}
/* De-reference the reference. */
- if (deref_ref)
+ if (options->deref_ref)
{
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{
value_at
(TYPE_TARGET_TYPE (type),
unpack_pointer (type, valaddr + embedded_offset));
- common_val_print (deref_val, stream, format, deref_ref,
- recurse + 1, pretty, current_language);
+ common_val_print (deref_val, stream, recurse + 1, options,
+ current_language);
}
else
fputs_filtered ("???", stream);
break;
case TYPE_CODE_UNION:
- if (recurse && !unionprint)
+ if (recurse && !options->unionprint)
{
fprintf_filtered (stream, "{...}");
break;
}
/* Fall through. */
case TYPE_CODE_STRUCT:
- if (vtblprint && pascal_object_is_vtbl_ptr_type (type))
+ if (options->vtblprint && pascal_object_is_vtbl_ptr_type (type))
{
/* Print the unmangled name if desired. */
/* Print vtable entry - we only get here if NOT using
&string_pos, &char_size, NULL))
{
len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
- LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0);
+ LA_PRINT_STRING (stream, valaddr + embedded_offset + string_pos, len, char_size, 0, options);
}
else
- pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream, format,
- recurse, pretty, NULL, 0);
+ pascal_object_print_value_fields (type, valaddr + embedded_offset, address, stream,
+ recurse, options, NULL, 0);
}
break;
case TYPE_CODE_ENUM:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
len = TYPE_NFIELDS (type);
break;
case TYPE_CODE_FLAGS:
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ if (options->format)
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
else
val_print_type_code_flags (type, valaddr + embedded_offset, stream);
break;
case TYPE_CODE_FUNC:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
break;
}
/* FIXME, we should consider, at least for ANSI C language, eliminating
break;
case TYPE_CODE_BOOL:
- format = format ? format : output_format;
- if (format)
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ if (options->format || options->output_format)
+ {
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
+ }
else
{
val = unpack_long (type, valaddr + embedded_offset);
/* FALLTHROUGH */
case TYPE_CODE_INT:
- format = format ? format : output_format;
- if (format)
+ if (options->format || options->output_format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
}
else
{
break;
case TYPE_CODE_CHAR:
- format = format ? format : output_format;
- if (format)
+ if (options->format || options->output_format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ struct value_print_options opts = *options;
+ opts.format = (options->format ? options->format
+ : options->output_format);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ &opts, 0, stream);
}
else
{
break;
case TYPE_CODE_FLT:
- if (format)
+ if (options->format)
{
- print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+ print_scalar_formatted (valaddr + embedded_offset, type,
+ options, 0, stream);
}
else
{
}
\f
int
-pascal_value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+pascal_value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
struct type *type = value_type (val);
fprintf_filtered (stream, ") ");
}
}
- return common_val_print (val, stream, format, 1, 0, pretty,
- current_language);
+ return common_val_print (val, stream, 0, options, current_language);
}
-/******************************************************************************
- Inserted from cp-valprint
-******************************************************************************/
-
-extern int vtblprint; /* Controls printing of vtbl's */
-extern int objectprint; /* Controls looking up an object's derived type
- using what we find in its vtables. */
-static int pascal_static_field_print; /* Controls printing of static fields. */
static void
show_pascal_static_field_print (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
static struct obstack dont_print_statmem_obstack;
static void pascal_object_print_static_field (struct value *,
- struct ui_file *, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
static void pascal_object_print_value (struct type *, const gdb_byte *,
- CORE_ADDR, struct ui_file *,
- int, int, enum val_prettyprint,
+ CORE_ADDR, struct ui_file *, int,
+ const struct value_print_options *,
struct type **);
/* It was changed to this after 2.4.5. */
c_val_print to print out a structure's fields:
pascal_object_print_value_fields and pascal_object_print_value.
- TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and PRETTY have the
+ TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
same meanings as in pascal_object_print_value and c_val_print.
DONT_PRINT is an array of baseclass types that we
void
pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
- int format, int recurse,
- enum val_prettyprint pretty,
+ int recurse,
+ const struct value_print_options *options,
struct type **dont_print_vb,
int dont_print_statmem)
{
duplicates of virtual baseclasses. */
if (n_baseclasses > 0)
pascal_object_print_value (type, valaddr, address, stream,
- format, recurse + 1, pretty, dont_print_vb);
+ recurse + 1, options, dont_print_vb);
if (!len && n_baseclasses == 1)
fprintf_filtered (stream, "<No data fields>");
for (i = n_baseclasses; i < len; i++)
{
/* If requested, skip printing of static fields. */
- if (!pascal_static_field_print
+ if (!options->pascal_static_field_print
&& field_is_static (&TYPE_FIELD (type, i)))
continue;
if (fields_seen)
fprintf_filtered (stream, ", ");
else if (n_baseclasses > 0)
{
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
fields_seen = 1;
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream);
{
wrap_here (n_spaces (2 + 2 * recurse));
}
- if (inspect_it)
+ if (options->inspect_it)
{
if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR)
fputs_filtered ("\"( ptr \"", stream);
}
else
{
+ struct value_print_options opts = *options;
v = value_from_longest (TYPE_FIELD_TYPE (type, i),
unpack_field_as_long (type, valaddr, i));
- common_val_print (v, stream, format, 0, recurse + 1,
- pretty, current_language);
+ opts.deref_ref = 0;
+ common_val_print (v, stream, recurse + 1, &opts,
+ current_language);
}
}
else
if (v == NULL)
fputs_filtered ("<optimized out>", stream);
else
- pascal_object_print_static_field (v, stream, format,
- recurse + 1, pretty);
+ pascal_object_print_static_field (v, stream, recurse + 1,
+ options);
}
else
{
+ struct value_print_options opts = *options;
+ opts.deref_ref = 0;
/* val_print (TYPE_FIELD_TYPE (type, i),
valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
address + TYPE_FIELD_BITPOS (type, i) / 8, 0,
val_print (TYPE_FIELD_TYPE (type, i),
valaddr, TYPE_FIELD_BITPOS (type, i) / 8,
address + TYPE_FIELD_BITPOS (type, i) / 8,
- stream, format, 0, recurse + 1, pretty,
+ stream, recurse + 1, &opts,
current_language);
}
}
dont_print_statmem_obstack = tmp_obstack;
}
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
static void
pascal_object_print_value (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
- int format, int recurse,
- enum val_prettyprint pretty,
+ int recurse,
+ const struct value_print_options *options,
struct type **dont_print_vb)
{
struct type **last_dont_print
boffset = baseclass_offset (type, i, valaddr, address);
- if (pretty)
+ if (options->pretty)
{
fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream);
fprintf_filtered (stream, "<invalid address>");
else
pascal_object_print_value_fields (baseclass, base_valaddr, address + boffset,
- stream, format, recurse, pretty,
+ stream, recurse, options,
(struct type **) obstack_base (&dont_print_vb_obstack),
0);
fputs_filtered (", ", stream);
static member classes in an obstack and refuse to print them more
than once.
- VAL contains the value to print, STREAM, RECURSE, and PRETTY
+ VAL contains the value to print, STREAM, RECURSE, and OPTIONS
have the same meanings as in c_val_print. */
static void
pascal_object_print_static_field (struct value *val,
- struct ui_file *stream, int format,
- int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream,
+ int recurse,
+ const struct value_print_options *options)
{
struct type *type = value_type (val);
+ struct value_print_options opts;
if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
{
CHECK_TYPEDEF (type);
pascal_object_print_value_fields (type, value_contents (val), VALUE_ADDRESS (val),
- stream, format, recurse, pretty, NULL, 1);
+ stream, recurse, options, NULL, 1);
return;
}
- common_val_print (val, stream, format, 0, recurse, pretty,
- current_language);
+
+ opts = *options;
+ opts.deref_ref = 0;
+ common_val_print (val, stream, recurse, &opts, current_language);
}
extern initialize_file_ftype _initialize_pascal_valprint; /* -Wmissing-prototypes */
_initialize_pascal_valprint (void)
{
add_setshow_boolean_cmd ("pascal_static-members", class_support,
- &pascal_static_field_print, _("\
+ &user_print_options.pascal_static_field_print, _("\
Set printing of pascal static members."), _("\
Show printing of pascal static members."), NULL,
NULL,
show_pascal_static_field_print,
&setprintlist, &showprintlist);
- /* Turn on printing of static fields. */
- pascal_static_field_print = 1;
-
}
#include "block.h"
#include "disasm.h"
#include "dfp.h"
+#include "valprint.h"
#ifdef TUI
#include "tui/tui.h" /* For tui_active et.al. */
#endif
extern int asm_demangle; /* Whether to demangle syms in asm printouts */
-extern int addressprint; /* Whether to print hex addresses in HLL " */
struct format_data
{
int current_display_number;
-/* Flag to low-level print routines that this value is being printed
- in an epoch window. We'd like to pass this as a parameter, but
- every routine would need to take it. Perhaps we can encapsulate
- this in the I/O stream once we have GNU stdio. */
-
-int inspect_it = 0;
-
struct display
{
/* Chain link to next auto-display item. */
return val;
}
\f
-/* Print value VAL on stream according to FORMAT, a letter or 0.
+/* Print value VAL on stream according to OPTIONS.
Do not end with a newline.
- 0 means print VAL according to its own type.
SIZE is the letter for the size of datum being printed.
This is used to pad hex numbers so they line up. SIZE is 0
for print / output and set for examine. */
static void
-print_formatted (struct value *val, int format, int size,
+print_formatted (struct value *val, int size,
+ const struct value_print_options *options,
struct ui_file *stream)
{
struct type *type = check_typedef (value_type (val));
if (size)
{
- switch (format)
+ switch (options->format)
{
case 's':
/* FIXME: Need to handle wchar_t's here... */
next_address = VALUE_ADDRESS (val)
- + val_print_string (VALUE_ADDRESS (val), -1, 1, stream);
+ + val_print_string (VALUE_ADDRESS (val), -1, 1, stream,
+ options);
return;
case 'i':
}
}
- if (format == 0 || format == 's'
+ if (options->format == 0 || options->format == 's'
|| TYPE_CODE (type) == TYPE_CODE_REF
|| TYPE_CODE (type) == TYPE_CODE_ARRAY
|| TYPE_CODE (type) == TYPE_CODE_STRING
|| TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION
|| TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
- /* If format is 0, use the 'natural' format for that type of
- value. If the type is non-scalar, we have to use language
- rules to print it as a series of scalars. */
- value_print (val, stream, format, Val_pretty_default);
+ value_print (val, stream, options);
else
/* User specified format, so don't look to the the type to
tell us what to do. */
print_scalar_formatted (value_contents (val), type,
- format, size, stream);
+ options, size, stream);
}
/* Return builtin floating point type of same length as TYPE.
}
/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
- according to letters FORMAT and SIZE on STREAM.
- FORMAT may not be zero. Formats s and i are not supported at this level.
+ according to OPTIONS and SIZE on STREAM.
+ Formats s and i are not supported at this level.
This is how the elements of an array or structure are printed
with a format. */
void
print_scalar_formatted (const void *valaddr, struct type *type,
- int format, int size, struct ui_file *stream)
+ const struct value_print_options *options,
+ int size, struct ui_file *stream)
{
LONGEST val_long = 0;
unsigned int len = TYPE_LENGTH (type);
/* If we get here with a string format, try again without it. Go
all the way back to the language printers, which may call us
again. */
- if (format == 's')
+ if (options->format == 's')
{
- val_print (type, valaddr, 0, 0, stream, 0, 0, 0, Val_pretty_default,
+ struct value_print_options opts = *options;
+ opts.format = 0;
+ opts.deref_ref = 0;
+ val_print (type, valaddr, 0, 0, stream, 0, &opts,
current_language);
return;
}
(TYPE_CODE (type) == TYPE_CODE_INT
|| TYPE_CODE (type) == TYPE_CODE_ENUM))
{
- switch (format)
+ switch (options->format)
{
case 'o':
print_octal_chars (stream, valaddr, len, byte_order);
};
}
- if (format != 'f')
+ if (options->format != 'f')
val_long = unpack_long (type, valaddr);
/* If the value is a pointer, and pointers and addresses are not the
/* If we are printing it as unsigned, truncate it in case it is actually
a negative signed value (e.g. "print/u (short)-1" should print 65535
(if shorts are 16 bits) instead of 4294967295). */
- if (format != 'd')
+ if (options->format != 'd')
{
if (len < sizeof (LONGEST))
val_long &= ((LONGEST) 1 << HOST_CHAR_BIT * len) - 1;
}
- switch (format)
+ switch (options->format)
{
case 'x':
if (!size)
break;
case 'c':
- if (TYPE_UNSIGNED (type))
- value_print (value_from_longest (builtin_type_true_unsigned_char,
- val_long),
- stream, 0, Val_pretty_default);
- else
- value_print (value_from_longest (builtin_type_true_char, val_long),
- stream, 0, Val_pretty_default);
+ {
+ struct value_print_options opts = *options;
+ opts.format = 0;
+ if (TYPE_UNSIGNED (type))
+ value_print (value_from_longest (builtin_type_true_unsigned_char,
+ val_long),
+ stream, &opts);
+ else
+ value_print (value_from_longest (builtin_type_true_char, val_long),
+ stream, &opts);
+ }
break;
case 'f':
break;
default:
- error (_("Undefined output format \"%c\"."), format);
+ error (_("Undefined output format \"%c\"."), options->format);
}
}
print_address_demangle (CORE_ADDR addr, struct ui_file *stream,
int do_demangle)
{
+ struct value_print_options opts;
+ get_user_print_options (&opts);
if (addr == 0)
{
fprintf_filtered (stream, "0");
}
- else if (addressprint)
+ else if (opts.addressprint)
{
fputs_filtered (paddress (addr), stream);
print_address_symbolic (addr, stream, do_demangle, " ");
struct type *val_type = NULL;
int i;
int maxelts;
+ struct value_print_options opts;
format = fmt.format;
size = fmt.size;
if (format == 's' || format == 'i')
maxelts = 1;
+ get_formatted_print_options (&opts, format);
+
/* Print as many objects as specified in COUNT, at most maxelts per line,
with the address of the next one at the start of each line. */
if (last_examine_value)
release_value (last_examine_value);
- print_formatted (last_examine_value, format, size, gdb_stdout);
+ print_formatted (last_examine_value, size, &opts, gdb_stdout);
/* Display any branch delay slots following the final insn. */
if (format == 'i' && count == 1)
struct format_data fmt;
int cleanup = 0;
- /* Pass inspect flag to the rest of the print routines in a global
- (sigh). */
- inspect_it = inspect;
-
if (exp && *exp == '/')
{
exp++;
if (voidprint || (val && value_type (val) &&
TYPE_CODE (value_type (val)) != TYPE_CODE_VOID))
{
+ struct value_print_options opts;
int histindex = record_latest_value (val);
if (histindex >= 0)
if (histindex >= 0)
annotate_value_history_value ();
- print_formatted (val, format, fmt.size, gdb_stdout);
+ get_formatted_print_options (&opts, format);
+ opts.inspect_it = inspect;
+
+ print_formatted (val, fmt.size, &opts, gdb_stdout);
printf_filtered ("\n");
if (histindex >= 0)
if (cleanup)
do_cleanups (old_chain);
- inspect_it = 0; /* Reset print routines to normal. */
}
static void
char format = 0;
struct value *val;
struct format_data fmt;
+ struct value_print_options opts;
fmt.size = 0;
annotate_value_begin (value_type (val));
- print_formatted (val, format, fmt.size, gdb_stdout);
+ get_formatted_print_options (&opts, format);
+ print_formatted (val, fmt.size, &opts, gdb_stdout);
annotate_value_end ();
}
else
{
+ struct value_print_options opts;
+
annotate_display_format ();
if (d->format.format)
annotate_display_expression ();
+ get_formatted_print_options (&opts, d->format.format);
print_formatted (evaluate_expression (d->exp),
- d->format.format, d->format.size, gdb_stdout);
+ d->format.size, &opts, gdb_stdout);
printf_filtered ("\n");
}
struct ui_file *stream)
{
struct value *val = read_var_value (var, frame);
+ struct value_print_options opts;
- value_print (val, stream, 0, Val_pretty_default);
+ get_user_print_options (&opts);
+ value_print (val, stream, &opts);
}
static void
#include "exceptions.h"
#include "language.h"
#include "dfp.h"
+#include "valprint.h"
/* List of all values which are currently exposed to Python. It is
maintained so that when an objfile is discarded, preserve_values
struct ui_file *stb;
struct cleanup *old_chain;
PyObject *result;
+ struct value_print_options opts;
volatile struct gdb_exception except;
+ get_user_print_options (&opts);
+ opts.deref_ref = 0;
+
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
TRY_CATCH (except, RETURN_MASK_ALL)
{
- common_val_print (((value_object *) self)->value, stb, 0, 0, 0,
- Val_pretty_default, current_language);
+ common_val_print (((value_object *) self)->value, stb, 0,
+ &opts, current_language);
s = ui_file_xstrdup (stb, &dummy);
}
GDB_PY_HANDLE_EXCEPTION (except);
static void
scm_printstr (struct ui_file *stream, const gdb_byte *string,
- unsigned int length, int width, int force_ellipses)
+ unsigned int length, int width, int force_ellipses,
+ const struct value_print_options *options)
{
fprintf_filtered (stream, "\"%s\"", string);
}
struct value;
extern int scm_value_print (struct value *, struct ui_file *,
- int, enum val_prettyprint);
+ const struct value_print_options *);
extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
- struct ui_file *, int, int, int,
- enum val_prettyprint);
+ struct ui_file *, int,
+ const struct value_print_options *);
extern LONGEST scm_get_field (LONGEST, int);
-extern void scm_scmval_print (LONGEST, struct ui_file *, int, int, int,
- enum val_prettyprint);
+extern void scm_scmval_print (LONGEST, struct ui_file *, int,
+ const struct value_print_options *);
extern int is_scmvalue_type (struct type *);
#include "objfiles.h"
static void scm_ipruk (char *, LONGEST, struct ui_file *);
-static void scm_scmlist_print (LONGEST, struct ui_file *, int, int,
- int, enum val_prettyprint);
-static int scm_inferior_print (LONGEST, struct ui_file *, int, int,
- int, enum val_prettyprint);
+static void scm_scmlist_print (LONGEST, struct ui_file *, int,
+ const struct value_print_options *);
+static int scm_inferior_print (LONGEST, struct ui_file *, int,
+ const struct value_print_options *);
/* Prints the SCM value VALUE by invoking the inferior, if appropraite.
Returns >= 0 on success; return -1 if the inferior cannot/should not
print VALUE. */
static int
-scm_inferior_print (LONGEST value, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_inferior_print (LONGEST value, struct ui_file *stream,
+ int recurse, const struct value_print_options *options)
{
struct objfile *objf;
struct gdbarch *gdbarch;
};
static void
-scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmlist_print (LONGEST svalue, struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
- unsigned int more = print_max;
+ unsigned int more = options->print_max;
if (recurse > 6)
{
fputs_filtered ("...", stream);
return;
}
- scm_scmval_print (SCM_CAR (svalue), stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
svalue = SCM_CDR (svalue);
for (; SCM_NIMP (svalue); svalue = SCM_CDR (svalue))
{
fputs_filtered ("...", stream);
return;
}
- scm_scmval_print (SCM_CAR (svalue), stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmval_print (SCM_CAR (svalue), stream, recurse + 1, options);
}
if (SCM_NNULLP (svalue))
{
fputs_filtered (" . ", stream);
- scm_scmval_print (svalue, stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmval_print (svalue, stream, recurse + 1, options);
}
}
}
void
-scm_scmval_print (LONGEST svalue, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty)
+scm_scmval_print (LONGEST svalue, struct ui_file *stream,
+ int recurse, const struct value_print_options *options)
{
taloop:
switch (7 & (int) svalue)
{
case 2:
case 6:
- print_longest (stream, format ? format : 'd', 1, svalue >> 2);
+ print_longest (stream,
+ options->format ? options->format : 'd',
+ 1, svalue >> 2);
break;
case 4:
if (SCM_ICHRP (svalue))
case scm_tcs_cons_imcar:
case scm_tcs_cons_nimcar:
fputs_filtered ("(", stream);
- scm_scmlist_print (svalue, stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmlist_print (svalue, stream, recurse + 1, options);
fputs_filtered (")", stream);
break;
case scm_tcs_closures:
fputs_filtered ("#<CLOSURE ", stream);
- scm_scmlist_print (SCM_CODE (svalue), stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmlist_print (SCM_CODE (svalue), stream, recurse + 1, options);
fputs_filtered (">", stream);
break;
case scm_tc7_string:
int done = 0;
int buf_size;
gdb_byte buffer[64];
- int truncate = print_max && len > (int) print_max;
+ int truncate = options->print_max && len > (int) options->print_max;
if (truncate)
- len = print_max;
+ len = options->print_max;
fputs_filtered ("\"", stream);
for (; done < len; done += buf_size)
{
{
if (i > 0)
fputs_filtered (" ", stream);
- scm_scmval_print (scm_get_field (elements, i), stream, format,
- deref_ref, recurse + 1, pretty);
+ scm_scmval_print (scm_get_field (elements, i), stream,
+ recurse + 1, options);
}
fputs_filtered (")", stream);
}
int
scm_val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format, int deref_ref,
- int recurse, enum val_prettyprint pretty)
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options)
{
if (is_scmvalue_type (type))
{
LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
- if (scm_inferior_print (svalue, stream, format,
- deref_ref, recurse, pretty) >= 0)
+ if (scm_inferior_print (svalue, stream, recurse, options) >= 0)
{
}
else
{
- scm_scmval_print (svalue, stream, format,
- deref_ref, recurse, pretty);
+ scm_scmval_print (svalue, stream, recurse, options);
}
gdb_flush (stream);
}
else
{
- return c_val_print (type, valaddr, 0, address, stream, format,
- deref_ref, recurse, pretty);
+ return c_val_print (type, valaddr, 0, address, stream, recurse, options);
}
}
int
-scm_value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+scm_value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
- return (common_val_print (val, stream, format, 1, 0, pretty,
- current_language));
+ struct value_print_options opts = *options;
+ opts.deref_ref = 1;
+ return (common_val_print (val, stream, 0, &opts, current_language));
}
#include "arch-utils.h"
#include "regcache.h"
#include "osabi.h"
+#include "valprint.h"
#include "elf-bfd.h"
struct frame_info *frame, int regnum)
{
unsigned char raw_buffer[MAX_REGISTER_SIZE];
+ struct value_print_options opts;
fputs_filtered (gdbarch_register_name (gdbarch, regnum), file);
print_spaces_filtered (15 - strlen (gdbarch_register_name
/* Get the data in raw format. */
if (!frame_register_read (frame, regnum, raw_buffer))
fprintf_filtered (file, "*value not available*\n");
-
+
+ get_formatted_print_options (&opts, 'x');
+ opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
- file, 'x', 1, 0, Val_pretty_default, current_language);
+ file, 0, &opts, current_language);
fprintf_filtered (file, "\t");
+ get_formatted_print_options (&opts, 0);
+ opts.deref_ref = 1;
val_print (register_type (gdbarch, regnum), raw_buffer, 0, 0,
- file, 0, 1, 0, Val_pretty_default, current_language);
+ file, 0, &opts, current_language);
fprintf_filtered (file, "\n");
}
if (val)
{
const struct language_defn *language;
+ struct value_print_options opts;
/* Use the appropriate language to display our symbol,
unless the user forced the language to a specific
else
language = current_language;
- common_val_print (val, stb->stream, 0, 0, 2,
- Val_no_prettyprint, language);
+ get_raw_print_options (&opts);
+ opts.deref_ref = 0;
+ common_val_print (val, stb->stream, 2,
+ &opts, language);
ui_out_field_stream (uiout, "value", stb);
}
else
sal.line + 1, 0);
else
{
+ struct value_print_options opts;
+ get_user_print_options (&opts);
/* We used to do this earlier, but that is clearly
wrong. This function is used by many different
parts of gdb, including normal_stop in infrun.c,
line. Only the command line really wants this
behavior. Other UIs probably would like the
ability to decide for themselves if it is desired. */
- if (addressprint && mid_statement)
+ if (opts.addressprint && mid_statement)
{
ui_out_field_core_addr (uiout, "addr", get_frame_pc (frame));
ui_out_text (uiout, "\t");
enum language funlang = language_unknown;
struct ui_stream *stb;
struct cleanup *old_chain, *list_chain;
+ struct value_print_options opts;
stb = ui_out_stream_new (uiout);
old_chain = make_cleanup_ui_out_stream_delete (stb);
ui_out_field_fmt_int (uiout, 2, ui_left, "level",
frame_relative_level (frame));
}
- if (addressprint)
+ get_user_print_options (&opts);
+ if (opts.addressprint)
if (get_frame_pc (frame) != sal.pc || !sal.symtab
|| print_what == LOC_AND_ADDRESS)
{
if (SYMBOL_CLASS (sym) == LOC_LABEL)
{
struct symtab_and_line sal;
+ struct value_print_options opts;
sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0);
values_printed = 1;
fputs_filtered (SYMBOL_PRINT_NAME (sym), stream);
- if (addressprint)
+ get_user_print_options (&opts);
+ if (opts.addressprint)
{
fprintf_filtered (stream, " ");
fputs_filtered (paddress (SYMBOL_VALUE_ADDRESS (sym)), stream);
+2008-10-28 Tom Tromey <tromey@redhat.com>
+
+ * gdb.base/exprs.exp (test_expr): Add enum formatting tests.
+
2008-10-24 Pedro Alves <pedro@codesourcery.com>
* gdb.python/python-value.exp (test_value_in_inferior): Don't use
# String concatentation.
test_expr "print \"x\" \"y\"" "\\$\[0-9\]* = \"xy\""
test_expr "print \"x\" \"y\" \"z\"" "\\$\[0-9\]* = \"xyz\""
+
+# Enum formatting tests.
+test_expr "print red" "\\$\[0-9\]* = red"
+gdb_test "set output-radix 8" ""
+test_expr "print red" "\\$\[0-9\]* = red"
+test_expr "print/d red" "\\$\[0-9\]* = 0"
+gdb_test "set output-radix 10" ""
#include "dictionary.h"
#include "observer.h"
#include "user-regs.h"
+#include "valprint.h"
#include "ax.h"
#include "ax-gdb.h"
extern void (*deprecated_readline_begin_hook) (char *, ...);
extern char *(*deprecated_readline_hook) (char *);
extern void (*deprecated_readline_end_hook) (void);
-extern int addressprint; /* Print machine addresses? */
/* GDB commands implemented in other modules:
*/
static void
trace_mention (struct tracepoint *tp)
{
+ struct value_print_options opts;
printf_filtered ("Tracepoint %d", tp->number);
- if (addressprint || (tp->source_file == NULL))
+ get_user_print_options (&opts);
+ if (opts.addressprint || (tp->source_file == NULL))
{
printf_filtered (" at ");
printf_filtered ("%s", paddress (tp->address));
ALL_TRACEPOINTS (t)
if (tpnum == -1 || tpnum == t->number)
{
- extern int addressprint; /* Print machine addresses? */
-
+ struct value_print_options opts;
+ get_user_print_options (&opts);
if (!found_a_tracepoint++)
{
printf_filtered ("Num Enb ");
- if (addressprint)
+ if (opts.addressprint)
{
if (gdbarch_addr_bit (current_gdbarch) <= 32)
printf_filtered ("Address ");
printf_filtered ("PassC StepC What\n");
}
strcpy (wrap_indent, " ");
- if (addressprint)
+ if (opts.addressprint)
{
if (gdbarch_addr_bit (current_gdbarch) <= 32)
strcat (wrap_indent, " ");
printf_filtered ("%-3d %-3s ", t->number,
t->enabled_p ? "y" : "n");
- if (addressprint)
+ if (opts.addressprint)
{
char *tmp;
#include "tui/tui-wingeneral.h"
#include "tui/tui-file.h"
#include "reggroups.h"
+#include "valprint.h"
#include "gdb_curses.h"
{
gdb_byte buf[MAX_REGISTER_SIZE];
int len;
+ struct value_print_options opts;
len = register_size (current_gdbarch, regnum);
fprintf_filtered (stream, "%-14s ", name);
get_frame_register (frame, regnum, buf);
- print_scalar_formatted (buf, type, 'f', len, stream);
+ get_formatted_print_options (&opts, 'f');
+ print_scalar_formatted (buf, type, &opts, len, stream);
}
else
{
#include "cp-abi.h"
#include "typeprint.h"
#include "gdb_string.h"
+#include "valprint.h"
#include <errno.h>
-/* For real-type printing in whatis_exp() */
-extern int objectprint; /* Controls looking up an object's derived type
- using what we find in its vtables. */
-
extern void _initialize_typeprint (void);
static void ptype_command (char *, int);
int full = 0;
int top = -1;
int using_enc = 0;
+ struct value_print_options opts;
if (exp)
{
type = value_type (val);
- if (objectprint)
+ get_user_print_options (&opts);
+ if (opts.objectprint)
{
if (((TYPE_CODE (type) == TYPE_CODE_PTR)
|| (TYPE_CODE (type) == TYPE_CODE_REF))
void _initialize_valprint (void);
-/* Maximum number of chars to print for a string pointer value or vector
- contents, or UINT_MAX for no limit. Note that "set print elements 0"
- stores UINT_MAX in print_max, which displays in a show command as
- "unlimited". */
-
-unsigned int print_max;
#define PRINT_MAX_DEFAULT 200 /* Start print_max off at this value. */
+
+struct value_print_options user_print_options =
+{
+ Val_pretty_default, /* pretty */
+ 0, /* prettyprint_arrays */
+ 0, /* prettyprint_structs */
+ 0, /* vtblprint */
+ 1, /* unionprint */
+ 1, /* addressprint */
+ 0, /* objectprint */
+ PRINT_MAX_DEFAULT, /* print_max */
+ 10, /* repeat_count_threshold */
+ 0, /* output_format */
+ 0, /* format */
+ 0, /* stop_print_at_null */
+ 0, /* inspect_it */
+ 0, /* print_array_indexes */
+ 0, /* deref_ref */
+ 1, /* static_field_print */
+ 1 /* pascal_static_field_print */
+};
+
+/* Initialize *OPTS to be a copy of the user print options. */
+void
+get_user_print_options (struct value_print_options *opts)
+{
+ *opts = user_print_options;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+ pretty-printing disabled. */
+void
+get_raw_print_options (struct value_print_options *opts)
+{
+ *opts = user_print_options;
+ opts->pretty = Val_no_prettyprint;
+}
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+ FORMAT as the formatting option. */
+void
+get_formatted_print_options (struct value_print_options *opts,
+ char format)
+{
+ *opts = user_print_options;
+ opts->format = format;
+}
+
static void
show_print_max (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
Default output radix for printing of values is %s.\n"),
value);
}
-int output_format = 0;
/* By default we print arrays without printing the index of each element in
the array. This behavior can be changed by setting PRINT_ARRAY_INDEXES. */
-static int print_array_indexes = 0;
static void
show_print_array_indexes (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
element in an array. Referenced by the low level language dependent
print routines. */
-unsigned int repeat_count_threshold = 10;
static void
show_repeat_count_threshold (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* If nonzero, stops printing of char arrays at first null. */
-int stop_print_at_null;
static void
show_stop_print_at_null (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* Controls pretty printing of structures. */
-int prettyprint_structs;
static void
show_prettyprint_structs (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* Controls pretty printing of arrays. */
-int prettyprint_arrays;
static void
show_prettyprint_arrays (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* If nonzero, causes unions inside structures or other unions to be
printed. */
-int unionprint; /* Controls printing of nested unions. */
static void
show_unionprint (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* If nonzero, causes machine addresses to be printed in certain contexts. */
-int addressprint; /* Controls printing of machine addresses */
static void
show_addressprint (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
/* 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 FORMAT (a letter, or 0 for natural
- format using TYPE).
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting.
+ stdio stream STREAM according to OPTIONS.
If the data are a string pointer, returns the number of string characters
printed.
int
val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
- CORE_ADDR address, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty,
+ CORE_ADDR address, struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
const struct language_defn *language)
{
volatile struct gdb_exception except;
- volatile enum val_prettyprint real_pretty = pretty;
int ret = 0;
-
+ struct value_print_options local_opts = *options;
struct type *real_type = check_typedef (type);
- if (pretty == Val_pretty_default)
- real_pretty = prettyprint_structs ? Val_prettyprint : Val_no_prettyprint;
+
+ if (local_opts.pretty == Val_pretty_default)
+ local_opts.pretty = (local_opts.prettyprint_structs
+ ? Val_prettyprint : Val_no_prettyprint);
QUIT;
TRY_CATCH (except, RETURN_MASK_ERROR)
{
ret = language->la_val_print (type, valaddr, embedded_offset, address,
- stream, format, deref_ref, recurse,
- real_pretty);
+ stream, recurse, &local_opts);
}
if (except.reason < 0)
fprintf_filtered (stream, _("<error reading variable>"));
}
/* Print using the given LANGUAGE the value VAL onto stream STREAM according
- to FORMAT (a letter, or 0 for natural format using TYPE).
-
- If DEREF_REF is nonzero, then dereference references, otherwise just print
- them like pointers.
-
- The PRETTY parameter controls prettyprinting.
+ to OPTIONS.
If the data are a string pointer, returns the number of string characters
printed.
GDB's value mechanism. */
int
-common_val_print (struct value *val, struct ui_file *stream, int format,
- int deref_ref, int recurse, enum val_prettyprint pretty,
+common_val_print (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
const struct language_defn *language)
{
if (!value_check_printable (val, stream))
return val_print (value_type (val), value_contents_all (val),
value_embedded_offset (val), VALUE_ADDRESS (val),
- stream, format, deref_ref, recurse, pretty,
- language);
+ stream, recurse, options, language);
}
-/* Print the value VAL in C-ish syntax on stream STREAM.
- FORMAT is a format-letter, or 0 for print in natural format of data type.
+/* Print the value VAL in C-ish syntax on stream STREAM according to
+ OPTIONS.
If the object printed is a string pointer, returns
the number of string bytes printed. */
int
-value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options)
{
if (!value_check_printable (val, stream))
return 0;
- return LA_VALUE_PRINT (val, stream, format, pretty);
+ return LA_VALUE_PRINT (val, stream, options);
}
/* Called by various <lang>_val_print routines to print
}
}
-/* Return non-zero if the debugger should print the index of each element
- when printing array values. */
-
-int
-print_array_indexes_p (void)
-{
- return print_array_indexes;
-}
-
/* Assuming TYPE is a simple, non-empty array type, compute its upper
and lower bound. Save the low bound into LOW_BOUND if not NULL.
Save the high bound into HIGH_BOUND if not NULL.
return 1;
}
-/* Print on STREAM using the given FORMAT the index for the element
+/* Print on STREAM using the given OPTIONS the index for the element
at INDEX of an array whose index type is INDEX_TYPE. */
void
maybe_print_array_index (struct type *index_type, LONGEST index,
- struct ui_file *stream, int format,
- enum val_prettyprint pretty)
+ struct ui_file *stream,
+ const struct value_print_options *options)
{
struct value *index_value;
- if (!print_array_indexes)
+ if (!options->print_array_indexes)
return;
index_value = value_from_longest (index_type, index);
- LA_PRINT_ARRAY_INDEX (index_value, stream, format, pretty);
-}
+ LA_PRINT_ARRAY_INDEX (index_value, stream, options);
+}
/* Called by various <lang>_val_print routines to print elements of an
array in the form "<elem1>, <elem2>, <elem3>, ...".
void
val_print_array_elements (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
- int format, int deref_ref,
- int recurse, enum val_prettyprint pretty,
+ int recurse,
+ const struct value_print_options *options,
unsigned int i)
{
unsigned int things_printed = 0;
annotate_array_section_begin (i, elttype);
- for (; i < len && things_printed < print_max; i++)
+ for (; i < len && things_printed < options->print_max; i++)
{
if (i != 0)
{
- if (prettyprint_arrays)
+ if (options->prettyprint_arrays)
{
fprintf_filtered (stream, ",\n");
print_spaces_filtered (2 + 2 * recurse, stream);
}
wrap_here (n_spaces (2 + 2 * recurse));
maybe_print_array_index (index_type, i + low_bound_index,
- stream, format, pretty);
+ stream, options);
rep1 = i + 1;
reps = 1;
++rep1;
}
- if (reps > repeat_count_threshold)
+ if (reps > options->repeat_count_threshold)
{
- val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
- deref_ref, recurse + 1, pretty, current_language);
+ val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+ recurse + 1, options, current_language);
annotate_elt_rep (reps);
fprintf_filtered (stream, " <repeats %u times>", reps);
annotate_elt_rep_end ();
i = rep1 - 1;
- things_printed += repeat_count_threshold;
+ things_printed += options->repeat_count_threshold;
}
else
{
- val_print (elttype, valaddr + i * eltlen, 0, 0, stream, format,
- deref_ref, recurse + 1, pretty, current_language);
+ val_print (elttype, valaddr + i * eltlen, 0, 0, stream,
+ recurse + 1, options, current_language);
annotate_elt ();
things_printed++;
}
/* FIXME: Use target_read_string. */
int
-val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream)
+val_print_string (CORE_ADDR addr, int len, int width, struct ui_file *stream,
+ const struct value_print_options *options)
{
int force_ellipsis = 0; /* Force ellipsis to be printed if nonzero. */
int errcode; /* Errno returned from bad reads. */
because finding the null byte (or available memory) is what actually
limits the fetch. */
- fetchlimit = (len == -1 ? print_max : min (len, print_max));
+ fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
/* Now decide how large of chunks to try to read in one operation. This
is also pretty simple. If LEN >= zero, then we want fetchlimit chars,
and then the error message. */
if (errcode == 0 || bufptr > buffer)
{
- if (addressprint)
+ if (options->addressprint)
{
fputs_filtered (" ", stream);
}
- LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis);
+ LA_PRINT_STRING (stream, buffer, (bufptr - buffer) / width, width, force_ellipsis, options);
}
if (errcode != 0)
switch (radix)
{
case 16:
- output_format = 'x'; /* hex */
+ user_print_options.output_format = 'x'; /* hex */
break;
case 10:
- output_format = 0; /* decimal */
+ user_print_options.output_format = 0; /* decimal */
break;
case 8:
- output_format = 'o'; /* octal */
+ user_print_options.output_format = 'o'; /* octal */
break;
default:
/* FIXME: cagney/2002-03-17: This needs to revert the bad radix
add_alias_cmd ("p", "print", no_class, 1, &showlist);
add_alias_cmd ("pr", "print", no_class, 1, &showlist);
- add_setshow_uinteger_cmd ("elements", no_class, &print_max, _("\
+ add_setshow_uinteger_cmd ("elements", no_class,
+ &user_print_options.print_max, _("\
Set limit on string chars or array elements to print."), _("\
Show limit on string chars or array elements to print."), _("\
\"set print elements 0\" causes there to be no limit."),
show_print_max,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("null-stop", no_class, &stop_print_at_null, _("\
+ add_setshow_boolean_cmd ("null-stop", no_class,
+ &user_print_options.stop_print_at_null, _("\
Set printing of char arrays to stop at first null char."), _("\
Show printing of char arrays to stop at first null char."), NULL,
NULL,
&setprintlist, &showprintlist);
add_setshow_uinteger_cmd ("repeats", no_class,
- &repeat_count_threshold, _("\
+ &user_print_options.repeat_count_threshold, _("\
Set threshold for repeated print elements."), _("\
Show threshold for repeated print elements."), _("\
\"set print repeats 0\" causes all elements to be individually printed."),
show_repeat_count_threshold,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("pretty", class_support, &prettyprint_structs, _("\
+ add_setshow_boolean_cmd ("pretty", class_support,
+ &user_print_options.prettyprint_structs, _("\
Set prettyprinting of structures."), _("\
Show prettyprinting of structures."), NULL,
NULL,
show_prettyprint_structs,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("union", class_support, &unionprint, _("\
+ add_setshow_boolean_cmd ("union", class_support,
+ &user_print_options.unionprint, _("\
Set printing of unions interior to structures."), _("\
Show printing of unions interior to structures."), NULL,
NULL,
show_unionprint,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("array", class_support, &prettyprint_arrays, _("\
+ add_setshow_boolean_cmd ("array", class_support,
+ &user_print_options.prettyprint_arrays, _("\
Set prettyprinting of arrays."), _("\
Show prettyprinting of arrays."), NULL,
NULL,
show_prettyprint_arrays,
&setprintlist, &showprintlist);
- add_setshow_boolean_cmd ("address", class_support, &addressprint, _("\
+ add_setshow_boolean_cmd ("address", class_support,
+ &user_print_options.addressprint, _("\
Set printing of addresses."), _("\
Show printing of addresses."), NULL,
NULL,
&showlist);
add_setshow_boolean_cmd ("array-indexes", class_support,
- &print_array_indexes, _("\
+ &user_print_options.print_array_indexes, _("\
Set printing of array indexes."), _("\
Show printing of array indexes"), NULL, NULL, show_print_array_indexes,
&setprintlist, &showprintlist);
-
- /* Give people the defaults which they are used to. */
- prettyprint_structs = 0;
- prettyprint_arrays = 0;
- unionprint = 1;
- addressprint = 1;
- print_max = PRINT_MAX_DEFAULT;
}
#ifndef VALPRINT_H
#define VALPRINT_H
-extern int prettyprint_arrays; /* Controls pretty printing of arrays. */
-extern int prettyprint_structs; /* Controls pretty printing of structures */
-extern int prettyprint_arrays; /* Controls pretty printing of arrays. */
+/* This is used to pass formatting options to various value-printing
+ functions. */
+struct value_print_options
+{
+ /* Pretty-printing control. */
+ enum val_prettyprint pretty;
-extern int vtblprint; /* Controls printing of vtbl's */
-extern int unionprint; /* Controls printing of nested unions. */
-extern int addressprint; /* Controls pretty printing of addresses. */
-extern int objectprint; /* Controls looking up an object's derived type
- using what we find in its vtables. */
+ /* Controls pretty printing of arrays. */
+ int prettyprint_arrays;
-extern unsigned int print_max; /* Max # of chars for strings/vectors */
+ /* Controls pretty printing of structures. */
+ int prettyprint_structs;
-/* Flag to low-level print routines that this value is being printed
- in an epoch window. We'd like to pass this as a parameter, but
- every routine would need to take it. Perhaps we can encapsulate
- this in the I/O stream once we have GNU stdio. */
-extern int inspect_it;
+ /* Controls printing of virtual tables. */
+ int vtblprint;
-/* Print repeat counts if there are more than this many repetitions of an
- element in an array. Referenced by the low level language dependent
- print routines. */
-extern unsigned int repeat_count_threshold;
+ /* Controls printing of nested unions. */
+ int unionprint;
-extern int output_format;
+ /* Controls printing of addresses. */
+ int addressprint;
-extern int stop_print_at_null; /* Stop printing at null char? */
+ /* Controls looking up an object's derived type using what we find
+ in its vtables. */
+ int objectprint;
+
+ /* Maximum number of chars to print for a string pointer value or vector
+ contents, or UINT_MAX for no limit. Note that "set print elements 0"
+ stores UINT_MAX in print_max, which displays in a show command as
+ "unlimited". */
+ unsigned int print_max;
+
+ /* Print repeat counts if there are more than this many repetitions
+ of an element in an array. */
+ unsigned int repeat_count_threshold;
+
+ /* The global output format letter. */
+ int output_format;
+
+ /* The current format letter. This is set locally for a given call,
+ e.g. when the user passes a format to "print". */
+ int format;
+
+ /* Stop printing at null character? */
+ int stop_print_at_null;
+
+ /* True if this value is being printed in an epoch window. */
+ int inspect_it;
+
+ /* True if we should print the index of each element when printing
+ an array. */
+ int print_array_indexes;
+
+ /* If nonzero, then dereference references, otherwise just print
+ them like pointers. */
+ int deref_ref;
+
+ /* If nonzero, print static fields. */
+ int static_field_print;
+
+ /* If nonzero, print static fields for Pascal. FIXME: C++ and Java
+ share one flag, why not Pascal too? */
+ int pascal_static_field_print;
+};
+
+/* The global print options set by the user. In general this should
+ not be directly accessed, except by set/show commands. Ordinary
+ code should call get_user_print_options instead. */
+extern struct value_print_options user_print_options;
+
+/* Initialize *OPTS to be a copy of the user print options. */
+extern void get_user_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but with
+ pretty-printing disabled. */
+extern void get_raw_print_options (struct value_print_options *opts);
+
+/* Initialize *OPTS to be a copy of the user print options, but using
+ FORMAT as the formatting option. */
+extern void get_formatted_print_options (struct value_print_options *opts,
+ char format);
-extern int print_array_indexes_p (void);
-
extern int get_array_bounds (struct type *type, long *low_bound,
long *high_bound);
extern void maybe_print_array_index (struct type *index_type, LONGEST index,
- struct ui_file *stream, int format,
- enum val_prettyprint pretty);
+ struct ui_file *stream,
+ const struct value_print_options *options);
extern void val_print_array_elements (struct type *, const gdb_byte *,
CORE_ADDR, struct ui_file *, int,
- int, int, enum val_prettyprint,
+ const struct value_print_options *,
unsigned int);
extern void val_print_type_code_int (struct type *, const gdb_byte *,
#include "block.h"
#include "dfp.h"
#include "objfiles.h"
+#include "valprint.h"
#include "python/python.h"
for (i = num; i < num + 10 && i <= value_history_count; i++)
{
+ struct value_print_options opts;
val = access_value_history (i);
printf_filtered (("$%d = "), i);
- value_print (val, gdb_stdout, 0, Val_pretty_default);
+ get_user_print_options (&opts);
+ value_print (val, gdb_stdout, &opts);
printf_filtered (("\n"));
}
{
struct internalvar *var;
int varseen = 0;
+ struct value_print_options opts;
+ get_user_print_options (&opts);
for (var = internalvars; var; var = var->next)
{
if (!varseen)
}
printf_filtered (("$%s = "), var->name);
value_print (value_of_internalvar (var), gdb_stdout,
- 0, Val_pretty_default);
+ &opts);
printf_filtered (("\n"));
}
if (!varseen)
struct type;
struct ui_file;
struct language_defn;
+struct value_print_options;
/* The structure which defines the type of a value. It should never
be possible for a program lval value to survive over a call to the
extern void print_decimal_floating (const gdb_byte *valaddr, struct type *type,
struct ui_file *stream);
-extern int value_print (struct value *val, struct ui_file *stream, int format,
- enum val_prettyprint pretty);
+extern int value_print (struct value *val, struct ui_file *stream,
+ const struct value_print_options *options);
extern void value_print_array_elements (struct value *val,
struct ui_file *stream, int format,
extern int val_print (struct type *type, const gdb_byte *valaddr,
int embedded_offset, CORE_ADDR address,
- struct ui_file *stream, int format,
- int deref_ref, int recurse,
- enum val_prettyprint pretty,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
const struct language_defn *language);
extern int common_val_print (struct value *val,
- struct ui_file *stream, int format,
- int deref_ref, int recurse,
- enum val_prettyprint pretty,
+ struct ui_file *stream, int recurse,
+ const struct value_print_options *options,
const struct language_defn *language);
extern int val_print_string (CORE_ADDR addr, int len, int width,
- struct ui_file *stream);
+ struct ui_file *stream,
+ const struct value_print_options *options);
extern void print_variable_value (struct symbol *var,
struct frame_info *frame,
#include "wrapper.h"
#include "gdbcmd.h"
#include "block.h"
+#include "valprint.h"
#include "gdb_assert.h"
#include "gdb_string.h"
struct ui_file *stb;
struct cleanup *old_chain;
char *thevalue;
+ struct value_print_options opts;
if (value == NULL)
return NULL;
stb = mem_fileopen ();
old_chain = make_cleanup_ui_file_delete (stb);
- common_val_print (value, stb, format_code[(int) format], 1, 0, 0,
- current_language);
+ get_formatted_print_options (&opts, format_code[(int) format]);
+ opts.deref_ref = 0;
+ common_val_print (value, stb, 0, &opts, current_language);
thevalue = ui_file_xstrdup (stb, &dummy);
do_cleanups (old_chain);