Debugging C extensions on Gentoo

Lonnie Princehouse finite.automaton at gmail.com
Wed May 4 15:54:04 EDT 2005


I've spent the last couple of hours trying to figure out how to set
breakpoints in Python C extensions under gdb 6.2 using Gentoo Linux,
and finally figured it out.   So for posterity (aka Google), here's the
trick:

  If GDB is giving you the message "Unable to find dynamic linker
breakpoint function", it's because the ebuild for glibc strips the
dynamic linker which makes it impossible to set breakpoints in shared
libraries.  You need to patch the ebuild.  Do this:

1. Find the ebuild that emerge is going to use:

  $ emerge -p
  These are the packages that I would merge, in order:

  Calculating dependencies ...done!
  [ebuild   R   ] sys-libs/glibc-2.3.4.20041102-r1
                           ^^^^^^^^^^^^^^^^^^^^^^^
2. Edit the corresponding .ebuild file in /usr/portage/sys-libs/glibc

You need to add one line of code, described by this patch submitted by
Benno Schulenberg (thanks!) on linux.gentoo.user in a thread from
Februrary titled "Mysterious GDB Error"  (the line numbers will be
different for your different ebuild version)

--- /usr/portage/sys-libs/glibc/glibc-2.3.4.20050125-r1.ebuild
2005-02-19 21:48:06.000000000 +0100
+++ /usr/local/portage/sys-libs/glibc/glibc-2.3.4.20050125-r1.ebuild
2005-02-24 23:54:34.000000000 +0100
@@ -371,8 +371,10 @@
        fi

        # now, strip everything but the thread libs #46186
        mkdir -p ${T}/thread-backup
        mv ${D}$(alt_libdir)/lib{pthread,thread_db}*
${T}/thread-backup/
+       # Also, don't strip the dynamic linker:
+       mv ${D}/$(get_libdir)/ld-* ${T}/thread-backup
        if use !nptlonly && want_nptl ; then
                mkdir -p ${T}/thread-backup/tls

3. emerge glibc (or "have a beer while you watch compiler messages
scroll by for half an hour")




More information about the Python-list mailing list