Introduce current_lwp_ptid
This commit introduces a new function, current_lwp_ptid, that shared Linux code can use to obtain the ptid of the current lightweight process. gdb/ChangeLog: * nat/linux-nat.h (current_lwp_ptid): New declaration. * linux-nat.c (current_lwp_ptid): New function. * x86-linux-nat.c: Include nat/linux-nat.h. (x86_linux_dr_get_addr): Use current_lwp_ptid. (x86_linux_dr_get_control): Likewise. (x86_linux_dr_get_status): Likewise. (x86_linux_dr_set_control): Likewise. (x86_linux_dr_set_addr): Likewise. gdb/gdbserver/ChangeLog: * linux-low.c (current_lwp_ptid): New function. * linux-x86-low.c: Include nat/linux-nat.h. (x86_dr_low_get_addr): Use current_lwp_ptid. (x86_dr_low_get_control): Likewise. (x86_dr_low_get_status): Likewise.
This commit is contained in:
parent
1563054901
commit
7b6690874f
7 changed files with 53 additions and 14 deletions
|
@ -1,3 +1,14 @@
|
||||||
|
2015-03-24 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* nat/linux-nat.h (current_lwp_ptid): New declaration.
|
||||||
|
* linux-nat.c (current_lwp_ptid): New function.
|
||||||
|
* x86-linux-nat.c: Include nat/linux-nat.h.
|
||||||
|
(x86_linux_dr_get_addr): Use current_lwp_ptid.
|
||||||
|
(x86_linux_dr_get_control): Likewise.
|
||||||
|
(x86_linux_dr_get_status): Likewise.
|
||||||
|
(x86_linux_dr_set_control): Likewise.
|
||||||
|
(x86_linux_dr_set_addr): Likewise.
|
||||||
|
|
||||||
2015-03-24 Antoine Tremblay <antoine.tremblay@ericsson.com>
|
2015-03-24 Antoine Tremblay <antoine.tremblay@ericsson.com>
|
||||||
|
|
||||||
PR breakpoints/16466
|
PR breakpoints/16466
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
2015-03-24 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* linux-low.c (current_lwp_ptid): New function.
|
||||||
|
* linux-x86-low.c: Include nat/linux-nat.h.
|
||||||
|
(x86_dr_low_get_addr): Use current_lwp_ptid.
|
||||||
|
(x86_dr_low_get_control): Likewise.
|
||||||
|
(x86_dr_low_get_status): Likewise.
|
||||||
|
|
||||||
2015-03-20 Pedro Alves <palves@redhat.com>
|
2015-03-20 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* tracepoint.c (cmd_qtstatus): Make "str" const.
|
* tracepoint.c (cmd_qtstatus): Make "str" const.
|
||||||
|
|
|
@ -6218,6 +6218,14 @@ linux_low_btrace_conf (const struct btrace_target_info *tinfo,
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LINUX_BTRACE */
|
#endif /* HAVE_LINUX_BTRACE */
|
||||||
|
|
||||||
|
/* See nat/linux-nat.h. */
|
||||||
|
|
||||||
|
ptid_t
|
||||||
|
current_lwp_ptid (void)
|
||||||
|
{
|
||||||
|
return ptid_of (current_thread);
|
||||||
|
}
|
||||||
|
|
||||||
static struct target_ops linux_target_ops = {
|
static struct target_ops linux_target_ops = {
|
||||||
linux_create_inferior,
|
linux_create_inferior,
|
||||||
linux_attach,
|
linux_attach,
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "tdesc.h"
|
#include "tdesc.h"
|
||||||
#include "tracepoint.h"
|
#include "tracepoint.h"
|
||||||
#include "ax.h"
|
#include "ax.h"
|
||||||
|
#include "nat/linux-nat.h"
|
||||||
|
|
||||||
#ifdef __x86_64__
|
#ifdef __x86_64__
|
||||||
/* Defined in auto-generated file amd64-linux.c. */
|
/* Defined in auto-generated file amd64-linux.c. */
|
||||||
|
@ -615,11 +616,9 @@ x86_dr_low_set_addr (int regnum, CORE_ADDR addr)
|
||||||
static CORE_ADDR
|
static CORE_ADDR
|
||||||
x86_dr_low_get_addr (int regnum)
|
x86_dr_low_get_addr (int regnum)
|
||||||
{
|
{
|
||||||
ptid_t ptid = ptid_of (current_thread);
|
|
||||||
|
|
||||||
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
|
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
|
||||||
|
|
||||||
return x86_linux_dr_get (ptid, regnum);
|
return x86_linux_dr_get (current_lwp_ptid (), regnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the inferior's DR7 debug control register from STATE. */
|
/* Update the inferior's DR7 debug control register from STATE. */
|
||||||
|
@ -638,9 +637,7 @@ x86_dr_low_set_control (unsigned long control)
|
||||||
static unsigned long
|
static unsigned long
|
||||||
x86_dr_low_get_control (void)
|
x86_dr_low_get_control (void)
|
||||||
{
|
{
|
||||||
ptid_t ptid = ptid_of (current_thread);
|
return x86_linux_dr_get (current_lwp_ptid (), DR_CONTROL);
|
||||||
|
|
||||||
return x86_linux_dr_get (ptid, DR_CONTROL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the value of the DR6 debug status register from the inferior
|
/* Get the value of the DR6 debug status register from the inferior
|
||||||
|
@ -649,9 +646,7 @@ x86_dr_low_get_control (void)
|
||||||
static unsigned long
|
static unsigned long
|
||||||
x86_dr_low_get_status (void)
|
x86_dr_low_get_status (void)
|
||||||
{
|
{
|
||||||
ptid_t ptid = ptid_of (current_thread);
|
return x86_linux_dr_get (current_lwp_ptid (), DR_STATUS);
|
||||||
|
|
||||||
return x86_linux_dr_get (ptid, DR_STATUS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Low-level function vector. */
|
/* Low-level function vector. */
|
||||||
|
|
|
@ -4938,6 +4938,15 @@ linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See nat/linux-nat.h. */
|
||||||
|
|
||||||
|
ptid_t
|
||||||
|
current_lwp_ptid (void)
|
||||||
|
{
|
||||||
|
gdb_assert (ptid_lwp_p (inferior_ptid));
|
||||||
|
return inferior_ptid;
|
||||||
|
}
|
||||||
|
|
||||||
/* Provide a prototype to silence -Wmissing-prototypes. */
|
/* Provide a prototype to silence -Wmissing-prototypes. */
|
||||||
extern initialize_file_ftype _initialize_linux_nat;
|
extern initialize_file_ftype _initialize_linux_nat;
|
||||||
|
|
||||||
|
|
|
@ -25,4 +25,11 @@
|
||||||
instead SIGTRAP with bit 7 set. */
|
instead SIGTRAP with bit 7 set. */
|
||||||
#define SYSCALL_SIGTRAP (SIGTRAP | 0x80)
|
#define SYSCALL_SIGTRAP (SIGTRAP | 0x80)
|
||||||
|
|
||||||
|
/* Return the ptid of the current lightweight process. With NPTL
|
||||||
|
threads and LWPs map 1:1, so this is equivalent to returning the
|
||||||
|
ptid of the current thread. This function must be provided by
|
||||||
|
the client. */
|
||||||
|
|
||||||
|
extern ptid_t current_lwp_ptid (void);
|
||||||
|
|
||||||
#endif /* LINUX_NAT_H */
|
#endif /* LINUX_NAT_H */
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include "x86-xstate.h"
|
#include "x86-xstate.h"
|
||||||
#include "nat/linux-btrace.h"
|
#include "nat/linux-btrace.h"
|
||||||
|
#include "nat/linux-nat.h"
|
||||||
|
|
||||||
/* Per-thread arch-specific data we want to keep. */
|
/* Per-thread arch-specific data we want to keep. */
|
||||||
|
|
||||||
|
@ -107,7 +108,7 @@ x86_linux_dr_get_addr (int regnum)
|
||||||
/* DR6 and DR7 are retrieved with some other way. */
|
/* DR6 and DR7 are retrieved with some other way. */
|
||||||
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
|
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
|
||||||
|
|
||||||
return x86_linux_dr_get (inferior_ptid, regnum);
|
return x86_linux_dr_get (current_lwp_ptid (), regnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the inferior's DR7 debug control register. */
|
/* Return the inferior's DR7 debug control register. */
|
||||||
|
@ -115,7 +116,7 @@ x86_linux_dr_get_addr (int regnum)
|
||||||
static unsigned long
|
static unsigned long
|
||||||
x86_linux_dr_get_control (void)
|
x86_linux_dr_get_control (void)
|
||||||
{
|
{
|
||||||
return x86_linux_dr_get (inferior_ptid, DR_CONTROL);
|
return x86_linux_dr_get (current_lwp_ptid (), DR_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */
|
/* Get DR_STATUS from only the one LWP of INFERIOR_PTID. */
|
||||||
|
@ -123,7 +124,7 @@ x86_linux_dr_get_control (void)
|
||||||
static unsigned long
|
static unsigned long
|
||||||
x86_linux_dr_get_status (void)
|
x86_linux_dr_get_status (void)
|
||||||
{
|
{
|
||||||
return x86_linux_dr_get (inferior_ptid, DR_STATUS);
|
return x86_linux_dr_get (current_lwp_ptid (), DR_STATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for iterate_over_lwps. Update the debug registers of
|
/* Callback for iterate_over_lwps. Update the debug registers of
|
||||||
|
@ -153,7 +154,7 @@ update_debug_registers_callback (struct lwp_info *lwp, void *arg)
|
||||||
static void
|
static void
|
||||||
x86_linux_dr_set_control (unsigned long control)
|
x86_linux_dr_set_control (unsigned long control)
|
||||||
{
|
{
|
||||||
ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
|
ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
|
||||||
|
|
||||||
iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
|
iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +165,7 @@ x86_linux_dr_set_control (unsigned long control)
|
||||||
static void
|
static void
|
||||||
x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
|
x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
|
||||||
{
|
{
|
||||||
ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
|
ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
|
||||||
|
|
||||||
gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
|
gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue