Building GDB on DJGPP
Here is a description of what I've done to build GDB on DJGPP as a native debugger.
You'll need to use a snapshot from later than 2008-08-10 (e.g., gdb-184.108.40.20680811.tar.bz2). I haven't tested GDB 6.8, but it most certainly doesn't build.
I didn't need to use the special djunpack to rename GDB's sources to 8.3 format, since as described below, I built DJGPP under bash on a Windows XP machine, which understands long filenames.
I did the initial DJGPP setup using DJGPP Zip File Picker. I installed DJGPP just like the zip-picker tells you to on the final download page.
GDB has a few more build dependencies that you'll need to download in addition to the base setup. Fortunately, you'll find pre-built binaries for all that is needed at ftp://ftp.delorie.com/pub/djgpp/current/v2gnu.
This is a list, of GDB's built dependencies, extracted from gdb611s.zip:/manifest/gdb611s.dsm. The gdb611s.zip file contains the sources of the gdb currently shipped with DJGPP, which you can download from the ftp directory above as well.
DPMI 0.9 gcc binutils djdev make >= 3.79.1 bash fileutils textutils sh-utils sed gawk grep findutils
You can check which package satisfies each dependency above, by consulting: http://www.delorie.com/djgpp/v2faq/faq4_4.html
Below is the list of all the zips I downloaded and installed. Most likely a couple aren't needed, though.
bnu217b.zip djlsr203.zip fil41d.zip gwk316b.zip rhid15ab.zip bnu217s.zip djtst203.zip find41b.zip gwk316d.zip rhid15as.zip bsh204br2.zip em2005b.zip find41d.zip m4-149b.zip sed415b.zip bsh204d.zip em2005li.zip flx254b.zip m4-149d.zip sed415d.zip bsn23b.zip em2005s1.zip gcc423b.zip mak3791b.zip shl2011b.zip bsn23s.zip em2005s2.zip gdb611b.zip objc423b.zip shl2011d.zip dif287b.zip faq230b.zip gpp423b.zip pakk023b.zip txi412b.zip dif287d.zip faq230s.zip grep253b.zip pakk023s.zip txt20b.zip djdev203.zip fil41b.zip grep253d.zip pdcur33b.zip txt20d.zip
bash-2.04$ gcc -v Using built-in specs. Target: djgpp Configured with: /v203/gcc-4.23/configure djgpp --prefix=/dev/env/DJDIR --disable-nls --disable-werror --enable-languages=c,c++,fortran,objc,obj-c++,ada Thread model: single gcc version 4.2.3
I've extracted GDB's sources using cygwin, into a directory named c:\djgdb\src. I created a c:\djgdb\build directory, which is where I've done the build.
From a Cygwin bash shell:
$ cd /cygdrive/c/djgdb $ ls gdb.tar.gz $ tar zxfv gdb.tar.gz ... $ ls src gdb.tar.gz $ mkdir build
Now on DJGPP:
Microsoft(R) Windows DOS (C)Copyright Microsoft Corp 1990-2001. C:\DJGDB>bash bash-2.04$ cd build bash-2.04$ ../src/configure --target=i586-pc-msdosdjgpp --host=i586-pc-msdosdjgpp --build=i586-pc-msdosdjgpp
I had to pass target,host to force a native build. The default of not passing any argument to configure, ended up building with target=i586-pc-msdosdjgpp host=i386-pc-msdosdjgpp, which, being different, triggers a cross build, which excludes go32-nat.c.
For some reason I haven't investigated, building libiberty fails with:
rm -f needed-list; touch needed-list; \ for f in atexit calloc memchr memcmp memcpy memmove memset rename strchr strerro r strncmp strrchr strstr strtol strtoul tmpnam vfprintf vprintf vfork waitpid bc mp bcopy bzero; do \ for g in ; do \ case "$g" in \ *$f*) echo $g >> needed-list ;; \ esac; \ done; \ done c:\djgpp\tmp/dj750000: line 1: syntax error near unexpected token `;' c:\djgpp\tmp/dj750000: line 1: `rm -f needed-list; touch needed-list; for f in atexit calloc memchr memcmp memcpy memmove memset rename strchr strerror strncmp strrchr strstr strtol strtoul tmpnam vfprintf vprintf vfork waitpid bcmp bcopy bzero; do for g in ; do case "$g" in *$f*) echo $g >> needed-list ;; esac; done; done' make.exe: *** [needed-list] Error 2
I didn't investigate what was going on here. I just hacked the needed-list rule in the generated Makefile to just touch the needed-list file and do nothing else with it. There's a comment in the makefile claining this is needed for libstdc++.
For some reason, maybe related to the above, a few required libiberty objects are not being built and archived into libiberty.a.
I manually added snprintf.o, vasprintf.o, asprintf.o and vsnprintf.o to REQUIRED_OFILES to libiberty's generated Makefile.
Other than that, GDB builds fine. Here's how it looks debugging itself.
bash-2.04$ ./gdb ./gdb GNU gdb (GDB) 220.127.116.1180810-cvs Copyright (C) 2008 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. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i586-pc-msdosdjgpp --target=djgpp". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... (gdb) start Temporary breakpoint 1 at 0x1f8c: file ../../gdb/gdb.c, line 28. Starting program: c:/djgdb/src/djgpp/gdb/./gdb.exe Temporary breakpoint 1, main (argc=1, argv=0x36da0c) at ../../gdb/gdb.c:28 28 memset (&args, 0, sizeof args); (gdb) info threads * 1 Thread <main> main (argc=1, argv=0x36da0c) at ../../gdb/gdb.c:28 (gdb) kill Kill the program being debugged? (y or n) y (gdb) info threads (gdb) n The program is not being run. (gdb)
Please report to GDB's main mailing list any trouble, or if the problems described above have been fixed in the mean time. Feel free to edit this page.