If you are in When debugging, hover the mouse over the data tip frequently, and you may want to fix the data tip of the variable so that you can check it at any time. Even after restarting, the fixed variables can remain intact. To pin the data tip, click the pin icon when hovering over it. You can fix multiple variables.
Most supported in Visual Studio In the language, you can edit the code during the debugging session, and then continue debugging. To use this function, please pause in the debugger first, click with the mouse to enter the code, edit it, and then press F5, F10 or F11 to continue debugging.
For more information about function usage and function limitations, please refer to edit and continue.
If it is difficult or time-consuming to re-implement a specific state in the application, consider using conditional breakpoints. You can use conditional breakpoints and filter them to avoid damage Apply the code until the application enters the required state (for example, the state where the variable is storing wrong data). You can use expressions, filters, hit counts, etc. to set Condition.
Create conditional breakpoints
-
Right-click the breakpoint icon (red ball), and select the condition.
< li>
In the breakpoint setting window, type an expression.
If you are interested in another type of condition, please select the filter instead of the conditional expression in the breakpoint setting dialog box, and then follow the prompts of the filter.< /span>
About C#, Visual Basic and C++ (C++ only/CLI code ), you can enable the debugger to use the following options to display the information DebuggerDisplay property. In the relevant C++ code, you can perform the same visualization using Natvis.
Hold the debugger on a certain line of code, and grab the yellow arrow pointer on the left with the mouse. Move the yellow arrow pointer to other points in the code execution path. Then use the F5 key or step commands to continue running the application. span>
By changing the execution flow, you can test different code execution paths or re-run the code without restarting the debugger.
< span style="font-family:'Microsoft YaHei'; font-size: 14px;" data-ttu-id="99350-140">Variables can be easily viewed through a debugger window (such as a monitor window). However, if the variable exceeds the scope of the monitoring window, you may notice that it turns gray. In some application scenarios, if the variable is out of range, the value of the variable may even change, so you may need to pay close attention to it (for example, the variable may be treated as garbage). You can create an object ID for the variable in the monitoring window to track this variable.
Create object ID
-
Set a breakpoint near the variable to be tracked.
-
Start the debugger (F5) and stop at the breakpoint.
-
Find the variable in the local variables window (Debug> Window> Local Variables), right-click the variable, and select Create Object ID.
You should see in the “local variables” window set a breakpoint to interrupt The execution of the instruction or line returned by the calling function. This variable is the object id.
-
Right-click the object ID variable and select Add Watch.< /span>
For details, please refer to the created object ID.
< div>
To view the return value of the function, please execute the code step by step , Check the function displayed in the automatic window. To check the return value of the function, please make sure that the function you are concerned about has been executed (if the function call is currently stopped, Please click the F10 key).< span data-ttu-id="99350-155">If the window is closed, please open the automatic window through Debug> Window> Automatic Window.
In addition, you can also enter a function in the immediate window to view the return value. (Through the debugging> window> Open this immediately Window.)
In addition, you can also use pseudo variables in the monitoring and immediate windows, such as $ReturnValue
.