|
From: Yan <ya...@ya...> - 2013-09-23 07:10:24
|
Hey guys, It's me again. I just wrote about Python VEX bindings that I put up here: https://github.com/zardus/pyvex Although I originally wrote them for static analysis, one obvious idea with these bindings is to have some ability to write Valgrind tools in Python. Presumably, once a Python interpreter is embedded into Valgrind, pyvex can expose the IRSBs to a Python instrumentation function. I think this would be useful for quick prototyping, and analyses where flexibility of programming is more important than speed. Personally, I'd use it a bunch. Hopefully other people are interested :-) Of course, the challenge is embedding a python interpreter in Valgrind. I've been trying to do this for a few days (see the pygrind subdirectory in the pyvex module). I've tried the following approaches: 1. #including <Python.h>, initializing Python normally, and so forth. This is, I presume for good reason, a complete nightmare to get to link with the way Valgrind wants to link things. When I force all the various things to be linked (including the python interpreter, math library, crypto libraries, libc, etc, which I'm sure breaks tons of things), Valgrind can no longer load the tool, with the following message: valgrind: mmap(0x400000, 102400) failed in UME with error 22 (Invalid argument). valgrind: this can be caused by executables with very large text, data or bss segments. 2. Using libdl to dlopen the Python interpreter on the fly and initialize it this way, in an attempt to avoid linking in tons of stuff. Unfortunately, libdl still relies on linking in libc, and Valgrind still fails with the error from #1. My next idea is to try to find a self-contained dlopen implementation, and see if I can make that work. Is anyone else interested in this sort of thing? Suggestions on how to actually do it? Thanks! - Yan |