Closed Bug 498511 Opened 14 years ago Closed 14 years ago

Produce debuggable optimized NSS builds for Mozilla on Linux

Categories

(NSS :: Build, enhancement, P1)

All
Linux
enhancement

Tracking

(Not tracked)

RESOLVED FIXED
3.12.4

People

(Reporter: nelson, Assigned: julien.pierre)

References

Details

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #498509 +++

NSS is now able to build special builds that are optimized but also have debugging symbols.  This is presently enabled by setting the environment 
variable MOZ_DEBUG_SYMBOLS to a non-empty string.  But presently this 
only works on Windows, and then only when built with MSVC.  

This bug requests that it also be made to work with Linux gcc builds.

The first step will be to determine what changes are needed to compiler 
and linker commands to do this.  Maybe we can get clues by studying 
Firefox build logs.
No longer depends on: 498509
Priority: -- → P1
Target Milestone: 3.12.4 → 3.12.5
Elio, Would you care to take this bug?
Sure.
Assignee: nobody → emaldona
Blocks: 506333
Heads up, due to other time-critical tasks in my plate I won't be able to work on this bug for another two weeks or more. Any help will be appreciated.
Julien, would you be willing to look at this?  
Thanks.
OK. What's the urgency of this bug ?
Please treat this bug as urgent and with high priority.  

Crashes in NSS code are found in Mozilla's list of most frequent crashes,
and many of them are undiagnosed and unresolved because of this bug. 
Lack of resolution to these is the single biggest hindrance to Mozilla 
taking newer versions of NSS 3.12.x.  That is why I have marked these bugs 
as P1 for 3.12.5.
The link to firefox Monday nightly build: http://tinderbox.mozilla.org/showlog.cgi?log=Firefox3.5/1248688925.1248691964.28123.gz

MOZ_DEBUG_SYMBOLS is defined only for win32 and indeed is used only in WIN32 related files/rules in NSS.
Seems that the reason why NSPR and PSM have debug info is that they are built with -gstabs+. We don't use this flag in our optimized build in NSS.

Building NSPR:
-------------------------
/tools/gcc/bin/gcc -o plhash.o -c -fvisibility=hidden    -gstabs+ -Wall -pthread -O2 -fPIC  -UDEBUG  -DMOZILLA_CLIENT=1 -DNDEBUG=1 -DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1 -DHAVE_VISIBILITY_PRAGMA=1 -DXP_UNIX=1 -D_GNU_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DLINUX=1 -Di386=1 -DHAVE_LCHOWN=1 -DHAVE_STRERROR=1 -D_REENTRANT=1  -DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include/nspr -I/builds/slave/mozilla-1.9.1-linux-nightly/build/nsprpub/pr/include  /builds/slave/mozilla-1.9.1-linux-nightly/build/nsprpub/lib/ds/plhash.c

Building NSS:
-------------------------
/tools/gcc/bin/gcc -o /builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/nss/pk11wrap/pk11util.o -c -Os -fPIC -DLINUX1_2 -Di386 -D_XOPEN_SOURCE -DLINUX2_1  -ansi -Wall -Werror-implicit-function-declaration -Wno-switch -pipe -DLINUX -Dlinux -D_POSIX_SOURCE -D_BSD_SOURCE -DHAVE_STRERROR -DXP_UNIX -DSHLIB_SUFFIX=\"so\" -DSHLIB_PREFIX=\"lib\" -DSHLIB_VERSION=\"3\" -DSOFTOKEN_SHLIB_VERSION=\"3\" -UDEBUG -DNDEBUG -D_REENTRANT -DNSS_ENABLE_ECC -DUSE_UTIL_DIRECTLY -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include/nspr -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/public/nss -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/private/nss -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include  -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/public/dbm  pk11util.c 

