View Full Version : Debugging C Library Functions on Linux

07-10-2006, 12:17 PM
Since Linux is an open source operating system, you can install the sources for the C runtime library. (Use the Red Hat package manager rpm to install them.) This lets you debug crashes within C library functions.

On Red Hat, the default compilation path used to build the C library appears to be /usr/src/bs/BUILD/... . The default location for installing sources is /usr/src/redhat/BUILD. If you want TotalView to locate these sources, you need to set up a symbolic link. For example:

cd /usr/src
mkdir bs
chmod 0755 bs
cd bs
ln -s /usr/src/redhat/BUILD

You can determine which version of glibc you are using by telling rpm to display a list of installed packages, and then use grep on the information it displays. For example:

% rpm -q -a | grep glibc

Because glibc-2.07-29 is being used, the source rpm will be glibc- The commands that you would now use to install this package are: rpm -iv glibc-2.07-29.src.rpm
cd /usr/src/redhat/SPECS
rpm -bp glibc-2.07-29.spec

These commands install the sources for glibc and apply patches packaged with it. Once this is done you will have to make a minor change to your TotalView preferences so that TotalView will debug symbols from libc. You should add *libc* to the "all symbols list as described in TotalView's user guide (http://www.etnus.com/Documentation/latest/html/wwhelp/wwhimpl/api.htm?href=User_Guide/ControllingWhichSymbolsTVReads.htm).