フィルターのクリア

How to stop on a variable getting a specific value?

10 ビュー (過去 30 日間)
Evgeny Bespechansky
Evgeny Bespechansky 2019 年 4 月 30 日
コメント済み: dpb 2019 年 5 月 1 日
I have a variable that can change its value in multiple locations within a long function.
For debugging purposes I want to stop-in-debug once this variable gets a specific value.
I could go throughout the code and set a conditional breakpoint in each line it can happen, but I wonder, if there is a way to set a "global" conditional breakpoint?

採用された回答

dpb
dpb 2019 年 4 月 30 日
編集済み: dpb 2019 年 4 月 30 日
dbstop in file at if expression
is best you can do I think...you don't have to manually insert the breakpoint at every line but would have to get the line numbers and put into a little script to run...a little grep utility could possibly be invoked to build/retrieve the lines in the m-file with an assignment to the subject variable name???
ADDENDUM:
I've long thought the debugger should have a watch facility besides...
  2 件のコメント
Evgeny Bespechansky
Evgeny Bespechansky 2019 年 5 月 1 日
You seem to be right.
Without the "at" statement the condition fails - it is defined for the variable that is undefined at the beggining of the function. So I have to execute something like
for i=61:200
cLine = sprintf('dbstop in myFunc.m at %d if myVar>X', i);
eval(cLine);
end
It looks ugly and not much easier than to search the code for every line where myVar can change its value and set a breakpoint manually...
dpb
dpb 2019 年 5 月 1 日
Excepting you could build a function that hides the ugly to invoke...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDebugging and Analysis についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by