Debugging a project which has mex files associated with it
Show older comments
Hi All, I have a project which I need to run. It has a few (10s) .m files and a few (5ish) mex files. I am in ubuntu. I have to debug the code. I can seem to run .m debugging and 1 mex file at a time debugging using matlab and gdb respectively. But I can't get to run both of them together. I have spend considerable amount of time on this and been using terminal and emacs and matlab. I have tried everything that was told online but most of the things were either only for mex files or only for .m files. how on earth do i get a project to debug ???
~neeraj
Answers (2)
Kaustubha Govind
on 28 Jun 2012
0 votes
Could you explain more about what you mean by "can't get to run both of them together"? I have debugged MATLAB files and C-MEX files together - the MATLAB breakpoints are to be set in the MATLAB Editor and the MEX breakpoints in the gdb. I would also recommend that you start MATLAB with the -nodesktop option when attaching with gdb - I have found that this is faster because all the additional libraries required to render the desktop need not be loaded.
Also, could you try running gdb from the shell (instead of from emacs) to see if that makes a difference? I understand that it's harder to set C breakpoints, but this setup has worked well for me in the past.
PS: Please remember to compile your MEX function with the -g (debug) option.
Neeraj
on 28 Jun 2012
0 votes
1 Comment
Kaustubha Govind
on 6 Jul 2012
Neeraj: It shouldn't matter whether you set the MEX breakpoint before starting MATLAB or after. Could you explain what you mean by "before i start running the jvm"? How do you start the JVM? I have found that running MATLAB with the -nojvm option is most reliable, because apparently JVM uses some signals like SIGSEGV during normal operation. A comment on this page suggests that you run "handle SIGSEGV pass noprint nostop" in gdb to avoid running into issues with SIGSEGV. I wonder if running "handle SIGUSR1 nostop" in gdb before "run -nojvm" might fix that?
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!