aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2022-03-17 10:55:35 +0800
committerTiezhu Yang <yangtiezhu@loongson.cn>2022-03-23 11:56:46 +0800
commitf629ad7dac5ff2d7ee92791071b731096dfa1eb5 (patch)
treed4109f42ad6b0db4f5030caef6127d48307e8c8e /gdb/testsuite
parent5b5442fbf0fab8bd3cb4d19e564b13501f547dac (diff)
downloadfsf-binutils-gdb-f629ad7dac5ff2d7ee92791071b731096dfa1eb5.zip
fsf-binutils-gdb-f629ad7dac5ff2d7ee92791071b731096dfa1eb5.tar.gz
fsf-binutils-gdb-f629ad7dac5ff2d7ee92791071b731096dfa1eb5.tar.bz2
gdb: testsuite: use gdb_attach to fix jit-elf.exp
If /proc/sys/kernel/yama/ptrace_scope is 1, when execute the following command without superuser: make check-gdb TESTS="gdb.base/jit-elf.exp" we can see the following messages in gdb/testsuite/gdb.log: (gdb) attach 1650108 Attaching to program: /home/yangtiezhu/build/gdb/testsuite/outputs/gdb.base/jit-elf/jit-elf-main, process 1650108 ptrace: Operation not permitted. (gdb) FAIL: gdb.base/jit-elf.exp: attach: one_jit_test-2: break here 1: attach use gdb_attach to fix the above issue, at the same time, the clean_reattach proc should return a value to indicate whether it worked, and the callers should return early as well on failure. Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.base/jit-elf.exp24
1 files changed, 16 insertions, 8 deletions
diff --git a/gdb/testsuite/gdb.base/jit-elf.exp b/gdb/testsuite/gdb.base/jit-elf.exp
index 8a4c5b7..4b75188 100644
--- a/gdb/testsuite/gdb.base/jit-elf.exp
+++ b/gdb/testsuite/gdb.base/jit-elf.exp
@@ -38,6 +38,7 @@ set jit_solib_basename jit-elf-solib
set jit_solib_srcfile ${srcdir}/${subdir}/${jit_solib_basename}.c
# Detach, restart GDB, and re-attach to the program.
+# Return 0 if attach failed, otherwise return 1.
proc clean_reattach {} {
global decimal gdb_prompt
global main_binfile main_srcfile
@@ -57,18 +58,18 @@ proc clean_reattach {} {
clean_restart ${main_binfile}
- set test "attach"
- gdb_test_multiple "attach $testpid" "$test" {
- -re "Attaching to program.*.*main.*at .*$main_srcfile:.*$gdb_prompt $" {
- pass "$test"
- }
+ if { ![gdb_attach $testpid \
+ -pattern "main.*at .*$::main_srcfile:.*"] } {
+ return 0
}
gdb_test_no_output "set var wait_for_gdb = 0"
+ return 1
}
# Continue to LOCATION in the program. If REATTACH, detach and
# re-attach to the program from scratch.
+# Return 0 if clean_reattach failed, otherwise return 1.
proc continue_to_test_location {location reattach} {
global main_srcfile
@@ -76,9 +77,12 @@ proc continue_to_test_location {location reattach} {
gdb_continue_to_breakpoint $location
if {$reattach} {
with_test_prefix "$location" {
- clean_reattach
+ if { ![clean_reattach] } {
+ return 0
+ }
}
}
+ return 1
}
proc one_jit_test {jit_solibs_target match_str reattach} {
@@ -114,7 +118,9 @@ proc one_jit_test {jit_solibs_target match_str reattach} {
gdb_continue_to_breakpoint "break here 0"
- continue_to_test_location "break here 1" $reattach
+ if { ![continue_to_test_location "break here 1" $reattach] } {
+ return
+ }
gdb_test "info function ^jit_function" "$match_str"
@@ -124,7 +130,9 @@ proc one_jit_test {jit_solibs_target match_str reattach} {
gdb_test "maintenance info break"
}
- continue_to_test_location "break here 2" $reattach
+ if { ![continue_to_test_location "break here 2" $reattach] } {
+ return
+ }
# All jit librares must have been unregistered
gdb_test "info function jit_function" \