External Interfaces/API |
Debugging on UNIX
You need to start MATLAB from within a debugger. To do this, specify the name of the debugger you want to use with the -D
option when starting MATLAB.
This example shows how to debug yprime.c
on Solaris using dbx
, the UNIX debugger.
unix> mex -g yprime.c unix> matlab -Ddbx <dbx> stop dlopen <matlab>/extern/examples/mex/yprime.mexsol
Once the debugger loads MATLAB into memory, you can start it by issuing a run
command.
Now, run the MEX-file that you want to debug as you would ordinarily do (either directly or by means of some other function or script). Before executing the MEX-file, you will be returned to the debugger.
You may need to tell the debugger where the MEX-file was loaded or the name of the MEX-file, in which case MATLAB will display the appropriate command for you to use. At this point, you are ready to start debugging. You can list the source code for your MEX-file and set breakpoints in it. It is often convenient to set one at mexFunction
so that you stop at the beginning of the gateway routine. To proceed from the breakpoint, issue a continue
command to the debugger.
Once you hit one of your breakpoints, you can make full use of any facilities that your debugger provides to examine variables, display memory, or inspect registers. Refer to the documentation provided with your debugger for information on its use.
Note For information on debugging on other UNIX platforms, access the MathWorks Technical Support Web site at http://www.mathworks.com/support. |
Debugging C Language MEX-Files | Debugging on Windows |