From Fedora Project Wiki

(Created page with '= Description =; This page is a description of how to probe Javascript programs through Mozilla Firefox, using SystemTap. We will be using the DTrace probe points in Firefox to ...')
 
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
= Description =;
= Description =


This page is a description of how to probe Javascript programs through Mozilla Firefox, using SystemTap. We will be using the DTrace probe points in Firefox to access information. I am using Fedora-12.
Firefox comes with DTrace probe points that can be used to profile Javascript processes. Want to profile memory, time, etc. on your Javascript, using Fedora 12? This page will show you how. If you need help, feel free to post on [[User_talk:Valce]]!


= Requirements =;
= Requirements =


*[[https://developer.mozilla.org/En/Developer_Guide/Source_Code/Mercurial|Firefox source]]
*[https://developer.mozilla.org/En/Developer_Guide/Source_Code/Mercurial Firefox source -- choose your version]
*[[SystemTap]]
*[[SystemTap]]


= Setup =


= Setup =;
* Download Firefox source from the above link.
 
* Create a ~/.mozconfig and fill it as follows (Gently adapted from [[http://blog.uxebu.com/2009/02/20/firefox-on-osx-with-dtrace | Uxebu]])
1. Download Firefox source from the above link.
2. Create a mozconfig file as follows (Gently adapted from [[http://blog.uxebu.com/2009/02/20/firefox-on-osx-with-dtrace | Uxebu]])
  . $topsrcdir/browser/config/mozconfig
  . $topsrcdir/browser/config/mozconfig
  mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff
  mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff
ac_add_options --enable-debug --disable-optimize
ac_add_options --enable-shared --disable-static --enable-dtrace
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
mk_add_options AUTOCONF="autoconf-2.13"


ac_add_options --enable-debug --disable-optimize
* Install autoconf 2.13 (<code>yum install autoconf213</code>)
* Enter the mozilla directory and run <code>make -f client.mk build</code>


ac_add_options --enable-shared --disable-static --enable-dtrace
= Playing =


mk_add_options MOZ_MAKE_FLAGS="-s -j4"
The libmozjs can be found in (source directory)firefox/obj-ff/dist/lib/libmozjs.so, and the binary is located at (source directory)firefox/obj-ff/dist/bin/firefox. To see a list of all available markers, run <code>stap -l 'process("/path/to/libmozjs.so").mark("*")</code>


mk_add_options AUTOCONF=autoconf213
Example:


3. Install autoconf 2.13 (yum install autoconf213)
Using the following [[File:Javascript.stp]] on the 'more complicated example' found [https://developer.mozilla.org/en/drawing_graphics_with_canvas here], we get:
4. Enter the mozilla directory and run <code>make -f client.mk build</code>


= Playing =;
                File              |          Function          | Time(ms) | Called
  --------------------------------------------------------------------------------------
    ...me/valce/Desktop/draw.html  |                      dot  |        0 |    4
    ...me/valce/Desktop/draw.html  |                drawBowtie  |        1 |    4
    ...me/valce/Desktop/draw.html  |                    onload  |        7 |    1
    ...me/valce/Desktop/draw.html  |                      draw  |        6 |    1


The libmozjs can be found in (source directory)firefox/obj-ff/dist/lib/libmozjs.so, and the binary is located at (source directory)firefox/obj-ff/dist/bin/firefox.
This basic script just shows the file name, function, time and the number of times called. Argument 2 in the script allows a basic file name filter which will prevent the program from picking up unrelated Javascript function calls.

Latest revision as of 17:10, 16 December 2009

Description

Firefox comes with DTrace probe points that can be used to profile Javascript processes. Want to profile memory, time, etc. on your Javascript, using Fedora 12? This page will show you how. If you need help, feel free to post on User_talk:Valce!

Requirements

Setup

  • Download Firefox source from the above link.
  • Create a ~/.mozconfig and fill it as follows (Gently adapted from [| Uxebu])
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff
ac_add_options --enable-debug --disable-optimize
ac_add_options --enable-shared --disable-static --enable-dtrace
mk_add_options MOZ_MAKE_FLAGS="-s -j4"
mk_add_options AUTOCONF="autoconf-2.13"
  • Install autoconf 2.13 (yum install autoconf213)
  • Enter the mozilla directory and run make -f client.mk build

Playing

The libmozjs can be found in (source directory)firefox/obj-ff/dist/lib/libmozjs.so, and the binary is located at (source directory)firefox/obj-ff/dist/bin/firefox. To see a list of all available markers, run stap -l 'process("/path/to/libmozjs.so").mark("*")

Example:

Using the following File:Javascript.stp on the 'more complicated example' found here, we get:

                File               |          Function          | Time(ms) | Called
 --------------------------------------------------------------------------------------
    ...me/valce/Desktop/draw.html  |                       dot  |        0 |     4
    ...me/valce/Desktop/draw.html  |                drawBowtie  |        1 |     4
    ...me/valce/Desktop/draw.html  |                    onload  |        7 |     1
    ...me/valce/Desktop/draw.html  |                      draw  |        6 |     1

This basic script just shows the file name, function, time and the number of times called. Argument 2 in the script allows a basic file name filter which will prevent the program from picking up unrelated Javascript function calls.