Ubuntu – How to get the eglibc source code used by Ubuntu

gdbsoftware-sourcessource code

How do I get the source code for eglibc in a format that will allow stepping through the source with gdb?

I have tried using apt-get source libc6-dev and that works for getting the source code, but I think that since the pre-processor directives were not applied that the line numbers that gdb has does not match with the source I downloaded. This makes it less useful when trying to step through the source and look at how functions in libc are working.

Best Answer

  • If you really want to step through the source I'd recommend building a libc without optimisation and without stripping the binaries.

    Fortunately, that should be easy - since you've already got the source, you can build packages from it. You'll want to ensure the DEB_BUILD_OPTIONS evnironment variable contains noopt to get -O0 binaries and nostrip to keep the debugging symbols, and then build as normal with debuild:

    sudo apt-get build-dep libc6
    DEB_BUILD_OPTIONS="noopt nostrip" debuild -us -uc

    will build you packages built with -O0 and without the debugging symbols stripped; you can then install them with dpkg and gdb will pick up the debugging symbols. As an added bonus, gdb will also know where to find the source files, so you'll get source listings.

    Since we haven't changed the version of the packages, the next time you run an upgrade apt will replace these locally-installed packages with the archive versions.

  • Related Question