Bug 207467 - Watchpoints broken on x86-64
Watchpoints broken on x86-64
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: kernel (Show other bugs)
rawhide
x86_64 Linux
medium Severity medium
: ---
: ---
Assigned To: Dave Jones
Brian Brock
: Patch, Regression
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2006-09-21 05:49 EDT by Jakub Jelinek
Modified: 2015-01-04 17:28 EST (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2006-10-11 20:12:19 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Jakub Jelinek 2006-09-21 05:49:33 EDT
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 10:45:54 EDT
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 11:55:47 EDT
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 13:32:49 EDT
Created attachment 136892 [details]
Updated fix, cryptocode sanitized; upon Jakub's advice
Comment 4 Jakub Jelinek 2006-09-21 14:22:08 EDT
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 14:58:29 EDT
Created attachment 136900 [details]
linux-2.6.18-utrace-x86-64-watchpoint.patch

My proposed patch.
Comment 6 Roland McGrath 2006-09-28 17:40:23 EDT
please send the comment change upstream; that comment is copied verbatim from
pre-utrace code
Comment 7 Roland McGrath 2006-09-28 18:12:30 EDT
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.