PTRACE_{READ,WRITE}{TEXT,DATA}
Hi Roland, David !
I noticed kernel/ptrace.c has ptrace_readdata/writedata functions that are only used by sparc and sparc64 which implements the ptrace requests PTRACE_READ_DATA, PTRACE_WRITE_DATA (and _TEXT variants).
Any reason not to make everybody benefit from these and moving the sparc implementation to the generic ptrace_request (&compat) ?
It's more efficient than read/writing one word at a time... I thought about it in the light of some work Rik is doing to make access_process_vm useable on video ram mappings done by the X server...
If you are ok, I'll do a patch.
Cheers,
Ben
From: Benjamin Herrenschmidt <[email protected]>
Date: Tue, 29 Apr 2008 13:54:08 +1000
Quoted 10 lines
I noticed
kernel/ptrace.chas ptrace_readdata/writedata functions that are only used by sparc and sparc64 which implements the ptrace requestsPTRACE_READ_DATA,PTRACE_WRITE_DATA(and_TEXTvariants).Any reason not to make everybody benefit from these and moving the sparc implementation to the generic
ptrace_request(&compat) ?It's more efficient than read/writing one word at a time... I thought about it in the light of some work Rik is doing to make
access_process_vmuseable on video ram mappings done by the X server...
It's kind of pointless because what gdb does these days on Linux is use the procfs 'mem' file to directly read in parts of the inferior's address space.
See linux_proc_xfer_partial() in gdb/linux-nat.c
Quoted 14 lines · On Mon, 28 Apr 2008 21:34:16 -0700 (PDT) David Miller <[email protected]>…
From: Benjamin Herrenschmidt <[email protected]>
Date: Tue, 29 Apr 2008 13:54:08 +1000Quoted 10 lines
I noticed
kernel/ptrace.chas ptrace_readdata/writedata functions that are only used by sparc and sparc64 which implements the ptrace requestsPTRACE_READ_DATA,PTRACE_WRITE_DATA(and_TEXTvariants).Any reason not to make everybody benefit from these and moving the sparc implementation to the generic
ptrace_request(&compat) ?It's more efficient than read/writing one word at a time... I thought about it in the light of some work Rik is doing to make
access_process_vmuseable on video ram mappings done by the X server...
Quoted 5 lines
It's kind of pointless because what gdb does these days on Linux is use the procfs 'mem' file to directly read in parts of the inferior's address space.
See
linux_proc_xfer_partial()ingdb/linux-nat.c
Strange, changing access_process_vm on Fedora 9 made gdb able to see video memory that the X server had mmapped.
Are you sure gdb behaves as you suggest?
On x86 my patch seems to work as I expected...
Signature · 1 line
All rights reversed.
Quoted 7 lines
Strange, changing
access_process_vmon Fedora 9 made gdb able to see video memory that the X server had mmapped.Are you sure gdb behaves as you suggest?
On x86 my patch seems to work as I expected...
Because /proc/<pid>/mem also uses access_process_vm(). See fs/proc/base.c
Cheers,
Ben.
Quoted 14 lines · David Miller
From: Benjamin Herrenschmidt <[email protected]>
Date: Tue, 29 Apr 2008 13:54:08 +1000Quoted 10 lines
I noticed
kernel/ptrace.chas ptrace_readdata/writedata functions that are only used by sparc and sparc64 which implements the ptrace requestsPTRACE_READ_DATA,PTRACE_WRITE_DATA(and_TEXTvariants).Any reason not to make everybody benefit from these and moving the sparc implementation to the generic
ptrace_request(&compat) ?It's more efficient than read/writing one word at a time... I thought about it in the light of some work Rik is doing to make
access_process_vmuseable on video ram mappings done by the X server...
Quoted 5 lines
It's kind of pointless because what gdb does these days on Linux is use the procfs 'mem' file to directly read in parts of the inferior's address space.
See
linux_proc_xfer_partial()in gdb/linux-nat.c=
Good point. That still uses access_process_vm() so Rik and I work is still valid tho.
Thanks,
Ben.
I don't see any sense in adding that. Using /proc/pid/mem is already the "efficient" API for this known to userland. I don't think keeping the fd around for that is any great burden, and if you do then the one pread64 call is just as efficient as one ptrace call to do the same thing.
Thanks,
Roland
Quoted 4 lines · Roland McGrath
I don't see any sense in adding that. Using
/proc/pid/memis already the "efficient" API for this known to userland. I don't think keeping the fd around for that is any great burden, and if you do then the one pread64 call is just as efficient as one ptrace call to do the same thing.
Yup, I didn't know gdb used /proc/pid/mem to be honest ... as long as it goes through access_process_vm(), I'm fine anyway.
Cheers,
Ben.
Quoted 2 lines
Yup, I didn't know gdb used
/proc/pid/memto be honest ... as long as it goes throughaccess_process_vm(), I'm fine anyway.
All user ABIs for this have always boiled down to access_process_vm.