-
Notifications
You must be signed in to change notification settings - Fork 0
Profiler
DebugTools can record all methods invoked in a target process, including their parameters/return values. This is achieved by launching the target process with a collection of environment variables set that cause the .NET runtime to inject DebugTools' custom profiler into the target process that records this information, and transmits it to DebugTools via ETW.
The flow of a profiling session typically goes as follows
- Launch a process under the control of the profiler
- Begin a trace
- Stop the trace and review the results
Steps 2 and 3 can then be repeated as necessary as long as the target process remains active.
The easiest way to launch a process under the control of the profiler is to use the Start-DbgProfiler
cmdlet
Start-DbgProfiler powershell
Methods profiled by .NET have hooks embedded in them that call out to a profiler on method entry/exit. These hooks are automatically embedded in methods at the point that they are JITted. Because of this, it is not possible to attach the profiler to a process and capture stack trace information after it has already started. For information on starting processes containing the DebugTools Profiler without the help of the Start-DbgProfiler
cmdlet, please see Global Session.
After a process has been launched, the typical workflow will be to capture a trace
# Press Ctrl+C to end tracing
C:\> Trace-DbgProfilerStack
and then display the results of the trace
# Display all unique frames that were executed. Many parameters can be specified
# to this cmdlet to filter the results
C:\> Show-DbgProfilerStackTrace -Unique -ExcludeNamespace
DebugTools provides a number of settings that can be configured to control how the profiler operates. For more information, please see the following articles