VS debugging detailed explanation (1) (Xiaobai tutorial)

1. Introduction to
Debug and Release Debug is usually called the debug version, which contains debugging information, and does not make any optimizations, which is convenient for programmers to debug the program.
Release is called the release version, which is often optimized to make the program in the code The size and running speed are both optimal, so that users can use it well.

First create a new project, write a simple program, run under the Debug and Release versions respectively, under the path where we created the project, find the Debug and Release folders, and click the .exe file of the code just written

We can see that the executable program of the Debug version is 38KB, and the executable program of the Release version is 9KB. Why?
Because the Debug version contains debugging information, it can be debugged, but the Release version cannot be debugged.
We can debug by pressing fn+F10 in the Debug version, but Release cannot

1. Press and hold fn+F10
2. Open our monitoring window
3. Add the items we want to monitor (i monitored by my program)
4. Press and hold fn+F10 for process-by-process debugging

You can also try to monitor in Release, will find variable has been optimized away, can not be reused .

2. Introduction to debugging in Windows environment

1. Preparation of debugging environment: change to Debug version

2. Learn shortcut keys

F5
starts debugging. It is often used to jump directly to the next breakpoint. It is used in conjunction with F9. Press F9 to add a breakpoint where we want the program to stop (press again to cancel the breakpoint).

F10
process by process, usually used to process a process, a process can be a function call, or a statement. F10 does not pay attention to the statements inside the function, only the result of the function call.

F11
statement by statement means to execute a statement every time, but this shortcut key can make our execution logic enter the function (this is the most commonly used).

CTRL+F5
start execution without debugging, if you want to run the program directly without debugging, you can use it directly

Shift+F11
jump out of the current function

Shift+F5
stop debugging

3. View the current information of the program during debugging
1. Automatic window, local variables
2. Memory
3. Call stack The
call stack can well reflect the calling relationship between functions, which is very similar to the stack structure

For more debugging functions, you can try and debug more by yourself, and there will be some debugging examples in the future.

Guess you like

Origin blog.csdn.net/DR5200/article/details/112269237