From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yJqOHWLLEWCGTwAAWB0awg (envelope-from ) for ; Wed, 27 Jan 2021 15:21:54 -0500 Received: by simark.ca (Postfix, from userid 112) id B88541EF84; Wed, 27 Jan 2021 15:21:53 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 38F331E590 for ; Wed, 27 Jan 2021 15:21:50 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 669B8398B853; Wed, 27 Jan 2021 20:21:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 669B8398B853 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611778907; bh=Ho5/e/NFgEC1HF8XaqxEa6lj2qD22wAnkpilrDsUO3I=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DrzXq2rxYj5+RbWsdetHrQE92ncMHE2PdfAlAOzGV4VmCn4YiSgCYUBBQ3kwl1hUa 1EBqxxcAHVfNQOi+oeAetlo7l4OPSduvrICI67quS0UBMm39UYJI6lzOTDw8NbNIuU uluSbm8Nyf90aQPa5+ES1SitaX2Nbu6JMUOl07vs= Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 5E259398B83E for ; Wed, 27 Jan 2021 20:21:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5E259398B83E Received: by mail-qk1-x731.google.com with SMTP id l27so3074093qki.9 for ; Wed, 27 Jan 2021 12:21:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ho5/e/NFgEC1HF8XaqxEa6lj2qD22wAnkpilrDsUO3I=; b=ke3or5Df2riq2+xDz8IFMLORMBiMIRDnGcAnDVRA4wZg7MkXEpn+PsL4wtFwXV/zT1 4wak8SUqELKy0krMmQlZNJircqXDt7HG5+jCNohbazDM1kZy7wxnz6TKVDuPJWYZgni/ nRJmgvcan82zGL6U3GDDMXxIDG9CH0TLP+OJiO+z1+J52uxZjoxeYWNo/uDE+zSI+HE8 jwN3q9dUUSkHGEdMWNUIr1OVuHUZaq1mXgBxHAXZBw3JBid0RWxoAeQtUQzQ5l0UjGjg VERXO8T7p8I4vohorFpPaN8KIS7lgy7+8kujczYqhSNH7aRoRXJDLET1C3bCdYTOcI49 uz/w== X-Gm-Message-State: AOAM5336oK6oO6cUjWGTwVvrubL7JT486DhElsUM8U+6h/0KVMINHCfp YldR7b507NRqAdBdxxNJnrNPqlalW0/8HQ== X-Google-Smtp-Source: ABdhPJwqC2z8DnL46vo4TRcT3IyPxrv4cx0m3HDrUpTUf04xhD4bTJxbvuQrjSmx2DDz8+wJgz68Lg== X-Received: by 2002:a05:620a:145a:: with SMTP id i26mr12123092qkl.346.1611778903940; Wed, 27 Jan 2021 12:21:43 -0800 (PST) Received: from localhost.localdomain ([2804:7f0:8284:874d:b82c:87fc:4324:adab]) by smtp.gmail.com with ESMTPSA id b194sm1854531qkc.102.2021.01.27.12.21.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Jan 2021 12:21:43 -0800 (PST) To: gdb-patches@sourceware.org Subject: [PATCH v5 16/25] AArch64: Add unit testing for logical tag set/get operations Date: Wed, 27 Jan 2021 17:21:03 -0300 Message-Id: <20210127202112.2485702-17-luis.machado@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210127202112.2485702-1-luis.machado@linaro.org> References: <20210127202112.2485702-1-luis.machado@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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 2fe88cf016..1063dd7a82 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -50,6 +50,8 @@ #include "arch-utils.h" #include "value.h" +#include "gdbsupport/selftest.h" + /* Signal frame handling. +------------+ ^ @@ -1955,10 +1957,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); + } +} + +} // namespace selftests +#endif /* GDB_SELF_TEST */ + void _initialize_aarch64_linux_tdep (); void _initialize_aarch64_linux_tdep () { gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX, aarch64_linux_init_abi); + +#if GDB_SELF_TEST + selftests::register_test ("aarch64-linux-tagged-address", + selftests::aarch64_linux_ltag_tests); +#endif } -- 2.25.1