How can I set breakpoints in multiple MEX files using DDD or GDB when debugging MEX files in MATLAB 7.8 (R2009a)?
조회 수: 4 (최근 30일)
이전 댓글 표시
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?
채택된 답변
MathWorks Support Team
2009년 8월 11일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!