1
votes

I have a problem debugging a Matlab S-function written in C. The source code is analysis.c, after mexing this file by

mex -g -v analysis.c

I obtain "analysis.mexw32" and "analysis.mexw32.pdb".

In Visual Studio 2010, I open "analysis.c", attach it to the process "Matlab" and set a breakpoint. So far, this breakpoint is not accepted:

"Breakpoint not hit. No symbols loaded."

When I run the file in Matlab, everything is executed without hitting the breakpoints. Can anybody give me some advise with this?

I have done this before, and it worked straightforward.

4
this may seem silly, but can you build the classic yprime.c example in the same directory as analysis.c and try to successfully hit a breakpoint? - macduff
I can build it in the same folder, but the breakpoints aren't hit. The pdb file is generated. - Papillon
same here even after 3 years. What a pain in the ***. The symbols are not loaded in Visual studio 2010 and already lost 3 hours trying to try different things. - infoclogged

4 Answers

1
votes

Looks like you've more-or-less followed the instructions in the MATLAB help. Can you double check that you've followed them exactly, please? For example, have you opened exactly the same C-file?

My first suggestion would be to make sure that you've configured your mex compiler to be the same installation of Visual Studio using mex -setup.

0
votes

The problem has been solved by making a change in the "Attach to process" settings. I had to choose "system own code" in the dialogue, after that the symbols were loaded.

0
votes

Using Native Code ,while attaching process to Matlab , it works , breakpoints are hit . hurray ,

0
votes

My setup with yprime.c as described very badly here: http://de.mathworks.com/help/matlab/matlab_external/debugging-on-microsoft-windows-platforms.html

Tools-Options-Debugging-General - "Enable just my code" is unchecked.
Tools-Options-Debugging-Native - Load DLL, Enable RPC Debugging.
Tools-Options-Debugging-Symbols - 
1. Uncheck Microsoft Symbol servers.
2. Add the *location* of your pdb file by clicking on new folder.
3. Cache symbols in this directoy in my case is empty.
Attach process -> *Automatic : Native code* -> Matlab
Debug -Windows- Modules should show your module (pdb file ) now.

I noticed in one of the situation that the symbols were still not being loaded inspite of the above written processs. But one of a module called OnDemand... was present in the Debug-Windows-Modules. So put a breakpoint even if Visual Studio does not show your module or the breakpoint complains that no symbols are loaded. Go ahead and run the program from Matlab yprime(1,1:4), then the symbol would be loaded on demand and the breakpoint would be activated. Atleast in my case I could. Phew !