0

Basically, I want to avoid system calls for reading to/writing from the debugee memory space. I only want to map a single mapping from /proc/pid/maps, I tried just mmap()ing from /proc/pid/mem but turns out procfs doesn't support mmap.

Tuxifan

tuxifan
  • 29
  • 5
  • No can do, I'm afraid. The best you can do is, I believe [process_vm_readv()/process_vm_writev()](https://man7.org/linux/man-pages/man2/process_vm_readv.2.html), which allow you to coalesce all reads you want into a single syscall and all writes to another, using `struct iovec`s. The [ptrace](https://man7.org/linux/man-pages/man2/ptrace.2.html) interface is rather strict, so that we can avoid all kinds of race conditions on widely diffrent hardware. – Blabbo the Verbose Aug 16 '22 at 07:28
  • I am only expecting to read/write memory while the process is stopped – tuxifan Aug 16 '22 at 13:31
  • Doesn't matter, especially because ptracing targets a specific thread in a thread group (including a process), and is never process-wide. Simply put, you're looking at the entire process, but ptracing occurs at the thread level and not at the process level, which explains why your desires do not match what the interface provides. (This is not intended as a slight, it is intended as an explanation why the interface does not provide what you think it should/could.) Besides, the syscall overhead is minuscule in Linux, and with proper/sensible code never a bottleneck. – Blabbo the Verbose Aug 17 '22 at 04:25
  • Alright, interesting! – tuxifan Aug 17 '22 at 12:28

0 Answers0