Редагувати

Поділитися через


FAQ - Debugger feature finder

This documentation addresses frequent questions about debugging features in Visual Studio. It also maps debugging tasks or issues to the relevant feature in the Visual Studio debugger. These links cover tasks or issues such as debugging multi-threaded application, code navigation, memory leak, inspecting variables, using breakpoints, external code debugging and many more. If you need an overview of debugger features, see First look at the debugger instead.

Breakpoints

  • How can I learn the commands to step through my code while debugging?

    For more information, see Navigate code with the debugger.

  • Can I run the code to a particular line while skipping breakpoints without removing or disabling them?

    You can use “Force Run To Cursor” for these scenarios. You can keep your breakpoints and the debugger will skip over them until it reaches the line of code with the cursor. It will also skip any of the first-chance exceptions break conditions that may occur. For more information, see Navigate code with the debugger.

  • If my line of code has calls to different methods, can I step into a specific method?

    Right-click on the line of code to bring up a context menu that allows you to select ‘Step Into Specific’. This will show a list of all the methods that you could step into. You can now select the method of interest.

Inspect and Visualize data

  • How can I check the value of variables while running my app?

    Hover over variables using data tips or inspect variables in the Autos and Locals window.

  • Can I observe the changing value of a specific variable?

    Set a watch on the variable. For more information, see Set a watch on variables.

  • How can I view strings that are too long for the debugger window?

    String Visualizer shows strings that are too long for a data tip or debugger window. It can also help you identify malformed strings.
    Built-in string visualizer in Visual Studio include Text, XML, HTML, and JSON options.

  • How can I view large collection objects?

    The DataSet Visualizer allows you to view the contents of a DataSet, DataTable, DataView, or DataViewManager. The IEnumerable Visualizer allows you to view objects such as Arrays, List, etc. For more information, see Tabular visualizers.

Debug an app that is already running

  • How can I debug running apps on local or remote computers, debug multiple processes simultaneously, debug apps that weren't created in Visual Studio, or debug any app I didn't start from Visual Studio?

    See Attach to a running processes.

  • How can I to attach to the same application repeatedly?

    You can use Reattach to Process (Shift+Alt+P) to easily allow you to start debugging your application in one click without needing to go through the Attach to Process dialog every time. See Reattach to a process

Debug multithreaded applications

Analyze memory

  • Does my application have a memory leak?

    Take a snapshot and open it with memory tool to troubleshoot further. See Measure memory usage.

  • How can I analyze memory usage for native or managed applications?

    Use the Visual Studio memory tool via live debugging, heap dumps, or the performance profiler.
    See Choose a memory analysis tool.

  • How can I analyze memory usage for native or managed applications without attaching a debugger? Use the Visual Studio performance profiler with the memory usage tool enabled.
    See Analyze memory usage.

  • Can I compare memory usage between two points in time?

    Compare snapshots in the memory tool or compare two heap dumps using the diff functionality. See Analyze memory usage.

External Code Debugging

  • Can I see only user code while debugging?

    Just My Code is a Visual Studio debugging feature that automatically steps over calls to system, framework, and other non-user code. In the Call Stack window, Just My Code collapses these calls into [External Code] frames. See Debug only user code with Just My Code

  • How can I view or debug the raw assembly instructions that my program is executing?

    Use the Disassembly Window from Debug > Windows > Disassembly. You can step over one instruction at a time and even set breakpoints on individual assembly instructions.

  • Can I see source code for .NET Libraries?

    Enable Microsoft Symbol Servers from Debug > Options > Symbols in order to download symbols and source for .NET Libraries. See Specify symbol

  • How can I load PDBs from a specific or shared location or server?

    Configure your Symbol Servers from Debug > Options > Symbols. See Specify symbol

  • How can I never load a specific PDB? Or, how can I always load one?

    Configure your Include and Exclude Lists in Debug > Options > Symbols.
    See Specify symbol

Configure debugging

  • How do I configure debugger settings?

    To configure debugger options and debugger project settings, see Debugger settings and preparation.

  • How can I 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

  • Do I need to save a dump?

    While stopped at an error or breakpoint during debugging, select Debug > Save Dump As. See Dump files

  • How do I analyze a dump file?

    Open the dump by choosing File > Open in Visual Studio. To start debugging, select Debug with Managed Only, Debug with Native Only, Debug with Mixed, or Debug with Managed Memory. See Dump files

  • Can I edit code during a debugging session?

    Use Edit and continue. For XAML, use XAML Hot Reload.

  • How can I debug on remote machines?

    See Remote debugging.

  • How can I fix performance issues?

    See First look at the profiling tools

  • How do I fix an exception?

    See Fix an exception.