Debugging methods in Visual studio __visual

Source: Internet
Author: User

First of all, write a simple code example in vs.

The normal attempt to run in VS is no breakpoint debugging, just press F5.


The resulting results are as follows.


When debugging, you need to set at least one breakpoint (click to the left of where you want to set it). debugging starts debugging by causing the program to run to a breakpoint and suspend its operation.


By pressing F5, you can find that the program runs to the end of the line where the breakpoint is paused (this line is about to be executed). The value of each variable can be observed at the arrow position. You can see I as a local auto variable, and its value is still a random number.


There are two common approaches to debugging: statement-by-step and process-by-procedure. Per-statement (F11): Each execution of a statement, when the function is encountered, into the function of the body to monitor, the function is also executed within the sentence. Process-by-step (F10): When a function is not encountered, as per-statement, the entire function is treated as a procedure when it is encountered, without stepping into the function to monitor it.

In addition, jump out (SHIFT+F11): In the function body using out, will directly execute the remaining statements in the function to end the function, to achieve the function is the use of the statement at the following point.

The yellow arrows in the following illustration indicate that the debugger has debugged to this line, and that the statement in the line has not yet been executed, that is, the statement before this line has been executed. You can see that the value of I has changed compared to the previous pause, the color of I in the Variable debug table is red, and we can see that its new value is 0.


If you set more than one breakpoint, each press F5 will execute to the next breakpoint, which is also a handy debugging technique. Use this technique to skip parts that are sure they won't go wrong and don't need to be monitored.


When you press F5 in the following figure, debugging runs from one breakpoint to the next.


After you find the error, press Stop Debugging (SHIFT+F5) to finish debugging.


In fact, can be seen, F11 is a sentence to monitor, shift+f11 a one-time jump out of a large set of statements (a process); F5 from the breakpoint to debug, Shift+f5 a one-time jump out of all breakpoints, that is, directly run to the end of the program, finished debugging.


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.