+2015-03-24 Gary Benson <gbenson@redhat.com>
+
+ * nat/x86-linux.h: New file.
+ * nat/x86-linux.c: Likewise.
+ * Makefile.in (HFILES_NO_SRCDIR): Add nat/x86-linux.h.
+ (x86-linux.o): New rule.
+ * config/i386/linux.mh (NATDEPFILES): Add x86-linux.o.
+ * config/i386/linux64.mh (NATDEPFILES): Likewise.
+ * nat/linux-nat.h (struct arch_lwp_info): New forward declaration.
+ (lwp_set_arch_private_info): New declaration.
+ (lwp_arch_private_info): Likewise.
+ * linux-nat.c (lwp_set_arch_private_info): New function.
+ (lwp_arch_private_info): Likewise.
+ * x86-linux-nat.c: Include nat/x86-linux.h.
+ (arch_lwp_info): Removed structure.
+ (update_debug_registers_callback):
+ Use lwp_set_debug_registers_changed.
+ (x86_linux_prepare_to_resume): Use lwp_debug_registers_changed
+ and lwp_set_debug_registers_changed.
+ (x86_linux_new_thread): Use lwp_set_debug_registers_changed.
+
2015-03-24 Gary Benson <gbenson@redhat.com>
* nat/linux-nat.h (ptid_of_lwp): New declaration.
common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
common/common-exceptions.h target/target.h common/symbol.h \
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h \
-common/common-remote-fileio.h
+common/common-remote-fileio.h nat/x86-linux.h
# Header files that already have srcdir in them, or which are in objdir.
$(COMPILE) $(srcdir)/nat/linux-personality.c
$(POSTCOMPILE)
+x86-linux.o: ${srcdir}/nat/x86-linux.c
+ $(COMPILE) $(srcdir)/nat/x86-linux.c
+ $(POSTCOMPILE)
+
#
# gdb/tui/ dependencies
#
x86-nat.o x86-dregs.o i386-linux-nat.o x86-linux-nat.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
- linux-btrace.o linux-waitpid.o linux-personality.o
+ linux-btrace.o linux-waitpid.o linux-personality.o x86-linux.o
NAT_CDEPS = $(srcdir)/proc-service.list
# The dynamically loaded libthread_db needs access to symbols in the
linux-nat.o linux-osdata.o \
proc-service.o linux-thread-db.o linux-fork.o \
linux-procfs.o linux-ptrace.o linux-btrace.o \
- linux-waitpid.o linux-personality.o
+ linux-waitpid.o linux-personality.o x86-linux.o
NAT_FILE= config/nm-linux.h
NAT_CDEPS = $(srcdir)/proc-service.list
+2015-03-24 Gary Benson <gbenson@redhat.com>
+
+ * Makefile.in (x86-linux.o): New rule.
+ * configure.srv: Add x86-linux.o to relevant targets.
+ * linux-low.c (lwp_set_arch_private_info): New function.
+ (lwp_arch_private_info): Likewise.
+ * linux-x86-low.c: Include nat/x86-linux.h.
+ (arch_lwp_info): Removed structure.
+ (update_debug_registers_callback):
+ Use lwp_set_debug_registers_changed.
+ (x86_linux_prepare_to_resume): Use lwp_debug_registers_changed
+ and lwp_set_debug_registers_changed.
+ (x86_linux_new_thread): Use lwp_set_debug_registers_changed.
+
2015-03-24 Gary Benson <gbenson@redhat.com>
* linux-low.h (linux_target_ops) <new_thread>: Changed signature.
btrace-common.o: ../common/btrace-common.c
$(COMPILE) $<
$(POSTCOMPILE)
+x86-linux.o: ../nat/x86-linux.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
srv_xmlfiles="${srv_xmlfiles} $srv_amd64_linux_xmlfiles"
fi
srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
- srv_tgtobj="${srv_tgtobj} linux-btrace.o"
+ srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
- srv_tgtobj="${srv_tgtobj} linux-btrace.o"
+ srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_xmlfiles="$srv_i386_linux_xmlfiles $srv_amd64_linux_xmlfiles"
srv_linux_usrregs=yes # This is for i386 progs.
srv_linux_regsets=yes
/* See nat/linux-nat.h. */
+void
+lwp_set_arch_private_info (struct lwp_info *lwp,
+ struct arch_lwp_info *info)
+{
+ lwp->arch_private = info;
+}
+
+/* See nat/linux-nat.h. */
+
+struct arch_lwp_info *
+lwp_arch_private_info (struct lwp_info *lwp)
+{
+ return lwp->arch_private;
+}
+
+/* See nat/linux-nat.h. */
+
int
lwp_is_stopped (struct lwp_info *lwp)
{
#include "tracepoint.h"
#include "ax.h"
#include "nat/linux-nat.h"
+#include "nat/x86-linux.h"
#ifdef __x86_64__
/* Defined in auto-generated file amd64-linux.c. */
struct x86_debug_reg_state debug_reg_state;
};
-/* Per-thread arch-specific data we want to keep. */
-
-struct arch_lwp_info
-{
- /* Non-zero if our copy differs from what's recorded in the thread. */
- int debug_registers_changed;
-};
-
#ifdef __x86_64__
/* Mapping between the general-purpose registers in `struct user'
{
/* The actual update is done later just before resuming the lwp,
we just mark that the registers need updating. */
- lwp->arch_private->debug_registers_changed = 1;
+ lwp_set_debug_registers_changed (lwp, 1);
/* If the lwp isn't stopped, force it to momentarily pause, so
we can update its debug registers. */
static void
x86_linux_new_thread (struct lwp_info *lwp)
{
- struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
-
- info->debug_registers_changed = 1;
-
- lwp->arch_private = info;
+ lwp_set_debug_registers_changed (lwp, 1);
}
/* See nat/x86-dregs.h. */
ptid_t ptid = ptid_of_lwp (lwp);
int clear_status = 0;
- if (lwp->arch_private->debug_registers_changed)
+ if (lwp_debug_registers_changed (lwp))
{
struct x86_debug_reg_state *state
= x86_debug_reg_state (ptid_get_pid (ptid));
if (state->dr_control_mirror != 0)
x86_linux_dr_set (ptid, DR_CONTROL, state->dr_control_mirror);
- lwp->arch_private->debug_registers_changed = 0;
+ lwp_set_debug_registers_changed (lwp, 0);
}
if (clear_status
/* See nat/linux-nat.h. */
+void
+lwp_set_arch_private_info (struct lwp_info *lwp,
+ struct arch_lwp_info *info)
+{
+ lwp->arch_private = info;
+}
+
+/* See nat/linux-nat.h. */
+
+struct arch_lwp_info *
+lwp_arch_private_info (struct lwp_info *lwp)
+{
+ return lwp->arch_private;
+}
+
+/* See nat/linux-nat.h. */
+
int
lwp_is_stopped (struct lwp_info *lwp)
{
#define LINUX_NAT_H
struct lwp_info;
+struct arch_lwp_info;
/* Unlike other extended result codes, WSTOPSIG (status) on
PTRACE_O_TRACESYSGOOD syscall events doesn't return SIGTRAP, but
extern ptid_t ptid_of_lwp (struct lwp_info *lwp);
+/* Set the architecture-specific data of LWP. This function must be
+ provided by the client. */
+
+extern void lwp_set_arch_private_info (struct lwp_info *lwp,
+ struct arch_lwp_info *info);
+
+/* Return the architecture-specific data of LWP. This function must
+ be provided by the client. */
+
+extern struct arch_lwp_info *lwp_arch_private_info (struct lwp_info *lwp);
+
/* Return nonzero if LWP is stopped, zero otherwise. This function
must be provided by the client. */
--- /dev/null
+/* Native-dependent code for GNU/Linux x86 (i386 and x86-64).
+
+ Copyright (C) 1999-2015 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "common-defs.h"
+#include "x86-linux.h"
+
+/* Per-thread arch-specific data we want to keep. */
+
+struct arch_lwp_info
+{
+ /* Non-zero if our copy differs from what's recorded in the
+ thread. */
+ int debug_registers_changed;
+};
+
+/* See nat/x86-linux.h. */
+
+void
+lwp_set_debug_registers_changed (struct lwp_info *lwp, int value)
+{
+ if (lwp_arch_private_info (lwp) == NULL)
+ lwp_set_arch_private_info (lwp, XCNEW (struct arch_lwp_info));
+
+ lwp_arch_private_info (lwp)->debug_registers_changed = value;
+}
+
+/* See nat/x86-linux.h. */
+
+int
+lwp_debug_registers_changed (struct lwp_info *lwp)
+{
+ struct arch_lwp_info *info = lwp_arch_private_info (lwp);
+
+ /* NULL means either that this is the main thread still going
+ through the shell, or that no watchpoint has been set yet.
+ The debug registers are unchanged in either case. */
+ if (info == NULL)
+ return 0;
+
+ return info->debug_registers_changed;
+}
--- /dev/null
+/* Native-dependent code for GNU/Linux x86 (i386 and x86-64).
+
+ Copyright (C) 1999-2015 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef X86_LINUX_H
+#define X86_LINUX_H
+
+#include "nat/linux-nat.h"
+
+/* Set whether our local mirror of LWP's debug registers has been
+ changed since the values were last written to the thread. Nonzero
+ indicates that a change has been made, zero indicates no change. */
+
+extern void lwp_set_debug_registers_changed (struct lwp_info *lwp,
+ int value);
+
+/* Return nonzero if our local mirror of LWP's debug registers has
+ been changed since the values were last written to the thread,
+ zero otherwise. */
+
+extern int lwp_debug_registers_changed (struct lwp_info *lwp);
+
+#endif /* X86_LINUX_H */
#include "x86-xstate.h"
#include "nat/linux-btrace.h"
#include "nat/linux-nat.h"
+#include "nat/x86-linux.h"
/* Per-thread arch-specific data we want to keep. */
static int
update_debug_registers_callback (struct lwp_info *lwp, void *arg)
{
- if (lwp->arch_private == NULL)
- lwp->arch_private = XCNEW (struct arch_lwp_info);
-
/* The actual update is done later just before resuming the lwp, we
just mark that the registers need updating. */
- lwp->arch_private->debug_registers_changed = 1;
+ lwp_set_debug_registers_changed (lwp, 1);
/* If the lwp isn't stopped, force it to momentarily pause, so we
can update its debug registers. */
ptid_t ptid = ptid_of_lwp (lwp);
int clear_status = 0;
- /* NULL means this is the main thread still going through the shell,
- or, no watchpoint has been set yet. In that case, there's
- nothing to do. */
- if (lwp->arch_private == NULL)
- return;
-
- if (lwp->arch_private->debug_registers_changed)
+ if (lwp_debug_registers_changed (lwp))
{
struct x86_debug_reg_state *state
= x86_debug_reg_state (ptid_get_pid (ptid));
if (state->dr_control_mirror != 0)
x86_linux_dr_set (ptid, DR_CONTROL, state->dr_control_mirror);
- lwp->arch_private->debug_registers_changed = 0;
+ lwp_set_debug_registers_changed (lwp, 0);
}
if (clear_status
static void
x86_linux_new_thread (struct lwp_info *lp)
{
- struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
-
- info->debug_registers_changed = 1;
-
- lp->arch_private = info;
+ lwp_set_debug_registers_changed (lp, 1);
}
\f