[09/13,v2] Linux x86 low-level debug register code synchronization

Message ID 1412848358-9958-10-git-send-email-gbenson@redhat.com
State Committed
Headers

Commit Message

Gary Benson Oct. 9, 2014, 9:52 a.m. UTC
  This commit makes several small changes to the low-level debug
register code for Linux x86, making the code in the GDB and
gdbserver implementations identical.

gdb/ChangeLog:

	* x86-linux-nat.c (x86_linux_dr_set_addr): Updated assertion.
	(x86_linux_new_thread): Renamed argument.

gdb/gdbserver/ChangeLog:

	* linux-x86-low.c (x86_linux_dr_get): Add assertion.
	Use perror_with_name.
	(x86_linux_dr_set): Likewise.
---
 gdb/ChangeLog                 |    5 +++++
 gdb/gdbserver/ChangeLog       |    6 ++++++
 gdb/gdbserver/linux-x86-low.c |    6 ++++--
 gdb/x86-linux-nat.c           |    6 +++---
 4 files changed, 18 insertions(+), 5 deletions(-)
  

Comments

Pedro Alves Oct. 28, 2014, 12:59 p.m. UTC | #1
On 10/09/2014 10:52 AM, Gary Benson wrote:
> This commit makes several small changes to the low-level debug
> register code for Linux x86, making the code in the GDB and
> gdbserver implementations identical.
> 
> gdb/ChangeLog:
> 
> 	* x86-linux-nat.c (x86_linux_dr_set_addr): Updated assertion.
> 	(x86_linux_new_thread): Renamed argument.

"Update"m "Rename".

> 
> gdb/gdbserver/ChangeLog:
> 
> 	* linux-x86-low.c (x86_linux_dr_get): Add assertion.
> 	Use perror_with_name.

 	* linux-x86-low.c (x86_linux_dr_get): Add assertion.
 	Use perror_with_name.  Pass string through gettext.

> 	(x86_linux_dr_set): Likewise.

OK.

Thanks,
Pedro Alves
  

Patch

diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index e5257a3..3064791 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -529,13 +529,14 @@  x86_linux_dr_get (ptid_t ptid, int regnum)
   int tid;
   unsigned long value;
 
+  gdb_assert (ptid_lwp_p (ptid));
   tid = ptid_get_lwp (ptid);
 
   errno = 0;
   value = ptrace (PTRACE_PEEKUSER, tid,
 		  offsetof (struct user, u_debugreg[regnum]), 0);
   if (errno != 0)
-    error ("Couldn't read debug register");
+    perror_with_name (_("Couldn't read debug register"));
 
   return value;
 }
@@ -545,13 +546,14 @@  x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value)
 {
   int tid;
 
+  gdb_assert (ptid_lwp_p (ptid));
   tid = ptid_get_lwp (ptid);
 
   errno = 0;
   ptrace (PTRACE_POKEUSER, tid,
 	  offsetof (struct user, u_debugreg[regnum]), value);
   if (errno != 0)
-    error ("Couldn't write debug register");
+    perror_with_name (_("Couldn't write debug register"));
 }
 
 static int
diff --git a/gdb/x86-linux-nat.c b/gdb/x86-linux-nat.c
index c4387eb..c5c8576 100644
--- a/gdb/x86-linux-nat.c
+++ b/gdb/x86-linux-nat.c
@@ -156,7 +156,7 @@  x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
 {
   ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
 
-  gdb_assert (regnum >= 0 && regnum <= DR_LASTADDR - DR_FIRSTADDR);
+  gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
   iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
 }
@@ -213,9 +213,9 @@  x86_linux_prepare_to_resume (struct lwp_info *lwp)
 }
 
 static void
-x86_linux_new_thread (struct lwp_info *lp)
+x86_linux_new_thread (struct lwp_info *lwp)
 {
-  lwp_set_debug_registers_changed (lp, 1);
+  lwp_set_debug_registers_changed (lwp, 1);
 }