linux-um archives
 help / color / mirror / Atom feed
From: Barry Friedman <barryf@google.com>
To: user-mode-linux-devel@lists.sourceforge.net
Cc: Barry Friedman <barryf@google.com>
Subject: [uml-devel] [PATCH] UML: Fix gdbserver "Couldn't write debug register" error
Date: Tue, 20 Apr 2010 17:21:51 -0700	[thread overview]
Message-ID: <1271809311-8460-1-git-send-email-barryf@google.com> (raw)

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(-)

diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index f3458d7..e491e48 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -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);
-- 
1.7.0.1


------------------------------------------------------------------------------
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


                 reply	other threads:[~2010-04-21  0:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1271809311-8460-1-git-send-email-barryf@google.com \
    --to=barryf@google.com \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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