rr icon indicating copy to clipboard operation
rr copied to clipboard

Handle file open/close during experimental sessions

Open rocallahan opened this issue 11 years ago • 7 comments

Some Gecko debugging helpers dump data to named files. This would require support stdio open/write/close. At least open() would need to be explicitly allowed and executed. Maybe we should only allow open() to create a file that doesn't already exist, to avoid a replaying process accidentally damaging the file system.

rocallahan avatar Jul 25 '14 04:07 rocallahan

Interesting. If we wanted, we could fully emulate open/write/close, because there's no (real) syscall buffering during experiment mode. That would also let us create files in an experiment-specific emufs, although that wouldn't necessarily be obvious to the user.

joneschrisg avatar Jul 25 '14 04:07 joneschrisg

These files need to be visible to the user. E.g. the user does p gfxUtils::WriteAsPNG(drawTarget, "/tmp/frame.png").

rocallahan avatar Jul 25 '14 04:07 rocallahan

By "emulate", I meant use PTRACE_SYSEMU to reach the syscall but have rr implement the syscall, like we use for writes to STD*_FILENO. rr would open the file, if it chose, on behalf of the tracee. So the file would appear in the fs (if rr chose), but the tracee processes wouldn't have real fds that referred to it.

joneschrisg avatar Jul 25 '14 05:07 joneschrisg

I also tried dumping the js heap to stdout in replay (crazy, I know) and that just seemed to hang rr. Is that a similar issue to what's being discussed here?

benturner avatar Sep 04 '14 15:09 benturner

Could be. Is it reproducible? Exactly which function call(s) did you try?

rocallahan avatar Sep 04 '14 23:09 rocallahan

Weird, I tried again and it worked!

I broke here: http://mxr.mozilla.org/mozilla-central/source/js/xpconnect/src/XPCComponents.cpp#2888 (PreciseGCRunnable::Run), then did |call js::DumpHeapComplete(rt, (FILE*)stdout, js::CollectNurseryBeforeDump)|

benturner avatar Sep 05 '14 00:09 benturner

For what it's worth, I would find it very useful to be able to run call dump_heap_to_file("/tmp/heap.dot") in GDB.

edit: It actually seems that this already works; horray!

bgamari avatar Nov 26 '22 15:11 bgamari