janestreet/magic-trace

Add a mode to automatically capture a trace and exit

knrafto opened this issue · 3 comments

We have a script to automatically run magic-trace during tests. Right now we have to start magic-trace, wait for some amount of time, and then send SIGINT to magic-trace using pkill. Unfortunately, the time we need to wait is not predictable (it could be 5s or more for large binaries) so this occasionally sends SIGINT too early. If would be nice if we could tell magic-trace to take a snapshot and exit when it's done.

I tried to implement this myself but I couldn't find a good way to know when perf is "ready". It looks like magic-trace itself has a hardcoded 500ms timeout, which is definitely not long enough for our binaries. Do you have any ideas?

(sorry, this is a feature request, not a bug report, but I don't see how to change the labels now)

Xyene commented

I think #230 should address this. You could write magic-trace attach -p [your process' pid] -- true and that would do the right thing.

Interesting, thanks! Closing to dedup