# Windows # gdb cross compiler arm-linux-gnueabihf-gdb
https://blog.csdn.net/xiaoting451292510/article/details/105228162
GDB (GNU symbolic debugger) simply is a debugging tool. It is a free software under GPL General Public License that is protected.
Like all the same debugger, GDB allows you to debug a program, including the program to stop at your desired location, then you can view variables, registers, memory, and stack. Further you can modify variables and memory values. GDB is a very powerful debugger that can debug multiple languages. Here we are dealing only C and C ++ debugging, and does not include other languages. Another point to note is that, GDB is a debugger, rather than VC is an integrated environment. You can use some front-end tools such as XXGDB, DDD and so on. They have a graphical interface, and therefore easier to use, but they are only GDB layer of the shell. Therefore, you should still be familiar with the GDB command. In fact, when you use these long time graphical interface, you will see the importance of the familiar GDB commands.
Embedded Linux GDB debug environment by the end of the Host (PC machine) and Target end (ARM) composed of two parts, using the Host side arm-linux-gdb debugger, and the need to run gdbserver Target end, or via the serial port between the two socket connections, the application returns ARM Target end in the performance Host. Host debug trace command is issued from the end of the arm-linux-gdb in. Therefore, you need to cross GDB debugging.
You can start http://ftp.gnu.org/gnu/gdb/ download the corresponding version of GDB URL. The latest version of gdb-9.1.tar.xz , is recommended if you are running arm-linux-gnueabihf words on a PC, install the same version as the PC gdb better. View GDB version gdb -v , below, my PC end is GNU gdb (Ubuntu 8.2-0ubuntu1 ~ 16.04.1) 8.2
$ gdb -v
GNU gdb (Ubuntu 8.2-0ubuntu1~16.04.1) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Compile gdb process requires the use texinfo, install texinfo
sudo apt-get install texinfo
Configuring decompression compilation
arm-linux-gnueabihf端:--host=arm-linux-gnueabihf
pc end: - host not configured, the default can be
./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/opt/arm-linux-gnueabihf-gdb-8.2
The new version of gdb will prompt the following information. That can not be configured to compile a source directory operations, create build in the build directory configuration required to compile again
configure: error: GDB must be configured and built in a directory separate from its sources.
To do so, create a dedicated directory for your GDB build and invoke
the configure script from that directory:
$ mkdir build
$ cd build
$ <full path to your sources>/gdb-VERSION/configure [etc...]
$ make
Then use the source command to compile
source /home/cll/99_temp/1/gdb-9.1/configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --program-prefix=arm-linux-gnueabihf- CC=arm-linux-gnueabihf-gcc --prefix=/opt/arm-linux-gnueabihf-gdb
Compiled, make install directory is set based on, if the permissions issue, use sudo make install
make -j4
make install
Source compiled to produce an executable program. The compile operation of the platform, the platform running the executable program, the executable program processing platform, compiling operation may be divided into a plurality of types, three corresponding configuration parameters are as follows:
- --build: Run compiler tool chain platform, which is being compiled platform operation to be performed. If this parameter is not specified, obtained by config.guess guess. Usually do not specify this parameter.
- --host: executable program will run platform. If this parameter is not specified, and the same --build. If --host and --build different, cross-compiler; otherwise ordinary compilation.
- --target: platform executable program will be handled. If this parameter is not specified, and the same --host. In general, the program runs in what platform, what is the deal with the platform, and the same value of this parameter --host parameter without explicitly specified, it is usually not concerned about this parameter. However, in the production of cross compiler tool (e.g., gcc, gdb, etc.) this special case, and this value is different --host, e.g. cross compiler arm-linux-gcc, it runs in the x86-linux platform (--host parameter) , but the process is arm-linux platform (--target parameters). If the application is compiled an ordinary cross, as the program runs on tftp arm-linux platform, its processing platform and operating platform are internet arm-linux
- --program-prefix:. Specifies the prefix is added to the name of the program that is installed, for example, using '--program-prefix = arm-linux -gnueabihf' to configure, gdb compiled file called arm-linux-gnueabihf -gdb
- --prefix: compile time the program is used to specify the storage path. Do not specify a prefix, the executable file in the default / usr / local / bin , the default library file in / usr / local / lib, the default configuration file in / usr / local / etc. Other resource files in / usr / local / share.
Compiled results are as follows:
arm-linux-gnueabihf end: copy files to the end of the arm-linux-gnueabihf run
PC side: Configure lib bin path and the path ~ / .bashrc file
export PATH=$PATH:/opt/arm-linux-gnueabihf-gdb-8.2/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/arm-linux-gnueabihf-gdb-8.2/lib
Confirm bin lib and add the correct path
View arm-linux-gnueabih-gdb version information
$ arm-linux-gnueabih-gdb -v
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.