From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd2c.google.com (mail-io1-xd2c.google.com [IPv6:2607:f8b0:4864:20::d2c]) by sourceware.org (Postfix) with ESMTPS id 949D93858C83 for ; Mon, 28 Feb 2022 18:33:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 949D93858C83 Received: by mail-io1-xd2c.google.com with SMTP id c18so15728696ioc.6 for ; Mon, 28 Feb 2022 10:33:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ygI1HOmBVeCoFzLQyzRqXDoQmX2GEvdiUqmeOlKLn+E=; b=iUxZFfeiM3AtuwFhr1TuaJZ2+1aE++WyK9rDXtDeRRBJIuwR0b+Ar7uJd/K3ZJarqY ZDP3mWcoY5YuLTYe3IJYu5mkMghuhfTxxA3cHdqP+4PeF7g3UBHz2BQbpWcdfso24CYY WD+7g9/zus7xjLtd6tOiJhfqYzvkYQ0j+0rRFbtzE5UlI3q7ac3cYu4Ym1LdopsghEGO UxjTyWWosZMGFbfzuSI2DUP/3dy9DKysHSu1DTWcSbd3Z8I8oRYHK/98hcKjWFlMJtx+ mAHo1rEBD+eQPYyB7xXJyD/330T0RbhmLO30AMR3hrr5aWFcoJeBOGKi7CbYqrg8tP1y wiOw== X-Gm-Message-State: AOAM533s6U+I8SRlDk1MxYClLOHfQ8rGyuUrShH/6TAZY+eX4PQtczmy D9UaKrEEgT3lNYMMZJQI8oTLtiulDpz+8A== X-Google-Smtp-Source: ABdhPJzcGVTSaRBlY3AcY6MMVIVHD1Dmm4Aa3qemYSUcya3JwMYW2OissISoohAw5Mb+cBm9gSLfyA== X-Received: by 2002:a02:a78c:0:b0:308:cae5:991c with SMTP id e12-20020a02a78c000000b00308cae5991cmr17801356jaj.116.1646073189053; Mon, 28 Feb 2022 10:33:09 -0800 (PST) Received: from murgatroyd.Home (75-166-141-253.hlrn.qwest.net. [75.166.141.253]) by smtp.gmail.com with ESMTPSA id h9-20020a92c089000000b002b8b3ce939fsm6558845ile.9.2022.02.28.10.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 10:33:08 -0800 (PST) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/5] Let phex and phex_nz handle sizeof_l==1 Date: Mon, 28 Feb 2022 11:33:02 -0700 Message-Id: <20220228183304.1162089-4-tromey@adacore.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220228183304.1162089-1-tromey@adacore.com> References: <20220228183304.1162089-1-tromey@adacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Feb 2022 18:33:10 -0000 Currently, neither phex nor phex_nz handle sizeof_l==1 -- they let this case fall through to the default case. However, a subsequent patch in this series needs this case to work correctly. I looked at all calls to these functions that pass a 1 for the sizeof_l parameter. The only such case seems to be correct with this change. --- gdbsupport/print-utils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc index 0ef8cb829a1..73ff1afda30 100644 --- a/gdbsupport/print-utils.cc +++ b/gdbsupport/print-utils.cc @@ -168,6 +168,10 @@ phex (ULONGEST l, int sizeof_l) str = get_print_cell (); xsnprintf (str, PRINT_CELL_SIZE, "%04x", (unsigned short) (l & 0xffff)); break; + case 1: + str = get_print_cell (); + xsnprintf (str, PRINT_CELL_SIZE, "%02x", (unsigned short) (l & 0xff)); + break; default: str = phex (l, sizeof (l)); break; @@ -206,6 +210,10 @@ phex_nz (ULONGEST l, int sizeof_l) str = get_print_cell (); xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xffff)); break; + case 1: + str = get_print_cell (); + xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xff)); + break; default: str = phex_nz (l, sizeof (l)); break; -- 2.31.1