1

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.

3
  • 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? Commented Feb 28, 2012 at 14:39
  • I can build it in the same folder, but the breakpoints aren't hit. The pdb file is generated. Commented Feb 28, 2012 at 16:36
  • 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. Commented Nov 23, 2015 at 15:02

4 Answers 4

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I followed the Matlab help. The C-file is the same. Running mex -setup shows me that there are only 2 compilers available: [1] Lcc-win32 C 2.4.1 in C:\PROGRA~1\MATLAB\R2011a\sys\lcc [2] Microsoft Visual C++ 2010 in C:\Programme\Microsoft Visual Studio 10.0 <-- The one I choose.
I also get this: --> cl /c /Zp8 /GR /W3 /EHs /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_SECURE_SCL=0 /DMATLAB_MEX_FILE /nologo /MD /FoC:\DOKUME~1\BENDER~1.WIN\LOKALE~1\TEMP\MEX_CS~1\analysis.obj -IC:\PROGRA~1\MATLAB\R2011A\extern\include -IC:\PROGRA~1\MATLAB\R2011A\simulink\include /Z7 -DMX_COMPAT_32 analysis.c
0

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.

Comments

0

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

Comments

0

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 !

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.