arm-linux-gdb+gdbserver環境搭建以及遠端偵錯

來源:互聯網
上載者:User

0) gdb源碼下載:http://ftp.gnu.org/gnu/gdb/

1) 編譯arm-linux-gdb

    指定交叉編譯工具鏈的位置

    export PATH=$PATH:/usr/local/arm/3.4.1/bin
    開始配置和編譯

    $cd gdb-6.6
    $./configure --target=arm-linux --prefix=/usr/local/arm/gdb -v
   $make
   

中間會出現一些地方編譯過去,如

gdb declared with attribute warn_unused_result

 檢查了下,發現是由於檢查太嚴格了,把 Makefile 裡面 -Wall 類似的強制警告檢查都去掉就可以過了

 

2) 編譯gdbserver
    $cd gdb/gdbserver
    $./configure --target=arm-linux --host=arm-linux
      target含義同前,host指明編譯產生的gdbserver運行在arm-linux上,前者沒有設定host的原因是
      arm-linux-gdb是在pc linux上啟動並執行,就像arm-linux-gcc (很好理解的:))
    $
make CC=/usr/local/arm/3.4.1/bin/arm-linux-gcc

 

   #gdbserver 192.168.1.200:7777 test
     Process test created; pid                                                                                   
     Listening on port 7777

   主機shell下
   $cd ~/tftpboot
   $arm-linux-gdb test
    GNU gdb 6.6
    Copyright (C) 2006 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-linux"...
    (gdb)
    注意一下顯示資訊的最後--host=i686-pc-linux-gnu --target=arm-linux,明白了吧。。。
    target remote 192.168.1.168:7777   --串連gdbserver
    Remote debugging using 192.168.1.168:7777
    0x40000dd0 in _start () from /lib/ld-linux.so.2
    表示串連上了伺服器,:),接下來就可以調試了。arm-linux-gdb和GDB的用法一樣,只是沒有r這個命  
   令,運行程式用c命令。
    (gdb) l
   1       #include<stdio.h>
   2
   3       int main()
   4       {
   5               char *ptr = "csdn";
   6               printf("%c/n",*(ptr++));
   7               return 0;
   8       }
    (gdb) b 3
   Breakpoint 1 at 0x83d0: file test.c, line 3.

   另外由於程式是在目標板上運行,調試是在PC下,程式的結果還是會在目標板上顯示的,
   例如:minicom,lcd等。
   btw,附近一篇介紹GDB使用的文章:http://blog.csdn.net/haoel/archive/2003/07.aspx,這下全了吧。哈

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.