VS breakpoint debugging simple notes

Conditions of Use

如果编译没有错误提示,运行时崩溃或者是结果和预期不一致,这时我们就可以使用断点调试。
If the compiler reports an error, you can directly find and modify it based on the error message. In this case, you do not need to use breakpoint debugging.

Instructions

有错误Add breakpoints where you think . If there is too much code and you don't know where, you can add breakpoints by dichotomy to keep narrowing the scope of errors.

Breakpoint means that the program stops at the point where you add the breakpoint. At this time, you can observe the state of each variable in the program.

For example

For example, if your breakpoint is on line 10, the program will only execute to line 9. After executing line 9, the program will stop at this step.
If the program does not crash at this time, 断点前the program is okay. At this time, we click in the toolbar, 逐语句F(11)and the line where we added the breakpoint will be executed, that is, line 10 (also possible 逐过程).

If the line where the breakpoint is added is a function (a function of the standard library), it is best to use the step-by-step procedure, otherwise, if you use the step-by-statement, it will jump to the inside of the function for execution (not necessary). Of course, if you write a function yourself, you can use statement by statement.
If you accidentally jump to the inside of the function using statement by statement, you can click 跳出.

After clicking the step by step (step by step), the 10th line is executed, and it is still in a suspended state (ready to execute the 11th line), because the execution effect of the 10th line will also come out. Continue and so on... until the error is reported, the wrong line can be determined.

Guess you like

Origin blog.csdn.net/qq_41363459/article/details/111466305