VS 2005 variable Tracking and breakpoint debugging

Source: Internet
Author: User

For variable tracking mainly depends on setting breakpoints, step by step debugging

To view the value of a variable:

1) The Local Variables window/Monitoring window can check the current values of each variable;

2) Place your mouse over the variable you want to see and stay for a while

To temporarily change the value of a variable:

1) through the "Instant Window" (Debugging, window, and so on), you can temporarily change the value of a variable (such as entering width = 32 in the Immediate window) while the program is running (in the breakpoint state, of course), and then enter it into effect, and the left local variable will display the changed value as red.

2) Double-click directly on the value of the local variable and enter the value you want to change

3) Hover over the variable you want to change, click on the value that pops up, and enter the value you want to change.

Pros: You may not have to stop testing/modifying code/re-debugging for each value of the debug variable, especially if you need to test the normal value of a variable repeatedly.

VS has a lot of advantages when debugging variables, it also has a lot of fun when setting breakpoints:

1) It can set breakpoints at any point in the code. Some people like to write multiple lines of code in one line, such as: statement for (int i = 0; i < i++) {if (i = = 5) j = 5;} Write on a line, want to be in J = 5; set a breakpoint here, as long as the mouse moves j = 5; Front, right-click Breakpoint, insert Breakpoint.

2) interrupts after a specified number of times inside the loop. Breakpoints are set within a 1000-time loop, and are interrupted after the loop has reached 900 times. such as procedures:

for (int i = 0; i <; i++)

{

if (i = = 901)

j = 5;

}

Insert a breakpoint on the curly brace of the loop, and then right-click on the small red dot of the Breakpoint, which pops up the menu window of the image below to

Select condition to set the breakpoint hit condition in the pop-up condition dialog box I = = 900

One thing to note here is that the conditional syntax is the same as the programming language syntax for the program, but the default is the same programming language as the current project. Different time can be changed according to Ctrl+b.

3) Interrupt when the value of the specified variable is changed. You have an expression that changes at some point in the loop, and you want to know which one it was and where it changed. As in the above procedure, to break when the value of the variable J changes (of course, this program is very simple to see, if the loop has a very complex function in the inside it is necessary to do so), or above, in the loop curly braces set breakpoints, also open the Breakpoint Condition dialog box, the condition is set to J, the hook selected "changed" can be

4) Intermittent interruption under specified conditions. For example, you want your breakpoint to be hit 100 times, three times per hit, such as 103th, 106th, 109th. By setting the number of hits for several breakpoints, right-clicking the breakpoint and selecting hit count in the pop-up menu pops up the following dialog box.

There are several breakpoint conditions, you can choose the conditions you want to set breakpoints.

There are a lot of features in the breakpoint setting of VS, which is not discussed, so you can try it yourself ...

Go from: http://zengwu3915.blog.163.com/blog/static/27834897200971313913153/

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.