External Interfaces Previous page   Next Page

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.

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.


Previous page  Debugging C Language MEX-Files Debugging on Windows Next page

© 1994-2005 The MathWorks, Inc.