Building PSM:
-------------------------
/tools/gcc/bin/g++ -o nsNSSComponent.o -c -I../../../../dist/include/system_wrappers -include /builds/slave/mozilla-1.9.1-linux-nightly/build/config/gcc_hidden.h -DNSS_ENABLE_ECC -DXPCOM_TRANSLATE_NSGM_ENTRY_POINT=1 -DMOZILLA_INTERNAL_API -D_IMPL_NS_COM -DEXPORT_XPT_API -DEXPORT_XPTC_API -D_IMPL_NS_COM_OBSOLETE -D_IMPL_NS_GFX -D_IMPL_NS_WIDGET -DIMPL_XREAPI -DIMPL_NS_NET -DIMPL_THEBES  -DZLIB_INTERNAL -DOSTYPE=\"Linux2.6.18-53.1.19\" -DOSARCH=Linux -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include/nss -I/builds/slave/mozilla-1.9.1-linux-nightly/build/security/manager/ssl/src -I. -I../../../../dist/include/nspr -I../../../../dist/include/xpcom -I../../../../dist/include/string -I../../../../dist/include/necko -I../../../../dist/include/uriloader -I../../../../dist/include/pref -I../../../../dist/include/docshell -I../../../../dist/include/caps -I../../../../dist/include/dom -I../../../../dist/include/intl -I../../../../dist/include/locale -I../../../../dist/include/profile -I../../../../dist/include/windowwatcher -I../../../../dist/include/js -I../../../../dist/include/widget -I../../../../dist/include/layout -I../../../../dist/include/content -I../../../../dist/include/xpconnect -I../../../../dist/include/unicharutil -I../../../../dist/include/pipboot -I../../../../dist/include   -I../../../../dist/include/pipnss -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/include/nspr    -I/builds/slave/mozilla-1.9.1-linux-nightly/build/obj-firefox/dist/sdk/include    -fPIC   -fno-rtti -fno-exceptions -Wall -Wpointer-arith -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align -Wno-invalid-offsetof -Wno-long-long -pedantic -gstabs+ -fno-strict-aliasing -fshort-wchar -pthread -pipe  -DNDEBUG -DTRIMMED -Os -freorder-blocks -fno-reorder-functions -finline-limit=50   -DMOZILLA_CLIENT -include ../../../../mozilla-config.h -Wp,-MD,.deps/nsNSSComponent.pp /builds/slave/mozilla-1.9.1-linux-nightly/build/security/manager/ssl/src/nsNSSComponent.cpp
Fedora builds produce optimized NSS shared libraries with a separately packaged set of debug symbols which allows us to get stack tracebacks and some limited debugging. This, however, is produced as part of the RPM build system (which somehow knows how to both produced optimized builds as well as output debug symbols for those builds).

Actually debugging such builds are a pain, however. optimized builds interleave instructions from more than one C statement, causing the debugger to swap back and forth between multiple lines as you 'step' through the program. It is, however, better than no symbols at all. I believe mozilla has tools to do this as well, since talkback output usually includes symbols in the stack traceback.

bob
> MOZ_DEBUG_SYMBOLS is defined only for win32 

I think you mean: is only TESTED on WIN32.
I believe that Firefox builds define it on all platforms.
The objective here is to USE it on all platforms in NSS (coreconf).
I have verified that this patch works on RHEL 4 with gcc 3.4.6 .
-gstabs loses the filename location information unlike -g, but setting NEED_ABSOLUTE_PATH to 1 fixes that problem by passing the full-qualified pathname.
Attachment #391264 - Flags: review?(nelson)
Assignee: emaldona → julien.pierre.boogz
Comment on attachment 391264 [details] [diff] [review]
Add debug info in optimized builds

>@@ -124,7 +124,16 @@ ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_COD
> else
> 	OPTIMIZER = -O2
> endif
>+else
>+endif
>+
>+ifdef BUILD_OPT

The above 4 lines seem unecessary.  If you eliminate them, 
the result is still entirely within #ifdef BUILD_OPT. 
Please eliminate them.  Then, r=nelson

>+ifdef MOZ_DEBUG_SYMBOLS
>+	NEED_ABSOLUTE_PATH = 1
>+	OPTIMIZER  += -gstabs
> endif
>+endif
>+
Attachment #391264 - Flags: review?(nelson) → review+
Alexie pointed out in comment 7 that for Linux Firefox builds are currently not setting MOZ_DEBUG_SYMBOLS at least in the tinderbox builds, and instead set
export CFLAGS="-gstabs+"
export CXXFLAGS="-gstabs+"
so the optimize builds always build with -gstabs+. With this current patch firefox linux build need to set MOZ_DEBUG_SYMBOLS or we change the patch 
to build with -gstabs+ for all optimize builds, or if CFLAGS is already set we use the configured valued (which is what NSPR does).
Yes, MOZ_DEBUG_SYMBOLS is originally a Mozilla build variable,
and Mozilla only uses MOZ_DEBUG_SYMBOLS on Windows.
I'll ask Benjamin about defining MOZ_DEBUG_SYMBOLS in FF builds on other 
platforms.
Summary: Produce debuggable optimized builds for Mozilla on Linux → Produce debuggable optimized NSS builds for Mozilla on Linux
We don't want to have this as the default, so Mozilla will have to define some kind of symbol to differentiate its build. It only makes sense to use MOZ_DEBUG_SYMBOLS here .
Attached patch CorrectionSplinter Review
Actually, using -gstabs+ instead of -gstabs retains the filepath information, so there is no need for NEED_ABSOLUTE_PATH anymore. I have fixed the unnecessary ifdef lines also.
Attachment #391264 - Attachment is obsolete: true
Attachment #391461 - Flags: review?(nelson)
Comment on attachment 391461 [details] [diff] [review]
Correction

r=nelson
Attachment #391461 - Flags: review?(nelson) → review+
Checking in Linux.mk;
/cvsroot/mozilla/security/coreconf/Linux.mk,v  <--  Linux.mk
new revision: 1.41; previous revision: 1.40
done
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Target Milestone: 3.12.5 → 3.12.4
You need to log in before you can comment on or make changes to this bug.