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.
This commit is contained in:
Tom Tromey
2017-07-11 06:40:40 -06:00
parent f978cb06db
commit d6382fffde
7 changed files with 44 additions and 8 deletions

View File

@ -413,7 +413,9 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
&& (options->format == 'o'
|| options->format == 'x'
|| options->format == 't'
|| options->format == 'z'))
|| options->format == 'z'
|| options->format == 'd'
|| options->format == 'u'))
{
LONGEST val_long = unpack_long (type, valaddr);
converted_float_bytes.resize (TYPE_LENGTH (type));
@ -427,11 +429,13 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
case 'o':
print_octal_chars (stream, valaddr, len, byte_order);
break;
case 'd':
print_decimal_chars (stream, valaddr, len, true, byte_order);
break;
case 'u':
print_decimal_chars (stream, valaddr, len, false, byte_order);
break;
case 0:
case 'd':
if (TYPE_CODE (type) != TYPE_CODE_FLT)
{
print_decimal_chars (stream, valaddr, len, !TYPE_UNSIGNED (type),