From: Gary Benson <gbenson@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 02/13 v2] Add x86_debug_reg_state to gdbserver
Date: Thu, 09 Oct 2014 09:53:00 -0000 [thread overview]
Message-ID: <1412848358-9958-3-git-send-email-gbenson@redhat.com> (raw)
In-Reply-To: <1412848358-9958-1-git-send-email-gbenson@redhat.com>
This commit introduces a new function, x86_debug_reg_state, that
shared x86 code can use to access the local mirror of a process's
debug registers. This function already existed in GDB and was
in use by GDB's x86_linux_prepare_to_resume. An equivalent was
written for gdbserver and gdbserver's x86_linux_prepare_to_resume
was modified to use it.
gdb/ChangeLog:
* x86-nat.h (x86_debug_reg_state): Move declaration to...
* nat/x86-dregs.h (x86_debug_reg_state): New declaration.
gdb/gdbserver/ChangeLog:
* linux-x86-low.c (x86_debug_reg_state): New function.
(x86_linux_prepare_to_resume): Use the above.
---
gdb/ChangeLog | 5 +++++
gdb/gdbserver/ChangeLog | 5 +++++
gdb/gdbserver/linux-x86-low.c | 16 ++++++++++++----
gdb/nat/x86-dregs.h | 5 +++++
gdb/x86-nat.h | 5 -----
5 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index d3ca298..e8c6a9c 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -763,6 +763,16 @@ x86_linux_new_thread (void)
return info;
}
+/* See nat/x86-dregs.h. */
+
+struct x86_debug_reg_state *
+x86_debug_reg_state (pid_t pid)
+{
+ struct process_info *proc = find_process_pid (pid);
+
+ return &proc->private->arch_private->debug_reg_state;
+}
+
/* Called when resuming a thread.
If the debug regs have changed, update the thread's copies. */
@@ -774,11 +784,9 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
if (lwp->arch_private->debug_registers_changed)
{
- int i;
- int pid = ptid_get_pid (ptid);
- struct process_info *proc = find_process_pid (pid);
struct x86_debug_reg_state *state
- = &proc->private->arch_private->debug_reg_state;
+ = x86_debug_reg_state (ptid_get_pid (ptid));
+ int i;
x86_linux_dr_set (ptid, DR_CONTROL, 0);
diff --git a/gdb/nat/x86-dregs.h b/gdb/nat/x86-dregs.h
index aebcbce..104d033 100644
--- a/gdb/nat/x86-dregs.h
+++ b/gdb/nat/x86-dregs.h
@@ -93,6 +93,11 @@ struct x86_debug_reg_state
#define ALL_DEBUG_ADDRESS_REGISTERS(i) \
for (i = DR_FIRSTADDR; i <= DR_LASTADDR; i++)
+/* Return a pointer to the local mirror of the debug registers of
+ process PID. This function must be provided by the client
+ if required. */
+extern struct x86_debug_reg_state *x86_debug_reg_state (pid_t pid);
+
/* Insert a watchpoint to watch a memory region which starts at
address ADDR and whose length is LEN bytes. Watch memory accesses
of the type TYPE. Return 0 on success, -1 on failure. */
diff --git a/gdb/x86-nat.h b/gdb/x86-nat.h
index df5e9f2..7769572 100644
--- a/gdb/x86-nat.h
+++ b/gdb/x86-nat.h
@@ -44,11 +44,6 @@ extern void x86_set_debug_register_length (int len);
extern void x86_cleanup_dregs (void);
-/* Return a pointer to the local mirror of the debug registers of
- process PID. */
-
-extern struct x86_debug_reg_state *x86_debug_reg_state (pid_t pid);
-
/* Called whenever GDB is no longer debugging process PID. It deletes
data structures that keep track of debug register state. */
--
1.7.1
next prev parent reply other threads:[~2014-10-09 9:53 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-09 9:53 [PATCH 00/13 v2] Refactor low-level Linux x86 debug register code Gary Benson
2014-10-09 9:53 ` Gary Benson [this message]
2014-10-28 12:56 ` [PATCH 02/13 v2] Add x86_debug_reg_state to gdbserver Pedro Alves
2014-10-09 9:53 ` [PATCH 04/13 v2] Make linux_stop_lwp be a shared function Gary Benson
2014-10-28 12:56 ` Pedro Alves
2014-10-09 9:53 ` [PATCH 01/13 v2] Introduce current_lwp_ptid Gary Benson
2014-10-28 12:56 ` Pedro Alves
2014-10-28 16:44 ` Doug Evans
2014-10-28 17:12 ` Doug Evans
2014-10-28 17:13 ` Doug Evans
2014-10-28 18:35 ` Pedro Alves
2014-10-28 19:43 ` Doug Evans
2014-10-31 18:57 ` Doug Evans
2014-10-09 9:54 ` [PATCH 12/13 v2] Move low-level Linux x86 debug register code to a shared file Gary Benson
2014-10-28 13:01 ` Pedro Alves
2014-10-09 10:18 ` [PATCH 05/13 v2] Introduce basic LWP accessors Gary Benson
2014-10-28 12:57 ` Pedro Alves
2014-10-09 10:18 ` [PATCH 07/13 v2] Make lwp_info.arch_private handling shared Gary Benson
2014-10-28 12:57 ` Pedro Alves
2014-10-09 10:18 ` [PATCH 03/13 v2] Add iterate_over_lwps to gdbserver Gary Benson
2014-10-28 12:56 ` Pedro Alves
2014-10-09 10:21 ` [PATCH 10/13 v2] Linux x86 low-level debug register comment synchronization Gary Benson
2014-10-28 12:59 ` Pedro Alves
2014-10-09 10:21 ` [PATCH 08/13 v2] Rename gdbserver's low-level Linux x86 debug register accessors Gary Benson
2014-10-28 12:58 ` Pedro Alves
2014-10-09 10:35 ` [PATCH 11/13 v2] Introduce x86_linux_update_debug_registers Gary Benson
2014-10-28 13:00 ` Pedro Alves
2014-10-09 10:35 ` [PATCH 06/13 v2] Change signature of linux_target_ops.new_thread Gary Benson
2014-10-28 12:57 ` Pedro Alves
2014-10-09 10:44 ` [PATCH 13/13 v2] Move duplicated Linux x86 code to nat/x86-linux.c Gary Benson
2014-10-28 13:01 ` Pedro Alves
2014-10-09 10:44 ` [PATCH 09/13 v2] Linux x86 low-level debug register code synchronization Gary Benson
2014-10-28 12:59 ` Pedro Alves
2015-03-24 14:11 ` [pushed] Refactor low-level Linux x86 debug register code Gary Benson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412848358-9958-3-git-send-email-gbenson@redhat.com \
--to=gbenson@redhat.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox