]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: testsuite: add new gdb_attach to check "attach" command
authorTiezhu Yang <yangtiezhu@loongson.cn>
Thu, 17 Mar 2022 02:22:14 +0000 (10:22 +0800)
committerSimon Marchi <simon.marchi@efficios.com>
Thu, 1 Dec 2022 15:01:43 +0000 (10:01 -0500)
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

index 6f6acfe188af67e8900e560a16f9f4c71799640b..819dfbfafca44df55e386b09d45ef1ea93eb8d01 100644 (file)
@@ -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.