⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 uc/os源码 uc/os源码
💻
📖 第 1 页 / 共 4 页
字号:
              size=2>选中这个选项并给它设置一个值,这样你就可以决定数据查看(data 
              view)多长时间更新一次。数据查看更新得越频繁,调试器显示的数据值就越新; </FONT>
              <LI><STRONG><FONT size=2>缓存运行中的符号文件</FONT><FONT 
              face="Arial, Helvetica, sans-serif" size=2>(Cache symbolics 
              between runs)</STRONG>: </FONT><FONT 
              size=2>在调试器运行时,符号文件</FONT><FONT 
              face="Arial, Helvetica, sans-serif" size=2>(</FONT><FONT 
              size=2>在编译过程中产生的一种文件</FONT><FONT 
              face="Arial, Helvetica, sans-serif" size=2>)</FONT><FONT 
              size=2>将被缓存起来。这可以提高调试的进程; </FONT>
              <LI><STRONG><FONT size=2>在观察点处停止</FONT><FONT 
              face="Arial, Helvetica, sans-serif" size=2>(Stop at 
              Watchpoints)</STRONG>: </FONT><FONT 
              size=2>选中此项,当观察点值为真时就中断调试。观察点和断点一样是很有用的。不同的是,断点每次都是在一个特定的代码行处停止下来,而观察点是监视一个变量或内存的一块区域,当此被观察的对象发生改变时,它就中断调试过程。这和 
              </FONT><FONT face="Arial, Helvetica, sans-serif" size=2>VC 
              </FONT><FONT 
              size=2>中的条件断点相似,都是在设定的条件被满足时中断调试过程的。这是一个很有用的调试工具。</FONT> </LI></UL>
            <P><B><FONT face="Arial, Helvetica, sans-serif" size=2>x86 
            </FONT><FONT face=幼圆 size=+1>异常</FONT><FONT 
            face="Arial, Helvetica, sans-serif" 
            size=+1>(Exceptions)</FONT></B></P><FONT 
            face="Arial, Helvetica, sans-serif" size=2>
            <DIV align=center>
            <CENTER>
            <TABLE cellSpacing=0 cellPadding=0 border=0>
              <TBODY>
              <TR>
                <TD><IMG height=423 
                  alt="Figure 5-7: The x86 Exceptions panel." 
                  src="第五课        调     试.files/icwwL5_fig7.gif" width=627 
                  align=left> </TD></TR></FONT>
              <TR>
                <TD align=middle>
                  <P align=center><I><FONT size=1>图 </FONT><FONT 
                  face="Arial, Helvetica, sans-serif" size=1>5-7:&nbsp; x86 
                  </FONT><FONT 
            size=1>出错信息面板</FONT></I></P></TD></TR></TBODY></TABLE></CENTER></DIV>
            <P><FONT face="Arial, Helvetica, sans-serif" 
            size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT size=2>当你调试有问题的代码时, 
            </FONT><FONT face="Arial, Helvetica, sans-serif" size=2>CodeWarrior 
            </FONT><FONT size=2>调试器会截取到由程序的 bug 引起的某些奇怪的操作</FONT><FONT 
            face="Arial, Helvetica, sans-serif" size=2>(</FONT><FONT size=2>即所谓的 
            异常——</FONT><FONT face="Arial, Helvetica, sans-serif" 
            size=2>Exceptions)</FONT><FONT size=2>。 </FONT><FONT 
            face="Arial, Helvetica, sans-serif" size=2>IDE </FONT><FONT 
            size=2>会将这些异常传递给一个特殊的代码——一个被称之为处理器的东西——由它来处理这些异常问题。</FONT></P>
            <P><FONT face="Arial, Helvetica, sans-serif" 
            size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT 
            size=2>但是,对于大多数的异常,调试器只是简单地中断它的工作而已。为什么会这样呢?</FONT></P>
            <P><FONT face="Arial, Helvetica, sans-serif" 
            size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT 
            size=2>如果你正在做一个高级开发,例如开发一个系统库或一个设备驱动程序,你可能想测试一下这些代码是如何处理这些异常的。只有调试器不截取这些异常时,你才能这么做。如果为了一些特定的原因,你希望调试器抓住某些特定异常发生时的控制</FONT><FONT 
            face="Arial, Helvetica, sans-serif" size=2>("seize control of the 
            moment" for specific exceptions) </FONT><FONT 
            size=2>,你就应该在这个设置面板上做一些设置。在该面板上显示的异常是 </FONT><FONT 
            face="Arial, Helvetica, sans-serif" size=2>CodeWarrior </FONT><FONT 
            size=2>的集成开发环境可以处置的情况。点击那些你希望由调试器来处理的异常情况,然后点击“保存”按钮保存设置。就像前面提到的,这是很高级的编程设置,因此我们在这将不作详细讨论。总之,</FONT><FONT 
            face="Arial, Helvetica, sans-serif" size=2>CodeWarrior </FONT><FONT 
            size=2>的调试器是一个非常先进的,而且很易于使用的附件。如果你学好了调试器的使用,它将会成为你开发软件的最重要的一个工具。</FONT></P>
            <P><FONT face="Arial, Helvetica, sans-serif" 
            size=2>&nbsp;&nbsp;&nbsp; </FONT><FONT 
            size=2>另外还有“其它的可执行程序”和“远程调试”设置面板,它们是针对高级用户设置的,本课程不打算再作介绍。如果你需要同时调试多个可执行程序或通过 
            </FONT><FONT face="Arial, Helvetica, sans-serif" size=2>TCP/IP 
            </FONT><FONT size=2>网络来调试程序的话,你可以自行参看这几个设置面板。</FONT><BR><FONT 
            face="Arial, Helvetica, sans-serif" 
            size=2>&nbsp;&nbsp;&nbsp;</FONT></P>
            <HR>

            <P>附原文:</P>
            <P> </P>
            <P><FONT face="Arial, Helvetica, sans-serif" color=#000000 
            size=3><B><B>An Introduction to 
            Debugging</B></B><BR></FONT><BR></P><FONT 
            face="Arial, Helvetica, sans-serif" size=2>
            <BLOCKQUOTE><I>
              <P>Purging pesky pests proves productive for programmers!</I> 
            </P></BLOCKQUOTE>
            <P>Debugging is the process of tracking down a problem in your code 
            and fixing it. The sad truth is there is always the possibility that 
            your code contains typing or logic errors. Maybe you thought through 
            a problem thoroughly but still missed a key step in solving it, or 
            maybe you made a tiny typo in your code or used the wrong variable. 
            In many cases, you'll know when you have a flaw in your logic or a 
            programming error because your program will not function as 
            expected. Or, in a worst-case scenario, your computer will crash. 
            When this happens, it's time to begin debugging.</P>
            <P>CodeWarrior includes an integrated debugger, which just means 
            that you can view it while you're looking at other windows of 
            CodeWarrior. Begin using the debugger by selecting Enable Debugger 
            from the Project menu; then rebuild your target. Once that's done, 
            your program will run within the debugger window, allowing you to 
            isolate and fix any problems you find.</P>
            <P>Quite often you will generate a debug target of the program. The 
            target's source files remain the same, but many of the options 
            required to produce a debuggable version of the program (such as 
            generating a symbol file) are preset. This lets you flip into debug 
            mode by just picking the debug target from the Project window's 
            pop-up menu. </P>
            <TABLE cellSpacing=0 cellPadding=0 border=0>
              <TBODY>
              <TR>
                <TD><IMG height=484 
                  alt="Figure 5-1: The debugger does its thing." 
                  src="第五课        调     试.files/icwwL5_fig1.gif" width=542 
                  align=left> </TD></TR>
              <TR>
                <TD align=middle><FONT size=1><I>Figure 5-1: The debugger does 
                  its thing.</I></FONT> </TD></TR></TBODY></TABLE>
            <P>Figure 5-1 shows the Hello World debug program running within the 
            CodeWarrior debugger. Note that we've added a few lines of code to 
            the program in the form of a loop using the variables i, x, and y. 
            We added this code in order to more easily demonstrate how the 
            debugger works. The debugger allows you to step through your code 
            line by line. As you move through the code, you can also note the 
            values of all of your variables. By forcing your program to run in 
            this "slow motion" mode, you can see exactly how your code is 
            working and very easily track down bugs.</P>
            <BLOCKQUOTE>
              <P>I lied. Not all bugs are easy to track down. I've personally 
              worked on bugs that have taken weeks to figure out and fix. Anyone 
              who has programmed for any length of time probably has similar 
              horror stories. Don't let them get you down. On top of everything 
              else, you are a beginner, so you will inevitably be writing buggy 
              code. Remember: we learn more from our mistakes than our 
              successes. OK, I'll stop now.</P></BLOCKQUOTE>
            <P>Notice the buttons at the top left corner of the debugger window. 
            These buttons assist you in stepping through your code. The buttons 
            are, from left to right: Run Program, Stop, Kill (Quit), Step Over, 
            Step Into, and Step Out. The last two step commands allow you to 
            decide whether you want to step into a particular function in your 
            code, or simply step over it and let the entire function execute in 
            one fell swoop. If you know that a certain function does not contain 
            the bug, you can easily step over it and save time. If you're not 
            sure, you can step into it and walk through its code line by line. 
            As a beginner, you should assume that nothing is bug-free -- and you 
            can use the practice. </P>
            <P>The Debugging window (Figure 5-1) contains three main sections:
            <UL>
              <LI><B>The Stack pane</B> (top left) contains a display of the 
              call stack, also known as call history. As you step through source 
              code and call function after function, this area displays the 
              history of functions you have called to get to the current 
              location. This list grows and shrinks as you step through 
              different sections of a program and according to whether you step 
              into functions or not. 
              <LI><B>The Variables pane</B> (top right) shows variable names and 
              their values. Depending on the type of variable, this display will 
              vary to allow you to view (and edit) the data accordingly. In the 
              case of the Hello World x86 program, shown in Figure 5-1, there 
              are four variables: c, i, x, and y. As you step through your code, 
              the values of the variables will update in this window in real 
              time. For example, notice how the latter three variables have 
              realistic values (since these values were set by the code loop), 
              while c has a nonsense value (you have yet to enter a character 
              into the getchar() function). Using this pane to spot odd or 
              unexpected values is one of the keys to your debugging success. 
              <LI><B>The Source pane</B> (bottom) displays the C source code for 
              Hello World x86 program. It can also display the assembly language 
              version of the code. Depending on the type of bug you are tracking 
              down, the C source display may not provide enough detail. In that 
              case, you may need to view the program at a finer level of detail 
              -- in assembly language. The pop-up menu at the bottom of this 
              window lets you choose whether you view the program as source, 
              assembly language, or a mix of the two. </LI></UL>
            <P>Note the red stop sign on the left edge of the Source pane. The 
            stop sign indicates a breakpoint. You set breakpoints in the 
            debugger to tell it where to stop executing your code. This feature 
            can come in very handy when you want to quickly move to a certain 
            point in your program and begin working from there. When you set a 
            breakpoint, the debugger will automatically stop at that line of 
            code and will let you take control. The small blue arrow is the 
            current program counter; it points to the line of code that is about 
            to be executed. In the Figure 5-1, we have set the breakpoint so 
            that the program executes the code loop before halting on the second 
            printf() statement. You can set and clear breakpoints by simply 
            clicking to the left of the line of code you're interested in.</P>
            <P>Let's look at some of the preferences for the CodeWarrior 
            debugger.</FONT><BR></P>
            <P><FONT face="Arial, Helvetica, sans-serif" color=#000000 
            size=3><B><B>Global Debugger 
            Preferences</B></B><BR></FONT><BR></P><FONT 
            face="Arial, Helvetica, sans-serif" size=2>
            <P>There are many global preferences in the CodeWarrior debugger. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -