Reputation: 81
I have been trying to compile a copy of GDB on 64 bit X86 Ubuntu for use with remote debugging of an ARM device. This means compiling GDB using expat; GDB uses XML parsing when connecting to a remote debugger. Here are some of the things I've tried, and the results.
Compile with just --with-expat
./configure --target=arm-none-eabi --with-expat
make
....
checking whether to use expat... yes
checking for libexpat... (cached) no
configure: error: expat is missing or unusable
Makefile:9125: recipe for target 'configure-gdb' failed
....
Compile with --with-libexpat-prefix
ls -alg /usr/local/lib/*expat*
-rw-r--r-- 1 root 999128 Mar 20 23:55 /usr/local/lib/libexpat.a
-rwxr-xr-x 1 root 942 Mar 20 23:55 /usr/local/lib/libexpat.la
lrwxrwxrwx 1 root 17 Mar 20 23:55 /usr/local/lib/libexpat.so -> libexpat.so.1.6.0
lrwxrwxrwx 1 root 17 Mar 20 23:55 /usr/local/lib/libexpat.so.1 -> libexpat.so.1.6.0
-rwxr-xr-x 1 root 534224 Mar 20 23:55 /usr/local/lib/libexpat.so.1.6.0
./configure --target=arm-none-eabi --with-expat --with-libexpat-prefix=/usr/local/lib
make
....
checking whether to use expat... yes
checking for libexpat... (cached) no
configure: error: expat is missing or unusable
Makefile:9125: recipe for target 'configure-gdb' failed
....
I've tried to install expat in every way I can think of. The above library binaries are from a local compile of expat with make install; I've also done:
apt-get install libexpat1-dev
apt-get install expat
Both are already the newest version. Same results as above; I can only compile if I omit --with-expat and --with-libexpat-prefix.
Suggestions welcome. How can I find out more about the failure - how can I figure out how/where the make process is failing to find/approve of expat?
Fellow travellers (but I found no working answers here):
http://comments.gmane.org/gmane.comp.gdb.devel/29306
gdb remote cross debugging fails with "Remote 'g' packet reply is too long"
Upvotes: 3
Views: 4545
Reputation: 1
This is for debugging aarch64 running a FreeBSD operating system, but
you may substitute Linux in place of FreeBSD I build this to debug a
Raspberry Pi 4B SBC, using a [Tigard Board][1] running OpenOCD, then
using aarch64-gdb to connect over the OpenOCD software to that BCM2711
Here are 4 lines, that may help you test and build your own arm32-gdb
or aarch64-gdb for Linux or FreeBSD. I know I was looking for examples
on how to configure and build GDB for Arm64. [Flirc Jeff Probe][2] is
another JTAG OpenOCD probe to look for your 3.3V ttl serial UART
connection to the target board using one port on the FT232H FTDI chip
and using the 2nd port to connect to JTAG pins.
FreeBSD.org/where location for 14.0-RELEASE images for x86_64 pc and Aarch64 Raspberry Pi SBCs 3/4/5
../configure --target=aarch64-freebsd --enable-target=amd64 --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
../configure --target=aarch64-unknown-freebsd --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
../configure --target=aarch64-elf-freebsd --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
../configure --target=arm-elf-linux --program-prefix=arm- --with-expat --with-libexpat-prefix=/usr/local/
https://github.com/libexpat/libexpat/releases/download/R_2_6_1/expat-2.6.1.tar.gz
cd /working_home_directory
mkdir -p ./src/gdb/gdb-14.2/build-aarch64-gdb
su -
password:
cd src/gdb
wget -c https://github.com/libexpat/libexpat/releases/download/R_2_6_1/expat-2.6.1.tar.gz
gunzip expat-2.6.1.tar.gz
tar xvf expat-2.6.1.tar.gz
cd expat-2.6.1
./configure
make
sudo make install
cd ../../gdb-14.2/build-aarch64-gdb
../configure --target=aarch64-elf-freebsd --program-prefix=aarch64- --with-expat --with-libexpat-prefix=/usr/local/
make
sudo make install
make distclean
find . -name "config.cache" -print
find . -name "config.cache" -print | xargs ls -lh
find . -name "config.cache" -print | xargs ls -1 | xargs rm -v
I got a debug probe, here's a bash script to build GDB for ARM
This is posted over on forums.raspberrypi.com
This is my personal blog post about porting GhostBSD.org to Arm64. I needed to build a version of aarch64-gdb to run on MX-Linux 21 Wildflower and that would debug FreeBSD aarch64 running on Raspberry Pi 4B, BCM2711 hardware single board computer.
Upvotes: 0
Reputation: 109
The version of gdb 8.3 has the same problem. I thought of various ways, but I still can't work. In the end, I used the 10.2 version and all the problems were gone. God bless you, Good luck.
Upvotes: 0
Reputation: 67
I ran into the exact same situation. While I can not give an exact reason for the trouble, I believe it may have something to do with makeinfo. When trying to upgrade from gdb-7.6 to gdb-7.11, I ran into a few things I needed to download along the way; thus rerunning configure and make a few times with package installations in between The long short: I deleted the gdb-7.11 folder, untared it a fresh, and it ran through just fine linking with expat: ./configure --with-read-line --with-expat
Upvotes: 0
Reputation: 1
On Ubuntu gdb your-program <- this is not correct arm-linux-gnueabihf-gdb your-program <- this is correct remote gdb
Upvotes: 0
Reputation: 81
I made two changes that got it working for me.
First, my ./configure
command was subtly wrong. Instead of
./configure --target=arm-none-eabi --with-expat --with-libexpat-prefix=/usr/local/lib
it should be
./configure --target=arm-none-eabi --with-expat --with-libexpat-prefix=/usr/local/
because the prefix is supposed to be above both include and lib. From the configure file:
--with-expat include expat support (auto/yes/no)
--with-libexpat-prefix[=DIR] search for libexpat in DIR/include and DIR/lib
But I'm not sure that was the real solution. I was still getting the same compile error until I accidentally started the compile from the gdb
directory in the root directory for gdb. Let me be totally explicit:
root@scallion:~/gdb-arm-build/gdb-7.11# ls -alg
total 5016
drwxr-xr-x 16 root 4096 Mar 21 23:48 .
drwxr-xr-x 3 root 4096 Mar 20 16:54 ..
drwxr-xr-x 7 root 20480 Mar 21 23:48 bfd
-rw-rw-rw- 1 200 492650 Feb 24 01:55 ChangeLog
-rwxrwxrwx 1 200 7333 Feb 19 2015 compile
drwxr-xr-x 2 root 4096 Mar 20 16:54 config
-rwxrwxrwx 1 200 43614 Feb 9 19:19 config.guess
-rw-rw-rw- 1 200 25713 Feb 9 19:19 config-ml.in
-rwxrwxrwx 1 200 14916 Jun 11 2014 config.rpath
-rwxr-xr-x 1 root 31637 Mar 21 23:48 config.status
-rwxrwxrwx 1 200 36139 Feb 9 19:19 config.sub
-rwxrwxrwx 1 200 486119 Feb 24 01:55 configure
-rw-rw-rw- 1 200 113771 Feb 24 01:59 configure.ac
-rw-rw-rw- 1 200 18002 Jun 11 2014 COPYING
-rw-rw-rw- 1 200 35147 Jun 11 2014 COPYING3
-rw-rw-rw- 1 200 7639 Jun 11 2014 COPYING3.LIB
-rw-rw-rw- 1 200 25291 Jun 11 2014 COPYING.LIB
drwxr-xr-x 2 root 4096 Mar 20 16:54 cpu
-rwxrwxrwx 1 200 22464 Feb 19 2015 depcomp
-rw-r--r-- 1 200 1887 Feb 24 01:59 djunpack.bat
drwxr-xr-x 2 root 4096 Mar 21 23:49 etc
drwxr-xr-x 27 root 36864 Mar 21 23:51 gdb **<<<<<<<< Here**
drwxr-xr-x 12 root 4096 Mar 20 16:54 include
-rwxrwxrwx 1 200 14675 Feb 19 2015 install-sh
drwxr-xr-x 2 root 4096 Mar 21 23:48 intl
drwxr-xr-x 4 root 4096 Mar 21 23:49 libdecnumber
drwxr-xr-x 4 root 12288 Mar 21 23:48 libiberty
-rw-rw-rw- 1 200 263820 Feb 9 19:19 libtool.m4
-rw-rw-rw- 1 200 1768 Jun 11 2014 ltgcc.m4
-rw-rw-rw- 1 200 249723 Jun 11 2014 ltmain.sh
-rw-rw-rw- 1 200 6126 Jun 11 2014 lt~obsolete.m4
-rw-rw-rw- 1 200 11950 Jun 11 2014 ltoptions.m4
-rw-rw-rw- 1 200 4372 Jun 11 2014 ltsugar.m4
-rw-rw-rw- 1 200 703 Jun 11 2014 ltversion.m4
-rw-rw-rw- 1 200 3909 Feb 19 2015 MAINTAINERS
-rw-r--r-- 1 root 414118 Mar 21 23:48 Makefile
-rw-rw-rw- 1 200 30110 Feb 9 19:19 Makefile.def
-rw-rw-rw- 1 200 1719859 Feb 24 01:57 Makefile.in
-rw-rw-rw- 1 200 69660 Feb 24 01:55 Makefile.tpl
-rw-r--r-- 1 200 736309 Feb 24 01:59 md5.sum
-rwxrwxrwx 1 200 6872 Feb 19 2015 missing
-rwxrwxrwx 1 200 2179 Jun 11 2014 mkdep
-rwxrwxrwx 1 200 3538 Feb 19 2015 mkinstalldirs
-rwxrwxrwx 1 200 2636 Feb 19 2015 move-if-change
drwxr-xr-x 5 root 12288 Mar 21 23:49 opcodes
drwxr-xr-x 7 root 4096 Mar 21 23:49 readline
-rw-rw-rw- 1 200 1719 Jun 11 2014 README
-rw-rw-rw- 1 200 961 Jun 11 2014 README-maintainer-mode
-rw-r--r-- 1 root 13 Mar 21 23:48 serdep.tmp
drwxr-xr-x 33 root 4096 Mar 21 23:49 sim
-rwxrwxrwx 1 200 9150 Feb 9 19:19 src-release.sh
-rwxrwxrwx 1 200 2265 Jun 11 2014 symlink-tree
drwxr-xr-x 2 root 4096 Mar 20 16:54 texinfo
-rwxrwxrwx 1 200 6421 Feb 19 2015 ylwrap
drwxr-xr-x 14 root 4096 Mar 21 23:48 zlib
Not until I ran make
from the directory gdb-arm-build/gdb-7.11/gdb
did it succeed for me. Using the resulting gdb binary, I can now connect to the target, stop, start, look at registers, symbols, etc. If I find there's anything deficient about my compile I will follow up, but for now I'm good.
I don't know what I'm not understanding here, so if someone can shed light on what mistake I was making, I'd appreciate it.
Upvotes: 3