From ecf25064e87a3d2d59871b3ea7126fa0dee0001d Mon Sep 17 00:00:00 2001 From: Kent Cheung Date: Thu, 13 May 2021 15:42:20 +0100 Subject: 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. --- gdb/testsuite/gdb.python/py-format-string.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdb/testsuite/gdb.python/py-format-string.c') 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. */ -- cgit v1.1