Skip to contentSkip to conversation

UML: Fix gdbserver "Couldn't write debug register" error

PATCH New Barry Friedman 1 participant 1 message Apr 21, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 UML: Fix gdbserver "Couldn't write debug register" error

Running gdbserver in a UML instance displays "Couldn't write debug register" after setting a breakpoint and continuing after attaching from a remote gdb on the host. This is on an AMD x86_64 machine. The error message was resulting from getting EIO error when making a PTRACE_POKEUSER call. I debugged the ptrace call handling on the kernel side and found that the poke_user() and peek_user() calls in arch/um/sys-x86_64/ptrace.c assume that long is 4 bytes instead of
8. Fix here calculates the register index based on 8 byte long.

arch/um/sys-x86_64/ptrace.c
- poke_user(): Fix register index calc based on 8 byte long
- peek_user(): Fix register index calc based on 8 byte long

---
 arch/um/sys-x86_64/ptrace.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
arch/um/sys-x86_64/ptrace.c +2 -2
index f3458d7..e491e48 100644
@@ -69,7 +69,7 @@ int poke_user(struct task_struct *child, long addr, long data)
 	else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
 		(addr <= offsetof(struct user, u_debugreg[7]))) {
 		addr -= offsetof(struct user, u_debugreg[0]);
-		addr = addr >> 2;
+		addr = addr >> 3;
 		if ((addr == 4) || (addr == 5))
 			return -EIO;
 		child->thread.arch.debugregs[addr] = data;
@@ -114,7 +114,7 @@ int peek_user(struct task_struct *child, long addr, long data)
 	else if ((addr >= offsetof(struct user, u_debugreg[0])) &&
 		(addr <= offsetof(struct user, u_debugreg[7]))) {
 		addr -= offsetof(struct user, u_debugreg[0]);
-		addr = addr >> 2;
+		addr = addr >> 3;
 		tmp = child->thread.arch.debugregs[addr];
 	}
 	return put_user(tmp, (unsigned long *) data);
Signature · 8 lines
1.7.0.1


------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel