How to set conditional breakpoints in Visual Studio?

前端 未结 13 2386
忘了有多久
忘了有多久 2020-11-27 03:35

Is there an easy way to set conditional breakpoints in Visual Studio?

If I want to hit a breakpoint only when the value of a variable becomes something, how can I do

13条回答
  •  猫巷女王i
    2020-11-27 04:26

    Visual Studio provides lots of options for conditional breakpoints:

    To set any of these you

    1. Set a breakpoint.
    2. Right-Click over the breakpoint, and in the popup menu you select an option that suites you.

    These options are as follows:

    • You can set a condition, based on a code expression that you supply (select Condition from the popup menu). For instance, you can specify that foo == 8 or some other expression.
    • You can make breakpoints trigger after they have been hit a certain number of times. (select Hit Count from the popup menu). This is a fun option to play with as you actually aren't limited to breaking on a certain hit count, but you have options for a few other scenarios as well. I'll leave it to you to explore the possibilities.
    • You can Set filters on the Process ID, thread ID, and machine name (select Filter from the popup menu)

提交回复
热议问题