User avatar
memecode
Posts: 17
Joined: Thu Dec 11, 2014 5:51 am
Location: Australia
Contact: Website

Raspbian GDB broken

Sat Mar 21, 2015 12:02 am

I have a raspbian system running on a Pi v2. I've had to build and install my own GTKv2 because the system binary is broken. Other than that it's fairly stock.

Anyway when I got to debug my app (C++) in gdb all I get this sort of rubish:

Code: Select all

GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 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 "arm-linux-gnueabihf".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/pi/Code/Lgi/trunk/LgiIde/lgiide...rdone.
(gdb) r
Starting program: /home/pi/Code/Lgi/trunk/LgiIde/lgiide 

Program received signal SIGILL, Illegal instruction.
0x76fe8acc in ?? () from /lib/ld-linux-armhf.so.3
This app runs fine if I launch it outside of the debugger. The backtrace is pretty useless:

Code: Select all

(gdb) bt
#0  0x76fe8acc in ?? () from /lib/ld-linux-armhf.so.3
#1  0x00000000 in ?? ()
Is this a known problem?

What can I do to get a functional gdb?

User avatar
memecode
Posts: 17
Joined: Thu Dec 11, 2014 5:51 am
Location: Australia
Contact: Website

Re: Raspbian GDB broken

Sat Mar 21, 2015 12:37 am

I also tried building 7.9 from source and it has the same behaviour. Although I didn't install it, just ran from the build folder.

Somewhat relevant thread:
https://github.com/raspberrypi/linux/issues/766

User avatar
memecode
Posts: 17
Joined: Thu Dec 11, 2014 5:51 am
Location: Australia
Contact: Website

Re: Raspbian GDB broken

Sun Mar 22, 2015 11:15 pm

I'm not in front of my Pi right now but maybe I could use a .gdbinit command to set the SIGILL to "pass" via the "handle" command.

Maybe that would work? Haven't tried it yet.

User avatar
memecode
Posts: 17
Joined: Thu Dec 11, 2014 5:51 am
Location: Australia
Contact: Website

Re: Raspbian GDB broken

Mon Mar 30, 2015 12:38 am

memecode wrote:I'm not in front of my Pi right now but maybe I could use a .gdbinit command to set the SIGILL to "pass" via the "handle" command.

Maybe that would work? Haven't tried it yet.
Ok so I tried it. The process is basically gone by the time the SIGILL happens. Passing the exception to the process doesn't lead anywhere.

