Friday, June 4, 2010

Debug Matlab MEX files with gdb in Linux / OSX

From the Mathworks helpdesk site here are some instructions for debugging mex files.

Make sure that the mex has been compiled with -g
>> mex -g function.c

Restart Matlab with:
shell> matlab -Dgdb
run -nojvm
>> dbmex on

Run the code:
>> function(param)

To access the debugger:
>> dbmex stop

To add a breakpoint at the gateway function (just before your code):
break mexFunction

No comments:

Post a Comment