当前位置:网站首页>Realize GDB remote debugging function between different network segments

Realize GDB remote debugging function between different network segments

2022-07-07 05:41:00 Big orange madness

Preface

In the development process , Use gdb When debugging remotely , You'll come across Linux The network segment of the server is not the same as that of the onboard device , Can't be used normally gbd Remote debugging function .

Onboard devices and computers connect to routers , Belong to the same network segment , Such as 192.168.1.1, And routers and Linux The server belongs to another network segment , Such as 10.20.51.251.

problem

Onboard devices and computers can interact ping through , Onboard devices or computers can also ping through Linux The server , but Linux The server cannot ping Connect onboard equipment or computer .

Onboard devices or computers can ping through Linux The server is because the router and the server belong to the same network segment , So you can forward it through the router ping through , The server can ping Through router IP, But can not ping Connect the LAN under the router IP

Because the server cannot ping On board equipment , Nature cannot use gdb Remote debugging , The following error occurred after entering the following instructions during server debugging ( Reference resources Use on Hisilicon chip GDB Remote debugging ).

# ./arm-himix200-linux-gdb test
...
(gdb) target remote 192.168.1.102:8005
192.168.1.102:8005:  Connection timeout .
(gdb)

terms of settlement

Enable router DMZ host function , Add onboard equipment IP address

About DMZ host , In fact, it is to expose a host in the internal network to the external network , Direct access to the public network IP, This can be the same as the Internet .
It can be simply interpreted as an access router IP, It's a transparent interview DMZ Host settings IP.

Suppose the onboard equipment IP yes “192.168.1.140”, The router IP yes “10.20.51.100”, Server's IP yes “10.20.51.120”.

In the use of GDB When debugging remotely , Onboard equipment execution gdbserver, Connected to the server IP Address .

# ./gdbserver --remote-debug 10.20.51.120:8005 test

Run on the server gdb, The connection uses the router IP Address , Instead of onboard equipment IP Address .

# ./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) 

It can be used normally at this time gdb Remote debugging function of .

attach

How to set the router DMZ Host function :

  1. With TP-LINK Router, for example , Log in to the setting interface of the router , Application management , Click on DMZ host
    image

  2. Enable DMZ Host function , Input... Of onboard equipment IP Address , Save it .
    image

原网站

版权声明
本文为[Big orange madness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207062340580823.html