summaryrefslogtreecommitdiff
path: root/gdb/valprint.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-07-11 06:40:40 -0600
committerTom Tromey <tom@tromey.com>2017-08-14 10:14:05 -0600
commitd6382fffde99214ce4aee99a208ddb703c647008 (patch)
tree91590151181ced3a46bf0dc6ea123036198bea30 /gdb/valprint.c
parentf978cb06dbfbd93dbd52bd39d992f8644b0c639e (diff)
Fix two regressions in scalar printing
PR gdb/21675 points out a few regressions in scalar printing. One type of regression is due to not carrying over the old handling of floating point printing -- where a format like "/d" causes a floating point number to first be cast to a signed integer. This patch restores this behavior. The other regression is a longstanding bug in print_octal_chars: one of the constants was wrong. This patch fixes the constant and adds static asserts to help catch this sort of error. ChangeLog 2017-08-14 Tom Tromey <tom@tromey.com> PR gdb/21675 * valprint.c (LOW_ZERO): Change value to 034. (print_octal_chars): Add static_asserts for octal constants. * printcmd.c (print_scalar_formatted): Add 'd' case. testsuite/ChangeLog 2017-08-14 Tom Tromey <tom@tromey.com> PR gdb/21675: * gdb.base/printcmds.exp (test_radices): New function. * gdb.dwarf2/var-access.exp: Use p/u, not p/d. * gdb.base/sizeof.exp (check_valueof): Use p/d. * lib/gdb.exp (get_integer_valueof): Use p/d.
Diffstat (limited to 'gdb/valprint.c')
-rw-r--r--gdb/valprint.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 166788279a..9e216cff92 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1593,15 +1593,21 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
*/
#define BITS_IN_OCTAL 3
#define HIGH_ZERO 0340
-#define LOW_ZERO 0016
+#define LOW_ZERO 0034
#define CARRY_ZERO 0003
+ static_assert (HIGH_ZERO + LOW_ZERO + CARRY_ZERO == 0xff,
+ "cycle zero constants are wrong");
#define HIGH_ONE 0200
#define MID_ONE 0160
#define LOW_ONE 0016
#define CARRY_ONE 0001
+ static_assert (HIGH_ONE + MID_ONE + LOW_ONE + CARRY_ONE == 0xff,
+ "cycle one constants are wrong");
#define HIGH_TWO 0300
#define MID_TWO 0070
#define LOW_TWO 0007
+ static_assert (HIGH_TWO + MID_TWO + LOW_TWO == 0xff,
+ "cycle two constants are wrong");
/* For 32 we start in cycle 2, with two bits and one bit carry;
for 64 in cycle in cycle 1, with one bit and a two bit carry. */