开发者

Visual Studio: Setting a conditional breakpoint without setting an unconditional one first

开发者 https://www.devze.com 2023-02-03 15:58 出处:网络
Sometimes, while I\'m watching my program run, I\'ll want to set a breakpoint with conditions. At the moment, I\'m doing this by clicking to create an unconditional breakpoint, then right-clicking to

Sometimes, while I'm watching my program run, I'll want to set a breakpoint with conditions. At the moment, I'm doing this by clicking to create an unconditional breakpoint, then right-clicking to change the condition.开发者_如何学C This has the drawback that I'll stop the program on an undesired iteration. Is there a way to set the condition immediately?


I was going to suggest the macro route too. I got bored and had a go at it, if this macro runs it pops up a dialog and asks for the condition. You may need to make it a little fancier if you want more bells and whistles.

Sub addBreakpointWithCondition()
    Dim cond As String = InputBox("Enter the condition")
    DTE.Debugger.Breakpoints.Add(File:=DTE.ActiveDocument.FullName,
        Line:=DTE.ActiveDocument.Selection.CurrentLine, Condition:=cond)
End Sub


Not through the IDE. You could write a macro to achieve this, EnvDTE.Debugger.Breakpoints.Add() method. It lets you specify the Condition property directly. Not so sure that the time you'll burn on this is equivalent to pressing F5 repeatedly.

0

精彩评论

暂无评论...
验证码 换一张
取 消