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
Best Answer