Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

GDB "Cannot Insert Breakpoint" [solved]

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
10 posts • Page 1 of 1
Author
Message
solrac776
n00b
n00b
Posts: 14
Joined: Mon Jun 07, 2004 8:50 am
Location: Denver, Colorado, USA

GDB "Cannot Insert Breakpoint" [solved]

  • Quote

Post by solrac776 » Wed Aug 18, 2004 9:14 am

Hi!

GDB works fine for me until I set a breakpoint, then it wigs out, and I can't figure out why. I have searched Gentoo-bugzilla, GDB-bugzilla, and the forums, but have come up with no solution that has worked. There's an article in the GDB manual about a similar problem (http://sources.redhat.com/gdb/current/o ... html#SEC38), but that was unhelpful as well.

Can anyone suggest a solution? This is really wracking my nerves as I need to use GDB and it fails on even tiny programs. I'm getting the same problems with GDB 5.3 & 6.0.

<gdb>
$ gdb ./simple.bin
GNU gdb 6.2
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0xef4: file simple.cc, line 11.

(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x00000ef4 in main at simple.cc:11

(gdb) run
Starting program: /home/gsolrac/Projects/C++AndC/simple.bin
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0xef4: Input/output error.

</gdb>

<simple.cc>
#include <iostream>
#include <string>

using namespace std;

string message();

int main()
{
cout << "Hello " << message() << endl;
return 0;
}


string message()
{
return "World";
}
</simple.cc>

Compiled with: $ g++ -g simple.cc -o simple.bin
$ gcc --version
gcc (GCC) 3.3.3 20040412 (Gentoo Hardened Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)

<emerge --info>
Portage 2.0.50-r9 (default-x86-2004.0, gcc-3.3.3, glibc-2.3.3.20040420-r1, 2.6.7-gentoo-r14)
=================================================================
System uname: 2.6.7-gentoo-r14 i686 Mobile Intel(R) Pentium(R) 4 - M CPU 2.00GHz
Gentoo Base System version 1.4.16
Autoconf: sys-devel/autoconf-2.59-r4
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=pentium4 -O3 -pipe -fomit-frame-pointer"
DISTDIR="/home/gentoo/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://gentoo.mirror.sdv.fr ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo http://www.gigaload.org/gentoo.org/ http://mir.zyrianes.net/gentoo/ http://ftp.easynet.nl/mirror/gentoo/ http://gd.tuwien.ac.at/opsys/linux/gentoo/"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/home/gentoo/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X acpi aim alsa apach arts avi bidi bonobo cdr crypt cups curl curlwrappers dga div4linux doc emacs encode esd ethereal fbcon flash foomaticdb gdbm gif gnome gphoto2 gpm gtk gtk2 gtkhtml guile iconv icq imap imlib innodb jabber java jikes jpeg junit kde ldap libg++ libwww mad maildir mailwrapper mikmod mime motif mpeg msn mysql mysqli ncurses nls offensive oggvorbis opengl oscar oss pam pcmcia pcre pdflib perl php pic pie plotutils png pnp posix prelude python qt quicktime readline samba sasl sdl simplexml slang soap sockets spell spl ssl svg svga tcltk tcpd tidy tiff truetype trusted unicode usb vhosts videos wxwindows x86 xine xml2 xmms xv xvid yahoo zlib"
</emerge --info>
Last edited by solrac776 on Fri Jul 15, 2005 8:28 pm, edited 1 time in total.
Top
solrac776
n00b
n00b
Posts: 14
Joined: Mon Jun 07, 2004 8:50 am
Location: Denver, Colorado, USA

  • Quote

Post by solrac776 » Wed Aug 18, 2004 9:04 pm

Nevermind. Problem solved.

I had originally built my system with "hardened" in my USE settings. I removed hardened and re-compiled my system with "emerge -e system", and now GDB works as expected.

# gcc --version
gcc (GCC) 3.3.3 20040412 (Gentoo Linux 3.3.3-r6, ssp-3.3.2-2, pie-8.7.6)
Copyright (C) 2003 Free Software Foundation, Inc.

I don't know if it was specifically GCC not being "Hardened" that did the trick, but it's fixed now.

<gdb>
$ gdb ./simple.bin
GNU gdb 6.2
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) b main
Breakpoint 1 at 0x8048915: file simple.cc, line 11.

(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048915 in main at simple.cc:11

(gdb) run
Starting program: /home/gsolrac/Projects/C++AndC/simple.bin
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

Breakpoint 1, main () at simple.cc:11
11 cout << "Hello " << message() << endl;

(gdb) bt
#0 main () at simple.cc:11
(gdb)

</gdb>

Maybe just re-emerging GDB without the hardened flag would've done the trick?

<emerge>
# emerge -pv gcc

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild R ] sys-devel/gcc-3.3.3-r6 +X -bootstrap -build -debug -debug -f77 -gcj -hardened +java -multilib +nls -objc +pic -static -(uclibc)
</emerge>
Top
jftuga
Tux's lil' helper
Tux's lil' helper
Posts: 139
Joined: Wed Jan 21, 2004 4:18 am
Location: Athens, GA

  • Quote

Post by jftuga » Wed Aug 18, 2004 11:07 pm

FWIW, I noticed that you used -g. To get maximum debug info, compile with -ggdb3. I know this wouldn't have helped you, but just wanted to share this tidbit of info. :)

-John
Top
solrac776
n00b
n00b
Posts: 14
Joined: Mon Jun 07, 2004 8:50 am
Location: Denver, Colorado, USA

  • Quote

Post by solrac776 » Sun Aug 22, 2004 11:12 pm

Thanks for the info John.

You're right. It was a nice little titbit. I will be making use of it.

Thanks again!

Carlos
Top
colonel_dolphin
n00b
n00b
User avatar
Posts: 39
Joined: Mon Jan 12, 2004 6:20 pm

bug report?

  • Quote

Post by colonel_dolphin » Sun Sep 19, 2004 9:18 pm

Did you post a bug report?
Top
kevquinn
Retired Dev
Retired Dev
User avatar
Posts: 52
Joined: Fri Jun 27, 2003 5:46 pm
Contact:
Contact kevquinn
Website

debugging on hardened systems

  • Quote

Post by kevquinn » Fri Jan 28, 2005 10:18 am

If you want to use gdb on a hardened system, you need two things:

1) If gdb says "warning: Unable to find dynamic linker breakpoint function. GDB will be unable to debug shared library initializers and track explicitly loaded dynamic code.", emerge glibc with FEATURES="nostrip" to allow the dynamic loader stuff to be handled - this is a bug in glibc that should be fixed but isn't on my systems at the time of writing; the nostrip thing is a workaround. See http://bugs.gentoo.org/show_bug.cgi?id=52100

2) Make sure the executable to be debugged does not have RANDEXEC and MPROTECT enabled (PAX-enabled kernels). The former means stuff isn't where gdb expects it to be, and the latter means it can't set breakpoints (since it can't write to the process space of the executable). Do one or both of:

Code: Select all

/sbin/paxctl -xm <executable>
/sbin/chpax -xm <executable>
depending on your kernel PAX configuration.

If you're using RSBAC or similar there may be more things you need to do to allow mprotect() on the executable.

Update: make that three things you need:

3) Do the final link with '-nopie'. You can build the application objects with -fpie/-fPIE (default with hardened toolchain), but linking the final executable needs to be nopie.
Last edited by kevquinn on Mon Feb 14, 2005 10:38 am, edited 1 time in total.
Top
kang__
n00b
n00b
Posts: 14
Joined: Fri Aug 22, 2003 9:26 am

  • Quote

Post by kang__ » Sat Feb 12, 2005 1:50 pm

rsbac_fd_menu /patch/to/file
=> PaX
and set flags here
Top
solrac776
n00b
n00b
Posts: 14
Joined: Mon Jun 07, 2004 8:50 am
Location: Denver, Colorado, USA

  • Quote

Post by solrac776 » Fri Jul 15, 2005 8:22 am

Thanks for the posts guys.

Should I still submit a bug report?
Top
kevquinn
Retired Dev
Retired Dev
User avatar
Posts: 52
Joined: Fri Jun 27, 2003 5:46 pm
Contact:
Contact kevquinn
Website

  • Quote

Post by kevquinn » Fri Jul 15, 2005 11:04 am

If you're happy that setting breakpoints works, don't raise a bug report as nothing is broken. It would probably get marked "resolved/invalid" :)
Top
solrac776
n00b
n00b
Posts: 14
Joined: Mon Jun 07, 2004 8:50 am
Location: Denver, Colorado, USA

  • Quote

Post by solrac776 » Fri Jul 15, 2005 8:26 pm

Thanks
Top
Post Reply

10 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic