public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tiezhu Yang <yangtiezhu@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: testsuite: add new gdb_attach to check "attach" command
Date: Wed, 23 Mar 2022 03:59:02 +0000 (GMT)	[thread overview]
Message-ID: <20220323035902.0C5433857C49@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a7e6a19e87f3d719ea23c65b580a6d9bca4ccab3

commit a7e6a19e87f3d719ea23c65b580a6d9bca4ccab3
Author: Tiezhu Yang <yangtiezhu@loongson.cn>
Date:   Thu Mar 17 10:22:14 2022 +0800

    gdb: testsuite: add new gdb_attach to check "attach" command
    
    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 <yangtiezhu@loongson.cn>

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
 }
 
+# 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.


                 reply	other threads:[~2022-03-23  3:59 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220323035902.0C5433857C49@sourceware.org \
    --to=yangtiezhu@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).