[Gc] Re: gprof and libgc
ludovic.courtes at laas.fr
Wed Jun 28 04:44:56 PDT 2006
Travis Griggs <tgriggs at key.net> writes:
> I have a program that uses libgc (I love it)... but I need to do some
> profiling on it. I use the debian testing version of libgc (no clue
> what version that is; how would I tell?).
You can know what Debian version you're using like this:
$ apt-cache show libgc-dev |grep ^Version
So, 6.7 is what we currently have in `unstable'.
As for profiling using GNU Gprof, you need to compile statically `libgc'
(and possibly the other libraries your program depends on if you want
profiling information about them), and then statically link you program
Concretely, you can do the following:
$ apt-get source libgc-dev
$ cd libgc-6.7
$ ./configure && make CFLAGS='-O1 -g -pg' LDFLAGS='-pg -static'
$ cd ../your-program
$ ./configure && make the-program CFLAGS='-O1 -g -pg' LDFLAGS='-pg -static'
Then, you should make sure that your program is really statically linked
against `libgc' and other libs:
$ ldd the-program
You can now run your program and look at the `gmon.out' output.
Now, you will certainly notice that `GC_mark_from ()' and other
functions from `libgc' appear as "spontaneous" (sic) calls in the call
graph. I don't really understand why this is the case. Perhaps this
happens when `libgc' is used in multi-threaded mode (i.e., with
`GC_THREADS' defined)? Hans, can you confirm?
More information about the Gc