aboutsummaryrefslogtreecommitdiff
path: root/gdb/fbsd-tdep.c
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2016-06-12 21:24:42 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2016-06-24 10:46:03 -0700
commite6cdd38e8f0fead14cd3c528e9a4b666e1871752 (patch)
tree357ce93c54e5400c660476da9aac57d511aca674 /gdb/fbsd-tdep.c
parent82372b2f2747d347e24bb10ddc7bc7e828222a42 (diff)
downloadgdb-e6cdd38e8f0fead14cd3c528e9a4b666e1871752.zip
gdb-e6cdd38e8f0fead14cd3c528e9a4b666e1871752.tar.gz
gdb-e6cdd38e8f0fead14cd3c528e9a4b666e1871752.tar.bz2
Add support for catching system calls to native FreeBSD targets.
All platforms on FreeBSD use a shared system call table, so use a single XML file to describe the system calls available on each FreeBSD platform. Recent versions of FreeBSD include the identifier of the current system call when reporting a system call entry or exit event in the ptrace_lwpinfo structure obtained via PT_LWPINFO in fbsd_wait. As such, FreeBSD native targets do not use the gdbarch method to fetch the system call code. In addition, FreeBSD register sets fetched via ptrace do not include an equivalent of 'orig_rax' (on amd64 for example), so the system call code cannot be extracted from the available registers during a system call exit. However, GDB assumes that system call catch points are not supported if the gdbarch method is not present. As a workaround, FreeBSD ABIs install a dummy gdbarch method that throws an internal_error if it is ever invoked. gdb/ChangeLog: * configure.ac: Check for support for system call LWP fields on FreeBSD. * config.in, configure: Rebuild. * data-directory/Makefile.in (SYSCALLS_FILES): Add freebsd.xml. * fbsd-nat.c (fbsd_wait) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]: Report system call events. [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE] (fbsd_set_syscall_catchpoint): New function. (fbsd_nat_add_target) [HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE]: Set "to_set_syscall_catchpoint" to "fbsd_set_syscall_catchpoint". * fbsd-tdep.c: Include xml-syscall.h (fbsd_get_syscall_number): New function. (fbsd_init_abi): Set XML system call file name. Add "get_syscall_number" gdbarch method. * syscalls/freebsd.xml: New file.
Diffstat (limited to 'gdb/fbsd-tdep.c')
-rw-r--r--gdb/fbsd-tdep.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index e8f8605..4329f97 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -24,6 +24,7 @@
#include "regcache.h"
#include "regset.h"
#include "gdbthread.h"
+#include "xml-syscall.h"
#include "elf-bfd.h"
#include "fbsd-tdep.h"
@@ -317,6 +318,22 @@ fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
fprint_auxv_entry (file, name, description, format, type, val);
}
+/* Implement the "get_syscall_number" gdbarch method. */
+
+static LONGEST
+fbsd_get_syscall_number (struct gdbarch *gdbarch,
+ ptid_t ptid)
+{
+
+ /* FreeBSD doesn't use gdbarch_get_syscall_number since FreeBSD
+ native targets fetch the system call number from the
+ 'pl_syscall_code' member of struct ptrace_lwpinfo in fbsd_wait.
+ However, system call catching requires this function to be
+ set. */
+
+ internal_error (__FILE__, __LINE__, _("fbsd_get_sycall_number called"));
+}
+
/* To be called from GDB_OSABI_FREEBSD_ELF handlers. */
void
@@ -326,4 +343,8 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_core_thread_name (gdbarch, fbsd_core_thread_name);
set_gdbarch_make_corefile_notes (gdbarch, fbsd_make_corefile_notes);
set_gdbarch_print_auxv_entry (gdbarch, fbsd_print_auxv_entry);
+
+ /* `catch syscall' */
+ set_xml_syscall_file_name (gdbarch, "syscalls/freebsd.xml");
+ set_gdbarch_get_syscall_number (gdbarch, fbsd_get_syscall_number);
}