VS breakpoint debugging skills

Conditional breakpoint:

A conditional breakpoint is a breakpoint that is triggered when a certain condition is met.
For example, in the loop body, we want to check the result of the 10,000th loop. Obviously, we cannot run the program step by step, but we should set the condition at the breakpoint.
Use process:
1. First, you need to set a breakpoint.
insert image description here
2. Click the setting button at the breakpoint, and
insert image description here
the following prompt box will
insert image description here
pop up. 3. Then check the conditions and fill in the conditions of the breakpoint.
insert image description here
4. Start debugging, and you will see that the breakpoint is triggered (note that the color is different from the general breakpoint)
insert image description here
5. View related information
insert image description here

Breakpoint operation:

In the breakpoint setting, there are not only conditions, but also operations. With the help of operations, we can print some information. Using this function of VS, we don’t need to write and print codes displayed in the code~ (Of course, this has advantages and disadvantages. Printing information is written directly in the code, which can be reproduced faster. It is also very convenient to use in combination with macros. This kind of breakpoint operation is troublesome to reproduce and is suitable for troubleshooting).
For example, we need to check the change of the value in the loop body, but do not want to write and modify the code. At this time, we can use the breakpoint operation.
Operation process
1. First, you need to set a breakpoint.
insert image description here
2. Click the setting button at the breakpoint, and
insert image description here
the following prompt box will
insert image description here
pop up. 3. Check the operation, and fill in the information to be printed.
Note that {} means a variable in the middle, and
insert image description here
the output result will be printed in the output window

4. Start debugging, and you will see that the breakpoint is triggered (note that the color is different from the normal one). The
insert image description here
output of the output window is as follows:
insert image description here
5. The breakpoint operation can be used in conjunction with the conditional breakpoint. The
insert image description here
output is as follows:
insert image description here
6. The special variables provided by VS can print their information during the breakpoint operation.
Using these special variables, you can easily obtain some information about the current program running. Note that the prefixes are $ and their
insert image description here
specific meanings are as follows:

$ADDRESS    当前指令的地址
$CALLED     调用当前函数的函数名称
$CALLSTACK  当前调用堆栈
$FILEPOS    当前文件和行位置
$FUNCTION   当前函数的名称
$PID        当前进程的ID
$PNAME      当前进程的名称
$TICK       自系统运行以来的毫秒数,最大为49.7天
$TID        当前线程的ID
$TNAME     当前线程的名称

Example: Output the file where the current breakpoint is located, the line position and the name of the current function Output
insert image description here
:
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43003108/article/details/121097552