Technical Solutions
How do I debug a MATLAB 7.2 (R2006a) MEX-file in Borland C++Builder 6?
Date Last Modified: Friday, June 26, 2009
| Solution ID: | 1-2Y9F7M | |
| Product: | MATLAB | |
| Reported in Release: | No Release | |
| Platform: | Windows | |
| Operating System: | Windows Any |
Subject:
How do I debug a MATLAB 7.2 (R2006a) MEX-file in Borland C++Builder 6?
Problem Description:
I would like to debug a MEX-file in Borland C++Builder 6.
Solution:This Solution is specific to the Borland C++Builder 6 debugger on Windows. For other configurations, see the Debugging section of Tech Note 1605, MEX-files Guide: The following steps demonstrate how to debug a MEX-file in the Borland C++Builder 6 Development Environment: 1. To debug a MEX-file from within MATLAB, you must first compile the MEX-file with the -g option to the MEX function. The -g option builds the MEX-file with debugging symbols included.
mex -g yprime.c
This will create yprime.mexw32. You should now simulate the model to make sure it executes properly. 2. Start the Borland C++Builder 6 Development Environment. Do not exit your MATLAB session. 3. From the Borland menu bar, select Run -> Attach to Process... 4. In the Process GUI that opens, select the MATLAB.exe process and click Attach. You should now be attached to the MATLAB process. 5. Attaching pauses the MATLAB process. Select Run->Run to continue executing MATLAB. 6. Open the source files by selecting File -> Open. As the default filter shows CPP-files but not C-files, you may need to change Files of Type to "C file". 7. Set a breakpoint on the desired line of code by right-clicking on the line of code, and selecting Debug -> Toggle Breakpoint. 8. Execute your MEX-file from within MATLAB:
yprime(1,1:4)
You are now executing your MEX-file in the Borland debugging environment. For more information on the how to use the debugging features in the Borland environment, refer to the Borland C++Builder documentation. |
|
|
Store

