From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121573 invoked by alias); 17 Feb 2020 11:04:50 -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 121563 invoked by uid 89); 17 Feb 2020 11:04:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 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.1 spammy= X-HELO: mail-qk1-f193.google.com Received: from mail-qk1-f193.google.com (HELO mail-qk1-f193.google.com) (209.85.222.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 17 Feb 2020 11:04:48 +0000 Received: by mail-qk1-f193.google.com with SMTP id c20so15785232qkm.1 for ; Mon, 17 Feb 2020 03:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=XMiTBO5Cl4DPa3aSLMW0lahNZbHLWECVPtj08ama5nI=; b=ZaOE2I1KlzzW1Pp0CTLi/6zf2vBILpJq4HyWL6g892E1aQKDLHq92AUhDutFBSMRve MgpyKoUnNknLXV6lRCFWTFJnAIj/8JlSR5aHMq/NixM0mEgNRyl6SdEzFeVcLUa9eAUq WvYKhlQVk53j/b6amTpyakSkEhD5H/wFUY7XbjMXXbb0MvVS3RqlRGtWvlxt4/oYRJxT l+t+j1jhV1nZHNRJctWLC2bdfj8uFNOQOBP+fAZgjLl03s+DqIFXDUnOMqeat3RxcyNN WgnEzXtGIdpbZKHLhQOKfd26R7IPhCl8XmALiYP1s44n2EXmvLroOwBwIPFHPmTTKFv2 2H8w== Return-Path: Received: from [192.168.0.185] ([191.34.156.101]) by smtp.gmail.com with ESMTPSA id e64sm1485qtd.45.2020.02.17.03.04.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Feb 2020 03:04:45 -0800 (PST) Subject: Re: [PATCH 4/5] gdb: print unknown part of flag enum in hex To: Simon Marchi , gdb-patches@sourceware.org References: <20200213203035.30157-1-simon.marchi@efficios.com> <20200213203035.30157-4-simon.marchi@efficios.com> From: Luis Machado Message-ID: <801f3b0d-d452-101f-7f12-b5d0299a0307@linaro.org> Date: Mon, 17 Feb 2020 11:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200213203035.30157-4-simon.marchi@efficios.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00612.txt.bz2 On 2/13/20 5:30 PM, Simon Marchi wrote: > When we print the "unknown" part of a flag enum, it is printed in > decimal. I think it would be more useful if it was printed in hex, as > it helps to determine which bits are set more than a decimal value. > Would it be better to mention the offending bit position explicitly? The hex value could be displayed along with it as well. I mean, in both decimal and hex you'd need to do some calculations to figure out the bit position anyway. Might as well make it easier for developers by displaying the information. > gdb/ChangeLog: > > * valprint.c (generic_val_print_enum_1): Print unknown part of > flag enum in hex. > > gdb/testsuite/ChangeLog: > > * gdb.base/printcmds.exp (test_print_enums): Expect hex values > for "unknown". > --- > gdb/testsuite/gdb.base/printcmds.exp | 4 ++-- > gdb/valprint.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp > index 6afb965af066..d6f5c75650bf 100644 > --- a/gdb/testsuite/gdb.base/printcmds.exp > +++ b/gdb/testsuite/gdb.base/printcmds.exp > @@ -743,10 +743,10 @@ proc test_print_enums {} { > gdb_test "print (enum flag_enum) 0x0" [string_to_regexp " = FE_NONE"] > > # Print a flag enum with value 0, where no enumerator has value 0. > - gdb_test "print flag_enum_without_zero" [string_to_regexp " = (unknown: 0)"] > + gdb_test "print flag_enum_without_zero" [string_to_regexp " = (unknown: 0x0)"] > > # Print a flag enum with unknown bits set. > - gdb_test "print (enum flag_enum) 0xf1" [string_to_regexp " = (FE_ONE | unknown: 240)"] > + gdb_test "print (enum flag_enum) 0xf1" [string_to_regexp " = (FE_ONE | unknown: 0xf0)"] > > # Test printing an enum not considered a "flag enum" (because one of its > # enumerators has multiple bits set). > diff --git a/gdb/valprint.c b/gdb/valprint.c > index 77b9a4993d79..bd21be69e1bf 100644 > --- a/gdb/valprint.c > +++ b/gdb/valprint.c > @@ -659,8 +659,8 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, > { > if (!first) > fputs_filtered (" | ", stream); > - fputs_filtered ("unknown: ", stream); > - print_longest (stream, 'd', 0, val); > + fputs_filtered ("unknown: 0x", stream); > + print_longest (stream, 'x', 0, val); > } > > fputs_filtered (")", stream); >