Debugging a function line by line from another script
Mostrar comentarios más antiguos
Hello All,
Here is the minimum working example for what I am trying to do:
% main script to run a function
a = 1;
b = 2;
c = fun(a,b);
% script end
function out = fun(a,b)
d = 1;
out = a + b;
end
I would like to programmatically debug the function 'fun' from the workspace of the main script in such a manner that I can get the information about what is going on in each line of the function 'fun'. When I tried 'dbstop' right before the function 'fun' is called, debugger puts a break point at the first executable line inside the 'fun' and waits there. I would like to silently (meaning not being taken to breakpoint in 'fun') debug line by line through the 'fun' programmatically without leaving the workspace of main script. Is that possible ? Thanks in advance for your help. Any help is greatly appreciated.
-Anand
1 comentario
Guillaume
el 18 de Jun. de 2015
That makes no sense to me. In order to debug the function, that is see what it does, you need to see the variables it is operating on, so you need to be in its workspace. Otherwise, what's the point?
Note that you can always switch back to the script workspace while in the function with dbup (and go back to the function workspace with dbdown). But your function won't have any influence on the script workspace (unless it's using globals or evalin and co.), so again there's little point in it.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Database Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!