On Dec 4, 2012, at 1:24 AM, Myles C. Maxfield wrote:

> Hello, all,
> I'm interested in learning about the internals of how libc works, so I was
> hoping to link a test application with a version of libc that has debugging
> symbols (reading the raw sources only gets me so far). The version of libc
> that comes with FreeBSD doesn't have debugging symbols (nor should it), so
> I'm wondering if there is a way to install / compile my own.
> 
> I have very naïvely checked out libc from /base/head at svn.freebsd.org,
> crossed my fingers, and ran 'make', but that didn't work (for many reasons,
> I'm sure). This leads me to the following questions:
> 
> 1. Is it possible to check out the sources of libc (and possibly other
> libraries) as they were when the FreeBSD 9.0 release was being compiled
> (since that's what I'm running)? Is there a way to map this to a particular
> SVN revision?

Yes.  The handbook should cover the different possibilities, but you'll want to 
check out the code from

http://svn.freebsd.org/base/releng/9.0

> 2. Is there a listing of the tools and versions used to compile libc at
> that time?

It's all in what you checked out using the above link.

> 3. Many other unix-like distributions have something like a libc-dbg
> package in their package manager. Do you think this would be worthwhile or
> even acceptable for me to try to create something similar in the ports
> database? (I couldn't find anything that already exists)

That's an interesting idea.  However, it is easy enough to build what you need:

cd svn-root-location            # change this to the real path
cd lib/libc
make DEBUG_FLAGS=-g obj all install clean

should suffice.  It will add a bunch of space to your root and /usr partitions, 
iirc, but disks these days are so huge you won't notice.  If you do, you can 
install to a different location using DESTDIR. Due to some interaction between 
different parts of the system that's a smidge more complex:

cd svn-root-location
make redistribute
cd lib/libc
make DEBUG_FLAGS=-g obj all install clean DESTDIR=/some/other/path

If you are hacking on libc, you can omit the 'clean' step.  If you are 
rebuilding libc, you can omit the 'obj' after the first time. If you are 
hacking on amd64, you may want to add WITHOUT_LIB32=t to the command line to 
disable the 32-bit build.

To rebuild libc takes just a couple of minutes.  Hope this helps.

Warner
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to