이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Debug stack on error
조회 수: 5 (최근 30일)
이전 댓글 표시
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
Adam Danz
2020년 8월 28일
편집: Adam Danz
2020년 8월 28일
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
2020년 8월 28일
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
2020년 8월 31일
I tried some different combinations, and it seems the problem only occurs in appdesigner applications. The output of dbstack is
> In appdesigner.internal.service/AppManagementService/tryCallback (line 391)
In matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 35)
In matlab.ui.control.internal.controller/ComponentController/executeUserCallback (line 382)
In matlab.ui.control.internal.controller/ComponentController/handleUserInteraction (line 332)
In matlab.ui.control.internal.controller/PushButtonController/handleEvent (line 86)
In appdesservices.internal.interfaces.controller/AbstractController/handleProxyViewEvent (line 280)
In appdesservices.internal.interfaces.controller.AbstractController>@(src,event)handleProxyViewEvent(obj,src,event) (line 208)
In appdesservices.internal.interfaces.view/AbstractProxyView/notify (line 117)
In appdesservices.internal.peermodel/PeerNodeProxyView/handlePeerEventFromClient (line 252)
In appdesservices.internal.peermodel.PeerNodeProxyView>@(varargin)obj.handlePeerEventFromClient(varargin{:}) (line 84)
In hgfeval (line 62)
In javaaddlistener>cbBridge (line 52)
In javaaddlistener>@(o,e)cbBridge(o,e,response) (line 47)
In this case, the code causing the error is a simple assert statement, but it happens to all errors in the app
Adam Danz
2020년 8월 31일
편집: Adam Danz
2020년 8월 31일
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
2020년 8월 31일
What do you mean by full error message? The error message is just
Error using SicfView/RunSicf (line 457)
Assertion failed.
as I said. And the problem is that I do not end up in RunSicf line 457 as I expect, but in AppManagementService, line 391.
I could try to make a simplified version of the app for you to run.
Adam Danz
2020년 8월 31일
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
2020년 9월 1일
There you go. If you click the import button, an error is generated (by assertion or directly throwing an error) and I end up in AppManagementService
Adam Danz
2020년 9월 1일
편집: Adam Danz
2020년 9월 2일
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
2020년 9월 2일
Thank you for the answer. I was not aware of that. Did that behaviour change somewhere in the last few Matlab versions? I never encountered it that way before.
With "dbstop if caught error", I get several stops due to try-catch-blocks in Propertyhandling, before I come to the section above, but I guess it is better than before. Thank you for that tip.
Bjorn Gustavsson
2020년 9월 2일
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
2020년 9월 2일
@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
2020년 9월 2일
편집: Bjorn Gustavsson
2020년 9월 2일
@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
2020년 9월 2일
@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
2020년 9월 3일
Usually, I set a breakpoint on the line (as suggested), but if the error doesn't occur very often, I used to do "dbstop if error". But using a try and catch block around the section works well, too. Thank you for all the suggestions :-)
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)