Small features you don't know in Visual Studio debugger

Source: Internet
Author: User
This article mainly for you in detail the visual Studio debugger seven little-known small features, with a certain reference value, interested in small partners can refer to

Visual Studio Debugger is a great debugging tool that can help program apes find and solve problems quickly. Here's a brief introduction to the seven little-known small features in the VS debugging tool.

1. One-click Jump to the specified statement

You often need to drag the yellow arrows during debugging to make certain statements execute or not execute. The general method is to use the mouse to drag directly.

In Visual Studio 2017 15.3 Preview, there is a more straightforward way to jump to the target line: Hover the mouse pointer over the target line, and then press and hold CTRL after the left mouse button click to move the debug yellow arrow Then click Debug Next or F5 to run directly on the specified line.

2. Add a breakpoint for the specified instance value

Sometimes the attribute value of an instance is somehow changed, and when we need to know why it changes, a breakpoint is added to the property code, but this will take effect for all instances.

When debugging, you can use the Make Object ID and the conditional breakpoint function to add breakpoints for the specified instance, as follows:

First I define a class and initialize two objects, change the value of Pointx, and want to add the change breakpoint of the Pointx value of instance a

During the debugging process, right-click instance A to select Make Object ID

When instance a is assigned to $ $, the breakpoint to be added is right-clicked to select conditions ...

After you add the = = This code and then run the program, the breakpoint takes effect when the instance a property changes, and the instance B property changes without taking effect.

Note that the Make object ID records the address of an in-memory object, which changes the next time it is debugged and needs to be reset.

3. Re-attach the process

Attach to process is a feature that you often need, and there is a new option in Visual Studio 2017 called Reattach to process, which allows you to reattach to the most recently attached process.

Attach to a process first, click on Stop Debugging, and then click Debug to see the Reattach to process option.

4. Show All Threads

During the debugging process, there is a new option in the Debug toolbar called: Show Threads in Source. Click to display an icon in front of the line stop lines of code, hover over the icon to display the thread, and right-click the icon to display the available actions.

Note that this feature may affect debug efficiency and is recommended to be turned off by default if not required.

5. Temporarily disable the specified breakpoint

When doing multi-threaded debugging, you can use the Disable breakpoint function to temporarily disable the specified breakpoint, preventing other threads from interrupting the breakpoint, affecting the current thread debugging work.

6. View the call stack for all threads

During debugging, you can see the call stack for all threads by entering "debug.listcallstack-allthreads" in the command window.

You can also use the WinDbg command "~*k":

7. Evaluate with no negative effects

Sometimes it may be necessary to look at the return value of a method in the Debug Watch window, but the actual execution of this method may have a negative effect, where you can add "NSE" to avoid negative effects when you enter the Watch window, which is the abbreviation for "No Side effects". Examples are as follows:

The first add was executed six times, so the total number of testlist is 6,

Now you want to see the return value of add currently executing, you can enter add (1) In the Watch window, but this will have a negative effect, change the value of testlist to 7,

Therefore, if you want to not affect the original value of testlist, you need to add ", NSE", shown below is 8, but the Testlist original value is unchanged or 7:

The introduction to this end, have your favorite debugging small function, welcome to comment ~

PS: Just introduce, do not like to spray.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.