1. Preface
GDB is a popular and common Linux Environment Debugging tool, mastering it is necessary for the embedded development work, can improve work efficiency, quickly find and solve problems. Recently interested in studying the use of the next GDB, the special summary is as follows for later review.
2. Download the latest GDB
: http://ftp.gnu.org/gnu/gdb/, choose the latest version of the current download. I chose the gdb-7.7.tar.gz version.
3. Compiling gdb and Gdbserver
(1) Extract to your working directory:
[Email protected]:~$ tar-xvf gdb-7.7.tar.gz
(2) Add environment variables:
[e-mail protected]:~$ vi. BASHRC
Add the following two lines,
#gdb安装位置
Export path= "$PATH:/home/zhaochenhui/gdb-7.7/bin"
#DM81xx交叉编译集安装位置
Exportpath= "$PATH:/opt/dvrrdk_04.00.00.03/ti_tools/cgt_a8/arago/linux-devkit/bin"
Then save the exit.
~ $source. BASHRC #立即生效
(3) Modify the code
Modify the following code for the./gdb-7.7/gdb/remote.c file, commenting out:
if (Buf_len > 2 * rsa->sizeof_g_packet)
Error (_ ("Remote ' G ' packet reply Istoo long:%s"), RS->BUF);
To be replaced by:
if (Buf_len > 2 *rsa->sizeof_g_packet) {
Rsa->sizeof_g_packet =buf_len;
for (i = 0; I <gdbarch_num_regs (gdbarch); i++)
{
if (Rsa->regs[i].pnum ==-1)
Continue
if (rsa->regs[i].offset>= rsa->sizeof_g_packet)
Rsa->regs[i].in_g_packet = 0;
Else
Rsa->regs[i].in_g_packet = 1;
}
}
Otherwise, there will be an error as shown in the appendix.
(4) Compile arm-arago-linux-gnueabi-gdb (server side)
gdb-7.7 used the Autoconf/automake. Therefore, by setting the Configure script's--target,--host,--prefix parameters can be easily ported to other platforms. --TARGET Specifies the target environment that needs to be debugged, typically set to a cross compiler prefix, such as--target=arm-linux,--target=mips-linux,--target=armv5-linux-uclibc,-- The default value for Target is I386-linux, which is the i386pc machine--host specifies the run environment of the compiled file, which can be prefixed with i386-linux or cross-compiler, default to I386-linux
--PREFIX Specifies the directory to install.
In the gdb-7.7 directory, enter:
[Email protected]:~/gdb-7.7$./configure--target=arm-arago-linux-gnueabi--prefix=/home/zhaochenhui/gdb-7.7/bin
A successful configuration will display the makefile created
Next
[Email Protected]:~/gdb-7.7$make
[Email protected]:~/gdb-7.7$make Install
(5) Compile Arm-arago-linux-gnueabi-gdbserver (target board side)
[Email PROTECTED]:~/GDB-7.7$CD gdb/gdbserver/
[Email Protected]:~/gdb-7.7/gdb/gdbserver$./configure--target=arm-arago-linux-gnueabi--prefix=/home/zhaochenhui /gdb-7.7/bin--host=arm-linux
The cross compiler is specified when compiling, because the Arm-arago-linux-gnueabi-gdbserver is running on the target board.
[Email Protected]:~/gdb-7.7/gdb/gdbserver$makecc=/opt/dvrrdk_04.00.00.03/ti_tools/cgt_a8/arago/linux-devkit/bin /arm-arago-linux-gnueabi-gcc
There was an error in compiling the result:
Linux-arm-low.c did not find the Sys/reg.h file, which may be makefile does not correctly contain the path of sys/reg.h, different operating systems have a certain difference. So start looking for the sys/reg.h of the system.
According to a certain experience, most likely in the/usr directory, then start from here, enter:
[Email protected]:/usr$find-iname "Reg.h"
Sure enough./include/x86_64-linux-gnu/sys/reg.h most likely, directly modify the code, or add in the makefile include, find the Include method, enter:
[Email Protected]:~/gdb-7.7/gdb/gdbserver$cat Makefile | Grep-i "include"
See Include_cflags, you can add-ibalabala~~~ and so on after this.
In LINUX-ARM-LOW.C 129 line modification:
Switch
Save exit.
[Email Protected]:~/gdb-7.7/gdb/gdbserver$make
[Email protected]:~/gdb-7.7/gdb/gdbserver$make Install
The compiled results are as follows:
As for what Arm-arago-linux-gnueabi-run is for, I do not know at present. But the arm-arago-linux-gnueabi-gdb,arm-arago-linux-gnueabi-gdbserver we need has been compiled.
4. Test is available
(1) Target Board end
Copy the Arm-arago-linux-gnueabi-gdbserver to the NFS debug directory on the target board, find a test program and enter:
./arm-arago-linux-gnueabi-gdbserver 192.165.54.12:30000 Edma_test_drv
Where 192.165.54.12 is your NFS Debug Server ip,30000 is the debug listening port, Gdbserver communicates with the target board through this 30000 port, Edma_test_drv is the debug application. As shown in the following:
(2) server-side
In the same NFS debug directory input:
[Email protected]:~/ti8168_mnt/projxxxx/app_driver$./arm-arago-linux-gnueabi-gdb edma_test_drv
GDB Startup:
Then enter: Target remote 192.165.54.170:30000
Where 192.165.54.170 is the target board IP, the port is also 30000, so that the gdbserver and the target board can communicate, debugging, such as:
Finish.
Appendix:
Remote ' G ' packet reply is too long error, input L, no code displayed