From e9076973c822e6df7f84bb8bc0b69aa42dd29eb3 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 13 Dec 2018 11:36:42 -0800 Subject: Add an optional "alias" attribute to syscall entries. When setting a syscall catchpoint by name, catch syscalls whose name or alias matches the requested string. When the ABI of a system call is changed in the FreeBSD kernel, this is implemented by leaving a compatibility system call using the old ABI at the existing "slot" and allocating a new system call for the version using the new ABI. For example, new fields were added to the 'struct kevent' used by the kevent() system call in FreeBSD 12. The previous kevent() system call in FreeBSD 12 kernels is now called freebsd11_kevent() and is still used by older binaries compiled against the older ABI. The freebsd11_kevent() system call can be tagged with an "alias" attribute of "kevent" permitting 'catch syscall kevent' to catch both system calls and providing the expected user behavior for both old and new binaries. It also provides the expected behavior if GDB is compiled on an older host (such as a FreeBSD 11 host). gdb/ChangeLog: * NEWS: Add entry documenting system call aliases. * break-catch-syscall.c (catch_syscall_split_args): Pass 'result' to get_syscalls_by_name. * gdbarch.sh (UNKNOWN_SYSCALL): Remove. * gdbarch.h: Regenerate. * syscalls/gdb-syscalls.dtd (syscall): Add alias attribute. * xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename from get_syscall_by_name. Now accepts a pointer to a vector of integers and returns a bool. [HAVE_LIBEXPAT] (struct syscall_desc): Add alias member. (syscall_create_syscall_desc): Add alias parameter and pass it to syscall_desc constructor. (syscall_start_syscall): Handle alias attribute. (syscall_attr): Add alias attribute. (xml_get_syscalls_by_name): Rename from xml_get_syscall_number. Now accepts a pointer to a vector of integers and returns a bool. Add syscalls whose alias or name matches the requested name. (get_syscalls_by_name): Rename from get_syscall_by_name. Now accepts a pointer to a vector of integers and returns a bool. * xml-syscall.h (get_syscalls_by_name): Likewise. gdb/doc/ChangeLog: * gdb.texinfo (Set Catchpoints): Add an anchor for 'catch syscall'. (Native): Add a FreeBSD subsection. (FreeBSD): Document use of system call aliases for compatibility system calls. --- gdb/doc/ChangeLog | 7 +++++++ gdb/doc/gdb.texinfo | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'gdb/doc') diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 59e7330..68d3068 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2018-12-13 John Baldwin + + * gdb.texinfo (Set Catchpoints): Add an anchor for 'catch syscall'. + (Native): Add a FreeBSD subsection. + (FreeBSD): Document use of system call aliases for compatibility + system calls. + 2018-11-21 Andrew Burgess * gdb.texinfo (Standard Target Features): Add RISC-V Features diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 7350d94..d766e44 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -4560,6 +4560,7 @@ A failed Ada assertion. @cindex break on fork/exec A call to @code{exec}. +@anchor{catch syscall} @item syscall @itemx syscall @r{[}@var{name} @r{|} @var{number} @r{|} @r{group:}@var{groupname} @r{|} @r{g:}@var{groupname}@r{]} @dots{} @kindex catch syscall @@ -22357,6 +22358,7 @@ configurations. * Cygwin Native:: Features specific to the Cygwin port * Hurd Native:: Features specific to @sc{gnu} Hurd * Darwin:: Features specific to Darwin +* FreeBSD:: Features specific to FreeBSD @end menu @node BSD libkvm Interface @@ -23242,6 +23244,27 @@ better understand the cause of a fault. The default is off. Show the current state of exceptions trapping. @end table +@node FreeBSD +@subsection FreeBSD +@cindex FreeBSD + +When the ABI of a system call is changed in the FreeBSD kernel, this +is implemented by leaving a compatibility system call using the old +ABI at the existing number and allocating a new system call number for +the version using the new ABI. As a convenience, when a system call +is caught by name (@pxref{catch syscall}), compatibility system calls +are also caught. + +For example, FreeBSD 12 introduced a new variant of the @code{kevent} +system call and catching the @code{kevent} system call by name catches +both variants: + +@smallexample +(@value{GDBP}) catch syscall kevent +Catchpoint 1 (syscalls 'freebsd11_kevent' [363] 'kevent' [560]) +(@value{GDBP}) +@end smallexample + @node Embedded OS @section Embedded Operating Systems -- cgit v1.1