From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77217 invoked by alias); 14 Aug 2017 15:43:39 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 77202 invoked by uid 89); 14 Aug 2017 15:43:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy2-pub.mail.unifiedlayer.com Received: from gproxy2-pub.mail.unifiedlayer.com (HELO gproxy2-pub.mail.unifiedlayer.com) (69.89.18.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 14 Aug 2017 15:43:34 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id C46AA1E0951 for ; Mon, 14 Aug 2017 09:43:12 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id x3j91v00m2f2jeq013jCq1; Mon, 14 Aug 2017 09:43:12 -0600 X-Authority-Analysis: v=2.2 cv=T7z8d7CQ c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=KeKAF7QvOSUA:10 a=zstS-IiYAAAA:8 a=0FD05c-RAAAA:8 a=cwd02sZVExwYtc3ilpcA:9 a=7Tnq0eETA_koXdKW:21 a=qTrBlGY_5MK6_9JG:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=l1rpMCqCXRGZwUSuRcM3:22 Received: from 75-166-24-97.hlrn.qwest.net ([75.166.24.97]:56528 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dhHWH-003g0e-5C; Mon, 14 Aug 2017 09:43:09 -0600 From: Tom Tromey To: Tom Tromey Cc: Pedro Alves , gdb-patches@sourceware.org Subject: Re: [RFA 1/2] Fix two regressions in scalar printing References: <20170713123400.28917-1-tom@tromey.com> <20170713123400.28917-2-tom@tromey.com> <22c48f9e-ec2c-850d-91d3-c6a3ea8cdb11@redhat.com> <871spjufnv.fsf@pokyo> <871sow9scp.fsf@tromey.com> <707a03e4-46ef-cea9-f098-cc687b02d31e@redhat.com> <87h8xauqd9.fsf@pokyo> Date: Mon, 14 Aug 2017 15:43:00 -0000 In-Reply-To: <87h8xauqd9.fsf@pokyo> (Tom Tromey's message of "Mon, 14 Aug 2017 09:21:38 -0600") Message-ID: <87r2wejgtw.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BWhitelist: no X-Exim-ID: 1dhHWH-003g0e-5C X-Source-Sender: 75-166-24-97.hlrn.qwest.net (bapiya) [75.166.24.97]:56528 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes X-SW-Source: 2017-08/txt/msg00306.txt.bz2 >>>>> "Tom" == Tom Tromey writes: Tom> However, these are kind of indirect, so I added tests for Tom> "print/d (unsigned char) -1" and "print/u (char) -1". Here's the updated patch. Tom commit e2575fc9ea66582b71d4bccee0a76f772558be40 Author: Tom Tromey Date: Tue Jul 11 06:40:40 2017 -0600 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. 2017-08-14 Tom Tromey 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 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. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index dcb591d..fd0f959 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2017-08-14 Tom Tromey + + 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 * symfile.c (add_symbol_file_command): Use std::vector. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index d5c83f0..a1231d4 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -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), diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 23658b0..6db249b 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-08-14 Tom Tromey + + 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 * lib/gdb.exp (get_valueof): Don't capture end-of-line diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 323ca73..9409c6a 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -155,6 +155,16 @@ proc test_float_rejected {} { 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 {} { global gdb_prompt @@ -981,3 +991,4 @@ test_printf test_printf_with_dfp test_print_symbol test_repeat_bytes +test_radices diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp index d7ada65..5d89407 100644 --- a/gdb/testsuite/gdb.base/sizeof.exp +++ b/gdb/testsuite/gdb.base/sizeof.exp @@ -81,7 +81,7 @@ check_sizeof "long double" ${sizeof_long_double} proc check_valueof { exp val } { 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. diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp index 8ebad6a..9180c88 100644 --- a/gdb/testsuite/gdb.dwarf2/var-access.exp +++ b/gdb/testsuite/gdb.dwarf2/var-access.exp @@ -282,16 +282,16 @@ gdb_test_no_output "set var \$[lindex $regname 0] = 81" \ "init reg for s2.a" gdb_test_no_output "set var \$[lindex $regname 1] = 28" \ "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" 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" -gdb_test "print/d \$[lindex $regname 1]" " = 108" \ +gdb_test "print/u \$[lindex $regname 1]" " = 108" \ "verify s2.c through reg" gdb_test_no_output "set var s2 = {191, 73, 231, 123}" \ "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" # Unaligned bitfield access through byte-aligned pieces. diff --git a/gdb/valprint.c b/gdb/valprint.c index 1667882..9e216cf 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. */