From patchwork Mon Jul 31 22:03:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21828 Received: (qmail 123841 invoked by alias); 31 Jul 2017 22:03:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 123820 invoked by uid 89); 31 Jul 2017 22:03:43 -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: gproxy6-pub.mail.unifiedlayer.com Received: from gproxy6-pub.mail.unifiedlayer.com (HELO gproxy6-pub.mail.unifiedlayer.com) (67.222.39.168) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 31 Jul 2017 22:03:40 +0000 Received: from cmgw3 (unknown [10.0.90.84]) by gproxy6.mail.unifiedlayer.com (Postfix) with ESMTP id 19C241E0ED9 for ; Mon, 31 Jul 2017 16:03:39 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw3 with id ra3b1v01N2f2jeq01a3eSe; Mon, 31 Jul 2017 16:03:39 -0600 X-Authority-Analysis: v=2.2 cv=epiv9shX c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=G3gG6ho9WtcA:10 a=20KFwNOVAAAA:8 a=zstS-IiYAAAA:8 a=A8oJy8mYAAAA:8 a=KKAkSRfTAAAA:8 a=cwd02sZVExwYtc3ilpcA:9 a=6XHFRtxWWR8ZBpKr:21 a=Zn3rgSFYLqvLjG7M:21 a=4G6NA9xxw8l3yy4pmD5M:22 a=MasS0_dV9q-jaWZIey9J:22 a=cvBusfyB2V15izCimMoJ:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:46816 helo=bapiya) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dcIml-0019RV-Pb; Mon, 31 Jul 2017 16:03:35 -0600 From: Tom Tromey To: Pedro Alves Cc: Tom Tromey , 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> Date: Mon, 31 Jul 2017 16:03:34 -0600 In-Reply-To: (Pedro Alves's message of "Fri, 14 Jul 2017 18:24:59 +0100") Message-ID: <871sow9scp.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-BWhitelist: no X-Exim-ID: 1dcIml-0019RV-Pb X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya) [174.29.39.24]:46816 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes >>>>> "Pedro" == Pedro Alves writes: Pedro> Yeah, that seems OK to me GDB-output-wise. "You get what you ask Pedro> for". Here is an updated version of this patch, that (I think) implements what was discussed in this thread. I regtested it on the buildbot. Let me know what you think. Tom commit 32d9b636591021a7d2a31ce53da6ba1db9f85689 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. gdb/ChangeLog 2017-07-31 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. gdb/testsuite/ChangeLog 2017-07-31 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 dd66a45..afdfb16 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2017-07-31 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-07-31 Xavier Roirand * solib-darwin.c (DYLD_VERSION_MAX): Increase value. diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a8cc052..f5ed513 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 2a777a8..f763661 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-07-31 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-07-26 Yao Qi * gdb.gdb/unittest.exp: Invoke command diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 323ca73..03275c3 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -155,6 +155,13 @@ 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\[^.\]" +} + proc test_print_all_chars {} { global gdb_prompt @@ -981,3 +988,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. */