public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
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	[thread overview]
Message-ID: <20221128184042.3781569-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20221128184042.3781569-1-simon.marchi@efficios.com>

From: Tiezhu Yang <yangtiezhu@loongson.cn>

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>
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.
-- 
2.38.1


  reply	other threads:[~2022-11-28 18:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 18:40 [PATCH gdb-12-branch 0/6] Backport fixes for PR 28275 to gdb-12-branch Simon Marchi
2022-11-28 18:40 ` Simon Marchi [this message]
2022-11-28 18:40 ` [PATCH gdb-12-branch 2/6] gdb/testsuite: remove global declarations in gdb.threads/detach-step-over.exp Simon Marchi
2022-11-28 18:40 ` [PATCH gdb-12-branch 3/6] gdb/testsuite: refactor gdb.threads/detach-step-over.exp Simon Marchi
2022-11-28 18:40 ` [PATCH gdb-12-branch 4/6] gdb: fix assert when quitting GDB while a thread is stepping Simon Marchi
2022-11-28 18:40 ` [PATCH gdb-12-branch 5/6] gdbserver: switch to right process in find_one_thread Simon Marchi
2022-11-28 18:40 ` [PATCH gdb-12-branch 6/6] gdb: disable commit resumed in target_kill Simon Marchi
2022-11-30 16:20 ` [PATCH gdb-12-branch 0/6] Backport fixes for PR 28275 to gdb-12-branch Tom Tromey
2022-12-01 15:07   ` Simon Marchi

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=20221128184042.3781569-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@sourceware.org \
    --cc=yangtiezhu@loongson.cn \
    /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).