Did you know… You can use Breakpoint Filters to break the right process – #273


Conditional breakpoints are for breaking at the expression level, when a particular condition is true, like x=5.  But what if you have multiple instances of the same app running?  How do you set to break the instance you want?

The answer is Breakpoint Filters.

Go to Tools – Options – Debugging – General, and there you’ll see the option to enable breakpoint filters.

image

Set a Breaking and Right-click to bring up the context menu.

Breakpoint Filter context menu option

Then in the Filter dialog box, you can specify when to break, for example, per PID (process ID).

image

and now you can verify the breakpoint filter in the Breakpoints window.

Breakpoints window showing breakpoint filter

Comments (10)

  1. Skip Valentine says:

    While you’re on Breakpoints, there’s one debugger feature that I’ve missed from the old VB6 days that I never have had success in finding in the .Net debugger world. It has to do with Conditional breakpoints.

    Apparently, in the .Net debugger you can setup a conditional breakpoint at a particular line of code, if the condition is true when that line of code is executed, the debugger will break at that line of code and let you walk thru it – (may be somewhat useful, I guess, but I’ve yet to have a need for it).

    In the VB6 debugger, you could setup a conditional breakpoint that would cause the debugger to break when the condition became true, (not at some predetermined line of code, but as soon as the condition became true).

    So, if you knew that somewhere in your vast amount of source, the soldQuantity integer variable was incorrectly getting set to say "-5", you could setup a conditional breakpoint of something like "soldQuantity == -5", and as soon as the soldQuantity was set to -5, the debugger would break execution and take you to the line of code that had just made the condition true (an EXTREMELY useful feature – when squashin’ bugs).

    So, my question is: Is there some ambiguous (or better yet, "wow! I never noticed that before! – (my bad)") way to setup the conditional breakpoint to break at the moment the condition becomes true? Or, is it as I suspect, and that subtle little feature of the "conditional breakpoint" just never made it’s way over to the .Net IDE’s debugger?

    Thanks,

    Skip V.

    ps. I love your "Did you know…"’s, I’m almost ashamed to say, but the majority of them result in a "well no, I didn’t. That’s pretty cool". Thru all of this, I’ve learned to not be quite so quick to criticize our users for "not reading the freakin’ screen". I’m a bit guilty of that myself.

  2. My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Chris Craft created a series of posts in July he called 31 Days of Visual Studio Tips & Tricks. All of the posts along with the

  3. 真见 says:

    友情提示:请大家直接看原英文,参照系列标题就是简介。消息与工具第一名:31天的VisualStudio提示和技巧。

  4. 真见 says:

    友情提示:请大家直接看原英文,参照系列标题就是简介。消息与工具第一名:31天的VisualStudio提示和技巧。

  5. cnblogs.com says:

    友情提示:请大家直接看原英文,参照系列标题就是简介。 消息与工具 第一名:31天的Visual Studio提示和技巧。   2. 微软下载(TFS ) -VSTS 2008 技术可行性说明书

  6. 真见 says:

    1.MicrosoftSyncFrameworkv1.0Released(

  7. 真见 says:

    1.MicrosoftSyncFrameworkv1.0Released(

  8. cnblogs.com says:

    1. Microsoft Sync Framework v1.0 Released (    特色: Sync Services for ADO.NET v2 AND Sync Framework

  9. Ofek says:

    Skip Valentine:

    I think you could accomplish that by setting a DATA breakpoint (at the address of soldQuantity, say 0x12345678), and assigning a condition to it (say, ((INT*)0x12345678) == -5 ).

    At least i know these are available for VC++.  don’t know much about VB though.