News for hackers. Stuff that matters.
Re:Pyrasite: Tools for injecting code into running Python pr... by tbarbugli on Monday August 11, 2014 @03:34AM (#8162335)
Would be nice to know how this actually works; docs dont say much about how the tool injects the code into the running process.
Re:Pyrasite: Tools for injecting code into running Python pr... by matthewmacleod on Monday August 11, 2014 @04:38AM (#8162475)
It basically uses GDB to call eval inside a running Python VM. Pretty simple, but quite useful from time to time.
Re:Pyrasite: Tools for injecting code into running Python pr... by BozeWolf on Monday August 11, 2014 @04:39AM (#8162478)
But how does it get into that running Python VM?
Re:Pyrasite: Tools for injecting code into running Python pr... by coolj on Monday August 11, 2014 @05:39AM (#8162616)
GDB uses a system call(s) to attach to the running process[1], and python exposes an API that lets you evaluate code in the current VM context[2]. Specifically, https://github.com/lmacken/pyrasite/blob/develop/pyrasite/in...

[1] http://aosabook.org/en/gdb.html [2] https://docs.python.org/2/c-api/veryhigh.html

Re:Pyrasite: Tools for injecting code into running Python pr... by BozeWolf on Monday August 11, 2014 @06:23AM (#8162722)
Excellent answer to my question. Thanks!
Re:Pyrasite: Tools for injecting code into running Python pr... by ionelm on Thursday August 14, 2014 @03:31PM (#8179378)
It's basically this: attach with GDB, get GIL, run commands (your session), release GIL. This is pretty dangerous as the GIL release is not guaranteed.

This is why I wrote https://pypi.python.org/pypi/manhole - I couldn't afford hosing up (deadlocking) my processes, and it happen pretty often with pyrasite in my usecases. Have in mind that manhole is not that flexible as it uses different technique.

Re:Pyrasite: Tools for injecting code into running Python pr... by klibertp on Monday August 11, 2014 @10:48AM (#8163468)
Just read this file: https://github.com/lmacken/pyrasite/blob/develop/pyrasite/in... it's rather straightforward.