We all know what breakpoints are, they tell the debugger that an application should break and pause execution, at a certain point. If we want to get certain information at this point, we need to copy it down to a paper or to the notepad. There are breakpoints which get hit hundred of times during the execution of a program, so it may be very exhausting to write down the breakpoint information each time it is hit. Well, last week, while I saw John Cunninghams session at PDC 2008 about Visual Studio Debugger Tips & Tricks, I learned something new. The Visual Studio debugger has another feature called tracepoints.
A tracepoint is a variation of a breakpoint, the difference between them is:
To set a tracepoint, we first have to set a breakpoint in code. Then right click on the breakpoint and select the “When Hit” context menu item:
The following screen appears, where we can add a log message for the breakpoint and tell it to continue with the program execution when it gets hit:
As can be seen in the image above, the log message can include the value of a variable or another expression like the current function name, call stack, thread ID… After pressing the OK button, the tracepoint will look like that:
This feature is very useful and can certainly save a lot of time. It came with Visual Studio 2005 but I am sure that, like me, some of you didn’t know about it, so enjoy.
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More
O. Askari Said on Dec 31, 2008 :
Great tip, thanks for sharing.
Gadi Said on Dec 31, 2008 :
GREAT
this was long time ago in Texas Instruments debugger.
we used it for generating graphs out of numeric data, for debugging signal processing.
Rocjoe Said on Jan 1, 2009 :
This rocks! For the longest time I wanted to have “trace comments” in my code, this comes closest to fitting that bill.
The “Run a macro” checkbox is an interesting option too– I wonder if you could write one that makes a diagnostic snapshot. You could replay all the snapshots to watch your system change over time.
Sai Baba Said on Aug 11, 2009 :
i still did not understand what the trace point is and what it does. please explain me in breaf