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.

 http://www.eggheadcafe.com/articles/20050511.asp

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

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading




 

Powered by BlogEngine.NET 1.4.5.0
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 jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  August 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

RecentPosts