Tech Tip: How to Build Firefox with Debugging Symbols on Linux
I spent a large part of today building Firefox on one of my Linux machines and trying to figure out why gdb did not display debugging symbols, and instead only displayed question marks in the backtrace (?? ). Eeventually, I found a solution, so I'd like to document the process for other people in the future.
The solution is documented in this bug report that I filed and involves the following steps:
-
Checkout the firefox source from the mozilla-central repository
-
Put something like the following in the .mozconfig file in the source's root (where client.mk can be found):
. $topsrcdir/browser/config/mozconfig export LDFLAGS="-Wl,--no-keep-memory" mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/ff-dbg ac_add_options --disable-optimize ac_add_options --enable-debug ac_add_options --enable-tests ac_add_options --enable-debug-symbols ac_add_options --prefix="$HOME/opt/firefox-from-hg"
The important lines are the --enable-debug, --enable-debug-symbols and the LDFLAGS one.
-
Type make -f client.mk. Now you'll need to wait.
-
Type make -f client.mk install PKG_SKIP_STRIP=1 and make sure you do not forget the PKG_SKIP_STRIP=1 parameter.
-
Now you can use gdb ~/opt/firefox-from-hg/bin/firefox to debug Firefox with all the debugging symbols.
Enjoy!