From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cTKfBAFN1mqbODMAWB0awg (envelope-from ) for ; Mon, 19 Oct 2026 13:01:53 -0400 Received: by simark.ca (Postfix, from userid 112) id 0F5EA1E050; Mon, 19 Oct 2026 13:01:53 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 3BB9C1E04F for ; Mon, 19 Oct 2026 13:01:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65D514BA23D1 for ; Mon, 19 Oct 2026 17:01:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65D514BA23D1 Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 6C7354BA23D5; Mon, 19 Oct 2026 16:59:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C7354BA23D5 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6C7354BA23D5 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792429176; cv=none; b=RHuSyel6RmFhbBZNb80HQraa5x2jg2H+HUG9FpPQDNhDGlQonIsE0NQrnDKM6phEoRTcTSn/tQ0E0r1lVJetY+mV1T8mbbr0+iv63v2MXmSHErrdCaKSnNs1ZN1VB5wP+CbPfqUjlN0Ps4U2mariHbHVfMdPfUXdHvRaPvQgo6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792429176; c=relaxed/simple; bh=EYF3hUJllEgTYxH0h/LHT9nHLOI/6Syh1HRVDZ7JqAo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Qbna5KQOASPzSiGIbBGwIPjYn//HA3k8p54qZsPItUt8qZAqkSwGsvZyiZxSKArU0SpIl+v4XsRVeM9DocVk0+Rg+6PcVUphlQ+9NEyC80U23zKLy/Nz2RdEgnmUPFu8dh2Q8R2x8VEpvjwZepQmV4eNdE1157067daD/sbql+g= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C7354BA23D5 Received: by simark.ca (Postfix) id 8B92C1E09E; Mon, 19 Oct 2026 12:59:35 -0400 (EDT) From: Simon Marchi To: gcc-patches@sourceware.org, gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 6/6] gdb: remove manual printing of values in some selftests Date: Mon, 19 Oct 2026 12:58:22 -0400 Message-ID: <20261019165929.792697-7-simon.marchi@efficios.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261019165929.792697-1-simon.marchi@efficios.com> References: <20261019165929.792697-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Now that SELF_CHECK prints the values of the operands of a failing comparison, some selftests no longer need to print them by hand. - split-name.c: check_split_name prints the result and expected components on failure. Remove that, and components_to_string, which is now unused. - disasm-selftests.c: disassemble_insn prints the expected string on failure. Remove that. Keep printing the instruction bytes, which give context. - remote-arg-selftests.c: the test counts failures, prints the split and joined arguments in verbose mode, and checks the failure count at the end. Replace that with a SELF_CHECK for each comparison. Keep printing the input in verbose mode. The test now stops at the first failing case, like most selftests. Change-Id: I1e4cc3da7e607c36bb0d67ef9562bb8216a2d42f --- gdb/disasm-selftests.c | 9 +--- gdb/split-name.c | 28 ------------ gdb/unittests/remote-arg-selftests.c | 65 ++-------------------------- 3 files changed, 6 insertions(+), 96 deletions(-) diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 1aa399a57d4a..9bd9e497b533 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -401,19 +401,14 @@ disassemble_insn (gdbarch *gdbarch, gdb::byte_vector &insn, std::string buffer = disassemble_one_insn_to_string (gdbarch, insn); - bool check_ok = buffer == expected; - - if (run_verbose () || !check_ok) + if (run_verbose () || buffer != expected) { for (gdb_byte b : insn) debug_printf ("0x%02x ", b); debug_printf ("-> %s\n", buffer.c_str ()); } - if (!check_ok) - debug_printf ("expected: %s\n", expected.c_str ()); - - SELF_CHECK (check_ok); + SELF_CHECK (buffer == expected); } } /* namespace selftests */ diff --git a/gdb/split-name.c b/gdb/split-name.c index b8605c4040f4..ea71e0589d1b 100644 --- a/gdb/split-name.c +++ b/gdb/split-name.c @@ -19,7 +19,6 @@ #include "split-name.h" #include "cp-support.h" -#include "gdbsupport/enumerate.h" #include "gdbsupport/selftest.h" /* See split-name.h. */ @@ -82,27 +81,6 @@ split_name (const char *name, split_style style) namespace selftests { -/* Return a string representation of COMPONENTS, for debugging. */ - -static std::string -components_to_string (const std::vector &components) -{ - std::string str = "{"; - - for (auto [i, component] : gdb::ranges::views::enumerate (components)) - { - if (i > 0) - str += ","; - - str += " \""; - str += component; - str += "\""; - } - - str += " }"; - return str; -} - /* Check that splitting NAME using STYLE gives EXPECTED. */ static void @@ -110,12 +88,6 @@ check_split_name (const char *name, split_style style, const std::vector &expected) { std::vector result = split_name (name, style); - - if (result != expected) - debug_printf ("split_name (\"%s\"): got %s, expected %s\n", name, - components_to_string (result).c_str (), - components_to_string (expected).c_str ()); - SELF_CHECK (result == expected); } diff --git a/gdb/unittests/remote-arg-selftests.c b/gdb/unittests/remote-arg-selftests.c index e55a7185c618..a306925c48dd 100644 --- a/gdb/unittests/remote-arg-selftests.c +++ b/gdb/unittests/remote-arg-selftests.c @@ -82,7 +82,6 @@ arg_test_desc desc[] = { static void self_test () { - int failure_count = 0; for (const auto &d : desc) { if (run_verbose ()) @@ -94,50 +93,11 @@ self_test () /* Split argument string into individual arguments. */ std::vector split_args = gdb::remote_args::split (d.input); - - if (run_verbose ()) - { - debug_printf ("Split:\n"); - - size_t len = std::max (split_args.size (), d.split.size ()); - for (size_t i = 0; i < len; ++i) - { - const char *got = "N/A"; - const char *expected = got; - - if (i < split_args.size ()) - got = split_args[i].c_str (); - - if (i < d.split.size ()) - expected = d.split[i].c_str (); - - debug_printf (" got (%s), expected (%s)\n", got, expected); - } - } - - if (split_args != d.split) - { - ++failure_count; - if (run_verbose ()) - debug_printf ("FAIL\n"); - continue; - } + SELF_CHECK (split_args == d.split); /* Now join the arguments. */ - std::string joined_args - = gdb::remote_args::join (split_args); - - if (run_verbose ()) - debug_printf ("Joined (%s), expected (%s)\n", - joined_args.c_str (), d.joined.c_str ()); - - if (joined_args != d.joined) - { - ++failure_count; - if (run_verbose ()) - debug_printf ("FAIL\n"); - continue; - } + std::string joined_args = gdb::remote_args::join (split_args); + SELF_CHECK (joined_args == d.joined); /* The contents of JOINED_ARGS will not be identical to D.INPUT. There are multiple ways that an argument can be escaped, and our @@ -146,25 +106,8 @@ self_test () SPLIT_ARGS. So test that next. */ std::vector split_args_v2 = gdb::remote_args::split (joined_args); - - if (split_args_v2 != split_args) - { - ++failure_count; - if (run_verbose ()) - { - debug_printf ("Re-split:\n"); - for (const auto &a : split_args_v2) - debug_printf (" got (%s)\n", a.c_str ()); - debug_printf ("FAIL\n"); - } - continue; - } - - if (run_verbose ()) - debug_printf ("PASS\n"); + SELF_CHECK (split_args_v2 == split_args); } - - SELF_CHECK (failure_count == 0); } } /* namespace remote_args_tests */ -- 2.56.0