mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-05 15:17:13 +08:00
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:
@ -1,3 +1,10 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2017-08-11 Tom Tromey <tom@tromey.com>
|
2017-08-11 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* symfile.c (add_symbol_file_command): Use std::vector.
|
* symfile.c (add_symbol_file_command): Use std::vector.
|
||||||
|
@ -413,7 +413,9 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
|
|||||||
&& (options->format == 'o'
|
&& (options->format == 'o'
|
||||||
|| options->format == 'x'
|
|| options->format == 'x'
|
||||||
|| options->format == 't'
|
|| options->format == 't'
|
||||||
|| options->format == 'z'))
|
|| options->format == 'z'
|
||||||
|
|| options->format == 'd'
|
||||||
|
|| options->format == 'u'))
|
||||||
{
|
{
|
||||||
LONGEST val_long = unpack_long (type, valaddr);
|
LONGEST val_long = unpack_long (type, valaddr);
|
||||||
converted_float_bytes.resize (TYPE_LENGTH (type));
|
converted_float_bytes.resize (TYPE_LENGTH (type));
|
||||||
@ -427,11 +429,13 @@ print_scalar_formatted (const gdb_byte *valaddr, struct type *type,
|
|||||||
case 'o':
|
case 'o':
|
||||||
print_octal_chars (stream, valaddr, len, byte_order);
|
print_octal_chars (stream, valaddr, len, byte_order);
|
||||||
break;
|
break;
|
||||||
|
case 'd':
|
||||||
|
print_decimal_chars (stream, valaddr, len, true, byte_order);
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
print_decimal_chars (stream, valaddr, len, false, byte_order);
|
print_decimal_chars (stream, valaddr, len, false, byte_order);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
case 'd':
|
|
||||||
if (TYPE_CODE (type) != TYPE_CODE_FLT)
|
if (TYPE_CODE (type) != TYPE_CODE_FLT)
|
||||||
{
|
{
|
||||||
print_decimal_chars (stream, valaddr, len, !TYPE_UNSIGNED (type),
|
print_decimal_chars (stream, valaddr, len, !TYPE_UNSIGNED (type),
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
2017-08-12 Simon Marchi <simon.marchi@ericsson.com>
|
2017-08-12 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* lib/gdb.exp (get_valueof): Don't capture end-of-line
|
* lib/gdb.exp (get_valueof): Don't capture end-of-line
|
||||||
|
@ -155,6 +155,16 @@ proc test_float_rejected {} {
|
|||||||
test_print_reject "p 1.1ll"
|
test_print_reject "p 1.1ll"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Regression test for PR gdb/21675
|
||||||
|
proc test_radices {} {
|
||||||
|
gdb_test "print/o 16777211" " = 077777773"
|
||||||
|
gdb_test "print/d 1.5" " = 1"
|
||||||
|
gdb_test "print/u 1.5" " = 1"
|
||||||
|
|
||||||
|
gdb_test "print/u (char) -1" " = 255"
|
||||||
|
gdb_test "print/d (unsigned char) -1" " = -1"
|
||||||
|
}
|
||||||
|
|
||||||
proc test_print_all_chars {} {
|
proc test_print_all_chars {} {
|
||||||
global gdb_prompt
|
global gdb_prompt
|
||||||
|
|
||||||
@ -981,3 +991,4 @@ test_printf
|
|||||||
test_printf_with_dfp
|
test_printf_with_dfp
|
||||||
test_print_symbol
|
test_print_symbol
|
||||||
test_repeat_bytes
|
test_repeat_bytes
|
||||||
|
test_radices
|
||||||
|
@ -81,7 +81,7 @@ check_sizeof "long double" ${sizeof_long_double}
|
|||||||
|
|
||||||
proc check_valueof { exp val } {
|
proc check_valueof { exp val } {
|
||||||
gdb_test "next" "" ""
|
gdb_test "next" "" ""
|
||||||
gdb_test "p value" " = ${val}" "check valueof \"$exp\""
|
gdb_test "p /d value" " = ${val}" "check valueof \"$exp\""
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check that GDB and the target agree over the sign of a character.
|
# Check that GDB and the target agree over the sign of a character.
|
||||||
|
@ -282,16 +282,16 @@ gdb_test_no_output "set var \$[lindex $regname 0] = 81" \
|
|||||||
"init reg for s2.a"
|
"init reg for s2.a"
|
||||||
gdb_test_no_output "set var \$[lindex $regname 1] = 28" \
|
gdb_test_no_output "set var \$[lindex $regname 1] = 28" \
|
||||||
"init reg for s2.c"
|
"init reg for s2.c"
|
||||||
gdb_test "print/d s2" " = \\{a = 81, b = 4, c = 28, d = 5\\}" \
|
gdb_test "print/u s2" " = \\{a = 81, b = 4, c = 28, d = 5\\}" \
|
||||||
"initialized s2 from mem and regs"
|
"initialized s2 from mem and regs"
|
||||||
gdb_test_no_output "set var s2.c += s2.a + s2.b - s2.d"
|
gdb_test_no_output "set var s2.c += s2.a + s2.b - s2.d"
|
||||||
gdb_test "print/d s2" " = \\{a = 81, b = 4, c = 108, d = 5\\}" \
|
gdb_test "print/u s2" " = \\{a = 81, b = 4, c = 108, d = 5\\}" \
|
||||||
"verify s2.c"
|
"verify s2.c"
|
||||||
gdb_test "print/d \$[lindex $regname 1]" " = 108" \
|
gdb_test "print/u \$[lindex $regname 1]" " = 108" \
|
||||||
"verify s2.c through reg"
|
"verify s2.c through reg"
|
||||||
gdb_test_no_output "set var s2 = {191, 73, 231, 123}" \
|
gdb_test_no_output "set var s2 = {191, 73, 231, 123}" \
|
||||||
"re-initialize s2"
|
"re-initialize s2"
|
||||||
gdb_test "print/d s2" " = \\{a = 191, b = 73, c = 231, d = 123\\}" \
|
gdb_test "print/u s2" " = \\{a = 191, b = 73, c = 231, d = 123\\}" \
|
||||||
"verify re-initialized s2"
|
"verify re-initialized s2"
|
||||||
|
|
||||||
# Unaligned bitfield access through byte-aligned pieces.
|
# Unaligned bitfield access through byte-aligned pieces.
|
||||||
|
@ -1593,15 +1593,21 @@ print_octal_chars (struct ui_file *stream, const gdb_byte *valaddr,
|
|||||||
*/
|
*/
|
||||||
#define BITS_IN_OCTAL 3
|
#define BITS_IN_OCTAL 3
|
||||||
#define HIGH_ZERO 0340
|
#define HIGH_ZERO 0340
|
||||||
#define LOW_ZERO 0016
|
#define LOW_ZERO 0034
|
||||||
#define CARRY_ZERO 0003
|
#define CARRY_ZERO 0003
|
||||||
|
static_assert (HIGH_ZERO + LOW_ZERO + CARRY_ZERO == 0xff,
|
||||||
|
"cycle zero constants are wrong");
|
||||||
#define HIGH_ONE 0200
|
#define HIGH_ONE 0200
|
||||||
#define MID_ONE 0160
|
#define MID_ONE 0160
|
||||||
#define LOW_ONE 0016
|
#define LOW_ONE 0016
|
||||||
#define CARRY_ONE 0001
|
#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 HIGH_TWO 0300
|
||||||
#define MID_TWO 0070
|
#define MID_TWO 0070
|
||||||
#define LOW_TWO 0007
|
#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 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. */
|
for 64 in cycle in cycle 1, with one bit and a two bit carry. */
|
||||||
|
Reference in New Issue
Block a user