+2015-02-27 Pedro Alves <palves@redhat.com>
+
+ * x86-linux-nat.c (u_debugreg_offset): New function.
+ (x86_linux_dr_get, x86_linux_dr_set): Use it.
+
2015-02-27 Pedro Alves <palves@redhat.com>
* nat/x86-dregs.h (enum target_hw_bp_type): Remove forward
+2015-02-27 Pedro Alves <palves@redhat.com>
+
+ * linux-x86-low.c (u_debugreg_offset): New function.
+ (x86_linux_dr_get, x86_linux_dr_set): Use it.
+
2015-02-27 Pedro Alves <palves@redhat.com>
* gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
return 0;
}
\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. */
static unsigned long
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)
error ("Couldn't read debug register");
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)
error ("Couldn't write debug register");
}
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. */
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"));
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"));
}