aboutsummaryrefslogtreecommitdiff
path: root/gdb/valprint.c
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2020-04-26 15:28:46 +0200
committerHannes Domani <ssbssa@yahoo.de>2020-04-29 12:57:25 +0200
commitd642b6920b1a697da2e8fa2326cb773612a87f3f (patch)
tree7efb5027f46519236ecc146f519d080033d7679f /gdb/valprint.c
parentea90f2278cee318976c66bf82284046214fb30af (diff)
downloadbinutils-d642b6920b1a697da2e8fa2326cb773612a87f3f.zip
binutils-d642b6920b1a697da2e8fa2326cb773612a87f3f.tar.gz
binutils-d642b6920b1a697da2e8fa2326cb773612a87f3f.tar.bz2
Fix array pretty formatter
Currently, printing with array pretty formatting makes the output actually less readable than without: (gdb) p -array on -- {{1,2,3},{4,5,6}} $1 = { {1, 2, 3}, {4, 5, 6}} (gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}} $2 = {[0] = {[0] = 1, [1] = 2, [2] = 3}, [1] = {[0] = 4, [1] = 5, [2] = 6}} These changes now also put the first element and the array end bracket on a new line, similar to the structure pretty formatter: (gdb) p -array on -- {{1,2,3},{4,5,6}} $1 = { { 1, 2, 3 }, { 4, 5, 6 } } (gdb) p -array on -array-indexes on -- {{1,2,3},{4,5,6}} $2 = { [0] = { [0] = 1, [1] = 2, [2] = 3 }, [1] = { [0] = 4, [1] = 5, [2] = 6 } } gdb/ChangeLog: 2020-04-29 Hannes Domani <ssbssa@yahoo.de> PR gdb/17320 * ada-valprint.c (val_print_packed_array_elements): Move array end bracket to new line. (ada_val_print_string): Remove extra spaces before first array element. * c-valprint.c (c_value_print_array): Likewise. * m2-valprint.c (m2_print_array_contents): Likewise. (m2_value_print_inner): Likewise. * p-valprint.c (pascal_value_print_inner): Likewise. * valprint.c (generic_val_print_array): Likewise. (value_print_array_elements): Move first array element and array end bracket to new line. gdb/testsuite/ChangeLog: 2020-04-29 Hannes Domani <ssbssa@yahoo.de> PR gdb/17320 * gdb.base/pretty-array.c: New test. * gdb.base/pretty-array.exp: New file.
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r--gdb/valprint.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0be7c60..2f91024 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -441,11 +441,6 @@ generic_val_print_array (struct value *val,
if (!get_array_bounds (type, &low_bound, &high_bound))
error (_("Could not determine the array high bound"));
- if (options->prettyformat_arrays)
- {
- print_spaces_filtered (2 + 2 * recurse, stream);
- }
-
fputs_filtered (decorations->array_start, stream);
value_print_array_elements (val, stream, recurse, options, 0);
fputs_filtered (decorations->array_end, stream);
@@ -1945,6 +1940,11 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
else
fprintf_filtered (stream, ", ");
}
+ else if (options->prettyformat_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,
stream, options);
@@ -1988,6 +1988,11 @@ value_print_array_elements (struct value *val, struct ui_file *stream,
annotate_array_section_end ();
if (i < len)
fprintf_filtered (stream, "...");
+ if (options->prettyformat_arrays)
+ {
+ fprintf_filtered (stream, "\n");
+ print_spaces_filtered (2 * recurse, stream);
+ }
}
/* Read LEN bytes of target memory at address MEMADDR, placing the