一个爱徒步的~IT民工
2894
- 收藏
- 点赞
- 分享
- 举报
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 21:59:39
-
2018-11-15 22:00:41
-
2018-11-15 22:28:55
-
12019-09-11 22:40:59
-
2018-05-14 16:58:25
-
2019-01-19 12:39:46
-
2020-09-22 11:14:03
-
2020-11-10 14:29:21
-
122018-11-11 13:02:53
-
2020-11-10 19:45:56
-
2020-11-11 10:21:07
-
2018-05-17 14:21:56
-
2018-08-17 11:13:28
-
2020-02-18 19:42:35
-
2018-11-21 20:38:30
-
2018-11-15 22:31:26
-
2008-09-10 10:52:48
-
2017-01-20 09:14:08
无更多相似问答 去提问

点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5SS928/SD3403 录像失败 venc stream time out, exit thread; venc 2 stream buffer is full
-
10Hi3516DV500无法运行PQTool软件
-
10君正T23+1084带TF卡插卡(给该主板适配TF卡驱动,电机驱动,适配GPIO)
-
5Hi3536A从vpss获取1080分辨率的yuv数据异常
-
10谁有RV1126 最新版本SDK卖吗?
-
10opencv算法移植海思3519能否用IVE加速
-
50【话题】DeepSeek爆火背后:人工智能时代,哪些岗位会被“替代”?快来看看吧
-
5ss928与虚拟机和pc端网络ping不通
-
10SS928 DC摄像头驱动移植,不报错不出图,求助!
-
10求hi3516cv610 sdk, 需含middleware
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认