1.) Get yourself an optimized libxul build of Firefox, with debugger info.
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-opt-libxul mk_add_options MOZ_MAKE_FLAGS=-j3 ac_add_options --enable-optimize ac_add_options --enable-libxul ac_add_options --enable-shark ac_add_options --enable-debugger-info-modules
2.) You'll want to run Shark on both the browser and xpcshell, since the host environments differ. Here are some instrumented tests to work from: media:Profiling-ammo.zip
Other Ways To Profile
For Linux, there are global jprof functions available. See the documentation on the --enable-jprof mozconfig option. We're working to add support for other profilers, such as oprofile and Intel VTune. When we have JS scriptable profiling options available for all tier 1 platforms, we'll look at adding global start/stop profiling functions.
If you'd like to profile something in more detail than the JS Shark functions allow, there are corresponding C functions available at the bottom of jsdbgapi.h.