Trace Point is nothing but a breakpoint with some actions. When Action is added into a breakpoint, Visual Studio would execute them during debugging. You do also have and option to continue the execution without pausing it or pause it. This is quite helpful when you want to inspect values, object without interrupting the debugging. Incase of breakpoint, the execution does pause and then you need to inspect them by your own. Where as for Trace Point, you can have a pre-defined actions setup to be execute during the debugging session.
Let’s try to understand this with one simple example. Consider a class with Main(), method having three additional method A(int), B() and C(). Now to check when A() is called and what is the value has been passed to it, we use a breakpoint and then use DataTip or Watch Windows to inspect the values. In other cases, we use Debug.WriteLine to write values in the output windows as shown in below screenshot.
Now to achieve this in an other way and without impacting your debugging flow, you add the actions to those breakpoints.
First, Right Click on the “Breakpoint” and select “Actions”
This will open the Breakpoint Settings window where you can provide the custom actions. In this case I have mentioned to log the “Function name and Parameter passed into it” . Then you have the option “Continue Execution” to set true or not.
With these, the breakpoint icon will change into a diamond which indicate there are some action attached with it. Now if you run the app, debugger won’t stop, but will log the requested message in output windows.
Similarly, you can attach multiple Trace point to log your information.
The Actions text window has intellisense enabled. So incase of custom object you should be able to write it easily.
Not only the function name, it has some predefined attributes like Address, Calls Stacks, PID defined, which you can use as and when you need.
This Trace point could be tremendous helpful when you are working with multiple threads.
Incase you are interested to look bit inside, you can export these Trace Point using the “Export” option available in the context menu. Open the saved xml, you will notice the information are saved as part of BreakPointCollection, and BreakPoint entity. The only difference you would notice the “IsTracePointAction” is set to 1. Incase of normal breakpoint it will be 0.
Hope this helps !