This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Introduce x86_linux_update_debug_registers


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2b95d4403883ba22687ecb81520855204348a7fb

commit 2b95d4403883ba22687ecb81520855204348a7fb
Author: Gary Benson <gbenson@redhat.com>
Date:   Tue Mar 24 14:05:44 2015 +0000

    Introduce x86_linux_update_debug_registers
    
    This commit moves the entire body of both GDB's and gdbserver's
    x86_linux_prepare_to_resume functions into new functions,
    x86_linux_update_debug_registers.  This reorganisation allows
    all Linux x86 low-level debug register code to be placed in one
    shared file, separate from general Linux x86 shared code.
    
    gdb/ChangeLog:
    
    	* x86-linux-nat.c (x86_linux_update_debug_registers):
    	New function, factored out from...
    	(x86_linux_prepare_to_resume): ...this.
    
    gdb/gdbserver/ChangeLog:
    
    	* linux-x86-low.c (x86_linux_update_debug_registers):
    	New function, factored out from...
    	(x86_linux_prepare_to_resume): ...this.

Diff:
---
 gdb/ChangeLog                 |  6 ++++++
 gdb/gdbserver/ChangeLog       |  6 ++++++
 gdb/gdbserver/linux-x86-low.c | 16 +++++++++++++---
 gdb/x86-linux-nat.c           | 16 +++++++++++++---
 4 files changed, 38 insertions(+), 6 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 18dff13..a8ad891 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
 2015-03-24  Gary Benson  <gbenson@redhat.com>
 
+	* x86-linux-nat.c (x86_linux_update_debug_registers):
+	New function, factored out from...
+	(x86_linux_prepare_to_resume): ...this.
+
+2015-03-24  Gary Benson  <gbenson@redhat.com>
+
 	* x86-linux-nat.c (x86_linux_dr_get): Update comments.
 	(x86_linux_dr_set): Likewise.
 	(x86_linux_dr_get_addr): Likewise.
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 2df8a02..f580103 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,5 +1,11 @@
 2015-03-24  Gary Benson  <gbenson@redhat.com>
 
+	* linux-x86-low.c (x86_linux_update_debug_registers):
+	New function, factored out from...
+	(x86_linux_prepare_to_resume): ...this.
+
+2015-03-24  Gary Benson  <gbenson@redhat.com>
+
 	* linux-x86-low.c (x86_linux_dr_get): Update comments.
 	(x86_linux_dr_set): Likewise.
 	(update_debug_registers_callback): Likewise.
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index c6a2acc..e371873 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -776,15 +776,17 @@ x86_debug_reg_state (pid_t pid)
   return &proc->priv->arch_private->debug_reg_state;
 }
 
-/* Called prior to resuming a thread.  Updates the thread's debug
-   registers if the values in our local mirror have been changed.  */
+/* Update the thread's debug registers if the values in our local
+   mirror have been changed.  */
 
 static void
-x86_linux_prepare_to_resume (struct lwp_info *lwp)
+x86_linux_update_debug_registers (struct lwp_info *lwp)
 {
   ptid_t ptid = ptid_of_lwp (lwp);
   int clear_status = 0;
 
+  gdb_assert (lwp_is_stopped (lwp));
+
   if (lwp_debug_registers_changed (lwp))
     {
       struct x86_debug_reg_state *state
@@ -821,6 +823,14 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
       || lwp_stop_reason (lwp) == TARGET_STOPPED_BY_WATCHPOINT)
     x86_linux_dr_set (ptid, DR_STATUS, 0);
 }
+
+/* Called prior to resuming a thread.  */
+
+static void
+x86_linux_prepare_to_resume (struct lwp_info *lwp)
+{
+  x86_linux_update_debug_registers (lwp);
+}
 
 /* When GDBSERVER is built as a 64-bit application on linux, the
    PTRACE_GETSIGINFO data is always presented in 64-bit layout.  Since
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index b49ef8f..9eb82c5 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -171,15 +171,17 @@ x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
   iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
 }
 
-/* Called prior to resuming a thread.  Updates the thread's debug
-   registers if the values in our local mirror have been changed.  */
+/* Update the thread's debug registers if the values in our local
+   mirror have been changed.  */
 
 static void
-x86_linux_prepare_to_resume (struct lwp_info *lwp)
+x86_linux_update_debug_registers (struct lwp_info *lwp)
 {
   ptid_t ptid = ptid_of_lwp (lwp);
   int clear_status = 0;
 
+  gdb_assert (lwp_is_stopped (lwp));
+
   if (lwp_debug_registers_changed (lwp))
     {
       struct x86_debug_reg_state *state
@@ -217,6 +219,14 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp)
     x86_linux_dr_set (ptid, DR_STATUS, 0);
 }
 
+/* Called prior to resuming a thread.  */
+
+static void
+x86_linux_prepare_to_resume (struct lwp_info *lwp)
+{
+  x86_linux_update_debug_registers (lwp);
+}
+
 /* Called when a new thread is detected.  */
 
 static void


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]