rr icon indicating copy to clipboard operation
rr copied to clipboard

Attaching rr record to an already running process

Open agentzh opened this issue 1 year ago • 1 comments

I wonder if implementing such features is technically possible, and we're interested in helping.

It seems like we just need to use ptrace, etc., first to attach and stop the target, save the current execution state as a snapshot, and then record any events while letting the target continue running. Any other technical hurdles here?

And for rr replay, we can revive from the saved snapshot into a new process and make the history start from the snapshot state.

Sorry if it makes little sense. I have very limited knowledge about the rr internals atm.

Many thanks!

agentzh avatar Feb 26 '24 22:02 agentzh

I thought we had an issue for this already but I can't find it.

Attaching is quite hard for a few reasons. We'd have to save the initial state as some kind of persistent checkpoint (see #2184) which would be at the start of the recording (which is not covered by #2184) and would break all kinds of assumptions. We'd have to inject librrpage.so and librrpreload.so somehow; the latter would be really hard. We'd have to collect state about the meaning of the currently open file descriptors, populate AddressSpace based on the current VMAs, etc etc. It actually sounds really hard.

rocallahan avatar Feb 27 '24 06:02 rocallahan