mozilla

Revision 187159 of Setting up jprof

  • Revision slug: Setting_up_jprof
  • Revision title: Setting up jprof
  • Revision id: 187159
  • Created:
  • Creator: Nickolay
  • Is current revision? Yes
  • Comment

Revision Content

Jprof is a profiling tool for Linux. To use it, one needs to build mozilla with special build options.

Checking it out

Since jprof isn't part of the default build, you'll need to explicitly check out its source:

cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co mozilla/tools/jprof

Setting up mozconfig

In order to enable jprof, you'll need to add

ac_add_options --enable-jprof

to your mozconfig file. Note that if you're going to be profiling stuff, it's good to have an optimized (--enable-optimize --disable-debug) build. Also, jprof needs symbols to operate, so you must not have --enable-strip in your mozconfig.

For more information about configuring your build, see Configuring Build Options.

Building

After you've checked out the source and set up a mozconfig file, you should be able to run

 make -f client.mk build

and have a build ready to profile with. See the jprof README for information on how to use jprof.

Tackling build errors

Missing bfd.h

When compiling bfd.cpp you may get the following error:

 error: bfd.h: No such file or directory

You will need to download the package which has the bfd.h header file in it. This is usually in the binutils development package on most platforms.

Linking error with libmalloc.o

When linking all the files together you may get this error:

 libmalloc.o: In function `DumpAddressMap()':libmalloc.cpp:(.text+0x252): undefined reference to `_r_debug'
 collect2: ld returned 1 exit status

In order to fix this, the following line must be added to Makefile.in in mozilla/tools/jprof/stub/:

 EXTRA_DSO_LDOPTS += /lib/ld-linux.so.2

Credits

Much of this information was taken from the {{ Source("tools/jprof/README.html", "jprof README") }} and a blog post by Gijs Kruitbosch (Hannibal).

Revision Source

<p>Jprof is a profiling tool for Linux. To use it, one needs to build mozilla with special build options.
</p>
<h3 id="Checking_it_out" name="Checking_it_out"> Checking it out </h3>
<p>Since jprof isn't part of the default build, you'll need to explicitly check out its source:
</p>
<pre class="eval">cvs -d <a class=" link-mailto" href="mailto::pserver:anonymous@cvs-mirror.mozilla.org" rel="freelink">:pserver:anonymous@cvs-mirror.mozilla.org</a>:/cvsroot co mozilla/tools/jprof
</pre>
<h3 id="Setting_up_mozconfig" name="Setting_up_mozconfig"> Setting up mozconfig </h3>
<p>In order to enable jprof, you'll need to add
</p>
<pre class="eval">ac_add_options --enable-jprof
</pre>
<p>to your mozconfig file. Note that if you're going to be profiling stuff, it's good to have an optimized (<code>--enable-optimize --disable-debug</code>) build. Also, jprof needs symbols to operate, so you must <b>not</b> have <code>--enable-strip</code> in your mozconfig.
</p><p>For more information about configuring your build, see <a href="en/Configuring_Build_Options">Configuring Build Options</a>.
</p>
<h3 id="Building" name="Building"> Building </h3>
<p>After you've checked out the source and set up a mozconfig file, you should be able to run
</p>
<pre class="eval"> make -f client.mk build
</pre>
<p>and have a build ready to profile with. See the <a class="external" href="http://lxr.mozilla.org/mozilla/source/tools/jprof/README.html">jprof README</a> for information on how to use jprof.
</p>
<h3 id="Tackling_build_errors" name="Tackling_build_errors"> Tackling build errors </h3>
<h4 id="Missing_bfd.h" name="Missing_bfd.h"> Missing bfd.h </h4>
<p>When compiling <code>bfd.cpp</code> you may get the following error:
</p>
<pre class="eval"> error: bfd.h: No such file or directory
</pre>
<p>You will need to download the package which has the <code>bfd.h</code> header file in it. This is usually in the binutils development package on most platforms.
</p>
<h4 id="Linking_error_with_libmalloc.o" name="Linking_error_with_libmalloc.o"> Linking error with libmalloc.o </h4>
<p>When linking all the files together you may get this error:
</p>
<pre class="eval"> libmalloc.o: In function `DumpAddressMap()':libmalloc.cpp:(.text+0x252): undefined reference to `_r_debug'
 collect2: ld returned 1 exit status
</pre>
<p>In order to fix this, the following line must be added to <code>Makefile.in</code> in <code>mozilla/tools/jprof/stub/</code>:
</p>
<pre class="eval"> EXTRA_DSO_LDOPTS += /lib/ld-linux.so.2
</pre>
<h3 id="Credits" name="Credits"> Credits </h3>
<p>Much of this information was taken from the {{ Source("tools/jprof/README.html", "jprof README") }} and a <a class="external" href="http://www.gijsk.com/blog/2006/06/profiling-venkman-jsd-startup">blog post</a> by Gijs Kruitbosch (Hannibal).
</p>
Revert to this revision