gdb+gdbserver 使用

來源:互聯網
上載者:User

===========================================================================================
cross compile
============================================================================================

1.下載GDB源碼
     ftp://ftp.gun.org/gun/gdb

2.編譯需要的庫termcap 和 gdb

 step 1:

compiling termcap-1.3.1.tar.gz

 $ tar zxvf termcap-1.3.1.tar.gz
 $ cd termcap-1.3.1
 $ mkdir -p /opt/termcap
 $ ./configure --host=mipsel-linux --prefix=/opt/termcap
 $ vi Makefile

   CC = mipsel-linux-gcc
   AR = mipsel-linux-ar
 $ make
 $ make install
 $ cp /opt/termcap/include/* /opt/mipseltools-clx-26/mipsel-linux/include/
 $ cp -a /opt/termcap/lib/* /opt/mipseltools-clx-26/mipsel-linux/lib/

 step 2:

    
     #cd /opt
     #tar zxvf gdb-6.6.tar.gz
     等待解壓完畢,就會在/opt產生一個gdb-6.6的目錄

 step 3:
      編譯pc跑的mipsel-linux-gdb
     建立你的安裝目錄,比如/opt下面
     #mkdir -p /opt/gdb
     #../gdb-6.6/gdb/configure --host=i686-linux   --target=mipsel-linux   --prefix=/opt/gdb
     等待完畢........
     #make
     #make install
    
 step 4:
      編譯開發板上跑的gdbserver
     接著編譯我們的gdbserver,他最終會運行在我們的開發板
     同樣我們在/opt下面建立我們的gdbserver安裝目錄
     #mkdir -p /opt/gdbserver
     #../gdb-6.6/gdb/gdbserver/configure --host=mips-linux --target=mipsel-linux --prefix=/opt/gdbserver
     #make
     #make install
     #cp -a /opt/gdbserver/bin/* /nfsroot/cq8401-mg3500/usr/bin/

3.接下來就是怎麼使用gdb和gdbserver

 pc ip:192.168.4.200
 board ip: 192.168.4.100
 dir: /tmp/test.c
 code compile: mipsel-linux-gcc -g test.c -o test  
 cp test test.c /nfsroot/cq8401/tmp

 
  step 1:
  board 端:  
       # cd /tmp
       #gdbserver 192.168.4.200:2000 ./test
  step 2:
   pc 端:
    # export PATH=$PATH:/opt/gdb/bin
    # cd /lib
    # ln -s /opt/mipseltools-clx-26/lib/ld.so.1 ld.so.1   //庫的匹配
       # ln -s /opt/mipseltools-clx-26/lib/ld.so.1 libc.so.6
  
    # cd /tmp
       # mips-linux-gdb ./test
            (gdb) target remote 192.168.4.100:2000

                接下來就是調試的具體過程了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.