From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 8CEB83858023 for ; Mon, 31 Jan 2022 14:34:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8CEB83858023 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 20VEYOl0024530 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 31 Jan 2022 09:34:28 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 20VEYOl0024530 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 1E71F1ECEB; Mon, 31 Jan 2022 09:34:23 -0500 (EST) Message-ID: <0a218fa8-83f4-7299-9b03-eba6f17b01bf@polymtl.ca> Date: Mon, 31 Jan 2022 09:34:23 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v6 16/25] AArch64: Add unit testing for logical tag set/get operations Content-Language: en-US To: Luis Machado , gdb-patches@sourceware.org References: <20210322132120.1202230-1-luis.machado@linaro.org> <20210322132120.1202230-17-luis.machado@linaro.org> From: Simon Marchi In-Reply-To: <20210322132120.1202230-17-luis.machado@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 31 Jan 2022 14:34:24 +0000 X-Spam-Status: No, score=-3039.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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, 31 Jan 2022 14:34:33 -0000 On 2021-03-22 09:21, Luis Machado via Gdb-patches wrote: > Update on v4: > > - Adjust function names. > > -- > > Add some unit testing to exercise setting/getting logical tags in the > AArch64 implementation. > > gdb/ChangeLog: > > YYYY-MM-DD Luis Machado > > * aarch64-linux-tdep.c: Include gdbsupport/selftest.h. > (aarch64_linux_ltag_tests): New function. > (_initialize_aarch64_linux_tdep): Register aarch64_linux_ltag_tests. > --- > gdb/aarch64-linux-tdep.c | 31 +++++++++++++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c > index 29440a8510c..9434f90e8f6 100644 > --- a/gdb/aarch64-linux-tdep.c > +++ b/gdb/aarch64-linux-tdep.c > @@ -51,6 +51,8 @@ > #include "arch-utils.h" > #include "value.h" > > +#include "gdbsupport/selftest.h" > + > /* Signal frame handling. > > +------------+ ^ > @@ -1942,10 +1944,39 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) > set_gdbarch_gcc_target_options (gdbarch, aarch64_linux_gcc_target_options); > } > > +#if GDB_SELF_TEST > + > +namespace selftests { > + > +/* Verify functions to read and write logical tags. */ > + > +static void > +aarch64_linux_ltag_tests (void) > +{ > + /* We have 4 bits of tags, but we test writing all the bits of the top > + byte of address. */ > + for (int i = 0; i < 1 << 8; i++) > + { > + CORE_ADDR addr = ((CORE_ADDR) i << 56) | 0xdeadbeef; > + SELF_CHECK (aarch64_mte_get_ltag (addr) == (i & 0xf)); > + > + addr = aarch64_mte_set_ltag (0xdeadbeef, i); > + SELF_CHECK (addr = ((CORE_ADDR) (i & 0xf) << 56) | 0xdeadbeef); Hi Luis, I ran clang-tidy on this file, got: /home/smarchi/build/binutils-gdb-clang/gdb/../../../src/binutils-gdb/gdb/aarch64-linux-tdep.c:2060:7: warning: Value stored to 'addr' is never read [clang-analyzer-deadcode.DeadStores] addr = aarch64_mte_set_ltag (0xdeadbeef, i); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/smarchi/build/binutils-gdb-clang/gdb/../../../src/binutils-gdb/gdb/aarch64-linux-tdep.c:2060:7: note: Value stored to 'addr' is never read addr = aarch64_mte_set_ltag (0xdeadbeef, i); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ I guess it should be == and not = in the SELF_CHECK? Simon