Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing older gdb version

Tags:

linux

gdb

I'm having a problem with the latest gdb so I want to use an older one. I found the gdb archive here but how do I compile/install one of them so it can be used?

According to the manual, first configure:

$ ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
[...]
configure: creating ./config.status
config.status: creating Makefile

Then make:

$ make
make[1]: Entering directory '/root/Desktop/gdb-7.7'
Configuring in ./libiberty
configure: creating cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... /root/Desktop/gdb-7.7/missing makeinfo --split-size=5000000
[...]

But it results in an error:

remote-utils.c:436:19: error: ‘hexchars’ defined but not used [-Werror=unused-const-variable=]
 static const char hexchars[] = "0123456789abcdef";
                   ^~~~~~~~
cc1: all warnings being treated as errors
Makefile:238: recipe for target 'remote-utils.o' failed
make[4]: *** [remote-utils.o] Error 1
make[4]: Leaving directory '/root/Desktop/gdb-7.7/gdb/gdbserver'
Makefile:1345: recipe for target 'subdir_do' failed
make[3]: *** [subdir_do] Error 1
make[3]: Leaving directory '/root/Desktop/gdb-7.7/gdb'
Makefile:1018: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/root/Desktop/gdb-7.7/gdb'
Makefile:8611: recipe for target 'all-gdb' failed
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory '/root/Desktop/gdb-7.7'
Makefile:832: recipe for target 'all' failed
make: *** [all] Error 2

The guide on downgrading programs found here also didn't help since I always got "version not found" errors:

$ sudo apt-get install gdb="7.8.1"
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '7.8.1' for 'gdb' was not found
like image 755
BullyWiiPlaza Avatar asked Jan 09 '17 20:01

BullyWiiPlaza


2 Answers

You are trying to compile an older GDB using newer GCC.

This generally doesn't work: newer GCC enables new warnings, and GDB developers fix these warnings (usually before the new GCC version is actually released).

You should be able to disable these warnings with:

 ./configure 'CFLAGS=-w'

or by editing the generated Makefile and modifying the CFLAGS there.

Other alternatives:

  • you could actually fix the code to not produce the warning (deleting line 436 of remote-utils.c should do it), or
  • you could install older GCC of the same "vintage", and build GDB with it (perhaps in a virtual machine).
like image 59
Employed Russian Avatar answered Nov 08 '22 06:11

Employed Russian


You can check error-related configure flags using this command:

./configure --help | grep error

there you should see:

--enable-werror enable -Werror in bootstrap stage2 and later

So you can disable treating warnings as errors:

./configure --disable-werror

like image 20
gdbuser Avatar answered Nov 08 '22 06:11

gdbuser