In C++ mode, we get:
gdb/gdbserver/linux-x86-low.c: In function ‘void x86_linux_dr_set(ptid_t, int, long unsigned int)’:
gdb/gdbserver/linux-x86-low.c:558:38: error: ‘regnum’ cannot appear in a constant-expression
offsetof (struct user, u_debugreg[regnum]), value);
^
gdb/gdbserver/ChangeLog:
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.
gdb/ChangeLog:
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>
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
declaration.
Include break-common.h.
* nat/x86-dregs.h (enum target_hw_bp_type): Remove forward
declaration.
Include break-common.h.
2015-02-27 Pedro Alves <palves@redhat.com>
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.
[!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare.
[!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread)
* gdb_proc_service.h: Wrap with EXTERN_C_PUSH/EXTERN_C_POP.
[!HAVE_PROC_SERVICE_H] (struct ps_prochandle): Forward declare.
[!HAVE_PROC_SERVICE_H] (ps_pdread, ps_pdwrite, ps_ptread)
+
+/* 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
/* Support for debug registers. */
static unsigned long
tid = ptid_get_lwp (ptid);
errno = 0;
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");
if (errno != 0)
error ("Couldn't read debug register");
tid = ptid_get_lwp (ptid);
errno = 0;
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");
}
if (errno != 0)
error ("Couldn't write debug register");
}
int have_ptrace_getregset = -1;
\f
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. */
/* Support for debug registers. */
/* Get debug register REGNUM value from only the one LWP of PTID. */
tid = ptid_get_lwp (ptid);
errno = 0;
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"));
if (errno != 0)
perror_with_name (_("Couldn't read debug register"));
tid = ptid_get_lwp (ptid);
errno = 0;
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"));
}
if (errno != 0)
perror_with_name (_("Couldn't write debug register"));
}