aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.python
diff options
context:
space:
mode:
authorKent Cheung <kent.cheung@arm.com>2021-05-13 15:42:20 +0100
committerAndrew Burgess <andrew.burgess@embecosm.com>2021-05-14 06:51:21 +0100
commitecf25064e87a3d2d59871b3ea7126fa0dee0001d (patch)
treeda6aa892b6386531716e8e1b3b33f4168f09d3e4 /gdb/testsuite/gdb.python
parent64654371d6324794d11131fc95c1bc4caaaf173d (diff)
downloadbinutils-ecf25064e87a3d2d59871b3ea7126fa0dee0001d.zip
binutils-ecf25064e87a3d2d59871b3ea7126fa0dee0001d.tar.gz
binutils-ecf25064e87a3d2d59871b3ea7126fa0dee0001d.tar.bz2
gdb: fix pretty printing max depth behaviour
The 'print max-depth' feature incorrectly causes GDB to skip printing the string representation of pretty printed variables if the variable is stored at a nested depth corresponding to the set max-depth value. This change ensures that it is always printed before checking whether the maximum print depth has been reached. Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64. gdb/ChangeLog: * cp-valprint.c (cp_print_value): Replaced duplicate code. * guile/scm-pretty-print.c (ppscm_print_children): Check max_depth just before printing child values. (gdbscm_apply_val_pretty_printer): Don't check max_depth before printing string representation. * python/py-prettyprint.c (print_children): Check max_depth just before printing child values. (gdbpy_apply_val_pretty_printer): Don't check max_depth before printing string representation. gdb/testsuite/ChangeLog: * gdb.python/py-format-string.c: Added a variable to test. * gdb.python/py-format-string.exp: Check string representation is printed at appropriate max_depth settings. * gdb.python/py-nested-maps.exp: Likewise. * gdb.guile/scm-pretty-print.exp: Add additional tests.
Diffstat (limited to 'gdb/testsuite/gdb.python')
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.c6
-rw-r--r--gdb/testsuite/gdb.python/py-format-string.exp9
-rw-r--r--gdb/testsuite/gdb.python/py-nested-maps.exp6
3 files changed, 18 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.python/py-format-string.c b/gdb/testsuite/gdb.python/py-format-string.c
index 763fcc6..450971c 100644
--- a/gdb/testsuite/gdb.python/py-format-string.c
+++ b/gdb/testsuite/gdb.python/py-format-string.c
@@ -23,6 +23,11 @@ typedef struct point
int y;
} point_t;
+typedef struct
+{
+ point_t the_point;
+} struct_point_t;
+
typedef union
{
int an_int;
@@ -84,6 +89,7 @@ main ()
point_t &a_point_t_ref = a_point_t;
#endif
struct point another_point = { 123, 456 };
+ struct_point_t a_struct_with_point = { a_point_t };
struct_union_t a_struct_with_union;
/* Fill the union in an endianness-independent way. */
diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index ed82ee2..ea5e958 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -126,6 +126,7 @@ set default_regexp_dict [dict create \
"a_point_t_pointer" $default_pointer_regexp \
"a_point_t_ref" "Pretty Point \\(42, 12\\)" \
"another_point" "Pretty Point \\(123, 456\\)" \
+ "a_struct_with_point" "\\{the_point = Pretty Point \\(42, 12\\)\\}" \
"a_struct_with_union" "\\{the_union = \\{an_int = 707406378, a_char = 42 '\\*'\\}\\}" \
"an_enum" "ENUM_BAR" \
"a_string" "${default_pointer_regexp} \"hello world\"" \
@@ -722,18 +723,26 @@ proc_with_prefix test_max_depth {} {
set opts "max_depth=-1"
with_test_prefix $opts {
check_format_string "a_struct_with_union" $opts
+ check_format_string "a_point_t" $opts "Pretty Point \\(42, 12\\)"
+ check_format_string "a_struct_with_point" $opts
}
set opts "max_depth=0"
with_test_prefix $opts {
check_format_string "a_struct_with_union" $opts "\\{\.\.\.\\}"
+ check_format_string "a_point_t" $opts "Pretty Point \\(42, 12\\)"
+ check_format_string "a_struct_with_point" $opts "\\{\.\.\.\\}"
}
set opts "max_depth=1"
with_test_prefix $opts {
check_format_string "a_struct_with_union" $opts "\\{the_union = \\{\.\.\.\\}\\}"
+ check_format_string "a_point_t" $opts "Pretty Point \\(42, 12\\)"
+ check_format_string "a_struct_with_point" $opts
}
set opts "max_depth=2"
with_test_prefix $opts {
check_format_string "a_struct_with_union" $opts
+ check_format_string "a_point_t" $opts "Pretty Point \\(42, 12\\)"
+ check_format_string "a_struct_with_point" $opts
}
}
diff --git a/gdb/testsuite/gdb.python/py-nested-maps.exp b/gdb/testsuite/gdb.python/py-nested-maps.exp
index 49cefa8..befc48c 100644
--- a/gdb/testsuite/gdb.python/py-nested-maps.exp
+++ b/gdb/testsuite/gdb.python/py-nested-maps.exp
@@ -222,15 +222,15 @@ with_test_prefix "headers=on" {
with_test_prefix "pretty=off" {
gdb_print_expr_at_depths "*m1" \
[list \
- "\{\\.\\.\\.\}" \
+ "pp_map = \{\\.\\.\\.\}" \
"pp_map = \{\\\[\{a = 3, b = 4\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 4, b = 5\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 5, b = 6\}\\\] = \{\\.\\.\\.\}\}" \
"pp_map = \{\\\[\{a = 3, b = 4\}\\\] = \{x = 0, y = 1, z = 2\}, \\\[\{a = 4, b = 5\}\\\] = \{x = 3, y = 4, z = 5\}, \\\[\{a = 5, b = 6\}\\\] = \{x = 6, y = 7, z = 8\}\}" \
]
gdb_print_expr_at_depths "*mm" \
[list \
- "\{\\.\\.\\.\}" \
- "pp_map_map = \{\\\[$hex \"m1\"\\\] = \{\\.\\.\\.\}, \\\[$hex \"m2\"\\\] = \{\\.\\.\\.\}\}" \
+ "pp_map_map = \{\\.\\.\\.\}" \
+ "pp_map_map = \{\\\[$hex \"m1\"\\\] = pp_map = \{\\.\\.\\.\}, \\\[$hex \"m2\"\\\] = pp_map = \{\\.\\.\\.\}\}" \
"pp_map_map = \{\\\[$hex \"m1\"\\\] = pp_map = \{\\\[\{a = 3, b = 4\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 4, b = 5\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 5, b = 6\}\\\] = \{\\.\\.\\.\}\}, \\\[$hex \"m2\"\\\] = pp_map = \{\\\[\{a = 6, b = 7\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 7, b = 8\}\\\] = \{\\.\\.\\.\}, \\\[\{a = 8, b = 9\}\\\] = \{\\.\\.\\.\}\}\}" \
"pp_map_map = \{\\\[$hex \"m1\"\\\] = pp_map = \{\\\[\{a = 3, b = 4\}\\\] = \{x = 0, y = 1, z = 2\}, \\\[\{a = 4, b = 5\}\\\] = \{x = 3, y = 4, z = 5\}, \\\[\{a = 5, b = 6\}\\\] = \{x = 6, y = 7, z = 8\}\}, \\\[$hex \"m2\"\\\] = pp_map = \{\\\[\{a = 6, b = 7\}\\\] = \{x = 9, y = 0, z = 1\}, \\\[\{a = 7, b = 8\}\\\] = \{x = 2, y = 3, z = 4\}, \\\[\{a = 8, b = 9\}\\\] = \{x = 5, y = 6, z = 7\}\}\}" \
]