Muting breakpoints
Debugging is an integral part of my workflow. One thing I continually encounter is the need to quickly disable all my breakpoints. After spending time inserting breakpoints at the right places with the right conditions, I sometimes want to quickly mute (disable) all of my breakpoints without actually removing them.
In order to do this, I wrote a couple of scripts, which mute and un-mute your breakpoints. I did this by reinstalling each breakpoint with a disabling expression (e.g. turn 'x==1' into 'false&&(x==1)') . To get all of the breakpoints currently installed in MATLAB, usedbstatus.
Here's whatdbmutelooks like :
functiondbmute%dbmute disables all breakpoints currently set in MATLAB.% iterate over each entry in the result of dbstatus,% and disable each of the breakpoints.breakpoints = dbstatus('-completenames');fori=1 : length(breakpoints) muteDbStatusEntry(breakpoints(i));endendfunctionmuteDbStatusEntry(dbstatusEntry)%muteDbStatusEntry disables each breapoint in the given entry.fori=1 : length(dbstatusEntry.line) file = dbstatusEntry.file; line = dbstatusEntry.line(i); anonymousIndex = dbstatusEntry.anonymous(i); expression = dbstatusEntry.expression{i}; lineNumberString = [num2str(line)'@'num2str(anonymousIndex)]; newExpression = createDisabledExpression(expression); dbstop(file, lineNumberString,'if', newExpression);endendfunctionnewExpression = createDisabledExpression(expression)%createDisabledExpression wraps the given expression in a disabling% expression if necessary.if(isDisabled(expression)) newExpression = expression;elseifstrcmp(expression,'') newExpression ='false';elsenewExpression = ['false&&('expression')'];endend
Here is the full suite of files:
I'd recommend alsocreating shortcutsfor them so you can quickly access them from the toolbar.
- Category:
- Debugging,
- Editor,
- MATLAB Shortcuts
Comments
To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.