Visual Studio Debugger Tips (cont'd)

by Jon Davis 8. July 2009 10:29

Here's another good article with debugger tips:

Have you ever hit Break while debugging a multi-threaded console app and the only thing VS tells you it's still on is ReadLine(), where it's waiting for some input but meanwhile some other threads are working and you can't see them? The above-referenced article showed me how to access those other threads. It's all at:

Debug menu -> Windows -> Threads

Visual Studio Debugger Tips You Need To Know

by Jon Davis 22. June 2009 17:45

Came across this article today. It's probably very old, as it's on an ASP Classic file and has no date.

Good stuff, I didn't know or forgot about half of that stuff. IMO, using a debugger correctly (vs. constant logging and alert pop-ups) is huge when measuring one's productivity.

Incidentally, When looking for a "breakpoints window" I ended up being rather pleased to find that there's a right-click context menu in the breakpoint gutter after a breakpoint has been set in the text editor, revealing:

  • Location - Break execution when the program reaches this location in a file: File: [file path]; Line: [##]; Character: [##]; [checkbox] Allow the source code to be different from the original version
  • Condition - When the breakpoint location is reached, the expression is evaluated and the breakpoint is hit only if the expression is true or has changed. [checkbox] Condition: [textbox] [radio]: Is true; [radio]: Has changed
    • Yessss!! I've SO badly needed this one, I don't know how many times I've pounded F5 while staring at my Watch window waiting for some string to show up in a loop, or actually wrote inline code like
      if (condition && System.Diagnostics.Debugger.IsAttached)
          System.Diagnostics.Debugger.Break(); // my head open against the wall
  • Breapoint Hit Count - A breakpoint is hit when the breakpoint is reached and the condition is satisfied. The hitcount is the number of times the breakpoint has been hit. When the breakpoint is hit [drop-down]:
    • break always
    • break when the hit count is equal to [##]
    • break when the hit count is a multiple of [##]
    • break when the hit count is greater than or equal to [##]
  • Filter - You can restrict the breakpoint to only being set in certain processes and threads. Enter an expression to describe where the breakpoint should be set, or clear the expression to have the breakpoint set in all processes and threads. You can combine clauses using & (AND), || (OR), ! (NOT), and parentheses. Sample clauses:
    • MachineName = "machine"
    • ProcessId = 123
    • ProcessName = "process"
    • ThreadId = 123
    • ThreadName = "thread"
  • When Breakpoint Is Hit - Specify what to do when the breakpoint is hit.
    • [checkbox] Print a message:
      • sample: "Function: $FUNCTION, Thread: $TID $TNAME"
    • [checkbox] Run a macro: [macros drop-down]
    • Continue execution
Wow, that's some powerful breakpoint logic I didn't realize was right under my nose.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Software Development


Powered by BlogEngine.NET
Theme by Mads Kristensen

About the author

Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 

Tag cloud


<<  May 2021  >>

View posts in large calendar