Bug 207467 - Watchpoints broken on x86-64
Summary: Watchpoints broken on x86-64
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: rawhide
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Dave Jones
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2006-09-21 09:49 UTC by Jakub Jelinek
Modified: 2015-01-04 22:28 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2006-10-12 00:12:19 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
utrace fix, typo-like fix (724 bytes, patch)
2006-09-21 14:45 UTC, Jan Kratochvil
no flags Details | Diff
Updated fix, cryptocode sanitized; upon Jakub's advice (4.62 KB, patch)
2006-09-21 17:32 UTC, Jan Kratochvil
no flags Details | Diff
linux-2.6.18-utrace-x86-64-watchpoint.patch (1.64 KB, patch)
2006-09-21 18:58 UTC, Jakub Jelinek
no flags Details | Diff

Description Jakub Jelinek 2006-09-21 09:49:33 UTC
rpm -q --qf '%{name}-%{version}-%{release}.%{arch} ' gdb glibc gcc; uname -r
gdb-6.5-8.fc6.x86_64 glibc-2.4.90-33.x86_64 glibc-2.4.90-33.i686 gcc-4.1.1-23.x86_64 2.6.17-1.2647.fc6
cat a.c
long i;

int
main (void)
{
  ++i;
  return i - 1;
}
cat .gdbinit
watch i
run
cont
quit
gcc -g -o a1 a.c
gcc -g -o a2 a.c -Dlong=int
gdb ./a1
gdb ./a2
Apparently gdb can watch 32-bit objects, but can't watch 64-bit objects.
Strace of gdb ./a1 shows (0x600800 is &i):
...
ptrace(PTRACE_PEEKTEXT, 2301, 0x600800, [0]) = 0
ptrace(PTRACE_PEEKTEXT, 2301, 0x2aaaaaaabb50, [0x528e8e78948]) = 0
ptrace(PTRACE_PEEKTEXT, 2301, 0x2aaaaaaabb58, [0x21922b058bc48949]) = 0
ptrace(PTRACE_PEEKTEXT, 2301, 0x600800, [0]) = 0
ptrace(PTRACE_POKEUSER, 2301, offsetof(struct user, u_debugreg), 0x600800) = 0
ptrace(PTRACE_POKEUSER, 2301, offsetof(struct user, u_debugreg) + 56, 0x90101) = -1 EIO (Input/output error)
Strace of gdb ./a2 shows (0x6007fc is &i):
ptrace(PTRACE_PEEKTEXT, 2296, 0x6007f8, [0]) = 0
ptrace(PTRACE_PEEKTEXT, 2296, 0x2aaaaaaabb50, [0x528e8e78948]) = 0
ptrace(PTRACE_PEEKTEXT, 2296, 0x2aaaaaaabb58, [0x21922b058bc48949]) = 0
ptrace(PTRACE_PEEKTEXT, 2296, 0x6007f8, [0]) = 0
ptrace(PTRACE_POKEUSER, 2296, offsetof(struct user, u_debugreg), 0x6007fc) = 0
ptrace(PTRACE_POKEUSER, 2296, offsetof(struct user, u_debugreg) + 56, 0xd0101) = 0
ptrace(PTRACE_PEEKUSER, 2296, offsetof(struct user, u_debugreg), [0x6007fc]) = 0
ptrace(PTRACE_PEEKUSER, 2296, offsetof(struct user, u_debugreg) + 8, [0]) = 0
ptrace(PTRACE_PEEKUSER, 2296, offsetof(struct user, u_debugreg) + 16, [0]) = 0
ptrace(PTRACE_PEEKUSER, 2296, offsetof(struct user, u_debugreg) + 24, [0]) = 0
ptrace(PTRACE_PEEKUSER, 2296, offsetof(struct user, u_debugreg) + 56, [0xd0101]) = 0

I certainly don't remember any issues with this on FC5, is that related to utrace?

Comment 1 Jan Kratochvil 2006-09-21 14:45:54 UTC
Created attachment 136860 [details]
utrace fix, typo-like fix

There is just a wrong constant, fixed to the one described in the comment there
and referenced to come from AMD x86_64 manual.

Comment 2 Jakub Jelinek 2006-09-21 15:55:47 UTC
Actually it should be 0x5554, see
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=893efca9279d7a78bae6532de0524e53370819d5
(which was for whatever reason not applied to arch/x86_64/ia32/ptrace32.c).
Also, the comments explaining this in i386 ptrace.c is very confusing, writing
binary 10 as 0x10 rather than either 10 or 2 means the comment is really hard to
understand.

Comment 3 Jan Kratochvil 2006-09-21 17:32:49 UTC
Created attachment 136892 [details]
Updated fix, cryptocode sanitized; upon Jakub's advice

Comment 4 Jakub Jelinek 2006-09-21 18:22:08 UTC
Well, I think the current code (with the right 0x5554 constant) is ok, only the
comment could be made more readable.  This isn't something that is changed
every day and the code with mask is definitely shorter.

Comment 5 Jakub Jelinek 2006-09-21 18:58:29 UTC
Created attachment 136900 [details]
linux-2.6.18-utrace-x86-64-watchpoint.patch

My proposed patch.

Comment 6 Roland McGrath 2006-09-28 21:40:23 UTC
please send the comment change upstream; that comment is copied verbatim from
pre-utrace code

Comment 7 Roland McGrath 2006-09-28 22:12:30 UTC
committed utrace fix, pls rebuild and push to fc6/rhel


Note You need to log in before you can comment on or make changes to this bug.