?? ape.htm
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1"><SCRIPT LANGUAGE="JavaScript"><!--function popUp(pPage) { var fullURL = document.location; var textURL = fullURL.toString(); var URLlen = textURL.length; var lenMinusPage = textURL.lastIndexOf("/"); lenMinusPage += 1; var fullPath = textURL.substring(0,lenMinusPage); popUpWin = window.open('','popWin','resizable=yes,scrollbars=no,width=525,height=394'); figDoc= popUpWin.document; zhtm= '<HTML><HEAD><TITLE>' + pPage + '</TITLE>'; zhtm += '</head>'; zhtm += '<BODY bgcolor="#FFFFFF">'; zhtm += '<IMG SRC="' + fullPath + pPage + '">'; zhtm += '<P><B>' + pPage + '</B>'; zhtm += '</BODY></HTML>'; window.popUpWin.document.write(zhtm); window.popUpWin.document.close(); // Johnny Jackson 4/28/98 }//--> </SCRIPT><link rel="stylesheet" href="/includes/stylesheets/ebooks.css"> <META NAME="GENERATOR" Content="Symantec Visual Page Mac 1.1.1"> <TITLE>Teach Yourself Visual C++ 6 in 21 Days -- Appendix E -- Using the Debugger and Profiler</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><H1 ALIGN="CENTER"><IMG SRC="../button/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM"BORDER="0"><BR>Teach Yourself Visual C++ 6 in 21 Days</H1><CENTER><P><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> <HR></CENTER><H1 ALIGN="CENTER">- E -<BR>Using the Debugger and Profiler</H1><H1></H1><UL> <LI><A HREF="#Heading1">Creating Debugging and Browse Information</A> <UL> <LI><A HREF="#Heading2">Using Debug and Release Modes</A> <LI><A HREF="#Heading3">Setting Debug Options and Levels</A> <LI><A HREF="#Heading4">Table E.2. Debug info settings.</A> <LI><A HREF="#Heading5">Creating and Using Browse Information</A> <LI><A HREF="#Heading6">Using Remote and Just-in-Time Debugging</A> <LI><A HREF="#Heading7">Installing the Remote Debugger Files</A> </UL> <LI><A HREF="#Heading8">Tracing and Single Stepping</A> <UL> <LI><A HREF="#Heading9">Using the TRACE Macro</A> <LI><A HREF="#Heading10">Using the ASSERT and VERIFY macros</A> <LI><A HREF="#Heading11">Using Breakpoints and Single Stepping the Program</A> <LI><A HREF="#Heading12">Using Edit and Continue</A> <LI><A HREF="#Heading13">Watching Program Variables</A> <LI><A HREF="#Heading14">Other Debugger Windows</A> </UL> <LI><A HREF="#Heading15">Additional Debugging Tools</A> <UL> <LI><A HREF="#Heading16">Using Spy++</A> <LI><A HREF="#Heading17">Process Viewer</A> <LI><A HREF="#Heading18">The OLE/COM Object Viewer</A> <LI><A HREF="#Heading19">The MFC Tracer</A> </UL></UL><P><HR SIZE="4"><BR><I>by Jon Bates</I></P><P><I></I><H2><A NAME="Heading1"></A>Creating Debugging and Browse Information</H2><P>A large part of application development is actually debugging your program. Allsoftware development is a tight cycle of application design, implementation, anddebugging.</P><P>Visual C++ has an extensive debugging environment and a range of debugging toolsthat really help with program development. You can quickly identify problems, watchthe contents of variables, and follow the flow of programs through your own codeand the MFC code.</P><P>Tools such as the Spy++ program can show you the messages passed between Windowsand your application and let you spy on applications to see which user interfacecontrols and Window styles they use.</P><P><H3><A NAME="Heading2"></A>Using Debug and Release Modes</H3><P>There are two main compiler configurations that you can set to build your application:Debug and Release mode. You can change these modes by clicking the Project menu andselecting the Settings option or by pressing Alt+F7, which will display the ProjectSettings dialog box (see Figure E.1). The main project settings are shown at thetop level and can be changed by selecting the options listed in the combo box. Whenone setting is selected, changes that you make to any options on the tabs on theright will be set against that configuration. When you build the application, itwill be built using your current configuration settings, or you can select All Configurationsto build and make changes to all configurations simultaneously.</P><P><A HREF="javascript:popUp('30fig01r.gif')"><B>FIGURE E.1.</B></A><B> </B><I>TheC/C++ tab of the Project Settings dialog box.</I></P><P>Both Release<B> </B>and Debug<B> </B>configurations are supplied whenever youcreate a new project; they produce very different object code. When configured forDebug mode, your build will produce a large and fairly slow executable program. Thisis because lots of debugging information is included in your program and all thecompiler optimizations are disabled.</P><P>When you compile the same program in Release mode, you'll see a small, fast executableprogram, but you won't be able to step through its source code or see any debuggingmessages from it.</P><P>Normally, when developing an application, you leave the compiler set to Debug<B></B>mode so that you can easily spot and debug problems that arise in your code.When you've finished your application and are preparing to release it, you can setthe configuration to Release<B> </B>mode and produce a small, fast program for yourusers.</P><BLOCKQUOTE> <P><HR><B>RELEASE MODE TESTING</B></P> <P>You should always fully test your application after rebuilding it in Release mode before sending it to users. Bugs can arise from things such as leaving proper program code in ASSERT macros (discussed later this chapter), which are then removed, or because of the effect of some speed and memory optimizations.<HR></BLOCKQUOTE><H3><A NAME="Heading3"></A>Setting Debug Options and Levels</H3><P>You can set a variety of debugging options and levels from the C/C++ tab of theProject Settings dialog box. This dialog page is available from the Project menuby selecting the Settings option (or by pressing Alt+F7) and then selecting the C/C++tab.</P><P>With the General<B> </B>Category selected, the following items are available:</P><P><UL> <LI>Warning Level.<B> </B>This is the level of compiler warning messages given during compilation. You can set it to any of the values shown in Table E.1. The default level is Level 3, which is quite sensitive, although many good C++ programmers insist on using Level 4 to get the most warning of potential problems from the compiler. Level 1 and no warnings (None) should be used only in special circumstances because they indicate only severe warnings (or none at all).</UL><BLOCKQUOTE> <P><HR><B>LEVEL 4 WARNINGS</B></P> <P>At level 4, you'll find that Microsoft's own AppWizard-generated code gives warnings (although usually only about unused function parameters that can be safely ignored).<HR></BLOCKQUOTE><UL> <LI>Warnings as Errors.<B> </B>When you check this, warning messages are shown as errors that then stop the compiler. <P> <LI>Generate Browse Info.<B> </B>When you check this, the compiler generates information that can be used to help you locate functions, symbols, and class relationships shown in a Browse window (discussed in the next section). Unfortunately, generating this useful information increases the compilation time quite a bit for large projects (where you most need it). <P> <LI>Debug Info.<B> </B>This lets you specify the level of debugging information generated by the compiler, as shown in Table E.2. <P> <LI>Optimizations.<B> </B>In Debug mode, you would normally leave these disabled because they interfere with the debugging process and take longer to compile. However, in Release mode you can decide whether to Maximize Speed or Minimize Size of your application (or a default that compromises to get the best of both). <P> <LI>Preprocessor Definitions.<B> </B>This specifies manifest definitions that are defined when your program is compiled. You can use these definitions in conjunction with the #ifdef, #else, and #endif preprocessor commands to compile sections of code in specific configurations. The _DEBUG definition is set by default when in Debug mode. You can use this to compile Debug mode-only code in your application like this:</UL><PRE>int a = b * c / d + e;#ifdef _DEBUGCString strMessage;strMessage.Format("Result of sum was %d",a);AfxMessageBox(strMessage);#endif</PRE><UL> <LI>The message box code is then compiled and run when your application is built in Debug mode. When you switch to Release mode, the code isn't compiled into your executable. <P> <LI>Project Options.<B> </B>The compiler itself runs as a console-based application and converts your Developer Studio options into several flags to be passed on the command line. You can add additional flag settings for more obscure compiler settings that don't have a user interface switch directly into this edit box.</UL><H4>TABLE E.1. COMPILER WARNING LEVELS.</H4><P><TABLE BORDER="1"> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT"><I>Level</I></TD> <TD ALIGN="LEFT"><I>Warnings Reported</I></TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">None </TD> <TD ALIGN="LEFT">None </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Level 1 </TD> <TD ALIGN="LEFT">Only the most severe </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Level 2 </TD> <TD ALIGN="LEFT">Some less severe messages </TD> </TR> <TR ALIGN="LEFT" VALIGN="TOP"> <TD ALIGN="LEFT">Level 3 </TD>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -