I am trying to debug an object-oriented application in MATLAB R2011b that I did not write myself. To do this, I want to place a breakpoint in a method in the classdef
. As far as I know, this is allowed. Yet, when I run the application, the breakpoint mysteriously disappears.
I have configured a breakpoint in clear
like so:
dbstop in clear
to see when clear
is being called. Before running the application, I check the presence of the breakpoint with dbstatus:
>> dbstatus
Breakpoint for Processor>Processor.setResult is on line 114.
Breakpoint for inputCompute is on line 30.
Breakpoint is set for m_interpreter>clear.
(The breakpoint in question is the first one in the list.) When I run the application, the breakpoint in the classdef disappears before the first clear is called:
>> rootFunction('configuration')
417 clear('Data');
K>> dbstatus
Breakpoint for inputCompute is on line 30.
Breakpoint is set for m_interpreter>clear.
To determine where the breakpoint gets cleared, I progressively moved a breakpoint closer and closer to the start of the root function, and found the offending line of code:
cd('./configs');
And sure enough -- any invocation of cd
, even indirectly, clears the breakpoints in the classdef
. That means that run
does exactly the same thing. This is infuriating behaviour. Why does MATLAB do this? How do I keep it from doing this?