当前位置:网站首页>不同网段之间实现GDB远程调试功能
不同网段之间实现GDB远程调试功能
2022-07-06 23:41:00 【大橙子疯】
前言
在开发过程中,使用gdb远程调试时,会碰到 Linux 服务器的网段和板载设备的网段不是一样的,不能正常使用 gbd 远程调试功能。
板载设备和电脑连接路由器,属于同一个网段,如192.168.1.1,而路由器和Linux服务器属于另一个网段,如10.20.51.251。
问题
板载设备和电脑可以互相ping通,板载设备或电脑也能ping通Linux服务器,但Linux服务器却不能ping通板载设备或电脑。
板载设备或电脑能ping通Linux服务器是因为路由器和服务器属于同一网段,所以通过路由器转发即可ping通,服务器可以ping通路由器的IP,但是无法ping通路由器下面的局域网IP
由于服务器不能ping通板载设备,自然无法使用gdb远程调试,在服务器调试时输入以下指令后出现以下错误(参考在海思芯片上使用GDB远程调试)。
# ./arm-himix200-linux-gdb test
...
(gdb) target remote 192.168.1.102:8005
192.168.1.102:8005: 连接超时.
(gdb)
解决办法
启用路由器的DMZ主机功能,添加板载设备的IP地址即可
关于DMZ主机,实际上就是把内网中的一台主机暴露在外网,直接使用公网IP,这样可以和外网一样。
可以简单地理解成访问路由器IP,就是透传访问DMZ主机设置的IP。
假设板载设备的IP是“192.168.1.140”,路由器的IP是“10.20.51.100”,服务器的IP是“10.20.51.120”。
在使用 GDB 远程调试时,板载设备执行gdbserver,连接的是服务器的IP地址。
# ./gdbserver --remote-debug 10.20.51.120:8005 test
在服务器上运行gdb,连接使用的是路由器的IP地址,而不是板载设备的IP地址。
# ./arm-himix200-linux-gdb test
...
(gdb) target remote 10.20.51.100:8005
Remote debugging using 10.20.51.100:8005
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading /lib/ld-linux-armhf.so.3 from remote target...
Reading symbols from target:/lib/ld-linux-armhf.so.3...(no debugging symbols found)...done.
0x76fcebc0 in ?? () from target:/lib/ld-linux-armhf.so.3
(gdb)
此时可以正常使用 gdb 的远程调试功能了。
附
如何设置路由器的DMZ主机功能:
以 TP-LINK 路由器为例,登录路由器的设置界面,应用管理,点击DMZ主机
启用DMZ主机功能,输入板载设备的IP地址,保存即可。
边栏推荐
- Most commonly used high number formula
- 《4》 Form
- [QT] custom control loading
- DOM node object + time node comprehensive case
- Leakage relay jelr-250fg
- ThinkPHP Association preload with
- Knapsack problem unrelated to profit (depth first search)
- App clear data source code tracking
- [PM products] what is cognitive load? How to adjust cognitive load reasonably?
- 一条 update 语句的生命经历
猜你喜欢
漏电继电器LLJ-100FS
数字化如何影响工作流程自动化
What changes will PMP certification bring?
《4》 Form
Leetcode: maximum number of "balloons"
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training
MySQL数据库学习(8) -- mysql 内容补充
1.AVL树:左右旋-bite
利用OPNET进行网络指定源组播(SSM)仿真的设计、配置及注意点
利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
随机推荐
Array initialization of local variables
Auto. JS get all app names of mobile phones
Leetcode (417) -- Pacific Atlantic current problem
阿里云的神龙架构是怎么工作的 | 科普图解
纪念下,我从CSDN搬家到博客园啦!
[JS component] custom select
漏电继电器JELR-250FG
1. AVL tree: left-right rotation -bite
EGR-20USCM接地故障继电器
[PHP SPL notes]
Design, configuration and points for attention of network specified source multicast (SSM) simulation using OPNET
Complete code of C language neural network and its meaning
什么是依赖注入(DI)
Initial experience of annotation
Jhok-zbg2 leakage relay
ThinkPHP Association preload with
When deleting a file, the prompt "the length of the source file name is greater than the length supported by the system" cannot be deleted. Solution
LinkedBlockingQueue源码分析-初始化
导航栏根据路由变换颜色
设f(x)=∑x^n/n^2,证明f(x)+f(1-x)+lnxln(1-x)=∑1/n^2