mozilla

Revision 187155 of Setting up jprof

  • Revision slug: Setting_up_jprof
  • Revision title: Setting up jprof
  • Revision id: 187155
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • 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 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.

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

Compile errors on x86_64 Linux

In order to be able to compile jprof on 64-bit Linux, the patches in {{template.Bug(349166)}} must be applied.

Credits

Much of this information was taken from the {{wiki.template('Named-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 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 co mozilla/tools/jprof
</pre>
<h3 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>
<h3 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 name="Tackling_build_errors"> Tackling build errors </h3>
<h4 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 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>
<h4 name="Compile_errors_on_x86_64_Linux"> Compile errors on x86_64 Linux </h4>
<p>In order to be able to compile jprof on 64-bit Linux, the patches in {{template.Bug(349166)}} must be applied.
</p>
<h3 name="Credits"> Credits </h3>
<p>Much of this information was taken from the {{wiki.template('Named-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