summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/catch-syscall.exp
diff options
context:
space:
mode:
authorGabriel Krisman Bertazi <gabriel@krisman.be>2013-12-19 17:01:49 -0200
committerSergio Durigan Junior <sergiodj@redhat.com>2013-12-19 17:01:49 -0200
commit4924df7977f97475c93709bd3119f3b83d84bc6a (patch)
tree67e55d849448a26c32c45ebcfb43e91ec34eb73c /gdb/testsuite/gdb.base/catch-syscall.exp
parent3f10b67a597334c1f7459ba696d40925fa7f4ae3 (diff)
Fix PR breakpoints/16297: catch syscall with syscall 0
Code rationale ============== by: Gabriel Krisman Bertazi This is a fix for bug 16297. The problem occurs when the user attempts to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was not able to catch the syscall and was missing the breakpoint. Now, breakpoint_hit_catch_syscall returns immediately when it finds the correct syscall number, avoiding a following check for the end of the search vector, that returns a no hit if the syscall number was zero. Testcase rationale ================== by: Sergio Durigan Junior This testcase is a little difficult to write. By doing a quick inspection at the Linux source, one can see that, in many targets, the syscall number 0 is restart_syscall, which is forbidden to be called from userspace. Therefore, on many targets, there's just no way to test this safely. My decision was to take the simpler route and just adds the "read" syscall on the default test. Its number on x86_64 is zero, which is "good enough" since many people here do their tests on x86_64 anyway and it is a popular architecture. However, there was another little gotcha. When using "read" passing 0 as the third parameter (i.e., asking it to read 0 bytes), current libc implementations could choose not to effectively call the syscall. Therefore, the best solution was to create a temporary pipe, write 1 byte into it, and then read this byte from it. gdb/ChangeLog 2013-12-19 Gabriel Krisman Bertazi <gabriel@krisman.be> PR breakpoints/16297 * breakpoint.c (breakpoint_hit_catch_syscall): Return immediately when expected syscall is hit. gdb/testsuite/ChangeLog 2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/16297 * gdb.base/catch-syscall.c (read_syscall, pipe_syscall) (write_syscall): New variables. (main): Create a pipe, write 1 byte in it, and read 1 byte from it. * gdb.base/catch-syscall.exp (all_syscalls): Include "pipe, "write" and "read" syscalls. (fill_all_syscalls_numbers): Improve the way to obtain syscalls numbers.
Diffstat (limited to 'gdb/testsuite/gdb.base/catch-syscall.exp')
-rw-r--r--gdb/testsuite/gdb.base/catch-syscall.exp11
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp
index fd7d2dba65..5925419f08 100644
--- a/gdb/testsuite/gdb.base/catch-syscall.exp
+++ b/gdb/testsuite/gdb.base/catch-syscall.exp
@@ -47,7 +47,7 @@ if { [prepare_for_testing ${testfile}.exp $testfile ${testfile}.c] } {
# All (but the last) syscalls from the example code
# They are ordered according to the file, so do not change this.
-set all_syscalls { "close" "chroot" }
+set all_syscalls { "close" "chroot" "pipe" "write" "read" }
set all_syscalls_numbers { }
# The last syscall (exit()) does not return, so
@@ -392,11 +392,12 @@ proc do_syscall_tests_without_xml {} {
# This procedure fills the vector "all_syscalls_numbers" with the proper
# numbers for the used syscalls according to the architecture.
proc fill_all_syscalls_numbers {} {
- global all_syscalls_numbers last_syscall_number
+ global all_syscalls_numbers last_syscall_number all_syscalls
+
+ foreach syscall $all_syscalls {
+ lappend all_syscalls_numbers [get_integer_valueof "${syscall}_syscall" -1]
+ }
- set close_syscall [get_integer_valueof "close_syscall" -1]
- set chroot_syscall [get_integer_valueof "chroot_syscall" -1]
- set all_syscalls_numbers [list $close_syscall $chroot_syscall]
set last_syscall_number [get_integer_valueof "exit_group_syscall" -1]
}