On Jul 13, 2007, at 4:39 PM, Joseph Wakeling wrote:
I have a small library which is built using the GNU autotools. It alsoincludes some executable programs which use the main library. I would like to profile the performance using gprof or another tool but havebeen having trouble working out how to do so. I tried simply adding -pto the CFLAGS but the resulting gmon.out appeared to contain no data(e.g. running gprof on the executable or on the .la file resulted in an error, "not in executable format", while running it on one of the objectfiles produced no information).I wonder if someone could give me a brief run-through on how to profilethe library---what options I need to place in the autotools-related files and when using ./configure, and how to use gprof effectively on the library once built.
Hello Joseph,when using libtool, the `binary' produced in the build directory is in fact a wrapper shell script that does some setup and then runs the real binary. This is required because your executable probably depends on uninstalled libraries and the script does some magic before running it (such as, typically, setting the LD_LIBRARY_PATH if you're on GNU/Linux).
If, say, I have a bin_PROGRAMS `foo' that depends on a lib_LTLIBRARIES `libfoo.la', this is what I have:
$ file foo libfoo.la foo: Bourne shell script text executable libfoo.la: ASCII English textThe .la file is a piece of shell script that contains information useful to libtool.
Now the answer to your question is to ask libtool to run gprof (or gdb) for you:
./libtool --mode=execute gprof ./foo Cheers, -- Benoit Sigoure aka Tsuna EPITA Research and Development Laboratory
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ http://lists.gnu.org/mailman/listinfo/libtool