how do i debug dll generated from compiler

3 visualizaciones (últimos 30 días)
rafael
rafael el 28 de Mzo. de 2016
Comentada: Walter Roberson el 29 de Mzo. de 2016
i created a c++ dll using matlab compiler. i am able to use the dll in my application. my problem is i can't debug the dll. once i send a bad value the program crashes. i would like to be able to step through the matlab code and see where it is failing. any advice on how to do this?

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de Mzo. de 2016
MATLAB Compiler generates encrypted data structures without the actual MATLAB code. It is not debuggable at the MATLAB level.
If you were to use MATLAB Coder then the resulting code could be debugged by any suitable debugger, at the C/C++ level.
Basically with the Compiler you need to fall back to disp() and fprintf() and the like. Any code that interacts with the user should be checking input and explicitly checking file existence. Every fopen() should have its result checked. Toss in try/catch to detect and report on errors.
  2 comentarios
rafael
rafael el 29 de Mzo. de 2016
thanks. i will try your advice. i was hoping of an easier way of checking. its just whenever i recompile my code it takes 5 mins.
Walter Roberson
Walter Roberson el 29 de Mzo. de 2016
Add an extra argument to your function that is the debugging level. Code debugging checks in lots of places that check the current debugging level to determine whether to dump information. Then leave those checks in place permanently (unless they are really interfering with performance.) As long as you do not have an error that interferes with all execution paths, you can then do multiple testing with the same .exe.
Command line arguments to .exe are passed as strings no matter what characters are in them (e.g., numeric-looking things are not made into numbers unless you convert it in the code) so you can use section names with a separator. For example,
MyExe fopen,handle_paranoia
function MyExe(debugopts)
debugflags = struct();
if nargin > 0
flagnames = strsplit(debugopts, ',');
for K = 1 : length(flagnames)
debugflags.(flagnames{K}) = true;
end
end
...
[fid, message] = fopen(filename)
if isfield(debugflags,'fopen')
fprintf('Result of open of "%s" was %d with message "%s"\n', filename, fid, message);
end

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB Compiler en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by