[gdb/testsuite] Handle unsupported catch syscall

On riscv64-linux, I run into:
...
Expecting: ^(catch syscall[^M
]+)?((&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done[^M
]+[(]gdb[)] ^M
[ ]*)
catch syscall^M
&"catch syscall\n"^M
&"The feature 'catch syscall' is not supported on this architecture yet.\n"^M
^error,msg="The feature 'catch syscall' is not supported on this architecture yet."^M
(gdb) ^M
FAIL: gdb.mi/mi-breakpoint-changed.exp: test_insert_delete_modify: catch syscall (unexpected output)
...

Fix this by:
- factoring out proc supports_catch_syscall out of gdb.base/catch-syscall.exp,
  and
- using it in gdb.mi/mi-breakpoint-changed.exp.

Tested on x86_64-linux and riscv64-linux.

Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Tom de Vries
2024-08-31 07:56:48 +02:00
parent d5de35fb07
commit 1a86b364a3
3 changed files with 75 additions and 28 deletions

View File

@@ -19,39 +19,18 @@
# It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
# on September/2008.
require supports_catch_syscall
standard_testfile
if { [prepare_for_testing "failed to prepare" $testfile ${testfile}.c] } {
return -1
}
# Check target supports catch syscall or not.
if {![runto_main]} {
return
}
set test "catch syscall"
gdb_test_multiple $test $test {
-re "The feature \'catch syscall\' is not supported.*\r\n$gdb_prompt $" {
unsupported "catch syscall isn't supported"
return -1
}
-re ".*$gdb_prompt $" {
pass $test
}
}
set test "check catch syscall"
gdb_test_multiple "continue" $test {
-re ".*Your system does not support this type\r\nof catchpoint.*$gdb_prompt $" {
unsupported "catch syscall isn't supported"
return -1
}
-re ".*Catchpoint.*$gdb_prompt $" {
pass $test
}
}
# Test-case for PR27313. Verify that negative syscall numbers are refused.
gdb_test "catch syscall -1" "Unknown syscall number '-1'\\."

View File

@@ -15,6 +15,8 @@
require allow_shlib_tests
set supports_catch_syscall [supports_catch_syscall]
load_lib mi-support.exp
standard_testfile pending.c
@@ -85,17 +87,34 @@ proc test_insert_delete_modify { } {
mi_gdb_test ${test} \
{(&.*)*.*~".*atchpoint 3: .*\\n".*=breakpoint-created,bkpt=\{number="3",type="(hw |)watchpoint".*\}.*\n\^done} \
$test
set test "trace marker"
mi_gdb_test $test \
{(&.*)*.*~"Tracepoint 4 at .*\\n".*=breakpoint-created,bkpt=\{number="4",type="tracepoint".*\}.*\n\^done} \
$test
set test "catch syscall"
mi_gdb_test $test \
{(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \
$test
if { $::supports_catch_syscall } {
mi_gdb_test $test \
{(&.*)*.*~"Catchpoint 5 .*\\n".*=breakpoint-created,bkpt=\{number="5",type="catchpoint".*\}.*\n\^done} \
$test
set bp_nr 6
} else {
unsupported $test
set bp_nr 5
}
set test "dprintf marker, \"arg\" \""
set bp_re [mi_make_breakpoint \
-number $bp_nr \
-type dprintf \
-func marker \
-script [string_to_regexp {["printf \"arg\" \""]}]]
mi_gdb_test $test \
{.*=breakpoint-created,bkpt=\{number="6",type="dprintf".*,script=\[\"printf \\\"arg\\\" \\\"\"\].*\}\r\n\^done} \
[multi_line \
".*" \
"=breakpoint-created,${bp_re}" \
"\\^done"] \
$test
# 2. when modifying condition
@@ -143,7 +162,7 @@ proc test_insert_delete_modify { } {
# Delete some breakpoints and verify that '=breakpoint-deleted
# notification is correctly emitted.
for {set i 3} {$i < 7} {incr i} {
for {set i 3} {$i <= $bp_nr} {incr i} {
mi_gdb_test "delete ${i}" ".*=breakpoint-deleted,id=\"${i}\".*\\^done" \
"delete ${i}"
}

View File

@@ -3568,6 +3568,55 @@ gdb_caching_proc supports_memtag {} {
return 0
}
# Return 1 if catch syscall is supported, otherwise return 0.
gdb_caching_proc supports_catch_syscall {} {
set me "supports_catch_syscall"
# Compile a test program.
set src {
int main() {
return 0;
}
}
if {![gdb_simple_compile $me $src executable]} {
verbose -log "$me: failed to compile"
return 0
}
# No error message, compilation succeeded so now run it via gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $::srcdir/$::subdir
gdb_load $obj
if { ![runto_main] } {
verbose -log "$me: failed to run to main"
return 0
}
# To make sure we test both setting and inserting the catchpoint.
gdb_test_no_output "set breakpoint always-inserted on"
set res 0
set re_yes \
[string_to_regexp \
"Catchpoint 2 (any syscall)"]
gdb_test_multiple "catch syscall" "" {
-re -wrap ^$re_yes {
set res 1
}
-re -wrap "" {
}
}
gdb_exit
remote_file build delete $obj
verbose "$me: returning $res" 2
return $res
}
# Return 1 if the target supports hardware single stepping.
proc can_hardware_single_step {} {