# 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'\\."
require allow_shlib_tests
+set supports_catch_syscall [supports_catch_syscall]
+
load_lib mi-support.exp
standard_testfile pending.c
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
# 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}"
}
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 {} {