Visual Studio Debugger Tips & Tricks

Sign in to queue

The Discussion

  • User profile image
    Data breakpoints is something I definitely miss.  Where you have properties in your own code it is easy enough to set a breakpoint in a setter.  But where the code isn't your own (think slot in an array or entry in a List<T>), it sure would be nice to be able to set a breakpoint on write.
  • User profile image
    I hear you.  I've wanted to build since V1 of the CLR.  We actually put a lot of effort into trying to build that feature for VS2010, but alas we couldn't come up with a good way to make it work.  Fundamentally, we are constrained by what the hardware will give us here (4 slots in the DR registers) to watch memory writes (and technically reads and executes).  Every time we tried to figure out "how would we provide an experience that people wouldn't find just weird", we came up short. 

    You can use a conditional breakpoint and use an expression with "has changed", but it is not nearly as performant as a databp, and it is not the same thing (the DRs fire no matter if you are writing the same value back).

    Anyway - hope you enjoyed the talk,

  • User profile image
    Ralph Trickey
      I enjoyed the talk, but I also wished you'd been able to get it in. I'm a native programmer switching to .Net.

      I'm not sure why they'd be any more 'weird' in .Net than they are under Native.

      As a games programmer, I've had several problems that I've had to troubleshoot in release mode because it takes too long to run things in debug mode. I assume that for .Net, I'd have to attach to the process after it starts to avoid running a debug build. I assume that a release build would inline the accessor, to the only optins available are hardware breakpoints and print statements Sad

      I've found them fantastically useful in debugging things like buffer overruns in native code. Even though that class of bugs isn't supposed to be there, I suspect that there is a new class of bugs related to multi-threading that are coming at us. Data breakpoints seem like an obvious way (to me) to troubleshoot these types of issues.

  • User profile image
    This certainly won't work for all instances but for a List you could instead use the System.Collection.ObjectModel.Collection<T>.  This has events you can subscribe to when you add and remove items to the collection and it would provide you what you were looking for in this particular instance.
  • User profile image

    Thanks, nice lecture!

    Also i would like to share an Add-in for visual studio that makes it easy to attaching to process

  • User profile image

    Nice tips let me just share that for debugger security you must be able to trust what you are debbugin, I think this is the most careful step for debuggin, there are many trheats and consequences involved. As Ralph tricky mentionede it takes too long to run things in debug mode


Add Your 2 Cents