From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 8A7B03858D32; Thu, 1 Dec 2022 15:07:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A7B03858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669907222; bh=xyMoHLfUq/IXh2Vz8qtTKEDz5IT5TThnKw7ysVGH5BM=; h=From:To:Subject:Date:From; b=nOCfyP3nGk7PmUT1gfRq8Os7h0bLl6gChSdYA+8y7VeVToKsDQmzyjeLDonAk5ow1 AYZYutGs4J+6qFP1+tVR/nVBIAG0lnGnFarP/SQrog2lS/YNYy0cvEll1vOijEBK1K ZBuLIa4SANb1G6keXv4O9rqYBxPNLbzkS2KQ2Q14= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb/gdb-12-branch] gdb: testsuite: add new gdb_attach to check "attach" command X-Act-Checkin: binutils-gdb X-Git-Author: Tiezhu Yang X-Git-Refname: refs/heads/gdb-12-branch X-Git-Oldrev: e15378735d3a7d17890bd811a4c6f746fdc00ce5 X-Git-Newrev: 5091924da94bf68d4301a93fe848bf2c4a674f36 Message-Id: <20221201150702.8A7B03858D32@sourceware.org> Date: Thu, 1 Dec 2022 15:07:02 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D5091924da94b= f68d4301a93fe848bf2c4a674f36 commit 5091924da94bf68d4301a93fe848bf2c4a674f36 Author: Tiezhu Yang Date: Thu Mar 17 10:22:14 2022 +0800 gdb: testsuite: add new gdb_attach to check "attach" command =20 This commit adds new gdb_attach to centralize the failure checking of "attach" command. Return 0 if attach failed, otherwise return 1. =20 Signed-off-by: Tiezhu Yang Change-Id: I553cf386cef60c67d38e331904b4aa01e132104a Diff: --- 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 } =20 +# 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] !=3D 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.