diff options
author | Josh Stone <jistone@redhat.com> | 2016-01-12 12:27:27 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2016-01-12 12:27:27 -0800 |
commit | 82075af2c14b1f8a54fa5796fb63f7ef23f98d9d (patch) | |
tree | 91cbb8ff3107608f7b93c82e3d0f532e5a739911 /gdb/testsuite/gdb.base/catch-syscall.exp | |
parent | 41549dfbcc747d0dc4a97c9a427c3a29e9878f05 (diff) | |
download | binutils-gdb-82075af2c14b1f8a54fa5796fb63f7ef23f98d9d.tar.gz |
Implement 'catch syscall' for gdbserver
This adds a new QCatchSyscalls packet to enable 'catch syscall', and new
stop reasons "syscall_entry" and "syscall_return" for those events. It
is currently only supported on Linux x86 and x86_64.
gdb/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the
syscall_entry and syscall_return stop reasons. Mention GDB
support for remote catch syscall.
* remote.c (PACKET_QCatchSyscalls): New enum.
(remote_set_syscall_catchpoint): New function.
(remote_protocol_features): New element for QCatchSyscalls.
(remote_parse_stop_reply): Parse syscall_entry/return stops.
(init_remote_ops): Install remote_set_syscall_catchpoint.
(_initialize_remote): Config QCatchSyscalls.
* linux-nat.h (struct lwp_info) <syscall_state>: Comment typo.
gdb/doc/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet.
(Stop Reply Packets): List the syscall entry and return stop reasons.
(General Query Packets): Describe QCatchSyscalls, and add it to the
table and the detailed list of stub features.
gdb/gdbserver/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* inferiors.h: Include "gdb_vecs.h".
(struct process_info): Add syscalls_to_catch.
* inferiors.c (remove_process): Free syscalls_to_catch.
* remote-utils.c (prepare_resume_reply): Report syscall_entry and
syscall_return stops.
* server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define.
* server.c (handle_general_set): Handle QCatchSyscalls.
(handle_query): Report support for QCatchSyscalls.
* target.h (struct target_ops): Add supports_catch_syscall.
(target_supports_catch_syscall): New macro.
* linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo.
(struct lwp_info): Add syscall_state.
* linux-low.c (handle_extended_wait): Mark syscall_state as an entry.
Maintain syscall_state and syscalls_to_catch across exec.
(get_syscall_trapinfo): New function, proxy to the_low_target.
(linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD.
(linux_low_filter_event): Toggle syscall_state entry/return for
syscall traps, and set it ignored for all others.
(gdb_catching_syscalls_p): New function.
(gdb_catch_this_syscall_p): New function.
(linux_wait_1): Handle SYSCALL_SIGTRAP.
(linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility.
(linux_supports_catch_syscall): New function.
(linux_target_ops): Install it.
* linux-x86-low.c (x86_get_syscall_trapinfo): New function.
(the_low_target): Install it.
gdb/testsuite/ChangeLog:
2016-01-12 Josh Stone <jistone@redhat.com>
Philippe Waroquiers <philippe.waroquiers@skynet.be>
* gdb.base/catch-syscall.c (do_execve): New variable.
(main): Conditionally trigger an execve.
* gdb.base/catch-syscall.exp: Enable testing for remote targets.
(test_catch_syscall_execve): New, check entry/return across execve.
(do_syscall_tests): Call test_catch_syscall_execve.
Diffstat (limited to 'gdb/testsuite/gdb.base/catch-syscall.exp')
-rw-r--r-- | gdb/testsuite/gdb.base/catch-syscall.exp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/catch-syscall.exp b/gdb/testsuite/gdb.base/catch-syscall.exp index 26fb6a513a4..5679000d82c 100644 --- a/gdb/testsuite/gdb.base/catch-syscall.exp +++ b/gdb/testsuite/gdb.base/catch-syscall.exp @@ -19,7 +19,7 @@ # It was written by Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com> # on September/2008. -if { [is_remote target] || ![isnative] } then { +if { ![isnative] } then { continue } @@ -322,6 +322,28 @@ proc test_catch_syscall_mid_vfork {} { } } +proc test_catch_syscall_execve {} { + global gdb_prompt decimal + + with_test_prefix "execve" { + + # Tell the test program we want an execve. + gdb_test_no_output "set do_execve = 1" + + # Check for entry/return across the execve, making sure that the + # syscall_state isn't lost when turning into a new process. + insert_catch_syscall_with_arg "execve" + check_continue "execve" + + # Continue to main so extended-remote can read files as needed. + # (Otherwise that "Reading" output confuses gdb_continue_to_end.) + gdb_continue "main" + + # Now can we finish? + check_for_program_end + } +} + proc test_catch_syscall_fail_nodatadir {} { with_test_prefix "fail no datadir" { # Sanitizing. @@ -392,6 +414,9 @@ proc do_syscall_tests {} { # Testing the 'catch syscall' command starting mid-vfork. if [runto_main] then { test_catch_syscall_mid_vfork } + # Testing that 'catch syscall' entry/return tracks across execve. + if [runto_main] then { test_catch_syscall_execve } + # Testing if the 'catch syscall' command works when switching to # different architectures on-the-fly (PR gdb/10737). if [runto_main] then { test_catch_syscall_multi_arch } |