From patchwork Thu Feb 13 20:30:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 38055 Received: (qmail 62700 invoked by alias); 13 Feb 2020 20:38:49 -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 62651 invoked by uid 89); 13 Feb 2020 20:38:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.26.124) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Feb 2020 20:38:47 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id A1CFB26155D for ; Thu, 13 Feb 2020 15:30:46 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id EHeRKM74zYH6; Thu, 13 Feb 2020 15:30:46 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id C047E26161D; Thu, 13 Feb 2020 15:30:43 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com C047E26161D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1581625843; bh=FDWs2JIBgyTU9WseX3rS68fhbVQa2bJR9QG6mLpYg6c=; h=From:To:Date:Message-Id:MIME-Version; b=iSWNrMsIrvsBDoMlnwJ0aiF+B33+zPAehsy9El8lVPkX3KSe+wb74t09Inlgicyed g8v70sNmhIYJIAM8SrZau8rWVIdA+PdoonnGl/MPyYzdpXzx52j+Ol2iRRsCGLujfH nwBCFrkfYGa4hiGD8erXBZXgUv1GZ4AlQvr8EBF9tsk+OPs+98kymZbGmgklZ/zPm6 l+D6BHqGQlmPQkbhKcFkr15YNvDx+4N05dSdbVLFt80KBkMSDgZKMDGdzWkI33L1dI xh9CHnilosDSFxz31Mapho70tZROvCX9b2q/JYX9/0ZVaL2Wh1plc17I4ZVpNvRvs2 KD/0jFXAqHGEw== Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id WUizcNkTadoo; Thu, 13 Feb 2020 15:30:43 -0500 (EST) Received: from smarchi-efficios.internal.efficios.com (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) by mail.efficios.com (Postfix) with ESMTPSA id AB8C8261701; Thu, 13 Feb 2020 15:30:42 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 4/5] gdb: print unknown part of flag enum in hex Date: Thu, 13 Feb 2020 15:30:34 -0500 Message-Id: <20200213203035.30157-4-simon.marchi@efficios.com> In-Reply-To: <20200213203035.30157-1-simon.marchi@efficios.com> References: <20200213203035.30157-1-simon.marchi@efficios.com> MIME-Version: 1.0 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. 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);