3 ms·
You can allocate memory in another process on Unix too: use ptrace to make the other process call malloc (use PTRACE_SETREGS to set PC to malloc and the first a
by jrtc27 5y ago
You can allocate memory in another process on Unix too: use ptrace to make the other process call malloc (use PTRACE_SETREGS to set PC to malloc and the first argument register to the number of bytes, then intercept the return).
GDB will use this if you tell it something like `p foo("bar")`, as it needs to allocate memory for that string somewhere.