If you need help to map your debugging task to the correct feature of the Visual Studio debugger that is relevant, use the links provided in this article. The list of tasks here includes common tasks such as pausing code to debug, inspecting variables, and sending messages to the Output window. If you need an overview of debugger features, see First look at the debugger instead.
Fix an exception
- See Fix an exception.
Pause running code
Pause running code to inspect a line of code that may contain a bug
Set a breakpoint. For more information, see Using breakpoints.
Pause and inspect your app when it reaches a specific state
Try a conditional breakpoint to control where and when a breakpoint gets activated by using conditional logic. For more information, see Breakpoint conditions.
Pause code only when a specific object’s property or value changes
For C++, set a data breakpoint.
For apps using .NET Core 3, you can also set a data breakpoint.
Otherwise, for C# and F# only, you can track an object ID with a conditional breakpoint.
Pause code inside a loop at a certain iteration
Set a breakpoint using Hit count as a condition. For more information, see Hit count.
Pause code at the start of a function when you know the function name but not its location
You can do this with a function breakpoint. For more information, see Set function breakpoints.
Pause code at the start of multiple functions with the same name
When you have multiple functions with the same name (overloaded functions or functions in different projects), you can use a function breakpoint.
Manage and keep track of your breakpoints
Use the Breakpoints window. For more information, see Manage breakpoints.
Pause code and debug when a specific handled or unhandled exception is thrown
Although the Exception Helper shows you where an error occurred, if you want to pause and debug the specific error, you can tell the debugger to break when an exception is thrown.
Set a breakpoint from the call stack
If you want to pause and debug code while examining execution flow or viewing functions in the Call Stack windows, see Set a breakpoint in the Call Stack window.
Pause code at a specific assembly instruction
You can do this by setting a breakpoint from the Disassembly window.
Execute code
Learn the commands to step through your code while debugging
For more information, see Navigate code with the debugger.
Inspect data
Check the value of variables while running your app
Hover over variables using data tips or inspect variables in the Autos and Locals window.
Observe the changing value of a specific variable
Set a watch on the variable. For more information, see Set a watch on variables.
View strings that are too long for the debugger window
Open the built-in string visualizer while debugging.
Debug an app that is already running
Debug multithreaded applications
Configure debugging
Configure debugger settings
To configure debugger options and debugger project settings, see Debugger settings and preparation.
Customize information shown in the debugger
You may want to show information other than the object type as the value in different debugger windows. For C#, Visual Basic, F#, and C++/CLI code, use the DebuggerDisplay attribute. For more advanced options, you can also customize the UI by creating a custom visualizer.
For native C++, use the NatVis framework.
Additional tasks
Edit code during a debugging session
Use Edit and continue. For XAML, use XAML Hot Reload.
Send messages to the Output window without modifying code
Set a tracepoint. For more information, see Using tracepoints.
View the order in which functions are called
Debug on remote machines
See Remote debugging.
Fix performance issues