<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Eric&#039;s Who Know &#187; Debug</title> <atom:link href="http://who-know.com/tag/debug/feed/" rel="self" type="application/rss+xml" /><link>http://who-know.com</link> <description>C&#039;est La Vie</description> <lastBuildDate>Mon, 17 May 2010 22:21:05 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Code::Blocks 教學 &#8211; Debugging</title><link>http://who-know.com/how-to-debug-with-codeblocks/</link> <comments>http://who-know.com/how-to-debug-with-codeblocks/#comments</comments> <pubDate>Wed, 03 Feb 2010 19:01:32 +0000</pubDate> <dc:creator>Eric</dc:creator> <category><![CDATA[Free Teaching]]></category> <category><![CDATA[Code::Blocks]]></category> <category><![CDATA[Debug]]></category> <category><![CDATA[GNU]]></category><guid isPermaLink="false">http://who-know.com/?p=96</guid> <description><![CDATA[01. File -> New -> Project -> Console application -> Go -> C/C++ -> 打上 Project title 和選擇要存放的位置 -> Next -> Finish
// 不要懶的創 Project，就 File -> New -> File -> C/C++ source -> Go -> C/C++ -> ...
// 或更偷懶直接，就 File -> Empty file
// 因為這樣會不能使用 Debug 功能
02. 點左邊 Projects 下的 Workspace -> Project title -> Sources [...]]]></description> <content:encoded><![CDATA[<p>01. File -> New -> Project -> Console application -> Go -> C/C++ -> 打上 Project title 和選擇要存放的位置 -> Next -> Finish</p><p>// 不要懶的創 Project，就 File -> New -> File -> C/C++ source -> Go -> C/C++ -> ...<br /> // 或更偷懶直接，就 File -> Empty file<br /> // 因為這樣會不能使用 Debug 功能</p><p>02. 點左邊 Projects 下的 Workspace -> Project title -> Sources -> *.cpp，貼上下面的程式碼，來體驗一下 Code::Blocks 的 Debug 功能。<span id="more-96"></span></p><pre class="brush: cpp;">
# include &lt;iostream&gt;
# define SIZE  10

using namespace std;

int main( ) {

  int test[ SIZE ] = { 0 };

  for ( int i = 0; i &lt; SIZE; i++ ) {
    test[ i ] = i;
  }

  system( &quot;PAUSE&quot; );
  return 0;
}
</pre><p>03. <a href="http://www.codeblocks.org/" target="_blank">Code::Blocks</a> Debug 三部曲</p><p>a. Build target 切換到 Debug</p><p>b. Settings -> Compiler and debugger -> Produce debugging symbols [-g] 打勾</p><p>c. 新增中斷點 : 在 test[ i ] = i; 那行，行號的右邊空白按左鍵( or 右鍵 -> Add breakpoint )</p><p>04. 上面都設定好後，按下 F8 or IDE 上的圖示( Debug / Continue ) 就可以開始 Debug 了。<br /> // Watches、Disassembly、Call Stack、Memory、CPU Registers 等，都可以在 Debug -> Debugging windows 下找到</p><p><a href="http://pic.who-know.com/CodeBlocks/007.png" class="highslide-image" onclick="return hs.expand(this);" target="_blank"><img class="doCenter" src="http://pic.who-know.com/CodeBlocks/007.png" alt="" width="460" height="280"/></a></p><p>05. 照上面設定還是不能 Debug 的話</p><p>a. Build target : Debug</p><p>b. 檢查 Settings -> Compiler and debugger -> Produce debugging symbols [-g] 是否有打勾 ( 要打勾 )<br /> // 特徵 : ( no debugging symbols found )</p><p>d. 檢查 Settings -> Compiler and debugger -> Strip all symbols from binarry ( minimizes size ) [-s] 是否有打勾 ( 不要打勾 )<br /> // 特徵 : ( no debugging symbols found )</p><p>c. 檢查是否有 gdb.exe</p><p>// 可以到 ( <a href="http://sourceforge.net/projects/mingw/files/" target="_blank">The GNU Project Debugger</a> ) 點 GNU Source-Level Debugger 下載<br /> // 可以到 ( <a href="http://prdownloads.sf.net/mingw/gdb-6.3-2.exe" target="_blank">The GNU Project Debugger</a> ) 下載</p> ]]></content:encoded> <wfw:commentRss>http://who-know.com/how-to-debug-with-codeblocks/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>