Compile gdb and gdbserver use wget to upload to the route to perform debugging

For the debugger on the router. If you use gdb for remote debugging, you need to compile gdbserver. and upload it to the router. Then the remote implements the gdb debugging function.

The host is x86_64. Routing is a mips architecture. Others are slightly different. Overall it's the same


mipsel is little endian mode. mips is big endian


1 Compile gdb and gdbserver

Be sure to pay attention to the version of gdbserver and the version of gdb, it is best to match each other, when I test. The same version is either a GDB compilation problem or a GDBSERVER problem. Only different versions can be used separately.

The version of the compiler also best matches.

GDBSERVER is in the gdb/gdbserver directory of the GDB source code


1.1 Compile GDB

GDB version GDB7.10

Native GCC compiler version gcc5.4.0

cd /gdb7.10

mkdir bin

cd bin

../configure --target=mipsel-linux

make -j8

Since gdb is compiled natively, executed natively, the target is mipsel. So configure is like that.


2

GDBSERVER version GDB7.7

The cross compiler gcc version 4.6.3 is a toolchain compiled by openwrt

cd /gdb/gdbserver

mdkir bin

cd bin

export CC=/home/xxx/src_file/openwrt_/malta/r2/bin/mipsel-openwrt-linux-gcc
export CXX=/home/xxx/src_file/openwrt_/malta/r2/bin/mipsel-openwrt-linux-g++

../configure --target=mipsel-linux --host=mipsel-linux

make -j8

gdbserver is running on mips. The target is also for debugging mips.

After the compilation is completed, gdbserver and gdb are obtained. Note that the compiled gdbserver environment must be the same as the one on the router. Otherwise gdb will not find various link libraries.


After setting up the ftp server of the host

can be used in routing

wget ftp://admin:[email protected]/filename to download the file.

After downloading, use chmod+x to change bin


Use gdbserver ip:port filename to open the debug port.

or gdbserver 192.168.1.100 --attach processid

Note that the ip here is the ip of the remote debugging host where gdb is located


remote use 

./gdb

target remote  ip:port 

The ip here is the ip of gbbserver. That is the ip of the board




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326129431&siteId=291194637