?? ape.htm
字號:
<TD ALIGN="LEFT">This stops the debugger and returns to editing mode. </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD WIDTH="134" ALIGN="LEFT"><IMG SRC="ic-07.gif" WIDTH="24" HEIGHT="27" ALIGN="BOTTOM" BORDER="0"> Restart </TD> <TD ALIGN="LEFT">Ctrl+Shift+F5 </TD> <TD ALIGN="LEFT">This option restarts the program from the beginning, stopping at the very first line of code. </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD WIDTH="134" ALIGN="LEFT"><IMG SRC="ic-09.gif" WIDTH="29" HEIGHT="28" ALIGN="BOTTOM" BORDER="0"> Break Execution </TD> <TD ALIGN="LEFT"> <P> </TD> <TD ALIGN="LEFT">This option stops a program running at normal speed in its tracks. </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD WIDTH="134" ALIGN="LEFT"><IMG SRC="ic-10.gif" WIDTH="29" HEIGHT="28" ALIGN="BOTTOM" BORDER="0"> Apply Code Changes </TD> <TD ALIGN="LEFT">Alt+F10 </TD> <TD ALIGN="LEFT">This option lets you compile the code after making changes during a debugging session and then continue debugging from where you left off. </TD> </TR></TABLE></P><P>By using these options, you can watch the flow of your program and see the contentsof the variables as they are manipulated by the code. The yellow arrow in the Editorwindow will always show the next statement to be executed.</P><P>The next sections describe some of the debugging windows you can use when youare stopped in the debugger.</P><P><H3><A NAME="Heading12"></A>Using Edit and Continue</H3><P>A great new feature of Visual C++ 6 is the capability to Edit and Continue. Thismeans that you can change or edit the code while you are stopped in the debugger.After editing, you'll notice the Debug menu's Apply Code Changes option becomes enabled(as well as the corresponding debug toolbar icon). You can then select the ApplyCode Changes option (or toolbar button) to compile your new code changes and thencontinue debugging the new changed code. By using this new feature, you can fix bugswhile debugging and continue the debug run from the same place in the code with thesame variable settings, which can be very useful when debugging large and complexprograms.</P><P><H3><A NAME="Heading13"></A>Watching Program Variables</H3><P>The Watch and Variables windows are shown in Figure E.11. These windows displaythe contents of variables when stopped in the debugger. You can view these windowsby clicking the View menu and selecting them from the Debug Windows pop-up menu orby clicking the icons from the toolbar.</P><P><A HREF="javascript:popUp('30fig11r.gif')"><B>FIGURE E.11.</B></A><B> </B><I>TheWatch window displays contents of variables while debugging.</I></P><P>The Variables window always shows the local variables of the function displayedin the Context combo box at the top of the window. To get to your current function,you can drop this combo box list to display all the functions that were called inturn. This is the call stack and shows your current context within the program byshowing the list of functions that have been called in order to get to the program'scurrently executing function where the debugger has stopped. When you select a differentfunction, the relevant local variables are shown for that function level.</P><P>You can expand any object pointers shown by clicking the plus symbol next to thepointer name. The special C++ this pointer is always shown for class member functionsand can be opened to show all the member variables for the current object.</P><P>The Watch window lets you enter variable names from the keyboard or drag variablenames from the editor window (after selecting and inverting them with the mouse point).The values that are held in the displayed variables are shown until they go out ofscope (that is, aren't relevant to the function currently being debugged).</P><P>You can also enter simple casts and array indexes in the Watch window to showrelated values. Right-clicking the mouse can switch the displayed values betweenhexadecimal and decimal display. As you step through the program, the values shownin the Watch and Variable windows are updated accordingly so that you can track howthe program changes the variables.</P><P><H3><A NAME="Heading14"></A>Other Debugger Windows</H3><P>Other debugging display windows are available by clicking the View menu and selectingthem from the Debug Windows pop-up menu or alternatively by clicking the variousicons shown to the right of the Debug toolbar. These windows are</P><P><UL> <LI>QuickWatch. By clicking a variable in the listing and choosing QuickWatch or pressing Shift+F9, you can display the contents of the select variable. You can also enter variables directly and then click the Add Watch button to transfer them into the main Watch window. <P> <LI>Registers. The Registers window displays the current values in your CPU's register set. This probably isn't too useful to you unless you are tracking machine or assembly code-level problems. <P> <LI>Memory. The Memory window displays the memory from the application's address space in columns that represent the address, the hex values, and the character values for each 8 bytes. You can change this display to show Byte, Short, or Long values by right-clicking to display the appropriate context menu options. <P> <LI>Call Stack. The Call Stack window shows the list of functions that were called in order to get to your current function and the parameter values that were passed to each function. This can be very useful to investigate how the program flow reached a specific function. By double-clicking any of the listed functions, you can display the position where the function call was made in the code, shown by the Editor window. <P> <LI>Where source code isn't available, function entries are shown as follows:</UL><PRE>KERNEL32! bff88f75()</PRE><UL> <LI>If you click these entries, you'll be shown assembly code rather than C++ code. <P> <LI>Disassembly. By selecting the Disassembly toolbar button or menu option, you can toggle between displaying the C++ code mixed with assembly code or just C++ code. Where the source code is unavailable, only assembly code is shown.</UL><H2><A NAME="Heading15"></A>Additional Debugging Tools</H2><P>Along with the integrated debugging tools are several nonintegrated but very usefultools. You can start these by clicking the Tools menu and selecting the specifictool option from the menu.</P><P>These tools generally let you track operating-specific items such as Windows messaging,running processes, and registered OLE objects to enhance your available informationwhile debugging your application.</P><P><H3><A NAME="Heading16"></A>Using Spy++</H3><P>Spy++ is undoubtedly one of the most useful of these tools. With Spy++, you cansee the hierarchical relationships of parent to child windows, the position and flagssettings for windows, and base window classes. You can also watch messages as theyare sent to a window.</P><P>When you first run Spy++, it shows all the windows on the current desktop, theirsiblings, and the base Windows class of each object (see Figure E.12). The view shownin Figure E.12 has been scrolled to shown the standard Microsoft Windows CD Player.Spy++ shows you all the buttons and combo boxes, which are windows in their own rightas child windows of the main CD Player window.</P><P><A HREF="javascript:popUp('30fig12.gif')"><B>FIGURE E.12.</B></A><B> </B><I>TheSpy++ initial view of the Windows desktop showing the CD Player portion.</I></P><P>If you click the Spy menu, you are shown the following options:</P><P><UL> <LI>Messages. You might find that the Messages view is probably one of the most useful options because you can use it to watch messages that are sent to any window (including your own application). You can also filter these messages so that you don't receive an avalanche of Mouse Movement messages. <P> <LI>To use messages, select this option to display the Message Options dialog box shown in Figure E.13. You can then drag the finder tool over any window in the system, displaying the details of the window as it moves. Spy++ also highlights the selected window, so you can see frame and client windows. When you've located the window you want to view, just let go of the tool. At this point you can use the other tabs to set filtering options and output formatting options. When you're finished, click OK to close the Message Options box.</UL><P><A HREF="javascript:popUp('30fig13.gif')"><B>FIGURE E.13.</B></A><B> </B><I>Usingthe Spy++ Message Options Finder to locate windows.</I></P><P><I></I><UL> <LI>The output shown in Figure E.14 are the messages produced from using a normal SDI application's toolbar. As you can see, with no filtering you'll receive many mouse movements and cursor check messages, but you can also see the familiar WM_LBUTTONUP message with its position parameters.</UL><P><A HREF="javascript:popUp('30fig14.gif')"><B>FIGURE E.14.</B></A><B> </B><I>WindowsMessages for a toolbar logged by Spy++.</I></P><P><I></I></P><UL> <LI>Windows. The Windows view is the view shown in Figure E.12 of the layout and structure of the Windows desktop. If you double-click any of these windows, you'll be shown a property sheet containing all the selected windows' positioning information and flag settings. To update this information, you must click the Windows menu and choose Refresh. <P> <LI>Processes. You can view all the running programs with the Processes view. These can be opened to show each thread and any windows attached to those threads. <P> <LI>Threads. The Threads option shows the same details without the processes level of hierarchy, so you can see every thread running on your machine and the windows that each thread owns.</UL><P>Spy++ is too sophisticated to cover in its entirety here, but as a tool for understandingthe structure of Windows hierarchies and messaging, it is unsurpassed. You can gleana lot of valuable knowledge just by looking at commercial applications with Spy++.It is also a wonderful tool for debugging messaging problems in your own applicationto ensure that your windows are getting the correct messages and to see how thesemessages are sequenced.</P><P><H3><A NAME="Heading17"></A>Process Viewer</H3><P>You can see all the processes in more detail than shown in Spy++ with the ProcessViewer (PView95.exe). You can start this application from your system's main WindowsStart menu from Programs under the Microsoft Visual Studio 6.0 Tools option (or similarprogram group). This application lists the processes running on your machine andlets you sort them by clicking any of the column headers. You can then click a processto display all its threads. Figure E.15 shows Process Viewer running with the DeveloperStudio application (MSDEV.EXE) selected and all its many threads displayed.</P><P><A HREF="javascript:popUp('30fig15.gif')"><B>FIGURE E.15.</B></A><B> </B><I>TheProcess Viewer showing MSDEV.EXE and its threads.</I></P><P><I></I><H3><A NAME="Heading18"></A>The OLE/COM Object Viewer</H3><P>The OLE/COM Object Viewer tool shows you all the registered OLE/COM objects onyour system, including ActiveX controls, type libraries, embeddable objects, automationobjects, and many other categories.</P><P>You can even create instances of various objects and view their interfaces indetail. The OLE/COM Object Viewer is very useful if you are developing an OLE/COMapplication or looking for an elusive ActiveX control.</P><P><H3><A NAME="Heading19"></A>The MFC Tracer</H3><P>Using the MFC Tracer tool shown in Figure E.16, you can stop the normal tracingor add specific Windows trace output to the normal program trace output. When youselect this tool, you are shown a set of check boxes that you can check or uncheckto include that tracing option.</P><P><A HREF="javascript:popUp('30fig16.gif')"><B>FIGURE E.16.</B></A><B> </B><I>TheMFC Tracer tool options.</I></P><P>You can add Windows messages, database messages, OLE messages, and many otherlevels of trace output to help track down elusive problems. These messages are thengenerated by the MFC code for the various selected flags.</P><P>You can even turn off the standard tracing generated by your application by uncheckingthe Enable Tracing option.</P><H1></H1><CENTER><P><HR><A HREF="../apd/apd.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apf/apf.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR><BR></P><P>© <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -