Update breakpad prebuilts

main difference: they are now built with
MINIMUM_SEVERITY=SEVERITY_ERROR to reduce stderr noise.

Change-Id: I40051f5ad036e31f7abf0ffa71df877bed2131ea
diff --git a/bin/core2md b/bin/core2md
index b1489f7..0acb795 100755
--- a/bin/core2md
+++ b/bin/core2md
Binary files differ
diff --git a/bin/dump_syms b/bin/dump_syms
index 9a5cb4f..9762fdd 100755
--- a/bin/dump_syms
+++ b/bin/dump_syms
Binary files differ
diff --git a/bin/linux_dumper_unittest_helper b/bin/linux_dumper_unittest_helper
index 062fd41..37cbaca 100755
--- a/bin/linux_dumper_unittest_helper
+++ b/bin/linux_dumper_unittest_helper
Binary files differ
diff --git a/bin/microdump_stackwalk b/bin/microdump_stackwalk
index 42a0373..392eaa8 100755
--- a/bin/microdump_stackwalk
+++ b/bin/microdump_stackwalk
Binary files differ
diff --git a/bin/minidump-2-core b/bin/minidump-2-core
index b679d21..b7a5323 100755
--- a/bin/minidump-2-core
+++ b/bin/minidump-2-core
Binary files differ
diff --git a/bin/minidump_dump b/bin/minidump_dump
index 3d65f29..cef95eb 100755
--- a/bin/minidump_dump
+++ b/bin/minidump_dump
Binary files differ
diff --git a/bin/minidump_stackwalk b/bin/minidump_stackwalk
index 297276f..90ec917 100755
--- a/bin/minidump_stackwalk
+++ b/bin/minidump_stackwalk
Binary files differ
diff --git a/bin/minidump_upload b/bin/minidump_upload
index f43bf96..179abb6 100755
--- a/bin/minidump_upload
+++ b/bin/minidump_upload
Binary files differ
diff --git a/bin/sym_upload b/bin/sym_upload
index 87f9491..44699b5 100755
--- a/bin/sym_upload
+++ b/bin/sym_upload
Binary files differ
diff --git a/breakpad.patches b/breakpad.patches
new file mode 100644
index 0000000..02a2859
--- /dev/null
+++ b/breakpad.patches
@@ -0,0 +1,345 @@
+From 0cd07b7ff1672505361e459b7dd8b9cea34890db Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 14:52:34 +0000
+Subject: [PATCH 1/9] Define intptr and uintptr in a more generic way
+
+---
+ src/common/dwarf/types.h | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/src/common/dwarf/types.h b/src/common/dwarf/types.h
+index 61ca457..59dda31 100644
+--- a/src/common/dwarf/types.h
++++ b/src/common/dwarf/types.h
+@@ -45,11 +45,7 @@ typedef unsigned short     uint16;
+ typedef unsigned int       uint32;
+ typedef unsigned long long uint64;
+ 
+-#ifdef __PTRDIFF_TYPE__
+-typedef          __PTRDIFF_TYPE__ intptr;
+-typedef unsigned __PTRDIFF_TYPE__ uintptr;
+-#else
+-#error "Can't find pointer-sized integral types."
+-#endif
++typedef intptr_t           intptr;
++typedef uintptr_t          uintptr;
+ 
+ #endif // _COMMON_DWARF_TYPES_H__
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From 231eec7e70d0a2ee3ebef86f9b7111d238a1ff3c Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 14:54:00 +0000
+Subject: [PATCH 2/9] Remove unused include
+
+---
+ src/processor/disassembler_x86.cc | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/processor/disassembler_x86.cc b/src/processor/disassembler_x86.cc
+index 9eba848..55902240 100644
+--- a/src/processor/disassembler_x86.cc
++++ b/src/processor/disassembler_x86.cc
+@@ -27,7 +27,6 @@
+ #include "processor/disassembler_x86.h"
+ 
+ #include <string.h>
+-#include <unistd.h>
+ 
+ namespace google_breakpad {
+ 
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From d2877788fdca7d4f2b800b150154094c63889549 Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 14:54:57 +0000
+Subject: [PATCH 3/9] Undefine MSVC macro to get code compiling
+
+---
+ src/processor/exploitability_win.cc | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/processor/exploitability_win.cc b/src/processor/exploitability_win.cc
+index a1f8703..b044265 100644
+--- a/src/processor/exploitability_win.cc
++++ b/src/processor/exploitability_win.cc
+@@ -46,6 +46,10 @@
+ 
+ #include "third_party/libdisasm/libdis.h"
+ 
++#ifdef exception_code
++#undef exception_code
++#endif
++
+ namespace google_breakpad {
+ 
+ // The cutoff that we use to judge if and address is likely an offset
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From 4498332f11710f391dbeea110b926d267c84a881 Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 14:57:23 +0000
+Subject: [PATCH 4/9] Don't depend on sizeof(void)
+
+---
+ src/third_party/libdisasm/x86_disasm.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/third_party/libdisasm/x86_disasm.c b/src/third_party/libdisasm/x86_disasm.c
+index 51a213a..1b82f4e 100644
+--- a/src/third_party/libdisasm/x86_disasm.c
++++ b/src/third_party/libdisasm/x86_disasm.c
+@@ -35,7 +35,7 @@ unsigned int x86_disasm( unsigned char *buf, unsigned int buf_len,
+ 
+         if ( offset >= buf_len ) {
+                 /* another caller screwup ;) */
+-                x86_report_error(report_disasm_bounds, (void*)(long)buf_rva+offset);
++                x86_report_error(report_disasm_bounds, (void*)(long)(buf_rva+offset));
+                 return 0;
+         }
+ 
+@@ -53,13 +53,13 @@ unsigned int x86_disasm( unsigned char *buf, unsigned int buf_len,
+ 
+         /* check and see if we had an invalid instruction */
+         if (! size ) {
+-                x86_report_error(report_invalid_insn, (void*)(long)buf_rva+offset );
++                x86_report_error(report_invalid_insn, (void*)(long)(buf_rva+offset));
+                 return 0;
+         }
+ 
+         /* check if we overran the end of the buffer */
+         if ( size > len ) {
+-                x86_report_error( report_insn_bounds, (void*)(long)buf_rva + offset );
++                x86_report_error( report_insn_bounds, (void*)(long)(buf_rva + offset));
+ 		MAKE_INVALID( insn, bytes );
+ 		return 0;
+ 	}
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From f2924671f89ae5ac9304ff07564fb454e272d39a Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 15:05:34 +0000
+Subject: [PATCH 5/9] snprintf fixes for MSVC
+
+---
+ src/processor/minidump_processor.cc     | 4 ++++
+ src/processor/stackwalk_common.cc       | 6 ++++++
+ src/processor/symbolic_constants_win.cc | 6 +++++-
+ 3 files changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/src/processor/minidump_processor.cc b/src/processor/minidump_processor.cc
+index 3a20dfa..5c9d191 100644
+--- a/src/processor/minidump_processor.cc
++++ b/src/processor/minidump_processor.cc
+@@ -45,6 +45,10 @@
+ #include "processor/stackwalker_x86.h"
+ #include "processor/symbolic_constants_win.h"
+ 
++#ifdef _MSC_VER
++#define snprintf _snprintf
++#endif
++
+ namespace google_breakpad {
+ 
+ MinidumpProcessor::MinidumpProcessor(SymbolSupplier *supplier,
+diff --git a/src/processor/stackwalk_common.cc b/src/processor/stackwalk_common.cc
+index 3a6e17f..836a980 100644
+--- a/src/processor/stackwalk_common.cc
++++ b/src/processor/stackwalk_common.cc
+@@ -52,6 +52,12 @@
+ #include "processor/logging.h"
+ #include "processor/pathname_stripper.h"
+ 
++#ifdef _MSC_VER
++#include <basetsd.h>
++#define snprintf _snprintf
++#define ssize_t SSIZE_T
++#endif
++
+ namespace google_breakpad {
+ 
+ namespace {
+diff --git a/src/processor/symbolic_constants_win.cc b/src/processor/symbolic_constants_win.cc
+index 333aa04..dcc0842 100644
+--- a/src/processor/symbolic_constants_win.cc
++++ b/src/processor/symbolic_constants_win.cc
+@@ -40,6 +40,10 @@
+ #include "google_breakpad/common/minidump_exception_win32.h"
+ #include "processor/symbolic_constants_win.h"
+ 
++#ifdef _MSC_VER
++#define snprintf _snprintf
++#endif
++
+ namespace google_breakpad {
+ 
+ std::string NTStatusToString(uint32_t ntstatus) {
+@@ -6406,7 +6410,7 @@ std::string NTStatusToString(uint32_t ntstatus) {
+       break;
+     default: {
+       char reason_string[11];
+-      std::snprintf(reason_string, sizeof(reason_string), "0x%08x", ntstatus);
++      snprintf(reason_string, sizeof(reason_string), "0x%08x", ntstatus);
+       reason = reason_string;
+       break;
+     }
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From 903316ffb5cff18eae9846f81947ced0e04f57bc Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 15:07:23 +0000
+Subject: [PATCH 6/9] Add dependencies on build/common.gypi
+
+---
+ src/processor/processor.gyp             | 1 +
+ src/third_party/libdisasm/libdisasm.gyp | 3 +++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/src/processor/processor.gyp b/src/processor/processor.gyp
+index fb3d7cd..8d81652 100644
+--- a/src/processor/processor.gyp
++++ b/src/processor/processor.gyp
+@@ -28,6 +28,7 @@
+ 
+ {
+   'includes': [
++    '../build/common.gypi',
+     'processor_tools.gypi',
+   ],
+   'targets': [
+diff --git a/src/third_party/libdisasm/libdisasm.gyp b/src/third_party/libdisasm/libdisasm.gyp
+index c48ac82..5c8dc45 100644
+--- a/src/third_party/libdisasm/libdisasm.gyp
++++ b/src/third_party/libdisasm/libdisasm.gyp
+@@ -27,6 +27,9 @@
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ 
+ {
++  'includes': [
++    '../../build/common.gypi',
++  ],
+   'targets': [
+     {
+       'target_name': 'libdisasm',
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From c3bffe4af98340d1c580c26c5d6b19d7dd29e727 Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 15:08:18 +0000
+Subject: [PATCH 7/9] Update processor.gyp: add/remove new/old files
+
+---
+ src/processor/processor.gyp | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/processor/processor.gyp b/src/processor/processor.gyp
+index 8d81652..2c76925 100644
+--- a/src/processor/processor.gyp
++++ b/src/processor/processor.gyp
+@@ -43,8 +43,6 @@
+         'basic_code_modules.h',
+         'basic_source_line_resolver.cc',
+         'basic_source_line_resolver_types.h',
+-        'binarystream.cc',
+-        'binarystream.h',
+         'call_stack.cc',
+         'cfi_frame_info-inl.h',
+         'cfi_frame_info.cc',
+@@ -79,6 +77,7 @@
+         'pathname_stripper.h',
+         'postfix_evaluator-inl.h',
+         'postfix_evaluator.h',
++	'proc_maps_linux.cc',
+         'process_state.cc',
+         'range_map-inl.h',
+         'range_map.h',
+@@ -144,7 +143,6 @@
+       'sources': [
+         'address_map_unittest.cc',
+         'basic_source_line_resolver_unittest.cc',
+-        'binarystream_unittest.cc',
+         'cfi_frame_info_unittest.cc',
+         'contained_range_map_unittest.cc',
+         'disassembler_x86_unittest.cc',
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From 45b0f73cc376b410064818ed542eab87f14fb7c0 Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 15:09:05 +0000
+Subject: [PATCH 8/9] Conditionally compile code for given platforms
+
+---
+ src/common/common.gyp | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/common/common.gyp b/src/common/common.gyp
+index 5a666de..96e1bce 100644
+--- a/src/common/common.gyp
++++ b/src/common/common.gyp
+@@ -35,6 +35,11 @@
+       ['OS=="linux"', {
+         'defines': ['HAVE_A_OUT_H'],
+       }],
++      ['OS!="android"', {'sources/': [['exclude', 'android/']]}],
++      ['OS!="linux"',   {'sources/': [['exclude', 'linux/'  ]]}],
++      ['OS!="mac"',     {'sources/': [['exclude', 'mac/'    ]]}],
++      ['OS!="solaris"', {'sources/': [['exclude', 'solaris/']]}],
++      ['OS!="win"',     {'sources/': [['exclude', 'windows/']]}],
+     ],
+   },
+   'targets': [
+-- 
+2.6.0.rc2.230.g3dd15c0
+
+From b829e2e56f2c51b4bec858e6d0087a9347eeb7cd Mon Sep 17 00:00:00 2001
+From: Pavel Labath <labath@google.com>
+Date: Tue, 17 Nov 2015 15:09:41 +0000
+Subject: [PATCH 9/9] Remove files which just don't compile on windows
+
+---
+ src/common/common.gyp | 8 --------
+ 1 file changed, 8 deletions(-)
+
+diff --git a/src/common/common.gyp b/src/common/common.gyp
+index 96e1bce..22941e3 100644
+--- a/src/common/common.gyp
++++ b/src/common/common.gyp
+@@ -81,8 +81,6 @@
+         'dwarf/types.h',
+         'dwarf_cfi_to_module.cc',
+         'dwarf_cfi_to_module.h',
+-        'dwarf_cu_to_module.cc',
+-        'dwarf_cu_to_module.h',
+         'dwarf_line_to_module.cc',
+         'dwarf_line_to_module.h',
+         'language.cc',
+@@ -163,10 +161,6 @@
+         'solaris/guid_creator.cc',
+         'solaris/guid_creator.h',
+         'solaris/message_output.h',
+-        'stabs_reader.cc',
+-        'stabs_reader.h',
+-        'stabs_to_module.cc',
+-        'stabs_to_module.h',
+         'string_conversion.cc',
+         'string_conversion.h',
+         'symbol_data.h',
+@@ -179,8 +173,6 @@
+         'windows/dia_util.h',
+         'windows/guid_string.cc',
+         'windows/guid_string.h',
+-        'windows/http_upload.cc',
+-        'windows/http_upload.h',
+         'windows/omap.cc',
+         'windows/omap.h',
+         'windows/omap_internal.h',
+-- 
+2.6.0.rc2.230.g3dd15c0
+
diff --git a/build-breakpad.sh b/build-breakpad.sh
index e8e7485..7f522ca 100755
--- a/build-breakpad.sh
+++ b/build-breakpad.sh
@@ -3,7 +3,7 @@
 # works on Linux, OS X and Windows
 # leaves output in /tmp/prebuilts/google-breakpad/$OS-x86
 
-build_and_install()
+build_and_install_MSVC()
 {
 	solution=$1
 	project=$2
@@ -13,13 +13,28 @@
 		project_switch="/Project $project"
 	fi
 
-	$RD/gyp/gyp --no-circular-check $solution.gyp
-	_CL_=/MDd devenv.com $solution.sln /Build Debug $project_switch
-	_CL_=/MD devenv.com $solution.sln /Build Release $project_switch
-	for build in Debug Release; do
-		find $build -name '*.exe' -exec cp -va -t $INSTALL/$build {} +
-		find $build -name '*.lib' -exec cp -va -t $INSTALL/$build {} +
-	done
+        $RD/gyp/gyp --no-circular-check --no-duplicate-basename-check $solution.gyp
+        (
+                export CL="/DBPLOG_MINIMUM_SEVERITY=SEVERITY_ERROR \"$VS120COMNTOOLS\\..\\..\\DIA SDK\\include\""
+                _CL_="/MDd /WX-" devenv $solution.sln /Build Debug $project_switch
+                _CL_="/MD /WX-" devenv $solution.sln /Build Release $project_switch
+        )
+        for build in Debug Release; do
+                find $build -name '*.exe' -exec cp -va -t $INSTALL/$build {} +
+                find $build -name '*.lib' -exec cp -va -t $INSTALL/$build {} +
+        done
+}
+
+build_and_install_configure()
+{
+        mkdir $RD/build
+        cd $RD/build
+        local defines="-DBPLOG_MINIMUM_SEVERITY=SEVERITY_ERROR"
+        export CFLAGS="$CFLAGS $defines"
+        export CXXFLAGS="$CXXFLAGS $defines"
+        ../sources/configure --prefix=/
+        make -j$CORES
+        make install-strip DESTDIR=$INSTALL
 }
 
 install_headers()
@@ -36,12 +51,21 @@
 
 MSVS=2013
 
-source $(dirname "$0")/build-common.sh build-common.sh
+source $(dirname "$0")/build-common.sh "$@"
 
 git clone https://chromium.googlesource.com/breakpad/breakpad --no-checkout sources
 cd sources
 git checkout $VER
 
+# This commit fixes dump_syms on mac. We can't just fast-forward to this commit
+# yet, one of the later commits breaks "make install" on linux.
+# TODO(labath): Fix make install upstream, so we can update properly here.
+git cherry-pick cc7b69a8
+
+# these patches make it possible to build minidump_stackwalk on windows
+# TODO(labath): Upstream these patches, so that we don't need to patch it locally
+git am "$SCRIPT_DIR/breakpad.patches"
+
 cd src/third_party
 git clone https://chromium.googlesource.com/linux-syscall-support --no-checkout lss
 cd lss
@@ -55,29 +79,30 @@
 
 case "$OS" in
 	linux)
-		mkdir build
-		cd build
-		../sources/configure --prefix=/
-		make -j$CORES
-		make install DESTDIR=$INSTALL
+                build_and_install_configure
 
-                # make install does not actually install all the headers. Let's finish the job
-                # for him.
-                # TODO: This can be removed when the upstream installation patch lands
-                install_headers
-        ;;
-        darwin)
-                cd $RD/sources/src/tools/mac/dump_syms
-                xcodebuild -project dump_syms.xcodeproj -configuration Release -target dump_syms -sdk macosx10.9 GCC_VERSION= GCC_TREAT_WARNINGS_AS_ERRORS=no
-                mkdir $INSTALL/bin
-                cp build/Release/dump_syms $INSTALL/bin
+		# make install does not actually install all the headers. Let's finish the job
+		# for him.
+		# TODO: This can be removed when the upstream installation patch lands
+		install_headers
+	;;
+	darwin)
+		cd $RD/sources/src/tools/mac/dump_syms
+		xcodebuild -project dump_syms.xcodeproj -configuration Release -target dump_syms -sdk macosx10.9 GCC_VERSION= GCC_TREAT_WARNINGS_AS_ERRORS=no
+		mkdir $INSTALL/bin
+		cp build/Release/dump_syms $INSTALL/bin
 
-                cd $RD/sources/src/client/mac
-                xcodebuild -project Breakpad.xcodeproj -configuration Release -target Breakpad -sdk macosx10.9 GCC_VERSION=
-                install_name_tool -id @executable_path/../Breakpad.framework/Resources/breakpadUtilities.dylib build/Release/breakpadUtilities.dylib
-                install_name_tool -id @executable_path/../Breakpad.framework/Breakpad build/Release/Breakpad.framework/Breakpad
-                install_name_tool -change @executable_path/../Frameworks/Breakpad.framework/Resources/breakpadUtilities.dylib @executable_path/../Breakpad.framework/Resources/breakpadUtilities.dylib build/Release/Breakpad.framework/Breakpad
-                cp -r build/Release/Breakpad.framework $INSTALL
+		cd $RD/sources/src/client/mac
+		xcodebuild -project Breakpad.xcodeproj -configuration Release -target Breakpad -sdk macosx10.9 GCC_VERSION=
+		install_name_tool -id @executable_path/../Breakpad.framework/Resources/breakpadUtilities.dylib build/Release/breakpadUtilities.dylib
+		install_name_tool -id @executable_path/../Breakpad.framework/Breakpad build/Release/Breakpad.framework/Breakpad
+		install_name_tool -change @executable_path/../Frameworks/Breakpad.framework/Resources/breakpadUtilities.dylib @executable_path/../Breakpad.framework/Resources/breakpadUtilities.dylib build/Release/Breakpad.framework/Breakpad
+		cp -r build/Release/Breakpad.framework $INSTALL
+
+                # for minidump_stackwalk
+                build_and_install_configure
+                # libbreakpad.a built by configure is unusable
+                rm $INSTALL/lib/libbreakpad.a
 
 		install_headers
 	;;
@@ -85,22 +110,25 @@
 		mkdir $INSTALL/Release $INSTALL/Debug
 
 		cd $RD/sources/src/client/windows/handler
-		build_and_install exception_handler exception_handler
+		build_and_install_MSVC exception_handler exception_handler
 
 		cd $RD/sources/src/client/windows/crash_generation
-		build_and_install crash_generation crash_generation_client
+		build_and_install_MSVC crash_generation crash_generation_client
 
 		cd $RD/sources/src/common/windows
-		build_and_install common_windows common_windows_lib
+		build_and_install_MSVC common_windows common_windows_lib
 
 		cd $RD/sources/src/tools/windows/dump_syms
-		build_and_install dump_syms dump_syms
+		build_and_install_MSVC dump_syms dump_syms
 
 		cd $RD/sources/src/tools/windows/symupload
-		build_and_install symupload symupload
+		build_and_install_MSVC symupload symupload
 
-		install_headers
+                cd $RD/sources/src/processor
+                build_and_install_MSVC processor minidump_stackwalk
+
+                install_headers
 	;;
 esac
 
-commit_and_push
+finalize_build
diff --git a/build-common.sh b/build-common.sh
index 0f252ea..e25bfc9 100755
--- a/build-common.sh
+++ b/build-common.sh
@@ -1,62 +1,97 @@
 # latest version of this file can be found at
-# https://android.googlesource.com/platform/external/lldb-utils
+# sso://googleplex-android/platform/external/lldb-utils
 #
 # inputs
-# $PROJ - project name (cmake|ninja|swig)
+# $PROJ - project name
 # $VER - project version
-# $1 - name of this file
+# $1 - (temporary) output directory
+# $2 - build directory for build artefacts
+# $3 - build number
 #
 # this file does the following:
 #
 # 1) define the following env vars
 #    OS - linux|darwin|windows
-#    USER - username
 #    CORES - numer of cores (for parallel builds)
 #    PATH (with appropriate compilers)
 #    CFLAGS/CXXFLAGS/LDFLAGS
 #    RD - root directory for source and object files
-#    INSTALL - install directory/git repo root
-#    SCRIPT_FILE=absolute path to the parent build script
-#    SCRIPT_DIR=absolute path to the parent build script's directory
-#    COMMON_FILE=absolute path to this file
-# 2) create an empty tmp directory at /tmp/$PROJ-$USER
-# 3) checkout the destination git repo to /tmp/prebuilts/$PROJ/$OS-x86/$VER
-# 4) cd $RD
+#    INSTALL - install directory
+#    SCRIPT_FILE - absolute path to the parent build script
+#    SCRIPT_DIR - absolute path to the parent build script's directory
+#    COMMON_FILE - absolute path to this file
+# 2) cd $RD
+#
+# after placing all your build products into $INSTALL you should call finalize_build to produce
+# the final build artifact
+
+# exit on error
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd -P)"
+SCRIPT_FILE="$SCRIPT_DIR/$(basename "${BASH_SOURCE[1]}")"
+COMMON_FILE="$SCRIPT_DIR/$(basename "${BASH_SOURCE[0]}")"
+
+# calculate the root directory from the script path
+# this script lives three directories down from the root
+# external/lldb-utils/prebuilts/build-common.sh
+ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd -P)"
+cd "$ROOT_DIR"
+
+function die() {
+	echo "$*" > /dev/stderr
+	echo "Usage: $0 <out_dir> <dest_dir> <build_number>" > /dev/stderr
+	exit 1
+}
+
+(($# > 3)) && die "[$0] Unknown parameter: $4"
+
+OUT="$1"
+DEST="$2"
+BNUM="$3"
+
+[ ! "$OUT"  ] && die "## Error: Missing out folder"
+[ ! "$DEST" ] && die "## Error: Missing destination folder"
+[ ! "$BNUM" ] && die "## Error: Missing build number"
+
+mkdir -p "$OUT" "$DEST"
+OUT="$(cd "$OUT" && pwd -P)"
+DEST="$(cd "$DEST" && pwd -P)"
+
+cat <<END_INFO
+## Building $PROJ ##
+## Out Dir  : $OUT
+## Dest Dir : $DEST
+## Build Num: $BNUM
+
+END_INFO
 
 UNAME="$(uname)"
+UPSTREAM=sso://googleplex-android/platform/prebuilts
 case "$UNAME" in
 Linux)
-    SCRATCH=/tmp
     OS='linux'
     INSTALL_VER=$VER
     ;;
 Darwin)
-    SCRATCH=/tmp
     OS='darwin'
-    OSX_MIN=10.6
+    OSX_MIN=10.8
+    export CC=clang
+    export CXX=$CC++
     export CFLAGS="$CFLAGS -mmacosx-version-min=$OSX_MIN"
-    export CXXFLAGS="$CXXFLAGS -mmacosx-version-min=$OSX_MIN"
+    export CXXFLAGS="$CXXFLAGS -mmacosx-version-min=$OSX_MIN -stdlib=libc++"
     export LDFLAGS="$LDFLAGS -mmacosx-version-min=$OSX_MIN"
     INSTALL_VER=$VER
     ;;
 *_NT-*)
-    if [[ "$UNAME" == CYGWIN_NT-* ]]; then
-        PATH_PREFIX=/cygdrive
-    else
-        # MINGW32_NT-*
-        PATH_PREFIX=
-    fi
-    SCRATCH=/tmp
-    USER=$USERNAME
     OS='windows'
     CORES=$NUMBER_OF_PROCESSORS
     # VS2013 x64 Native Tools Command Prompt
     case "$MSVS" in
     2013)
-        export PATH="$PATH_PREFIX/c/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64/":"$PATH_PREFIX/c/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/":"$PATH"
-        export INCLUDE="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\INCLUDE;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\shared;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\um;C:\\Program Files (x86)\\Windows Kits\\8.1\\include\\winrt;"
-        export LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64;"
-        export LIBPATH="C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\ATLMFC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\8.1\\References\\CommonConfiguration\\Neutral;C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\ExtensionSDKs\\Microsoft.VCLibs\\12.0\\References\\CommonConfiguration\\neutral;"
+        devenv() {
+            cmd /c "${VS120COMNTOOLS}VsDevCmd.bat" '&' devenv.com "$@"
+        }
         INSTALL_VER=${VER}_${MSVS}
         ;;
     *)
@@ -72,18 +107,9 @@
     ;;
 esac
 
-RD=$SCRATCH/$PROJ-$USER
+RD=$OUT/$PROJ
 INSTALL="$RD/install"
 
-# OSX lacks a "realpath" bash command
-realpath() {
-    [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
-}
-
-SCRIPT_FILE=$(realpath "$0")
-SCRIPT_DIR="$(dirname "$SCRIPT_FILE")"
-COMMON_FILE="$SCRIPT_DIR/$1"
-
 cd /tmp # windows can't delete if you're in the dir
 rm -rf $RD
 mkdir -p $INSTALL
@@ -93,41 +119,30 @@
 # clone prebuilt gcc
 case "$OS" in
 linux)
-    GCC_DIR=$RD/gcc
-    GCC_LIB=$GCC_DIR/lib/gcc/x86_64-linux/4.8 # crtbegin.o and libgcc.a
-    GCC_LIB2=$GCC_DIR/x86_64-linux/lib64 # libgcc_s.so
-
     # can't get prebuilt clang working so we're using host clang-3.5 https://b/22748915
+    #CLANG_DIR=$RD/clang
+    #git clone $UPSTREAM/clang/linux-x86/host/3.6 $CLANG_DIR
+    #export CC="$CLANG_DIR/bin/clang"
+    #export CXX="$CC++"
     export CC=clang-3.5
     export CXX=clang++-3.5
-    export CFLAGS="$CFLAGS -fuse-ld=gold --sysroot $GCC_DIR/sysroot -B$GCC_LIB"
-    export CXXFLAGS="$CFLAGS -Ix86_64-linux/include/c++/4.8 -Ix86_64-linux/include/x86_64-linux/c++/4.8"
-    export LDFLAGS="$LDFLAGS -m64 --sysroot $GCC_DIR/sysroot -L$GCC_LIB -L$GCC_LIB2"
-    # lldb uses at least one function from glibc2.12
-    git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 $GCC_DIR
+
+    GCC_DIR=$RD/gcc
+    git clone $UPSTREAM/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 $GCC_DIR
+
+    find "$GCC_DIR" -name x86_64-linux -exec ln -fns {} {}-gnu \;
+
+    FLAGS+=(-fuse-ld=gold)
+    FLAGS+=(--gcc-toolchain="$GCC_DIR")
+    FLAGS+=(--sysroot "$GCC_DIR/sysroot")
+    FLAGS+=(-B"$GCC_DIR/bin/x86_64-linux-")
+    export CFLAGS="$CFLAGS ${FLAGS[*]}"
+    export CXXFLAGS="$CXXFLAGS ${FLAGS[*]}"
+    export LDFLAGS="$LDFLAGS -m64"
     ;;
 esac
 
-commit_and_push()
-{
-    # check into a local git clone
-    rm -rf $SCRATCH/prebuilts/$PROJ/
-    mkdir -p $SCRATCH/prebuilts/$PROJ/
-    cd $SCRATCH/prebuilts/$PROJ/
-    git clone persistent-https://googleplex-android.git.corp.google.com/platform/prebuilts/$PROJ/$OS-x86 --no-checkout
-    GIT_REPO="$SCRATCH/prebuilts/$PROJ/$OS-x86"
-    cd $GIT_REPO
-    git checkout lldb-master-dev
-    git rm -r * || true  # ignore error caused by empty directory
-    mv $INSTALL/* $GIT_REPO
-    cp $SCRIPT_FILE $GIT_REPO
-    cp $COMMON_FILE $GIT_REPO
-
-    git add .
-    git commit -m "Adding binaries for $INSTALL_VER"
-
-    # execute this command to upload
-    #git push origin HEAD:refs/for/master
-
-    rm -rf $RD || true  # ignore error
+function finalize_build() {
+    cp "$SCRIPT_FILE" "$COMMON_FILE" "$INSTALL"
+    (cd "$INSTALL" && zip --symlinks -r "$DEST/$PROJ-$BNUM.zip" .)
 }
diff --git a/include/breakpad/common/dwarf/types.h b/include/breakpad/common/dwarf/types.h
index 61ca457..59dda31 100644
--- a/include/breakpad/common/dwarf/types.h
+++ b/include/breakpad/common/dwarf/types.h
@@ -45,11 +45,7 @@
 typedef unsigned int       uint32;
 typedef unsigned long long uint64;
 
-#ifdef __PTRDIFF_TYPE__
-typedef          __PTRDIFF_TYPE__ intptr;
-typedef unsigned __PTRDIFF_TYPE__ uintptr;
-#else
-#error "Can't find pointer-sized integral types."
-#endif
+typedef intptr_t           intptr;
+typedef uintptr_t          uintptr;
 
 #endif // _COMMON_DWARF_TYPES_H__
diff --git a/lib/libbreakpad.a b/lib/libbreakpad.a
index 61edcdb..47e6776 100644
--- a/lib/libbreakpad.a
+++ b/lib/libbreakpad.a
Binary files differ
diff --git a/lib/libbreakpad_client.a b/lib/libbreakpad_client.a
index 91e15ce..d39bcdf 100644
--- a/lib/libbreakpad_client.a
+++ b/lib/libbreakpad_client.a
Binary files differ