Dbstep call from function

I am trying to write my version of the debugging command of Matlab dbstep , that is, I want to do dbstep and some other things at a time. However, including dbstep in a function does not work:

 % in file my_dbstep.m function my_dbstep() evalin('caller', 'dbstep'); 

When I call my_dbstep during a debugging session, it acts as if I typed dbstep inside a function, not the caller.

Is there any other solution?

+5
source share
1 answer

The solution I found is to use the mex file from which I can call the function in Matlab to do the things that I want, every time I find the line in debug mode (using this new dbstep2 mex file) and then dbstep call from mex:

 // file dbstep2.c #include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexCallMATLAB(0,NULL,0, NULL, "do_some_stuff"); mexCallMATLAB(0,NULL,0, NULL, "dbstep"); } 

In my case, I use the do_some_stuff function to send keystrokes in vim when debugging in Matlab (no gui), so the current line is highlighted in a script that opens in vim. Of course, it can be used in any other case.

+1
source

All Articles