Ruby has an very interesting tracer tool: https://github.com/tmm1/rbtrace/ Hunter could have something like that: - IPC with SysV queues (tracer would write to the queue, and external process can read from it). - Now there's the question of POSIX queues. Or not. They aren't supported on OSX: http://semanchuk.com/philip/posix_ipc/#platforms - Need external activation of tracer. There are two ways to do it: - On demand activation: - Tracer is installed from signal handler. - Signal handler is installed from pth file. - Only works for mainthread. Installing tracers in other threads means patching some PyThreadState structs from C code (dangerous, eg: https://github.com/bobfrank/pydebug/blob/master/debug.py#L291) - Passive tracer: - Tracer is always installed from pth file but I doesn't do anything until someone connects to queue. - Need to detects connections to queue. Or use signal to start pushing stuff in queue? - Overhead should be ok for CPython, but what about PyPy? - It would allow tracing threads too (since tracer can be installed for threads too).
Activity
ionelmc commentedon Mar 5, 2016
If we'd use a signal I'd go with SIGTRAP: https://www.gnu.org/software/coreutils/manual/html_node/Signal-specifications.html (as opposed to rbtrace's SIGURG, also: tmm1/rbtrace#53).
ionelmc commentedon Oct 20, 2016
Take note of https://github.com/khamidou/lptrace
ionelmc commentedon Aug 29, 2017
Make note of https://gist.github.com/CAFxX/571a1558db9a7b393579 and https://news.ycombinator.com/item?id=10195297 (a file-based queue technique).
ionelmc commentedon Aug 29, 2017
For queues this seems like the package: http://semanchuk.com/philip/sysv_ipc/ (supports osx too).