Search code examples
debuggingmatlabmatlab-deployment

Not reproducible exe hang of Matlab Compiler output executable


I have the following problem: I have a Matlab program in form of some set of *.m files. It is later compiled into executable and used. The problem is that occasionally the resulted executable just hangs and this behavior cannot be reproduced when debugging/running *.m files from IDE (even using the same input data).

To figure out what hapens I intended to:

  • compile (somehow) *.m files into C/C++
  • compile C/C++ as debug to get .exe and .pdb And later when .exe hangs just 'attach' visual studio debugger to hanged .exe to check where it 'loops/waits'.

Unfortunaley Matlab Compiler (as I was told today) does not produce C/C++ code before creating executable. I was misleaded by -g option of mcc which according to the documenttion is supposed to do the following:

-g Generate Debugging Information

Include debugging symbol information for the C/C++ code generated by MATLAB Compiler.

It looks exacly like the thing I want to archive. I would appreciate if someone could explain me that discapency or suggest how to archive what I am trying to do (if it can be done at all).


Solution

  • It is not possible to create a debuggable code in Matlab compiler, because the deployed code uses MCR. (Matlab virtual machine) .

    See this question : Is there any way to debug compiled components using Matlab Debugger?

    Since you don't have errors, but rather an infinite loop, the best solution in that case would be screen outputs, and hopefully you will trace the bug.