How can I set breakpoints in multiple MEX files using DDD or GDB when debugging MEX files in MATLAB 7.8 (R2009a)?
3 views (last 30 days)
Show older comments
I have a complex MATLAB program that I'm trying to interface and debug with some fairly complex C/C++ code. So I have multiple mex-files created to call different C/C++ functions from an external library. I need some help in setting the breakpoints when I run MATLAB within a debuggger.
I'm currently using ddd which is just a frontend to gdb. The examples in the MATLAB documentation only deal with the simple example of debugging a single mex-file. How do I specify a breakpoint for a specific mex-file?
If I type 'break mexFunction' as specified in the simple example in the documentation. I just get a breakpoint for the very first mexFunction that is called. And if I type break foo.c:mexFunction to stop at the entry point for a specific mex-file, I get the response "No source file named foo.c"
Are there any suggestions or methods to debug mex-files in this situation?
Accepted Answer
MathWorks Support Team
on 11 Aug 2009
Here is an example of setting breakpoints in two MEX files. The example uses the following files:
1) timestwo.mexw32 % Refer to MATLAB documentation for code sample
2) yprime.mexw32 % Refer to MATLAB documentation for code sample
3) debugMexGDB.m: A MATLAB function that calls the above two MEX files as follows:
yprime(1:1,4)
disp('Hello world')
timestwo
Run the following commands in a Unix shell for debugging:
matlab -Dgdb # Launch MATLAB in gdb
run -nojvm
>> dbstop in debugMexGDB # You are currently inside MATLAB
>> dbmex on
>> debugMexGDB
K>> dbstep # You are currently inside debugMexGDB
(gdb) break yprime.c:mexFunction # You are currently inside yprime
(gdb) break timestwo.c:10
(gdb) continue
K>> dbstep # You are currently inside debugMexGDB
Hello world
K>> dbstep
(gdb) continue # You are currently inside timestwo
(gdb) quit
0 Comments
More Answers (0)
See Also
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!