Add array start and end strings to generic_val_print_decorations
For Rust value-printing, I wanted to use generic_val_print_array, but I also wanted to control the starting and ending strings. This patch adds new strings to generic_val_print_decorations, updates generic_val_print_array to use them, and updates all the existing instances of generic_val_print_decorations. 2016-05-17 Tom Tromey <tom@tromey.com> * valprint.h (struct generic_val_print_array) <array_start, array_end>: New fields. * valprint.c (generic_val_print_array): Add "decorations" parameter. Use "array_start", "array_end". (generic_val_print) <TYPE_CODE_ARRAY>: Update. * p-valprint.c (p_decorations): Update. * m2-valprint.c (m2_decorations): Update. * f-valprint.c (f_decorations): Update. * c-valprint.c (c_decorations): Update.
This commit is contained in:
parent
dcd1f97951
commit
00272ec4b0
7 changed files with 36 additions and 10 deletions
|
@ -1,3 +1,15 @@
|
||||||
|
2016-05-17 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* valprint.h (struct generic_val_print_array) <array_start,
|
||||||
|
array_end>: New fields.
|
||||||
|
* valprint.c (generic_val_print_array): Add "decorations"
|
||||||
|
parameter. Use "array_start", "array_end".
|
||||||
|
(generic_val_print) <TYPE_CODE_ARRAY>: Update.
|
||||||
|
* p-valprint.c (p_decorations): Update.
|
||||||
|
* m2-valprint.c (m2_decorations): Update.
|
||||||
|
* f-valprint.c (f_decorations): Update.
|
||||||
|
* c-valprint.c (c_decorations): Update.
|
||||||
|
|
||||||
2016-05-17 Tom Tromey <tom@tromey.com>
|
2016-05-17 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* NEWS: Add "maint selftest" entry.
|
* NEWS: Add "maint selftest" entry.
|
||||||
|
|
|
@ -124,7 +124,9 @@ static const struct generic_val_print_decorations c_decorations =
|
||||||
" * I",
|
" * I",
|
||||||
"true",
|
"true",
|
||||||
"false",
|
"false",
|
||||||
"void"
|
"void",
|
||||||
|
"{",
|
||||||
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Print a pointer based on the type of its target.
|
/* Print a pointer based on the type of its target.
|
||||||
|
|
|
@ -203,6 +203,8 @@ static const struct generic_val_print_decorations f_decorations =
|
||||||
".TRUE.",
|
".TRUE.",
|
||||||
".FALSE.",
|
".FALSE.",
|
||||||
"VOID",
|
"VOID",
|
||||||
|
"{",
|
||||||
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* See val_print for a description of the various parameters of this
|
/* See val_print for a description of the various parameters of this
|
||||||
|
|
|
@ -301,7 +301,9 @@ static const struct generic_val_print_decorations m2_decorations =
|
||||||
" * I",
|
" * I",
|
||||||
"TRUE",
|
"TRUE",
|
||||||
"FALSE",
|
"FALSE",
|
||||||
"void"
|
"void",
|
||||||
|
"{",
|
||||||
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* See val_print for a description of the various parameters of this
|
/* See val_print for a description of the various parameters of this
|
||||||
|
|
|
@ -49,7 +49,9 @@ static const struct generic_val_print_decorations p_decorations =
|
||||||
" * I",
|
" * I",
|
||||||
"true",
|
"true",
|
||||||
"false",
|
"false",
|
||||||
"void"
|
"void",
|
||||||
|
"{",
|
||||||
|
"}"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* See val_print for a description of the various parameters of this
|
/* See val_print for a description of the various parameters of this
|
||||||
|
|
|
@ -407,10 +407,12 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
generic_val_print_array (struct type *type, const gdb_byte *valaddr,
|
generic_val_print_array (struct type *type, const gdb_byte *valaddr,
|
||||||
int embedded_offset, CORE_ADDR address,
|
int embedded_offset, CORE_ADDR address,
|
||||||
struct ui_file *stream, int recurse,
|
struct ui_file *stream, int recurse,
|
||||||
const struct value *original_value,
|
const struct value *original_value,
|
||||||
const struct value_print_options *options)
|
const struct value_print_options *options,
|
||||||
|
const struct
|
||||||
|
generic_val_print_decorations *decorations)
|
||||||
{
|
{
|
||||||
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
|
struct type *unresolved_elttype = TYPE_TARGET_TYPE (type);
|
||||||
struct type *elttype = check_typedef (unresolved_elttype);
|
struct type *elttype = check_typedef (unresolved_elttype);
|
||||||
|
@ -427,11 +429,11 @@ generic_val_print_array (struct type *type, const gdb_byte *valaddr,
|
||||||
print_spaces_filtered (2 + 2 * recurse, stream);
|
print_spaces_filtered (2 + 2 * recurse, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf_filtered (stream, "{");
|
fputs_filtered (decorations->array_start, stream);
|
||||||
val_print_array_elements (type, valaddr, embedded_offset,
|
val_print_array_elements (type, valaddr, embedded_offset,
|
||||||
address, stream,
|
address, stream,
|
||||||
recurse, original_value, options, 0);
|
recurse, original_value, options, 0);
|
||||||
fprintf_filtered (stream, "}");
|
fputs_filtered (decorations->array_end, stream);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -851,7 +853,7 @@ generic_val_print (struct type *type, const gdb_byte *valaddr,
|
||||||
{
|
{
|
||||||
case TYPE_CODE_ARRAY:
|
case TYPE_CODE_ARRAY:
|
||||||
generic_val_print_array (type, valaddr, embedded_offset, address, stream,
|
generic_val_print_array (type, valaddr, embedded_offset, address, stream,
|
||||||
recurse, original_value, options);
|
recurse, original_value, options, decorations);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE_CODE_MEMBERPTR:
|
case TYPE_CODE_MEMBERPTR:
|
||||||
|
|
|
@ -186,6 +186,10 @@ struct generic_val_print_decorations
|
||||||
/* What to print when we see TYPE_CODE_VOID. */
|
/* What to print when we see TYPE_CODE_VOID. */
|
||||||
|
|
||||||
const char *void_name;
|
const char *void_name;
|
||||||
|
|
||||||
|
/* Array start and end strings. */
|
||||||
|
const char *array_start;
|
||||||
|
const char *array_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue