External Interfaces |
Debugging on UNIX
You must 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. For example, to use dbx
, the UNIX debugger, type
Once the debugger loads MATLAB into memory, you can start it by issuing a run
command. Now, from within MATLAB, enable MEX-file debugging by typing
at the MATLAB prompt. Then run the MEX-file you want to debug as you would ordinarily (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 break points 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 your debugger provides to examine variables, display memory, or inspect registers. Refer to the documentation provided with your debugger for information on its use.
If you are at the MATLAB prompt and want to return control to the debugger, you can issue the command
which allows you to gain access to the debugger so you can set additional breakpoints or examine source code. To resume execution, issue a continue
command to the debugger.
Debugging Fortran Language MEX-Files | Debugging on Windows |
© 1994-2005 The MathWorks, Inc.