Use gdbpy_enter in gdbpy_before_prompt_hook
[binutils-gdb.git] / gdb / fbsd-tdep.c
index 7310ea09208cc066f612275e8ead6ff38a3421b6..e7579100234b1e0c50e88ace1e209c9ee67e3c62 100644 (file)
@@ -1,6 +1,6 @@
 /* Target-dependent code for FreeBSD, architecture-independent.
 
-   Copyright (C) 2002-2016 Free Software Foundation, Inc.
+   Copyright (C) 2002-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "auxv.h"
 #include "gdbcore.h"
 #include "inferior.h"
 #include "regcache.h"
 #include "regset.h"
 #include "gdbthread.h"
+#include "xml-syscall.h"
 
 #include "elf-bfd.h"
 #include "fbsd-tdep.h"
@@ -283,7 +285,56 @@ fbsd_make_corefile_notes (struct gdbarch *gdbarch, bfd *obfd, int *note_size)
   return note_data;
 }
 
-/* To be called from GDB_OSABI_FREEBSD_ELF handlers. */
+/* Print descriptions of FreeBSD-specific AUXV entries to FILE.  */
+
+static void
+fbsd_print_auxv_entry (struct gdbarch *gdbarch, struct ui_file *file,
+                      CORE_ADDR type, CORE_ADDR val)
+{
+  const char *name;
+  const char *description;
+  enum auxv_format format;
+
+  switch (type)
+    {
+#define _TAGNAME(tag) #tag
+#define TAGNAME(tag) _TAGNAME(AT_##tag)
+#define TAG(tag, text, kind) \
+      case AT_FREEBSD_##tag: name = TAGNAME(tag); description = text; format = kind; break
+      TAG (EXECPATH, _("Executable path"), AUXV_FORMAT_STR);
+      TAG (CANARY, _("Canary for SSP"), AUXV_FORMAT_HEX);
+      TAG (CANARYLEN, ("Length of the SSP canary"), AUXV_FORMAT_DEC);
+      TAG (OSRELDATE, _("OSRELDATE"), AUXV_FORMAT_DEC);
+      TAG (NCPUS, _("Number of CPUs"), AUXV_FORMAT_DEC);
+      TAG (PAGESIZES, _("Pagesizes"), AUXV_FORMAT_HEX);
+      TAG (PAGESIZESLEN, _("Number of pagesizes"), AUXV_FORMAT_DEC);
+      TAG (TIMEKEEP, _("Pointer to timehands"), AUXV_FORMAT_HEX);
+      TAG (STACKPROT, _("Initial stack protection"), AUXV_FORMAT_HEX);
+    default:
+      default_print_auxv_entry (gdbarch, file, type, val);
+      return;
+    }
+
+  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 handlers. */
 
 void
 fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
@@ -291,4 +342,9 @@ fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_core_pid_to_str (gdbarch, fbsd_core_pid_to_str);
   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);
 }