VC debugging entry

xiaoxiao2021-03-06  72

Overview Debugging is the most basic skill of programmers, and its importance even exceeds learning a language. The programmer who will not debug means that he will not prepare any good software even if he will speak in a language. Here I briefly lists the more common skills in debug according to their own experience, I hope to use it for everyone. This article contemplates, when selecting a menu, by / representing a hierarchical menu, such as File / Open, a submenu Open of the top-level menu file. Set to debug a program, you must first make the program contain debug information. In general, a debug configuration included in the project created from AppWizard automatically contains debugging information, but is the Debug version is not a program contains determinants of debugging information, and program designers can add debugging information in any Configuration, including Release. version. In order to increase the debugging information, you can perform according to the following steps: Open the Project Settings dialog (can be opened by shortcut ALT F7, or open by IDE menu Project / Settings) Select C / C page, select General in Category, A debug info drop-down list box, optional debugging information, including: Command line Project Settings Description None None does not debug information / zd line number online only contains only global and export symbols and code row information, no Contains symbol debugging information / z7 c 7.0- compatible target file or executable contains line numbers and all symbol debug information, including variable name, function, and prototype / zi Program Database Create a library (PDB), including type Information and symbol debugging information. / Zi Program Database for Edit and Continue In addition to the function of the front / zi, this option allows the code to be modified and continued during the debugging process. This option simultaneously selects the Optimization function of #pragma settings, select the check box "Generate Debug Info, this option will make the connector to write the debug information into the executable and DLL set in the C / C page set up Program The Database or above, the link incrementAlly can choose. Select this option, which will make the program can be compiled (ie, incremental compilation) on the basis of the last compilation, without having to start compilation from the head every time. The breakpoint breakpoint is a code location set by the debugger. When the program is running to the breakpoint, the program is interrupted, returns to the debugger. Breakpoint is the most common skill. When debugging, only the breakpoint is set and the program will be commissioned online. Set breakpoints: You can set a breakpoint by the following method. First move the cursor to the code line that needs to set the breakpoint, then press the F9 shortcut to pop up the BreakPoints dialog box, the method is to press the shortcut key Ctrl B or Alt F9, or open by menu Edit / Breakpoints. After opening, click the arrow on the right side of the BREAK AT Edit box, select the appropriate location information. Under normal circumstances, directly selecting Line XXX is enough. If you want to set a breakpoint that is not the current location, you can select Advanced, then fill in functions, line numbers, and executable information. Remove the breakpoint: Move the cursor to the line where the break point is located, and press F9 again to cancel the breakpoint. Once the BreakPoints dialog is opened as described above, you can also remove the breakpoint in accordance with the interface prompt. Condition breakpoint: You can set a condition for breakpoints, such a breakpoint called condition breakpoint.

For newly added breakpoints, you can click the Conditions button to set an expression for the breakpoint. When this expression changes, the program is interrupted. Under the bottom setting includes "Observing an array or structure", it seems that the size of the memory area points to which a pointer points can be set, but I set a comparison value but the memory area outside the change range seems to also result in breakpoints. The last setting allows the program to execute how many times will then reach the breakpoint. Data breakpoint: Data breakpoint can only be set in the BreakPoints dialog. Select the "DATA" page to display the dialog box for setting up data breakpoints. Enter an expression in the edit box, when the value of this expression changes, the data breakpoint is arrived. In general, this expression should be composed of operators and global variables, for example, enter the name of G_bflag's global variable in the edit box, then there is g_bflag =! G_bflag in the program, the program will stop at this statement. Message breakpoint: VC also supports interception of Windows messages. He has two ways to intercept: Window message processing function and a specific message interrupt. When you select your message breakpoint in the BreakPoints dialog box, you can set the message breakpoint. If you write the name of the message processing function in the above dialog, each message is processed by this function, the breakpoint arrives (I think if it is intercepted in this function, the effect should be the same). If a message is selected at the drop-down list box below, each time this message arrives, the program is interrupted. Value WatchVC supports the value of the viewing variables, expressions, and memory. All of these observations must be carried out in the case of breakpoint interruption. The value of watching the variable is the simplest, when the breakpoint arrives, move the cursor to this variable, and stay in a while, you can see the value of the variable. VC provides a mechanism that is Watch to view variables and expressions. In the breakpoint state, right-click on the variable, select Quick Watch, pop up a dialog, display the value of this variable. Click the WATCH button on the debug toolbar, there is a Watch view (Watch1, Watch2, Watch3, Watch4), enter variables or expressions in this view, you can observe the value of variables or expressions. Note: This expression does not have side effects, such as operators absolutely for use in this expression because this operator will modify the value of the variable, resulting in the logic of the software to be destroyed. Memory only shows the value of the first element due to the array pointed to by the pointer. In order to display the subsequent content of the array, or display the contents of the memory, the Memory function can be used. On the Debug toolbar, point the Memory button, pop up a dialog box, enter the address in it, you can display the contents of the memory pointing to by. The VaribleSDebug tool bar pops up a box that displays all the values ​​of the variables visible in the context. In particular, the current instructions involved, in red display. The REIGSTERS button on the Register Debug tool bar pops up a box to display the value of all current registers. Process Control VC allows the program to be interrupted to continue to run, single-step operation and running to the specified cursor, respectively, and corresponding shortcuts F5, F10 / F11, and CTRL F10. Each shortcut key function is as follows: Shortcut Key Description F5 Continue to run the F10 single step, The Call Stack call stack reflects that the current breakpoint function is called by those functions. Click the call stack on the Debug toolbar to display the Call Stack dialog.

转载请注明原文地址:https://www.9cbs.com/read-88008.html

New Post(0)