From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3FBCC383FB86 for ; Mon, 20 Feb 2023 14:14:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3FBCC383FB86 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676902444; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8JEwUwwdIxa/gR94llCxNdbM4oAFWprhhwueizwFx+Y=; b=af0Hz1s/MtL4aQRacaZKJBFMhpUt9hTxSRHjXhr9QUlN9N0tBL3wQET9UhNN/ihpqKqtnD 7drQ+ehFBvHUYVu4pmYBbbyJatVAVwN1FY8fqW3LKSXGWCjcU1P4sfA4r/x1oSNfG2mj06 rBQDYaXBrUx6TVItusnNdHFSsdpx850= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-487-AndQXnOJMr2nb26T1SqOrg-1; Mon, 20 Feb 2023 09:14:03 -0500 X-MC-Unique: AndQXnOJMr2nb26T1SqOrg-1 Received: by mail-wr1-f72.google.com with SMTP id z6-20020a5d4c86000000b002c54ce46094so370241wrs.17 for ; Mon, 20 Feb 2023 06:14:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8JEwUwwdIxa/gR94llCxNdbM4oAFWprhhwueizwFx+Y=; b=WmEE9a2LqHFhDX0h9Klp7Z4BZlRu/zuAYxp2uMvExKXh7valZ36U6HFzsu57IZELZl gahZ1E9s9SfvHUdQJiWpJm/lfX+C1yq/VOzXLMMRDvLlwAt/R1ONWiuyDLnz8cATPuq2 nbhKeREITtMbUwz2Fs46ffJEY1HjQ4IBmGK/cvO9pNji5nnhl+cCt1rTadVTAhUAafYK QJIOqXlG9h62iZAoREmyOaj1sO1Mqa6io7NgEXKRnQPTD4nzhi4zOZZ6o2TY7QZj4mup ljvkmguLl/JIj0gK36PEenpmHwzzrceRQ8Jyj+5hHFK3fqHmOERq3tUAfXg+hsaSK3It kJZg== X-Gm-Message-State: AO0yUKXsJTD3GZ9/XWl6ofJK35BlUjtVNB/2Y2jvazY9Ddw5x2IhzXli 5utcqDlSqffGtH5A5WfUWzH+sV9jZ37SVyAIpZM6zl+KQzdzHXqdlmGK7com1nTXJDR31s/jbuA t4A0P73NR1wRIC5t0bzYOBVVEQWi0abx5gSzTBFu9EHoPszjIRLvzn2+shbTDEc7P5kEZSF/tnd I25FM= X-Received: by 2002:a5d:64ac:0:b0:2c5:4c9f:cf3b with SMTP id m12-20020a5d64ac000000b002c54c9fcf3bmr2149510wrp.7.1676902442517; Mon, 20 Feb 2023 06:14:02 -0800 (PST) X-Google-Smtp-Source: AK7set80dPHu085tEF6eQVn/tDy0Mm/E9ViN+LLOTuMv2/9edvTxpp/Lgg/cL/GNhtXCg7Co0RXPgw== X-Received: by 2002:a5d:64ac:0:b0:2c5:4c9f:cf3b with SMTP id m12-20020a5d64ac000000b002c54c9fcf3bmr2149493wrp.7.1676902442143; Mon, 20 Feb 2023 06:14:02 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id n13-20020a5d4c4d000000b002c55de1c72bsm5385536wrt.62.2023.02.20.06.14.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Feb 2023 06:14:01 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 5/8] gdb/testsuite introduce foreach_mi_ui_mode helper proc Date: Mon, 20 Feb 2023 14:13:50 +0000 Message-Id: <922925c1c55324deb567a51633fafc457afa381d.1676901929.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Introduce foreach_mi_ui_mode, a helper proc which can be used when tests are going to be repeated once with the MI in the main UI, and once with the MI on a separate UI. The proc is used like this: foreach_mi_ui_mode VAR { # BODY } The BODY will be run twice, once with VAR set to 'main' and once with VAR set to 'separate', inside BODY we can then change the behaviour based on the current UI mode. The point of this proc is that we sometimes shouldn't run the separate UI tests (when gdb_debug_enabled is true), and this proc hides all this logic. If the separate UI mode should not be used then BODY will be run just once with VAR set to 'main'. I've updated two tests that can make use of this helper proc. I'm going to add another similar test in a later commit. There should be no change to what is tested with this commit. --- gdb/testsuite/gdb.mi/mi-break.exp | 9 +------ gdb/testsuite/gdb.mi/mi-watch.exp | 9 +------ gdb/testsuite/lib/mi-support.exp | 44 +++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 16 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index 5b5d3aad2e4..3400e2e6f7c 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -419,13 +419,6 @@ proc test_break {mi_mode} { test_forced_conditions } -if [gdb_debug_enabled] { - # gdb debug doesn't work for separate-mi-tty. - set modes {"main"} -} else { - set modes {"main" "separate"} -} - -foreach_with_prefix mi-mode $modes { +foreach_mi_ui_mode mi-mode { test_break ${mi-mode} } diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp index aaac7611015..12b9781e95a 100644 --- a/gdb/testsuite/gdb.mi/mi-watch.exp +++ b/gdb/testsuite/gdb.mi/mi-watch.exp @@ -175,16 +175,9 @@ proc test_watchpoint_all {mi_mode type} { test_watchpoint_triggering } -if [gdb_debug_enabled] { - # gdb debug doesn't work for separate-mi-tty. - set modes {"main"} -} else { - set modes {"main" "separate"} -} - # Run the tests twice, once using software watchpoints, and another # with hardware watchpoints. -foreach_with_prefix mi-mode $modes { +foreach_mi_ui_mode mi-mode { foreach_with_prefix wp-type {"sw" "hw"} { test_watchpoint_all ${mi-mode} ${wp-type} } diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp index 1a0dc584a4b..2ab751749e9 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -2785,3 +2785,47 @@ proc mi_get_valueof { fmt exp default {test ""} } { } return ${val} } + +# Some MI tests should be run in the normal way, on the main UI, while +# other tests should be run twice, once when the MI is on the main UI, +# and once with the MI on a secondary UI, this proc facilitates that. +# +# Use as: +# +# foreach_mi_ui_mode mode { +# # ... body ... +# } +# +# The BODY with then be run multiple times with MODE set to either +# 'main' or 'separate'. +# +# However, there are times when we know using the 'separate' UI will +# not work. This proc handles figuring that out, if the 'separate' UI +# is known not to work then the 'separate' mode will be skipped and +# only 'main' will be run. + +proc foreach_mi_ui_mode { var_name body } { + upvar 1 $var_name var + + if [gdb_debug_enabled] { + # gdb debug doesn't work for separate-mi-tty. + set modes {"main"} + } else { + set modes {"main" "separate"} + } + + foreach var $modes { + with_test_prefix "$var_name=$var" { + set code [catch {uplevel 1 $body} result] + } + + if {$code == 1} { + global errorInfo errorCode + return -code $code -errorinfo $errorInfo -errorcode $errorCode $result + } elseif {$code == 3} { + break + } elseif {$code == 2} { + return -code $code $result + } + } +} -- 2.25.4