* syscalls/s390x-linux.xml: New file.
* syscalls/s390-linux.xml: New file.
* s390-linux-tdep.c (XML_SYSCALL_FILENAME_S390): New macro.
(XML_SYSCALL_FILENAME_S390X): Likewise.
(op_svc): New enum value for SVC opcode.
(s390_sigtramp_frame_sniffer): Replace literal by 'op_svc'.
(s390_linux_get_syscall_number): New function.
(s390_gdbarch_init): Register '*get_syscall_number' and the
syscall xml file name.
* data-directory/Makefile.in (SYSCALLS_FILES): Add
"s390-linux.xml" and "s390x-linux.xml".
* NEWS: Announce new feature.
gdb/testsuite/ChangeLog:
* gdb.base/catch-syscall.exp: Activate test on s390*-linux.
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.
While fixing another bug, I found that the current
gdb.base/catch-syscall.exp is kind of messy, could use some
improvements, and is not correctly testing some things.
I've made the following patch to address all the issues I found. On the
organization side, it does a cleanup and removes unecessary imports of
gdb_prompt, uses prepare_for_testing and clean_restart where needed, and
fixes some comments. The testcase was also not correctly testing
catching syscalls using only numbers, or catching many syscalls at
once. I fixed that.
The patch also uses a new method for obtaining the syscalls numbers: it
relies on the C source file to get them, via <sys/syscall.h> and SYS_*
macros. This makes the .exp file simpler because there is no need to
include target conditionals there.
I tested this on x86_64 Fedora 18.
gdb/testsuite/ChangeLog:
2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.base/catch-syscall.c: Include <sys/syscall.h>.
(close_syscall, chroot_syscall, exit_group_syscall): New
variables.
* gdb.base/catch-syscall.exp: Replace gdb_compile by
prepare_for_testing. Call fill_all_syscalls_numbers before
starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and
gdb_load by clean_restart.
(check_info_bp_any_syscall, check_info_bp_specific_syscall)
(check_info_bp_many_syscalls): Remove global gdb_prompt.
(check_call_to_syscall): Likewise. Add global decimal. Improve
testing regex.
(check_return_from_syscall): Likewise.
(check_continue, insert_catch_syscall_with_arg): Remove global
gdb_prompt.
(insert_catch_syscall_with_many_args): Likewise. Add global
decimal. Fix $filter_str. Improve testing regex.
(check_for_program_end): Remove global gdb_prompt.
(test_catch_syscall_without_args): Likewise. Add global decimal.
Improve testing regex.
(test_catch_syscall_with_args, test_catch_syscall_with_many_args)
(test_catch_syscall_with_wrong_args)
(test_catch_syscall_restarting_inferior)
(test_catch_syscall_fail_nodatadir): Remove global gdb_prompt.
(do_syscall_tests): Likewise. Remove global srcdir.
(test_catch_syscall_without_args_noxml): Remove global gdb_prompt.
Add global last_syscall_number. Test for the exact syscall number
to be caught.
(test_catch_syscall_with_args_noxml): Remove global gdb_prompt.
Add global all_syscalls_numbers. Test each syscall number to be
caught, instead of only testing "close".
(test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt.
(do_syscall_tests_without_xml): Likewise. Remove global srcdir.
Remove stale comment.
(fill_all_syscalls_numbers): Add global last_syscall_number. Fill
the correct syscall numbers using information from the inferior.
catch-syscall.exp has a series of duplicated output in gdb.sum. This
patch makes sure all test names are unique, using with_test_prefix.
Tested on x86_64 Fedora 17.
gdb/testsuite/
2013-10-09 Pedro Alves <palves@redhat.com>
* gdb.base/catch-syscall.exp (test_catch_syscall_without_args)
(test_catch_syscall_with_args, test_catch_syscall_with_many_args)
(test_catch_syscall_with_wrong_args)
(test_catch_syscall_restarting_inferior)
(test_catch_syscall_fail_nodatadir)
(test_catch_syscall_without_args_noxml)
(test_catch_syscall_with_args_noxml)
(test_catch_syscall_with_wrong_args_noxml): Use with_test_prefix.
This time, it passes all the tests and comes with a nearly complete
XML file (plus a script that can nearly regenerate the XML file).
(I elected to leave out __ARM_NR_cmpxchg, since it has dire warnings
to the effect that the only pieces of code that should be aware of it
are the implementation and the __kuser_cmpxchg code in entry-armv.S.)
gdb/
2013-08-14 Samuel Bronson <naesten@gmail.com>
ARM Linux support for `catch syscall'.
* syscalls/arm-linux.py: New file.
* syscalls/arm-linux.xml: Likewise.
* arm-linux-tdep.c (arm_linux_get_syscall_number): New function.
(arm_linux_init_abi): Register the new function and syscall xml file.
* data-directory/Makefile.in: Install the new syscall xml file.
* NEWS: Brag about this.
gdb/testsuite/
2013-08-14 Samuel Bronson <naesten@gmail.com>
ARM Linux support for `catch syscall'.
* gdb.base/catch-syscall.exp: Test this on ARM now.
(fill_all_syscalls_numbers): ARM has close/chroot on 6/61, too.
Two modifications:
1. The addition of 2013 to the copyright year range for every file;
2. The use of a single year range, instead of potentially multiple
year ranges, as approved by the FSF.
2011-02-04 David Daney <ddaney@caviumnetworks.com>
* mips-linux-tdep.c: Include xml-syscall.h.
(mips_linux_get_syscall_number): New function.
(mips_linux_init_abi): Add calls to
mips_linux_get_syscall_number() and set_xml_syscall_file_name().
* data-directory/Makefile.in (SYSCALLS_FILES): Add
mips-o32-linux.xml, mips-n32-linux.xml and mips-n64-linux.xml
* syscalls/mips-n32-linux.xml: New file.
* syscalls/mips-n64-linux.xml: New file.
* syscalls/mips-o32-linux.xml: New file.
gdb/testsuite/
2011-02-04 David Daney <ddaney@caviumnetworks.com>
* gdb.base/catch-syscall.exp: Enable for mips*-linux*.
* Makefile.in (XML_SYSCALL_DIR, XML_SYSCALL_FILES): Moved to
data-directory/Makefile.in.
(SUBDIRS): Add data-directory.
(all): Remove xml-syscall-copy dependency.
(xml-syscall-copy): Moved to data-directory/Makefile.in as
stamp-syscalls.
(xml-syscall-install): Moved to data-directory/Makefile.in as
install-syscalls.
(install-only): Remove xml-syscall-install dependency.
(all-data-directory): New rule.
(data-directory/Makefile): New rule.
* configure.ac (AC_OUTPUT): Add data-directory/Makefile.
* configure: Regenerate.
* data-directory/Makefile.in: New file.
* python/lib/gdb/__init__.py: New file.
testsuite/
* gdb.base/catch-syscall.exp (do_syscall_tests): Update location
of syscall staging area.
gdb/testsuite/
2010-02-25 David S. Miller <davem@davemloft.net>
* gdb.base/catch-syscall.exp: Allow to run on sparc*-*-linux and
fix logic for setting all_syscalls_numbers.
2009-31-10 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* breakpoint.c (catch_syscall_split_args): Remove unecessary warning
displayed when the user provided a syscall name and there is no
XML support.
* xml-syscall.c: Renamed `_sysinfo' to `sysinfo'.
(set_xml_syscall_file_name): Remove syscall_warn_user.
(xml_init_syscalls_info): Remove warning.
(init_sysinfo): Update warnings.
gdb/testsuite/ChangeLog:
2009-31-10 Sergio Durigan Junior <sergiodj@linux.vnet.ibm.com>
* gdb.base/catch-syscall.exp: Adapt the testcase in order to accept
the modified warnings for catch syscall. Verify if GDB was compiled
with support for lib expat, and choose which tests to run depending
on this.