<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 學(xué)習(xí)方法與實(shí)踐 > 嵌入式Linux的GDB調(diào)試環(huán)境建立

          嵌入式Linux的GDB調(diào)試環(huán)境建立

          ——
          作者: 時(shí)間:2008-01-11 來源:電子產(chǎn)品世界 收藏

            嵌入式Linux的GDB調(diào)試環(huán)境由Host和Target兩部分組成,Host端使用arm-linux-gdb,Target Board端使用gdbserver。這樣,應(yīng)用程序在嵌入式目標(biāo)系統(tǒng)上運(yùn)行,而gdb調(diào)試在Host端,所以要采用遠(yuǎn)程調(diào)試(remote)的方法。

          本文引用地址:http://www.ex-cimer.com/article/76982.htm

              一、建立安裝gdb組件

              從ftp://ftp.gnu.org/gnu/gdb上下載gdb套件,我下載的是gdb-5.2.1.tar.gz。假定在debug下編譯gdb套件,你前面已經(jīng)設(shè)定了TARGET,PREFIX參數(shù)。其中TARGET是你的目標(biāo)板,我的是arm-linux,PREFIX是你要安裝的目標(biāo)文件夾。

          $tar xvzf gdb-5.2.1.tar.gz
          $mkdir debug/build-gdb
          $cd build-gdb
          $../gdb-5.2.1/configure --target=$TARGET --prefix=$PREFIX
          $make
          $make install
          然后建立gdbserver。
          $mkdir debug/build-gdbserver
          $cd build-gdbserver
          $chmod +x ../gdb-5.2.1/gdb/gdbserver/configure
          $CC=arm-linux-gcc ../gdb-5.2.1/gdb/gdbserver/configure
          >--host=$TARGET --prefix=$TARGET
          $make
          $make install

            使用arm-linux-strip命令處理一下gdbserver,然后將之復(fù)制到你的根文件系統(tǒng)的/usr/bin下,建立ramdisk盤。

              二、調(diào)試步驟

          1、交叉編譯,帶參數(shù)-g加入調(diào)試信息。

            假設(shè)要調(diào)試的程序?yàn)閠est.c。

          #arm-linux-gcc -g test.c -o test

          2、在Target Board開啟gdbserver

          #gdbserver  :2345 test
          gdbserver開始監(jiān)聽2345端口(你也可以設(shè)其他的值),然后啟動(dòng)test,你會(huì)看到“Process test created:pid=157”

          3、回到Host端

          #arm-linux-gdb test

            最后一行顯示:This GDB was configured as “--h(huán)ost=i686-pc-linux-gnu,--target=arm-linux”...
          說明此gdb在X86的Host上運(yùn)行,但是調(diào)試目標(biāo)是ARM代碼。

          (gdb)target remote :2345

            注意:你的端口號(hào)必須與gdbserver開啟的端口號(hào)一致,這樣才能進(jìn)行通信。

            建立鏈接后,就可以進(jìn)行調(diào)試了。調(diào)試在Host端,跟gdb調(diào)試方法相同。注意的是要用“c”來執(zhí)行命令,不能用“r”。因?yàn)槌绦蛞呀?jīng)在Target Board上面由gdbserver啟動(dòng)了。結(jié)果輸出是在Target Board端,用超級(jí)終端查看。

          pid控制相關(guān)文章:pid控制原理


          linux相關(guān)文章:linux教程




          關(guān)鍵詞:

          評(píng)論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();