Debug stack on error
Show older comments
Dear all,
since I use the newer version of Matlab, I habe a problem with the debug mode. Whenever I use dbstop if error, the debugger stops miles deep in some Matlab functions and not at the position of the error. Even if I try to step through the call stack, I only step though a lot of Matlab functionality until I end up outside of debug mode.
Why is this happening? I really loved to use dbstop if error and now it is useless to me.
Best regards
15 Comments
At the very least we need the full error message. It may also be helpful to run the following command at the point where the break occurs while still in debug mode and share the results.
dbstack
If the problem is reproducible, I'd like to tinker with it on my end, but I would need to lines of code that cause the problem.
Bjorn Gustavsson
on 28 Aug 2020
That occurs to me too - sometimes. For me it was a case of loosing my patience and repeating dbup too many times in quick succession without looking where I should stop.
Alexandra
on 31 Aug 2020
Too bad we don't have an example of a full error message. That would have helped us out a bit.
Depending on what's causing the error (which may be indicated in the full error message), this behavior may be expected with app designer. Or, it may indicate that the app is corrupted.
Alexandra
on 31 Aug 2020
Adam Danz
on 31 Aug 2020
I wonder what part of the assertion at line 457 is going bad. Perhaps you could place a break point on that line and then cause the error so that it stops at that line before continuing. Then look at the inputs and share that line of code and its inputs. Is SicfView/RunSicf something your wrote in your app?
Having a working example may be helpful - I could at least report whether it's happening on my end or not.
Alexandra
on 1 Sep 2020
Walter Roberson
on 1 Sep 2020
dbstop if caught error
Thanks for the demo file.
"dbstop if error pauses execution at the first run-time error that occurs outside a try/catch block.". In this case, execution is stopped when the caught error is thrown within AppManagementService.m.
As Walter Roberson pointed out, for "dbstop if caught error", execution pauses within the try-portion of a try/catch block and the callback function is executed within the try portion.
Alexandra
on 2 Sep 2020
Bjorn Gustavsson
on 2 Sep 2020
If that becomes too cumbersome you could consider temporarily removing the "protecting try-catch" around the code you want to investigate - it might make the debugging-process slightly less anoying.
Adam Danz
on 2 Sep 2020
@Alexandra once you know where the error is, you can always put a break point on that line and then run the code without any dbstop's. That how I troubleshoot most of the time.
@Bjorn Gustavsson, by "removing the protecting try-catch", do you mean commenting-out the "try" and the catch-block? I don't have Alexandra's app open now but I recall that the callback function was executed internally within a try/catch, within Matlab app functions. I believe this line of the error stack points to it,
In matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 35)
Otherwise, commenting out the try/catch would be a good idea.
Bjorn Gustavsson
on 2 Sep 2020
Edited: Bjorn Gustavsson
on 2 Sep 2020
@Adam, Yes, exactly that. Explicitly setting the break-point is typically better, but if the error occurs seldom commenting out the try and catch to "expose" the function-call and get the debug-stop only when the error happens, can be useful too. (Since I typically debug in anger, peculiar actions are taken)
Adam Danz
on 2 Sep 2020
@Bjorn, 😃 I know exactly what you're talking about. The problem with commenting-out the try/catch in this case is that it's part of a Matlab function so alterations to that file are not an option. The OP could write her own try/catch around the problematic section of code to troubleshoot that way, though.
Alexandra
on 3 Sep 2020
Answers (0)
Categories
Find more on Debugging and Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!