david

david

33个粉丝

368

问答

253

专栏

229

资料

david  发布于  2018-11-16 13:07:10
采纳率 1%
368个问答
一个爱徒步的~IT民工
2582

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)。
我来回答
回答0个
时间排序
认可量排序
易百纳技术社区暂无数据
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区