一个爱徒步的~IT民工
2918
- 收藏
- 点赞
- 分享
- 举报
T30 gdbserver使用方法
gdbserver使用方法
gdbserver是嵌入式开发调试的主要工具,依赖开发板上的gdbserver程序以及交叉编译工具链中的mips-linux-gnu-gdb命令。gdbserver需要调试的PC和开发板网络相通。
本文仅介绍gdbserver的开启及连接方法,相关命令遵循标准gdbserver命令,详细内容请在互联网查询。
gdb以及gdbserver命令位置:
[code]gdb在toolchain文件夹下,位于bin/mips-linux-gnu-gdb
gdbserver位于toolchain文件夹下:
glibc: mips-linux-gnu/libc/usr/lib/bin/gdbserver
uclibc: mips-linux-gnu/libc/uclibc/usr/lib/bin/gdbserver[/code]
1. PC运行gdb
$ mips-linux-gnu-gdb [PC端应用程序路径]
例如:
[code]$ mips-linux-gnu-gdb sample-Encoder-h264
GNU gdb (Ingenic 2015.02) 7.4.50.20120716-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=mips-linux-gnu".
For bug reporting instructions, please see:
...
Reading symbols from sample-Encoder-h264...done.[/code]
(gdb)
注:
如果出现(no debugging symbols found)的提示,可能是因为应用程序strip过了(PC端),删除了debug需要的段,无法进行gdb调试
开发板上程序是可以strip的,Symbol的读取在PC端gdb工具完成。这也就是gdbserver相对与local gdb以及core dump的优势——开发板端可以strip——因为前两者都需要在开发板端load symbol,因此应用程序会变得非常大,无法放在flash中
2. 设置动态库搜索路径
应用程序往往动态链接libc、ld等库,当运行于动态库中break时(比如memcpy)往往无法跟踪到当前pc所在位置。这是因为动态库的加载地址是不固定的。因此需要在PC端gdb上指定动态库加载路径。方法是:
[code]
set solib-search-path /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/:/opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/lib[/code]
多个路径之间通过“:”来隔开。注:上述例子中仅指定了toolchain中glibc的libc系列库和libstdc++等主要外部库。
[code]glibc的动态库在toolchain文件夹下的相对目录为:mips-linux-gnu/libc/lib与mips-linux-gnu/lib
uclibc的动态库在toolchain文件夹下的相对目录为:mips-linux-gnu/libc/uclibc/lib与mips-linux-gnu/lib/uclibc[/code]
3. 开发板启动gdbserver
gdbserver [PC机IP:端口,与步骤2中端口需一致] [应用程序路径]
例如:
[code]
gdbserver 192.168.1.100:1234 /tmp/sample-Encoder-h264[/code]
4. 链接开发板
target remote [开发板IP:端口]
例如:
[code]target remote 192.168.1.101:1234[/code]
5. gdbserver连通
开发板会出现如下信息:
[code]
(gdb) target remote 192.168.1.101:1234
Remote debugging using 192.168.1.101:1234
Reading symbols from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1...done.
Loaded symbols for /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1
0x77fc7070 in __start () from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1[/code]
至此,即可在PC端运行gdb命令。注:与gdbserver与local gdb不同,启动程序的命令为“c”(continue)。
gdbserver是嵌入式开发调试的主要工具,依赖开发板上的gdbserver程序以及交叉编译工具链中的mips-linux-gnu-gdb命令。gdbserver需要调试的PC和开发板网络相通。
本文仅介绍gdbserver的开启及连接方法,相关命令遵循标准gdbserver命令,详细内容请在互联网查询。
gdb以及gdbserver命令位置:
[code]gdb在toolchain文件夹下,位于bin/mips-linux-gnu-gdb
gdbserver位于toolchain文件夹下:
glibc: mips-linux-gnu/libc/usr/lib/bin/gdbserver
uclibc: mips-linux-gnu/libc/uclibc/usr/lib/bin/gdbserver[/code]
1. PC运行gdb
$ mips-linux-gnu-gdb [PC端应用程序路径]
例如:
[code]$ mips-linux-gnu-gdb sample-Encoder-h264
GNU gdb (Ingenic 2015.02) 7.4.50.20120716-cvs
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=mips-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from sample-Encoder-h264...done.[/code]
(gdb)
注:
如果出现(no debugging symbols found)的提示,可能是因为应用程序strip过了(PC端),删除了debug需要的段,无法进行gdb调试
开发板上程序是可以strip的,Symbol的读取在PC端gdb工具完成。这也就是gdbserver相对与local gdb以及core dump的优势——开发板端可以strip——因为前两者都需要在开发板端load symbol,因此应用程序会变得非常大,无法放在flash中
2. 设置动态库搜索路径
应用程序往往动态链接libc、ld等库,当运行于动态库中break时(比如memcpy)往往无法跟踪到当前pc所在位置。这是因为动态库的加载地址是不固定的。因此需要在PC端gdb上指定动态库加载路径。方法是:
[code]
set solib-search-path /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/:/opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/lib[/code]
多个路径之间通过“:”来隔开。注:上述例子中仅指定了toolchain中glibc的libc系列库和libstdc++等主要外部库。
[code]glibc的动态库在toolchain文件夹下的相对目录为:mips-linux-gnu/libc/lib与mips-linux-gnu/lib
uclibc的动态库在toolchain文件夹下的相对目录为:mips-linux-gnu/libc/uclibc/lib与mips-linux-gnu/lib/uclibc[/code]
3. 开发板启动gdbserver
gdbserver [PC机IP:端口,与步骤2中端口需一致] [应用程序路径]
例如:
[code]
gdbserver 192.168.1.100:1234 /tmp/sample-Encoder-h264[/code]
4. 链接开发板
target remote [开发板IP:端口]
例如:
[code]target remote 192.168.1.101:1234[/code]
5. gdbserver连通
开发板会出现如下信息:
[code]
(gdb) target remote 192.168.1.101:1234
Remote debugging using 192.168.1.101:1234
Reading symbols from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1...done.
Loaded symbols for /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1
0x77fc7070 in __start () from /opt/mips-gcc472-glibc216-64bit/mips-linux-gnu/libc/lib/ld.so.1[/code]
至此,即可在PC端运行gdb命令。注:与gdbserver与local gdb不同,启动程序的命令为“c”(continue)。
我来回答
回答0个
时间排序
认可量排序

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片
相关问答
-
2018-11-16 13:05:40
-
2018-11-15 22:00:41
-
2018-11-15 21:59:39
-
2018-11-15 22:28:55
-
12019-09-11 22:40:59
-
2019-01-19 12:39:46
-
2018-05-17 14:21:56
-
2020-11-10 19:45:56
-
2020-11-10 14:29:21
-
2018-05-14 16:58:25
-
2020-11-11 10:21:07
-
2020-09-22 11:14:03
-
122018-11-11 13:02:53
-
2018-08-17 11:13:28
-
2018-11-21 20:38:30
-
2018-11-15 22:31:26
-
2020-02-18 19:42:35
-
2008-09-10 10:52:48
-
2017-01-20 09:14:08
无更多相似问答 去提问

点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5DTOF的demo运行时内核挂死
-
10Hi3516DV500+IMX482运行sample_venc,报错:HI_MPI_ISP_MemInit failed with 0xa01c800c!
-
10PQTOOL在调试的时候,出现通讯异常,是不是PQ软件问题?还是什么?
-
5hi3516dv500改了sensor驱动后使用pqtools出图出现彩色的竖条纹
-
10海思3559的VGS模块在VI上画线问题
-
53519dv500接lvds的sensor mn34120,图像出现很多竖线,sensor板接以前的3519v101没问题
-
103403外接hdmi口1024*600显示屏报错
-
5SS928点DC camera的6946,全屏紫色
-
5hi3519 的 网络传输的MTU值可以修改到比1500大嘛?
-
10WS73V100星闪扫描不到设备sle
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认