一、下载gdb-6.4.tar.gz源代码http://ftp.gnu.org/gnu/gdb/二、编译 GDB#tar zxvf gdb-6.4.tar.gz2.1、编译GDB Server#cd gdb-6.4
#./configure --target=arm-linux --prefix=/usr/local/arm-gdb
#make注意: 这里如果你用的是gcc-4.3.2的话,编译可能会出错!你可以改成 gcc-4.1 就可以顺利编译通过编译ARM用的GDB时出现error: no termcap library found错误的解决方法2009年03月28日 星期六 21:55在Ubuntu下编译gdb时出现如下错误:........checking for library containing gethostbyname... none required
checking for library containing socketpair... none required
checking for library containing waddstr... no
checking for library containing dlgetmodinfo... no
checking for library containing tgetent... no
configure: error: no termcap library found
make[1]: *** [configure-gdb] 错误 1解决方法:sudo apt-get install libncurses5-dev安装完后,在make就OK了!#make install // 生成/usr/local/arm-gdb/bin2.2、编译GDB Client#cd ./gdb/gdbserver
#export PATH=$PATH:/usr/local/arm-gdb/bin
#./configure --target=arm-linux --host=arm-linux
#vi config.h
//#define HAVA_SYS_REG_H //注释此句
#make CC=arm-softfloat-linux-gnu-gcc //编译用于目标机的stub程序 生成gdbserver是GDB客户端程序,在板子上运行。三、实战调试1.编辑文件# vi gdbtest.c
1 #include <stdio.h>
2
3 int
4 func(int n){
5 int sum=0, i;
6 for (i=0; i<n; i++){
7 sum += i;
8 }
9 return sum;
10 }
11
12 int
13 main(void)
14 {
15 int i;
16 long result = 0;
17 for (i=0; i<=100; i++){
18 result += i;
19 }
20
21 printf("result[1-100] = %d
", result);
22 printf("resutl[1-225] = %d
", func(255));
23
24 return 0;
25 }
# arm-linux-gcc -g gdbtest.c -o gdbtest // 交叉编译2.下载文件到目标板: gdbtest和gdbserver假设 host pc ip:192.168.1.45
board ip:192.168.1.180 将文件拷贝到目标板上:先将gdbtest和gdbserver两个文件拷贝到主机的/tftpboot目录下在目标板的Linux中运行:#mount 192.168.1.108:/tftpboot /mnt/nfs
#cd /mnt/nfs
#ls看是否有gdbtest和gdbserver两个文件。3.运行调试client board:
#./gdbserver 192.168.1.45:1234 gdbtest // 目标板上运行gdbtest 监听端口1234
host pc:
#cd /usr/local/arm-gdb/bin/
#copy gdbtest /usr/local/arm-gdb/bin/ // 将前面编译的文件gdbtest拷贝到此目录
#./arm-linux-gdb gdbtest
(gdb)target remote 192.168.1.180:1234 // 连接到开发板 成功后就可以进行调试
(gdb)list or l
(gdb)break func
(gdb)break 22
(gdb)info br
(gdb)continue or c // 这里不能用 run
(gdb)next or n
(gdb)print or p result
(gdb) finish // 跳出func函数
(gdb) next
(gdb) quit建立连接后进行gdb远程调试和gdb本地调试方法相同Ubuntu Unity 快捷键列表红旗Linux 桌面6.0 SP3 中的tvtime部分台没声音的解决办法相关资讯 Linux教程
- Linux教程:如何在命令行中查看目 (07/28/2014 12:22:23)
- Linux 修改root密码 (11/03/2012 07:53:38)
- su - root 与su root的区别 (06/06/2012 00:39:40)
| - Linux进程间通信:消息队列 (01/28/2013 09:43:00)
- U盘安装Linux开机无法启动解决方法 (10/07/2012 08:55:52)
- Windows 7/Linux 同步时间 (05/15/2012 06:17:55)
|
本文评论 查看全部评论 (0)