From patchwork Mon Nov 28 18:40:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 61181 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA7473853D4E for ; Mon, 28 Nov 2022 18:41:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA7473853D4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669660886; bh=d7KIMio0lDGzHegbUc7OL3/DFDZe/ct0DsnV/24NGnk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=aQpYJi6jqZwUoXVQioykCgTi9QGS8jGnfwQVnK/JYwPljzPecNfVK7L87J01dZJXu DU86TbjETcke0G5diRhag1g4cNxLESXH1yYYR+Ojsu5Jhig9k8hz0NsBKHH8FibryC YXXUiQsA3iAFEUVpLKPCw/bByH8TJbWVoVNEvGnE= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 1F3E2385841D for ; Mon, 28 Nov 2022 18:40:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F3E2385841D X-ASG-Debug-ID: 1669660845-0c856e02a143f580001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id xJmL904Xz5E9saql (version=TLSv1 cipher=AES128-SHA bits=128 verify=NO); Mon, 28 Nov 2022 13:40:45 -0500 (EST) X-Barracuda-Envelope-From: simon.marchi@efficios.com X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from epycamd.internal.efficios.com (192-222-180-24.qc.cable.ebox.net [192.222.180.24]) by smtp.ebox.ca (Postfix) with ESMTP id 20923441D65; Mon, 28 Nov 2022 13:40:45 -0500 (EST) X-Barracuda-RBL-IP: 192.222.180.24 X-Barracuda-Effective-Source-IP: 192-222-180-24.qc.cable.ebox.net[192.222.180.24] X-Barracuda-Apparent-Source-IP: 192.222.180.24 To: gdb-patches@sourceware.org Cc: Tiezhu Yang Subject: [PATCH gdb-12-branch 1/6] gdb: testsuite: add new gdb_attach to check "attach" command Date: Mon, 28 Nov 2022 13:40:37 -0500 X-ASG-Orig-Subj: [PATCH gdb-12-branch 1/6] gdb: testsuite: add new gdb_attach to check "attach" command Message-Id: <20221128184042.3781569-2-simon.marchi@efficios.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221128184042.3781569-1-simon.marchi@efficios.com> References: <20221128184042.3781569-1-simon.marchi@efficios.com> MIME-Version: 1.0 X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1669660845 X-Barracuda-Encrypted: AES128-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 1418 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=5.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.102463 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Spam-Status: No, score=-3498.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, 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 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-Patchwork-Original-From: Simon Marchi via Gdb-patches From: Simon Marchi Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" From: Tiezhu Yang This commit adds new gdb_attach to centralize the failure checking of "attach" command. Return 0 if attach failed, otherwise return 1. Signed-off-by: Tiezhu Yang Change-Id: I553cf386cef60c67d38e331904b4aa01e132104a --- gdb/testsuite/lib/gdb.exp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 6f6acfe188a..819dfbfafca 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5151,6 +5151,32 @@ gdb_caching_proc can_spawn_for_attach { return 1 } +# Centralize the failure checking of "attach" command. +# Return 0 if attach failed, otherwise return 1. + +proc gdb_attach { testpid args } { + parse_args { + {pattern ""} + } + + if { [llength $args] != 0 } { + error "Unexpected arguments: $args" + } + + gdb_test_multiple "attach $testpid" "attach" { + -re -wrap "Attaching to.*ptrace: Operation not permitted\\." { + unsupported "$gdb_test_name (Operation not permitted)" + return 0 + } + -re -wrap "$pattern" { + pass $gdb_test_name + return 1 + } + } + + return 0 +} + # Kill a progress previously started with spawn_wait_for_attach, and # reap its wait status. PROC_SPAWN_ID is the spawn id associated with # the process.