bug 378463 - build time logic to extract debug symbols on OS X. r=mento
--- a/Makefile.in
+++ b/Makefile.in
@@ -129,26 +129,49 @@ ifdef MOZ_PROFILE
echo splitting symbols out of binaries
/bin/find $(DIST) -name "*.dll" -exec splitsym {} \;
/bin/find $(DIST) -name "*.exe" -exec splitsym {} \;
/bin/find $(DIST) -name "*.EXE" -exec splitsym {} \;
mkdir -p $(DIST)/$(BUILDID)
/bin/find $(DIST) -name "*.dbg" -exec mv {} $(DIST)/$(BUILDID) \;
endif # MOZ_PROFILE
endif # MOZILLA_OFFICIAL
+endif # WINNT
+
+ifeq ($(OS_ARCH),WINNT)
+SYM_FIND_CMD := /bin/find . -path dist -prune -o -name "*.exe" \
+ -o -name "*.dll" -o -name "*.EXE" | sed "s/\.[^\.]*$$/\.pdb/"
+# we want to copy PDB files on Windows
+MAKE_SYM_STORE_ARGS := -c
+DUMP_SYMS_BIN := $(topsrcdir)/toolkit/airbag/tools/win32/dump_syms.exe
+endif
+ifeq ($(OS_ARCH),Darwin)
+# need to pass arch flags for universal builds
+ifdef UNIVERSAL_BINARY
+MAKE_SYM_STORE_ARGS := -a "ppc i386"
+SYM_DIST := $(DIST)/universal
+else
+MAKE_SYM_STORE_ARGS := -a $(OS_TEST)
+SYM_DIST := $(DIST)
+endif
+# |file| is stupid on universal binaries, it produces one line of output
+# for the file, and one line of output for each architecture contained within.
+SYM_FIND_CMD := find -L $(SYM_DIST) -type f -a -perm -100 -o -name "*.dylib" \
+ | xargs file -L | grep "Mach-O" | grep -v "for architecture" | cut -f1 -d':'
+DUMP_SYMS_BIN := $(DIST)/host/bin/dump_syms
+endif
buildsymbols:
ifdef MOZ_DEBUG_SYMBOLS
ifdef MOZ_AIRBAG
echo building symbol store
mkdir -p $(DIST)/crashreporter-symbols/$(BUILDID)
- /bin/find . -path "./dist" -prune -o -name "*.exe" \
- -o -name "*.dll" -o -name "*.EXE" | sed "s/\.[^\.]*$$/\.pdb/" | \
- xargs $(topsrcdir)/toolkit/airbag/tools/make_symbol_store.pl -c \
- $(topsrcdir)/toolkit/airbag/tools/win32/dump_syms.exe \
+ $(SYM_FIND_CMD) | \
+ xargs $(topsrcdir)/toolkit/airbag/tools/make_symbol_store.pl \
+ $(MAKE_SYM_STORE_ARGS) $(DUMP_SYMS_BIN) \
$(DIST)/crashreporter-symbols/$(BUILDID) > \
$(DIST)/crashreporter-symbols/$(BUILDID)/$(MOZ_APP_NAME)-$(MOZ_APP_VERSION)-$(OS_ARCH)-$(BUILDID)-symbols.txt
echo packing symbols
mkdir -p $(topsrcdir)/../$(BUILDID)
cd $(DIST)/crashreporter-symbols/$(BUILDID) && \
zip -r9D ../crashreporter-symbols-$(BUILDID).zip .
mv $(DIST)/crashreporter-symbols/crashreporter-symbols-$(BUILDID).zip \
$(topsrcdir)/../$(BUILDID)
@@ -157,20 +180,21 @@ endif # MOZ_AIRBAG
uploadsymbols:
ifdef MOZ_DEBUG_SYMBOLS
ifdef MOZ_AIRBAG
$(topsrcdir)/toolkit/airbag/tools/upload_symbols.sh $(topsrcdir)/../$(BUILDID)/crashreporter-symbols-$(BUILDID).zip
endif
endif
+ifeq ($(OS_ARCH),WINNT)
signnss:
ifdef MOZILLA_OFFICIAL
echo signing NSS libs
cd $(DIST)/bin; ./shlibsign.exe -v -i softokn3.dll
cd $(DIST)/bin; ./shlibsign.exe -v -i freebl3.dll
endif # MOZILLA_OFFICIAL
-BUILDID = $(shell cat $(DEPTH)/config/build_number)
deliver: splitsymbols rebase signnss
endif # WINNT
+BUILDID = $(shell cat $(DEPTH)/config/build_number)
--- a/build/macosx/universal/flight.mk
+++ b/build/macosx/universal/flight.mk
@@ -81,19 +81,19 @@ endif # } xulrunner
endif # } !camino
postflight_all:
# Build the universal package out of only the bits that would be released.
# Call the packager to set this up. Set UNIVERSAL_BINARY= to avoid producing
# a universal binary too early, before the unified bits have been staged.
# Set SIGN_NSS= to skip shlibsign.
$(MAKE) -C $(OBJDIR_PPC)/$(INSTALLER_DIR) \
- UNIVERSAL_BINARY= SIGN_NSS= stage-package
+ UNIVERSAL_BINARY= SIGN_NSS= PKG_SKIP_STRIP=1 stage-package
$(MAKE) -C $(OBJDIR_X86)/$(INSTALLER_DIR) \
- UNIVERSAL_BINARY= SIGN_NSS= stage-package
+ UNIVERSAL_BINARY= SIGN_NSS= PKG_SKIP_STRIP=1 stage-package
# Remove .chk files that may have been copied from the NSS build. These will
# cause unify to warn or fail if present. New .chk files that are
# appropriate for the merged libraries will be generated when the universal
# dmg is built.
rm -f $(DIST_PPC)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(APP_CONTENTS)/*.chk \
$(DIST_X86)/$(MOZ_PKG_APPNAME)/$(APPNAME)/$(APP_CONTENTS)/*.chk
# The only difference betewen the two trees now should be the
# about:buildconfig page. Fix it up.
--- a/toolkit/airbag/Makefile.in
+++ b/toolkit/airbag/Makefile.in
@@ -56,19 +56,22 @@ DIRS = \
ifeq ($(OS_ARCH),WINNT)
DIRS += airbag/src/common/windows \
airbag/src/client/windows \
$(NULL)
endif
ifeq ($(OS_ARCH),Darwin)
- DIRS += airbag/src/common/mac \
- airbag/src/client/mac/handler \
- $(NULL)
+DIRS += \
+ airbag/src/common/ \
+ airbag/src/common/mac \
+ airbag/src/client/mac/handler \
+ airbag/src/tools/mac/dump_syms \
+ $(NULL)
endif
DIRS += client
LOCAL_INCLUDES = -I$(srcdir)/airbag/src
DEFINES += -DUNICODE -D_UNICODE
XPIDLSRCS = \
new file mode 100644
--- /dev/null
+++ b/toolkit/airbag/airbag/src/common/Makefile.in
@@ -0,0 +1,65 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla Breakpad integration
+#
+# The Initial Developer of the Original Code is
+# Ted Mielczarek <ted.mielczarek@gmail.com>
+# Portions created by the Initial Developer are Copyright (C) 2007
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = breakpad_common
+LIBRARY_NAME = breakpad_common_s
+HOST_LIBRARY_NAME = host_breakpad_common_s
+
+LOCAL_INCLUDES = -I$(srcdir)/..
+
+CPPSRCS = \
+ string_conversion.cc \
+ $(NULL)
+
+CSRCS = \
+ convert_UTF.c \
+ $(NULL)
+
+HOST_CPPSRCS = $(CPPSRCS)
+
+HOST_CSRCS = $(CSRCS)
+
+# need static lib
+FORCE_STATIC_LIB = 1
+
+include $(topsrcdir)/config/rules.mk
--- a/toolkit/airbag/airbag/src/common/mac/Makefile.in
+++ b/toolkit/airbag/airbag/src/common/mac/Makefile.in
@@ -38,31 +38,36 @@ DEPTH = ../../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = breakpad_mac_common
LIBRARY_NAME = breakpad_mac_common_s
+HOST_LIBRARY_NAME = host_breakpad_mac_common_s
LOCAL_INCLUDES = -I$(srcdir)/../..
-CPPSRCS = \
- file_id.cc \
- macho_id.cc \
- macho_walker.cc \
- string_utilities.cc \
- ../string_conversion.cc \
- $(NULL)
+# This is a little weird, but we're building a host and a target lib here.
+# The host lib is used for dump_syms, and the target lib for the
+# crash reporter client. Therefore, we don't need all the srcs in both.
+CPPSRCS = \
+ file_id.cc \
+ macho_id.cc \
+ macho_walker.cc \
+ string_utilities.cc \
+ $(NULL)
-CMSRCS = \
- HTTPMultipartUpload.m \
- $(NULL)
+CMSRCS = \
+ HTTPMultipartUpload.m \
+ $(NULL)
-CSRCS = \
- ../convert_UTF.c
+HOST_CPPSRCS = $(CPPSRCS)
+HOST_CMMSRCS = \
+ dump_syms.mm \
+ $(NULL)
# need static lib
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/toolkit/airbag/airbag/src/tools/mac/dump_syms/Makefile.in
@@ -0,0 +1,68 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla Breakpad integration
+#
+# The Initial Developer of the Original Code is
+# Ted Mielczarek <ted.mielczarek@gmail.com>
+# Portions created by the Initial Developer are Copyright (C) 2007
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../../../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+HOST_PROGRAM = dump_syms
+
+LOCAL_INCLUDES = \
+ -I$(srcdir)/../../.. \
+ -I$(srcdir)/../../../common/mac \
+ $(NULL)
+
+HOST_CMSRCS = \
+ dump_syms_tool.m \
+ $(NULL)
+
+HOST_LIBS += \
+ $(DEPTH)/toolkit/airbag/airbag/src/common/mac/$(LIB_PREFIX)host_breakpad_mac_common_s.$(LIB_SUFFIX) \
+ $(DEPTH)/toolkit/airbag/airbag/src/common/$(LIB_PREFIX)host_breakpad_common_s.$(LIB_SUFFIX) \
+ $(NULL)
+
+HOST_LDFLAGS += \
+ -framework Foundation \
+ -lcrypto \
+ $(NULL)
+
+# force C++ linking
+CPP_PROG_LINK = 1
+
+include $(topsrcdir)/config/rules.mk
--- a/toolkit/airbag/tools/make_symbol_store.pl
+++ b/toolkit/airbag/tools/make_symbol_store.pl
@@ -30,79 +30,99 @@
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
#
-# Usage: make_symbol_store.pl <params> <dump_syms path> <symbol store path> <pdb files>
-# Runs dump_syms on each pdb file specified on the command line,
+# Usage: make_symbol_store.pl <params> <dump_syms path> <symbol store path>
+# <debug info files>
+# Runs dump_syms on each debug info file specified on the command line,
# then places the resulting symbol file in the proper directory
-# structure in the symbol store path. Accepts multiple pdb files
+# structure in the symbol store path. Accepts multiple files
# on the command line, so can be called as part of a pipe using
-# find <dir> -name "*.pdb" | xargs make_symbol_store.pl <dump_syms> <storepath>
+# find <dir> | xargs make_symbol_store.pl <dump_syms> <storepath>
# Parameters accepted:
-# -c : Copy pdb files to the same directory structure as sym files
+# -c : Copy debug info files to the same directory structure
+# as sym files
+# -a "<archs>" : Run dump_syms -a <arch> for each space separated
+# cpu architecture in <archs> (only on OS X)
use FileHandle;
use File::Path;
use File::Copy;
use File::Basename;
-print "Usage: make_symbol_store.pl <dump_syms path> <storepath> <pdb files>>\n" and exit if scalar @ARGV < 3;
+print "Usage: make_symbol_store.pl <params>" .
+ "<dump_syms path> <storepath> <debug info files>\n"
+ and exit if scalar @ARGV < 3;
# Given a symbol file generated by dump_syms,
# and a directory to store the resulting symbol path,
# move the symbol file into the directory structure
-# expected by the airbag processor:
-# file.pdb/GUID+age/file.sym
+# expected by the breakpad processor. For details, see:
+# http://google-breakpad.googlecode.com/svn/trunk/src/processor/simple_symbol_supplier.h
sub rename_symbol_file
{
my ($symbol_file, $dest_path) = @_;
my $fh = FileHandle->new($symbol_file, "r");
return "" unless $fh;
my $line = <$fh>;
+ return "" unless $line;
$line =~ s/\s*$//;
$fh->close();
return "" unless $line =~ m/^MODULE/;
- my ($guid,$age,$dbgfile) = (split(/ +/, $line))[1..3];
- $guid =~ s/\-//g;
- my $newpath = $dest_path . "/" . $dbgfile . "/" . uc($guid . $age);
+ # the first line of a sym file looks like:
+ # MODULE os cpu identifier debug_file
+ my ($guid,$dbgfile) = (split(/ +/, $line))[3..4];
+ my $newpath = $dest_path . "/" . $dbgfile . "/" . $guid;
eval { mkpath($newpath) };
return "" if $@;
if(move($symbol_file, $newpath)) {
my $out = $newpath;
my ($f) = fileparse($symbol_file);
$out =~ s/^$dest_path//;
$out =~ s|^/||;
print "$out/$f\n";
return $newpath;
}
return "";
}
-my $copy_pdbs = 0;
-if($ARGV[0] eq '-c') {
- $copy_pdbs = 1;
- shift;
+my $copy_dbg = 0;
+my @archs = ('');
+while (@ARGV && $ARGV[0] =~ m/^-/) {
+ my $arg = shift;
+ if ($arg eq '-c') {
+ $copy_dbg = 1;
+ }
+ elsif ($arg eq '-a') {
+ @archs = (split(/\s+/, shift));
+ }
}
+
my $dump_syms = shift;
my $symbol_path = shift;
-foreach my $pdbfile (@ARGV) {
- next unless -f $pdbfile;
- my ($sf) = fileparse($pdbfile, ".pdb");
+foreach my $dbgfile (@ARGV) {
+ next unless -f $dbgfile;
+ # get filename without path or .pdb extension, if it exists
+ my ($sf) = fileparse($dbgfile, ".pdb");
my $symfile = $symbol_path . "/" . $sf . ".sym";
- system("$dump_syms $pdbfile > $symfile");
- my $newpath = rename_symbol_file $symfile, $symbol_path;
- if($copy_pdbs && $newpath ne "") {
+ foreach my $arch (@archs) {
+ my $a = '';
+ $a = "-a $arch" if $arch ne '';
+ system("${dump_syms} ${a} ${dbgfile} > ${symfile}");
+ my $newpath = rename_symbol_file $symfile, $symbol_path;
+ if ($copy_dbg && $newpath ne "") {
my $out = $newpath;
$out =~ s/^$symbol_path//;
$out =~ s|^/||;
print "$out/${sf}.pdb\n";
- copy($pdbfile, $newpath);
+ copy($dbgfile, $newpath);
+ }
}
}
--- a/toolkit/xre/Makefile.in
+++ b/toolkit/xre/Makefile.in
@@ -195,16 +195,17 @@ ifeq ($(OS_ARCH),WINNT)
SHARED_LIBRARY_LIBS += \
$(DEPTH)/toolkit/airbag/airbag/src/client/windows/handler/$(LIB_PREFIX)exception_handler_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/airbag/airbag/src/common/windows/$(LIB_PREFIX)breakpad_windows_common_s.$(LIB_SUFFIX)
endif
ifeq ($(OS_ARCH),Darwin)
SHARED_LIBRARY_LIBS += \
$(DEPTH)/toolkit/airbag/airbag/src/client/mac/handler/$(LIB_PREFIX)exception_handler_s.$(LIB_SUFFIX) \
+ $(DEPTH)/toolkit/airbag/airbag/src/common/$(LIB_PREFIX)breakpad_common_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/airbag/airbag/src/common/mac/$(LIB_PREFIX)breakpad_mac_common_s.$(LIB_SUFFIX)
endif
endif
include $(topsrcdir)/config/rules.mk
ifdef BUILD_STATIC_LIBS
export::