quit_force: Replace TRY_CATCH wrapper macros
[deliverable/binutils-gdb.git] / gdb / x86-linux-nat.c
index 67300d8053d3aeda5407b66a8aec2a45457ee616..26ae0b834fdbfab9a270bb77faf97782003ca737 100644 (file)
@@ -1,6 +1,6 @@
 /* Native-dependent code for GNU/Linux x86 (i386 and x86-64).
 
-   Copyright (C) 1999-2014 Free Software Foundation, Inc.
+   Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -24,6 +24,7 @@
 #include <sys/ptrace.h>
 #include <sys/user.h>
 #include <sys/procfs.h>
+#include <sys/uio.h>
 
 #include "x86-nat.h"
 #include "linux-nat.h"
@@ -50,6 +51,16 @@ struct arch_lwp_info
 int have_ptrace_getregset = -1;
 \f
 
+/* Return the offset of REGNUM in the u_debugreg field of struct
+   user.  */
+
+static int
+u_debugreg_offset (int regnum)
+{
+  return (offsetof (struct user, u_debugreg)
+         + sizeof (((struct user *) 0)->u_debugreg[0]) * regnum);
+}
+
 /* Support for debug registers.  */
 
 /* Get debug register REGNUM value from only the one LWP of PTID.  */
@@ -64,8 +75,8 @@ x86_linux_dr_get (ptid_t ptid, int regnum)
   tid = ptid_get_lwp (ptid);
 
   errno = 0;
-  value = ptrace (PTRACE_PEEKUSER, tid,
-                 offsetof (struct user, u_debugreg[regnum]), 0);
+  value = ptrace (PTRACE_PEEKUSER, tid, u_debugreg_offset (regnum), 0);
+
   if (errno != 0)
     perror_with_name (_("Couldn't read debug register"));
 
@@ -83,8 +94,7 @@ x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
   tid = ptid_get_lwp (ptid);
 
   errno = 0;
-  ptrace (PTRACE_POKEUSER, tid,
-         offsetof (struct user, u_debugreg[regnum]), value);
+  ptrace (PTRACE_POKEUSER, tid, u_debugreg_offset (regnum), value);
   if (errno != 0)
     perror_with_name (_("Couldn't write debug register"));
 }
@@ -213,7 +223,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
       lwp->arch_private->debug_registers_changed = 0;
     }
 
-  if (clear_status || lwp->stopped_by_watchpoint)
+  if (clear_status || lwp->stop_reason == TARGET_STOPPED_BY_WATCHPOINT)
     x86_linux_dr_set (lwp->ptid, DR_STATUS, 0);
 }
 
@@ -426,22 +436,25 @@ x86_linux_read_description (struct target_ops *ops)
 /* Enable branch tracing.  */
 
 static struct btrace_target_info *
-x86_linux_enable_btrace (struct target_ops *self, ptid_t ptid)
+x86_linux_enable_btrace (struct target_ops *self, ptid_t ptid,
+                        const struct btrace_config *conf)
 {
   struct btrace_target_info *tinfo;
   struct gdbarch *gdbarch;
 
   errno = 0;
-  tinfo = linux_enable_btrace (ptid);
+  tinfo = linux_enable_btrace (ptid, conf);
 
   if (tinfo == NULL)
     error (_("Could not enable branch tracing for %s: %s."),
           target_pid_to_str (ptid), safe_strerror (errno));
 
   /* Fill in the size of a pointer in bits.  */
-  gdbarch = target_thread_architecture (ptid);
-  tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
-
+  if (tinfo->ptr_bits == 0)
+    {
+      gdbarch = target_thread_architecture (ptid);
+      tinfo->ptr_bits = gdbarch_ptr_bit (gdbarch);
+    }
   return tinfo;
 }
 
@@ -469,12 +482,22 @@ x86_linux_teardown_btrace (struct target_ops *self,
 
 static enum btrace_error
 x86_linux_read_btrace (struct target_ops *self,
-                      VEC (btrace_block_s) **data,
+                      struct btrace_data *data,
                       struct btrace_target_info *btinfo,
                       enum btrace_read_type type)
 {
   return linux_read_btrace (data, btinfo, type);
 }
+
+/* See to_btrace_conf in target.h.  */
+
+static const struct btrace_config *
+x86_linux_btrace_conf (struct target_ops *self,
+                      const struct btrace_target_info *btinfo)
+{
+  return linux_btrace_conf (btinfo);
+}
+
 \f
 
 /* Helper for ps_get_thread_area.  Sets BASE_ADDR to a pointer to
@@ -549,6 +572,7 @@ x86_linux_create_target (void)
   t->to_disable_btrace = x86_linux_disable_btrace;
   t->to_teardown_btrace = x86_linux_teardown_btrace;
   t->to_read_btrace = x86_linux_read_btrace;
+  t->to_btrace_conf = x86_linux_btrace_conf;
 
   return t;
 }
This page took 0.025672 seconds and 4 git commands to generate.