VC++6.0 debugging detailed tutorial

 

 

Reprinted from: http://blog.sina.com.cn/s/blog_6377a3100100h40e.html

 

vc++6.0 debugging detailed tutorial

 

Step into

Step over

Step out

Run to cursorvc++6.0 <wbr>debugging detailed tutorial

Watch

Variables

Registers

Memory

Stop Debug

Call stack

Disassembly

Restart Debugger

 

2. The general process of debugging

Debugging is to observe the state of the program at a certain stage of the running process of the program. In general the program runs continuously, so we must make the program stop at a certain point. The first thing we do is to set breakpoints; secondly, run the program; when the program stops at the set breakpoint, we use various tools to observe the state of the program.

   After the program stops at the breakpoint, sometimes we need to control the operation of the program according to our requirements to further observe the flow of the program.

   Next, we will introduce the setting of breakpoints, how to control the running of the program and the use of various observation tools.

3. Set breakpoints

In VC, many types of breakpoints can be set, and these breakpoints can be divided into three categories according to the way the breakpoint works:

1. Position-related breakpoints;

2. Breakpoints related to logical conditions

3. Breakpoints related to WINDOWS messages.

Mainly introduce the first two breakpoints.

4. Set location breakpoints

The easiest is to set a general location breakpoint:

¡ Move the cursor to the position where you want to set a breakpoint, of course, this line must contain a valid statement;

¡ Then press the add/remove breakpoint button on the toolbar or press the shortcut key F9.

  You will see a red dot appear on the screen to the left of the line indicating that a breakpoint has been set

5. Set the location breakpoint - iconvc++6.0 <wbr>debugging detailed tutorial

 

 

6. Set logical breakpoints

Sometimes it may not be necessary for the program to stop here every time it runs, but only when certain conditions are met. In this case, a position-related logical breakpoint needs to be set.

  Select the Breakpoints command from the EDIT menu and the Breakpoints dialog will appear on the screen. Select the Location tab in the Breakpoint dialog box to make the Location page pop up.

   As shown on the following page.

7、 vc++6.0 <wbr>debugging detailed tutorial

 

8. Set logical breakpoints

   Click the Condition button on the previous page, the Breakpoint Condition dialog box will pop up, write your logical expression in the expression_r edit box, and finally press OK to return.

   Such breakpoints are primarily acted upon by their location, but also incorporate logical conditions to make them more flexible.

9. The operation of the control program

Above we talked about how to set various breakpoints, let's introduce how to control the operation of the program. When we select Go from the menu Build to the submenu Start Debug, the program starts to run in the Debug state, and after the program stops due to breakpoints, you can see a small arrow pointing to the code to be executed.

 

10. Control the operation of the program vc++6.0 <wbr>debugging detailed tutorial

Then, we can control the operation of the program as required: there are four commands:

¡          Step over

¡          Step Into

¡          Step Out

¡          Run to Cursor

¡ Step over : run the code pointed to by the current arrow (only run one code);

¡ Step Into: If the code pointed to by the current arrow has a function call, use Step Into to enter the function for single-step execution;

¡ Step Out: If the code pointed to by the current arrow is in a function, use it to run the program to the return of the function;

¡ Run to Cursor: Make the program run to the code pointed by the cursor.

11. View the use of tools

The most important thing in the debugging process is to observe the state of the program during the running process, so that we can find out what is wrong with the program. The state mentioned here includes the value of each variable, the value in the register, the value in the memory, and the value in the stack. For this reason, we need to use various tools to help us observe the state of the program.

12. View the use of tools

Ø Pop-up debugging information bubble (Data Tips Pop_up Information).

  The easiest way to observe the value of a variable or expression after the program has stopped at a breakpoint is to use debug information bubbles. To see the value of a variable, just in the source program window, place the mouse over the variable and you will see an information bubble pop up showing the variable's value.

13. View tool usage - variable window

Ø Variable window (VARIABLE WINDOW).

  From the View menu, select Variables for Debug Windows; the Variables window will appear on the screen. It shows the variable name and its corresponding value. You will see three tabs in the lower part of the variable watch window: Auto, Locals, this Select different tabs, and different types of variables will be displayed in this window.

14、

Ø WATCH WINDOW

  From the View menu, select the Watch subcommand of the Debug Windows command. The watch window will then appear on the screen.

15、

 vc++6.0 <wbr>debugging detailed tutorial

Double-click an empty line in the Name column in the observation window above, and enter the variable name or expression you want to view;

After pressing enter you will see the corresponding value.

16. View the use of tools

The watch window can have multiple pages, corresponding to the labels Watch1, Watch2, Watch3 and Watch4 respectively. If the expression you input is a structure or an object, you can use the mouse to click on the right side of the expression, such as +, to further observe the values ​​of the member variables.

vc++6.0 <wbr>debugging detailed tutorial

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326654891&siteId=291194637