Yesterday I identified a symbol loading issue with the current internal drop of the VS debugger.  Within minutes, I had Steve Steiner from the debugger team here in my office, stepping through the code with me.  It was a tricky situation because we were using the Visual Studio debugger to debug another instance of the VS debugger operating against yet another instance of VS.  It was a trip trying to remember the context across three separate IDE instances.

Although I consider myself pretty proficient with debuggers, I always enjoy watching other hard core debugging folks do their magic because every once in awhile I learn something new, or some prior lesson gets reinforced.   Yesterday's experience yielded two nuggets:

  • Set Next Statement is very handy
  • Using the “,hr” syntax in expressions

I've used the debugger's Set Next Statement for years ago, but watching an actual debugger developer use it much like I do was very cool.

Set Next Statement has a variety of uses.  My favorite is when I've stepped over a function that I expected to work correctly, yet it failed instead.   If the function hasn't mucked with any of its input parameters, or caused side effects, it's usually safe to just set the next statement back to the desired statement and step into it.

Another cool use for Set Next Statement is when a block of code causes the function to exit with an error or crash. If it isn't absolutely essential to execute that code, set a breakpoint at the beginning of the code, and after it's hit, use Set Next Statement to set control to a point after the bad code.   I used this functionality yesterday when a code parser refused to work properly in the context I was in.  The underlying problem is already slated to be fixed, but in the meanwhile, I needed to get past that point to focus on the code I'm working on.

As for the “,hr” syntax, it's great when you're working with HRESULTS in COM.  For the longest time I used the IDE's error lookup feature to convert HRESULT values into readable strings.  Now I know that you can just tack “,hr” on to the end of an expression (for instance:  “myHresultValue,hr”), and the IDE does its best to look up the HRESULT string for you.