From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7873) id 0C5433857C49; Wed, 23 Mar 2022 03:59:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C5433857C49 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tiezhu Yang To: gdb-cvs@sourceware.org Subject: [binutils-gdb] 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/master X-Git-Oldrev: 11c19d73c35e6ce74a51302233199ddaa9551f09 X-Git-Newrev: a7e6a19e87f3d719ea23c65b580a6d9bca4ccab3 Message-Id: <20220323035902.0C5433857C49@sourceware.org> Date: Wed, 23 Mar 2022 03:59:02 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Mar 2022 03:59:02 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Da7e6a19e87f3= d719ea23c65b580a6d9bca4ccab3 commit a7e6a19e87f3d719ea23c65b580a6d9bca4ccab3 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 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 892bf07266e..d8015fb92ec 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -5143,6 +5143,32 @@ 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.