gdb gdb交叉编译
来源:互联网 发布:淘宝首页轮播代码 编辑:程序博客网 时间:2024/05/16 13:38
交叉编译gdb和gdbserver
1、下载gdb:
下载地址为:
http://ftp.gnu.org/gnu/gdb/
按照一般的想法,最新版本越好,因此下载7.2这个版本。当然,凡事无绝对。
我们以gdb-7.2.tar.bz2 这个文件为例。
2、解压缩:
4、配置
$ ls -lh
总计 33M
-rwxr-xr-x 1 latelee root 14M 12-14 16:16 arm-linux-gdb
-rwxr-xr-x 1 latelee root 3.1M 12-14 16:25 arm-linux-gdb-stripped
可以看到,strip后的文件大小只有3.1MB,瘦身效果明显!如果做广告的话,绝对有说服力。
这个文件就是我们以后远程调试时在主机上运行的交叉调试器了:在主机上执行,调试的却是另一种体系结构的代码。但是,光有主机的调试器还不够。还需要在目标板上运行一个叫gdbserver的东东。这个东东是怎么来的呢?
1、在刚才那个gdb解压后的目录:gdb-7.2,进入./gdb/gdbserver子目录
gdbserver
1、cd gdb/gdbserver/
2、配置: ./configure –target=arm-hismall-linux –host=arm-hismall-linux –prefix=/mnt/hgfs/vmshare/gdbserver7.41/
(同样,target 和 host 为你的交叉编译器, prefix为安装的目录)
3、编译: make CC=make CC=arm-hismall-linux-gcc
出现错误:
linux-arm-low.c: In function arm_stopped_by_watchpoint':
PTRACE_GETSIGINFO’ undeclared (first use in this function)
linux-arm-low.c:642: error:
linux-arm-low.c:642: error: (Each undeclared identifier is reported only once
linux-arm-low.c:642: error: for each function it appears in.)
解决方法:这里提示没有PTRACE_GETSIGINFO这个东西,这里搜索PTRACE_GETSIGINFO的路径为-I指定的头文件以及交叉 编译工
具链,我们不妨到交叉编译工具链里面去查找一下:
cd /usr/local/arm/3.4.5/
grep “PTRACE_GETSIGINFO” * -nR
找到如下信息:
arm-linux/sys-include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202
arm-linux/include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202
distributed/arm-linux/sys-include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202
distributed/arm-linux/include/linux/ptrace.h:27:#define PTRACE_GETSIGINFO 0x4202
说明PTRACE_GETSIGINFO是在交叉编译工具链:linux/ptrace.h文件里定义的,那么可能是头文件没有包含好吧!
我们到gdbserver下的linux-arm-low.c里面一看,可不是嘛,只有:#include
0 0x08048373 in ?? ()
(gdb) bt
0 0x08048373 in ?? ()
1 0xbfffd8f8 in ?? ()
2 0x0804839e in ?? ()
3 0xb74cc6b3 in ?? ()
4 0x00000000 in ?? ()
此时用bt看不到backtrace,也就是调用堆栈,原来GDB还不知道符号信息在哪里。我们告诉它一下:
(gdb) file ./a.out
Reading symbols from ./a.out…done.
Using host libthread_db library “/lib/tls/libthread_db.so.1”.
(gdb) bt
0 0x08048373 in sub () at foo.c:17
1 0x08048359 in main () at foo.c:8
此时backtrace出来了。
(gdb) l
8 sub();
9 return 0;
10 }
11
12 static void sub(void)
13 {
14 int *p = NULL;
15
16
17 printf(“%d”, *p);
(gdb)
对于GDBServer出现的问题
1. GDBServer调试时出现packet error 问题。
主要是虚拟机与目标机的网络连接要经过windows,数据包容易丢失。换到Linux系统下则恢复正常。
- gdb gdb交叉编译
- gdb 交叉编译arm
- gdb+gdbserver交叉编译
- gdb+gdbserver交叉编译
- 交叉编译gdb
- 交叉编译gdb
- 交叉编译GDB
- ARM GDB交叉编译
- goke 交叉编译gdb
- 交叉编译arm gdb
- 怎么交叉编译gdb
- 交叉编译GDB工具
- 交叉编译gdb与gdbserver
- gdb调试,交叉编译调试
- Linux下交叉编译GDB
- HI3516A交叉编译gdb-7.8
- linux powerpc 交叉编译gdb
- linux交叉编译gdb/gdbserver
- Linux终端Tab补全提示忽略大小写
- 经典最短路算法的原理启示
- HashSet
- bintray-release添加对Maven Central同步的支持(五)
- MySQL5.7.19安装及主从复制构架配置
- gdb gdb交叉编译
- Your account has been blocked
- bzoj1176 [Balkan2007]Mokia
- Android——Intent
- Cookie中存放json字符串异常的解析
- 一.C++ 零散知识点
- 利用Maven搭建Spring+SpringMVC+Mybatis框架项目(一)
- 【51Nod1310】Chandrima and XOR
- Python3 和 Python2的区别