Ask HN: How to programmatically observe program execution?
4 comments
DTrace and SystemTap can insert probes in code if you're only interested in certain parts. If you want basic-block-level or instruction-level coverage, look at Pin, DynamoRIO, or Valgrind.
Thanks, the latter two sound good. Pin seems to be a too generic acronym to Google it, what does it stand for?
Ah, good point; it took me a few tries to find the site myself. Apparently Pin isn't an acronym; it's just Pin.
http://www.pintool.org/
http://www.pintool.org/
Maybe something like dtrace? I'm not sure what your application scenario is though.
Thanks, meanwhile I have just stumbled up on ptrace which also looks promising.
My application is to visualise the execution of programs, for which I want to ideally capture everything the processor does and generalise what I see...
My application is to visualise the execution of programs, for which I want to ideally capture everything the processor does and generalise what I see...
There's been research on this, e.g. http://www.cs.nmsu.edu/~jeffery/alamo/
That's about 10 years old, though, and I don't know what's been done since.
That's about 10 years old, though, and I don't know what's been done since.
If you run your debugger via emacs, you should be able to use emacs macros to programmatically observe execution.
Rigging up a debugger was my first idea, as they do the same thing for human consumption, but that doesn't seem to be a normal use scenario, and hence no APIs. Alternatively one could extend some virtualization software to capture what the processor is doing. I would settle for source modification, which would work for just capturing function calls, but that brings in other complications. Finally there's the issue of languages: I was thinking of simple C programs, although it would probably be easier in Java or Lisp, but I'd like to stay general.
Have you ever solved this or what approach would you try?