Feature request: Breakpoint stop on errors in non Mathworks code

조회 수: 3 (최근 30일)
Knut
Knut 2016년 1월 7일
댓글: Walter Roberson 2016년 1월 8일
I like to use the "stop on errors" function. This allows me to run and test my stuff, and whenever some error occurs, I have instantly access to inspect variables and figuring out what went wrong.
But whenever my code calls functions written by Mathworks, I get a more or less deep breakpoint into code that I did not write and do not care about. Also, my editor fills up with irrelevant files.
Would it be possible to break execution at the latest "user contributed file" (i.e. trace the call-stack backwards until such a file is found) while displaying the error message in the Command window?
Also, if this setting could be persistent from Matlab session to session, it would be greatly appreciated. Thank you.
-k
  댓글 수: 2
Stephen23
Stephen23 2016년 1월 7일
편집: Stephen23 2016년 1월 7일
"my editor fills up with irrelevant files"... you don't need to open every file that is listed in the error message. Just read through the message, and focus on the parts that mention your functions.
Walter Roberson
Walter Roberson 2016년 1월 7일
dbstop on error automatically opens the deepest .m code that it can if you are running the MATLAB Desktop (which is most people.) This can be a nuisance.

댓글을 달려면 로그인하십시오.

답변 (4개)

Ilham Hardy
Ilham Hardy 2016년 1월 7일
As far as I can remember, you can trace the stack based on the scary red text on matlab command window (when error took place).
You can click the underlined part of the text on the "user contributed file", to focus on the specific line that caused the error.

Walter Roberson
Walter Roberson 2016년 1월 7일
At the moment about all you can do is to go into Preferences -> Editor/Debugger and turn off "Automatically open files when MATLAB reaches a breakpoint".
I know this is not what you are asking for.

Image Analyst
Image Analyst 2016년 1월 8일
On the Editor tab/tool ribbon, when it stops, you should see a "Function call stack" drop down list. You can drop that down, then find the first function you recognize (the one you wrote) and select it to go there. Then quit debugging and set a break point there. Next time it will stop there.

Knut
Knut 2016년 1월 8일
편집: Knut 2016년 1월 8일
I am aware of the call stack and the link in the error message. What I requested was slightly different though. Let me try to explain.
I love Breakpoints -> stop on error. It allows me to find errors in my code that much faster. If a simulation runs for 60 seconds (or 3 hours), I want to be able to fix the error right away. Preferreably using the interactivity of the MATLAB to inspect variables, jump up and down in the call stack, plot, and do whatever it is that makes me so much more productive when I am using MATLAB than when I am developing in C (though tools like Microsoft Visual Studio does allow similar luxury when doing C).
My issue is that given that I want to have this feature, anytime my code calls e.g. "interp1()" with erroneous parameters, I will get a breakpoint (potentially) somewhere deep inside MATLAB code that I did not write, do not understand, and have no intention to "fix". Further, my editor opens that file in a new fan. Of course I can choose the drop-down for the call stack, navigate to my own code, then close any mathworks .m files and get tje job done, but that are steps that could have been automated.
This might sound like a small annoyance (it is), but it would be great to have an option to rather break (open the editor) at the last point where user-submitted code was running.
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 1월 8일
This is why you would turn off automatically opening the files. You would go to the console and dbstack or dbup until you found the routine you wanted, without having those other files opened.
Not as convenient as what you are asking for, but this is what is available at the moment.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Debugging and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by