dbup does not behave as expected

조회 수: 5 (최근 30일)
敬 杨
敬 杨 2025년 5월 29일
댓글: 敬 杨 2025년 5월 30일
In MATLAB '25.1.0.2943329 (R2025a)', when in debug mode, calling dbup within a function behaves differently from calling dbup directly.
Save the following code as test_bug1:
function test_bug1(a,b)
c = a + b;
end
First, run
dbstop if error,
then call
test_bug1([1 2 3], [2 3]);
This will enter debug mode at the line c = a + b inside the test_bug1 function.
Executing dbup at this point behaves as expected and returns to the previous workspace.
However, if you define the following function:
function dbup_1()
dbup;
end
Executing dbup_1 at that moment results in an error, indicating that the current command is not a debugging command.
Similarly, if you create the following script and save it as dbup_2:
dbup;
Calling dbup_2 still results in the same error.
My question is: What causes the issue above?
If I want to include dbup, dbdown, and similar commands inside a function, how should I proceed?
  댓글 수: 2
Adam Danz
Adam Danz 2025년 5월 29일
Accessing variables from a different workspace usually it not a good idea. What's the ultimate goal? Why can't it be realized by passing variables into the function?
敬 杨
敬 杨 2025년 5월 30일
You can refer to another question I asked for more details.
Simply put, I would like to save the variables from every level of the function call stack when an error occurs in the program.

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

채택된 답변

Matt J
Matt J 2025년 5월 29일
편집: Matt J 2025년 5월 29일
There are special limitations on dbup, dbdown, and friends. You cannot call them from functions, because when a function is executing, you are not in debug mode anymore.
  댓글 수: 3
Adam Danz
Adam Danz 2025년 5월 29일
This is documented in the dbup page, "dbup can only be called from the command line."
Matt J
Matt J 2025년 5월 29일
편집: Matt J 2025년 5월 29일
Specifically, though, from the debugger command line:
>> dbup
Error using dbup
Debug commands only allowed when stopped in debug mode.
>> keyboard
K>> dbup
In base workspace.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2025a

Community Treasure Hunt

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

Start Hunting!

Translated by