2
Vote

Debug visualization of non-python code

description

Numpy/scipy are great for prototyping, but all too often production numerics code has to be implemented in C++ or C#. It would be extremely useful to be able to use numpy/matplotlib visualization capabilities while debugging such applications.

Would it be possible to provide at a wrapper of VS Debugger API to Python scripts? ...or at least a subset of it, so that Python scripts could evaluate debugger expressions in the context of debuggee, as well as to read data from debuggee's memory into numpy arrays (and possibly write back). Bonus points for being able to trigger Python functions upon hitting breakpoints.

Example:
Let's say my C++ app has a variable "vector<float> a" in the current stack frame. I would like to be able to do something like the following in the Interactive Python window:
import numpy
import pyvsdebug

def array_from_stdvector(name):
    valtype = pyvsdebug.get_type(name)
    first = pyvsdebug.eval(name + "._Myfirst")
    last = pyvsdebug.eval(name + "._Mylast")
    buffer = pyvsdebug.read_memory(first, last-first)
    return numpy.from_buffer(buffer, numpy_type_from_c_type(valtype))

a = array_from_stdvector("a")
plot(a)

comments