Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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.

share|improve this answer

You can try apt-get source -d libc6-dev and this should give you the source and the diff in deb format. Then you can uncompress it and it should give the sources in tar.gz uncompress this as well.It should be stored in the directory that you ran the apt-get command in.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.