From 5881505662c068fe22426d1cd2df8c23109e25cb Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Tue, 1 May 2007 16:33:00 -0700 Subject: [PATCH] bug 378463 - build time logic to extract debug symbols on OS X. r=mento --- Makefile.in | 34 ++++++++-- build/macosx/universal/flight.mk | 4 +- toolkit/airbag/Makefile.in | 9 ++- toolkit/airbag/airbag/src/common/Makefile.in | 65 ++++++++++++++++++ .../airbag/airbag/src/common/mac/Makefile.in | 29 ++++---- .../src/tools/mac/dump_syms/Makefile.in | 68 +++++++++++++++++++ toolkit/airbag/tools/make_symbol_store.pl | 64 +++++++++++------ toolkit/xre/Makefile.in | 1 + 8 files changed, 230 insertions(+), 44 deletions(-) create mode 100644 toolkit/airbag/airbag/src/common/Makefile.in create mode 100644 toolkit/airbag/airbag/src/tools/mac/dump_syms/Makefile.in diff --git a/Makefile.in b/Makefile.in index 8b50fda8766..77eab666b39 100644 --- a/Makefile.in +++ b/Makefile.in @@ -134,16 +134,39 @@ ifdef MOZ_PROFILE /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 @@ -162,6 +185,7 @@ ifdef MOZ_AIRBAG endif endif +ifeq ($(OS_ARCH),WINNT) signnss: ifdef MOZILLA_OFFICIAL echo signing NSS libs @@ -169,8 +193,8 @@ ifdef MOZILLA_OFFICIAL 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) diff --git a/build/macosx/universal/flight.mk b/build/macosx/universal/flight.mk index 4cfe5844da2..de1216224a1 100644 --- a/build/macosx/universal/flight.mk +++ b/build/macosx/universal/flight.mk @@ -86,9 +86,9 @@ postflight_all: # 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 diff --git a/toolkit/airbag/Makefile.in b/toolkit/airbag/Makefile.in index 82cda6748fe..ae4050f5cdf 100644 --- a/toolkit/airbag/Makefile.in +++ b/toolkit/airbag/Makefile.in @@ -61,9 +61,12 @@ ifeq ($(OS_ARCH),WINNT) 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 diff --git a/toolkit/airbag/airbag/src/common/Makefile.in b/toolkit/airbag/airbag/src/common/Makefile.in new file mode 100644 index 00000000000..c8f74195f1f --- /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 +# 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 diff --git a/toolkit/airbag/airbag/src/common/mac/Makefile.in b/toolkit/airbag/airbag/src/common/mac/Makefile.in index d01df8f766e..2976798eab5 100644 --- a/toolkit/airbag/airbag/src/common/mac/Makefile.in +++ b/toolkit/airbag/airbag/src/common/mac/Makefile.in @@ -43,24 +43,29 @@ 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 diff --git a/toolkit/airbag/airbag/src/tools/mac/dump_syms/Makefile.in b/toolkit/airbag/airbag/src/tools/mac/dump_syms/Makefile.in new file mode 100644 index 00000000000..2524b23ce23 --- /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 +# 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 diff --git a/toolkit/airbag/tools/make_symbol_store.pl b/toolkit/airbag/tools/make_symbol_store.pl index d76dd8f82a6..553dc6170e3 100755 --- a/toolkit/airbag/tools/make_symbol_store.pl +++ b/toolkit/airbag/tools/make_symbol_store.pl @@ -35,27 +35,33 @@ # # ***** END LICENSE BLOCK ***** # -# Usage: make_symbol_store.pl -# Runs dump_syms on each pdb file specified on the command line, +# Usage: make_symbol_store.pl +# +# 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 -name "*.pdb" | xargs make_symbol_store.pl +# find | xargs make_symbol_store.pl # 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 "" : Run dump_syms -a for each space separated +# cpu architecture in (only on OS X) use FileHandle; use File::Path; use File::Copy; use File::Basename; -print "Usage: make_symbol_store.pl >\n" and exit if scalar @ARGV < 3; +print "Usage: make_symbol_store.pl " . + " \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) = @_; @@ -63,13 +69,15 @@ sub rename_symbol_file 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 $@; @@ -85,24 +93,36 @@ sub rename_symbol_file 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); + } } } diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in index 10091d9e5a1..15d6e8dcbed 100644 --- a/toolkit/xre/Makefile.in +++ b/toolkit/xre/Makefile.in @@ -200,6 +200,7 @@ 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