So basically gdb on the Rpi is useless. Nice :(

Brian Beuken
Posts: 455
Joined: Fri Jan 29, 2016 12:51 pm

Re: Raspbian GDB broken

Sat Mar 04, 2017 1:02 pm

I am experiencing continuied lock ups using VisualGDB which is reliant on GDB on the target, it does seem to be an internal issue on the Pi's GDB

I've googled around it it seems to have been an issue for a couple of years now, is there any way to resolve this, it's rather a major issue for coders wanting to debug code.
Last edited by Brian Beuken on Sun Mar 05, 2017 4:39 pm, edited 1 time in total.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
http://www.scratchpadgames.net/
https://www.patreon.com/BrianBeuken

Brian Beuken
Posts: 455
Joined: Fri Jan 29, 2016 12:51 pm

Re: Raspbian GDB broken

Sun Mar 05, 2017 5:32 am

I’ve managed to work out a possible fix, posting here for the benefit of others who like me may not be very comfortable with linux and are having debugging hangs. The Rasbian version of GDB seems to be faulty, its also a little old at version 7.7.1 with a specific Rasbian build.

I was directed to this site to help and it was very useful..but is not Rasbian specific so a bit more work was needed.
http://www.linuxfromscratch.org/blfs/vi ... l/gdb.html

Downloading the newer generic GDB (7.12.1) and unzipping it to a working folder was fine… then I tried to use

./configure –prefix=/usr –with-system-readline && make

however it seems the readline libs were missing on the Pi, so this failed.. so I installed them with,

sudo apt-get install libreadline-dev

You should avoid my error, and install it before attempting the GDB build.
I repeated the configure/make process this time for a successful result (note it takes quite some time)

This does not actually seem to replace the Rasbian GDB, which still reported itself as 7.7 Rasbian, but by then copying the new built version to a more accessible directory with
sudo cp gdb/gdb /usr/local/bin/gdb

After a reset, GDB now reports a new 7.12.1 version, not specific to Rasbian.

I don’t really know the final copy step was needed, or if a reset was all that was needed, but regardless I now have a later generic GDB in place and it seems on initial tests on a piece of code that hanged every time, to be much more stable in fact I’ve single stepped through a very complex piece of code with no problems.

Of course this may not be an ideal fix, It replaces a specific piece of code that may have uses elsewhere, if you need the specific Rasbian GDB, I do not know what functions it provides and may now be lost, but for the moment at least I am very happy not to be hanging the instant I trigger a breakpoint.
I will report back if I find any issues with this fix.

I hope this is helpful and if I've made a mess of something, please let me know.
Last edited by Brian Beuken on Sun Mar 05, 2017 4:39 pm, edited 1 time in total.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
http://www.scratchpadgames.net/
https://www.patreon.com/BrianBeuken

Brian Beuken
Posts: 455
Joined: Fri Jan 29, 2016 12:51 pm

Re: Raspbian GDB broken

Sun Mar 05, 2017 2:26 pm

and a cleaner faster way to do the same thing is

Code: Select all

wget https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz -P ~/Downloads/
tar vxzf ~/Downloads/gdb-7.12.tar.gz -C ~/Downloads/
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install libreadline-dev -y
sudo apt-get autoclean
cd ~/Downloads/gdb-7.12
./configure --prefix=/usr --with-system-readline && make -j4
sudo make -j4 -C gdb/ install
sudo shutdown -r 0
gdb --version
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
http://www.scratchpadgames.net/
https://www.patreon.com/BrianBeuken

RomanMeR
Posts: 6
Joined: Fri Jan 06, 2017 3:00 pm

Re: Raspbian GDB broken

Tue Apr 11, 2017 1:36 pm

Brian, thank you very much for detailed step-by-step commands!
I should mention that on my system I had to

Code: Select all

sudo apt-get install texinfo
in order for

Code: Select all

sudo make -j4 -C gdb/ install
step to succeed.

fctr
Posts: 5
Joined: Mon Aug 15, 2016 8:39 pm
Contact: Website

Re: Raspbian GDB broken

Sun Jun 11, 2017 6:19 pm

Thank you guys/gals so much for all the information! I can finally debug using VisualGDB now.


Code: Select all

wget https://ftp.gnu.org/gnu/gdb/gdb-7.12.tar.gz -P ~/Downloads/
tar vxzf ~/Downloads/gdb-7.12.tar.gz -C ~/Downloads/
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install texinfo libreadline-dev -y
sudo apt-get autoclean
cd ~/Downloads/gdb-7.12
./configure --prefix=/usr --with-system-readline && make -j4
sudo make -j4 -C gdb/ install
sudo shutdown -r 0
gdb --version
-=> Andrew

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Raspbian GDB broken

Sun Jun 11, 2017 6:26 pm

Bookmarked for when I next need gdb on a pi 8-)
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

echmain
Posts: 332
Joined: Fri Mar 04, 2016 8:26 pm

Re: Raspbian GDB broken

Thu Apr 26, 2018 1:45 am

Bumping this only to report that by following the above instructions I was able to successfully build and install gdb 8.1 on a Pi 3B+ (with Stretch).

I first attempted to build gdb 8.1 using vanilla configure/make/install but got errors during the install.

Found this thread and followed the instructions and it all worked. I’ve only quickly stepped through a few programs but so far all seems to be in working order.

Beware that installing the texinfo packge installed a total of 36 packages(!).

Return to “C/C++”