Skip to content

Commit

Permalink
Bug 769048 part C - Build an injector DLL which can watch for crashes…
Browse files Browse the repository at this point in the history
… in Flash player processes. This involves building two copies of breakpad: one to live inside of libxul which uses mozalloc and the dynamic CRT, another to link into the injector which links the CRT statically and doesn't use mozalloc. Introduce a new define/makefile variable MOZ_CRASHREPORTER_INJECTOR rather than repeating "#if defined(XP_WIN) && !defined(HAVE_64BIT_OS) in many places. r=ehsan/khuey

--HG--
extra : rebase_source : 33bd0a74ce70a564963a6ca125e01048577fb554
  • Loading branch information
bsmedberg committed Jul 2, 2012
1 parent 745e24e commit b9aa5ee
Show file tree
Hide file tree
Showing 19 changed files with 182 additions and 123 deletions.
3 changes: 3 additions & 0 deletions browser/installer/package-manifest.in
Expand Up @@ -661,6 +661,9 @@ bin/libfreebl_32int64_3.so
#endif
#endif
@BINPATH@/crashreporter-override.ini
#ifdef MOZ_CRASHREPORTER_INJECTOR
@BINPATH@/breakpadinjector.dll
#endif
#endif

; [Extensions]
Expand Down
1 change: 1 addition & 0 deletions config/autoconf.mk.in
Expand Up @@ -156,6 +156,7 @@ LIBJPEG_TURBO_ARM_ASM = @LIBJPEG_TURBO_ARM_ASM@
NS_PRINTING = @NS_PRINTING@
MOZ_PDF_PRINTING = @MOZ_PDF_PRINTING@
MOZ_CRASHREPORTER = @MOZ_CRASHREPORTER@
MOZ_CRASHREPORTER_INJECTOR = @MOZ_CRASHREPORTER_INJECTOR@
MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@
MOC = @MOC@
RCC = @RCC@
Expand Down
6 changes: 6 additions & 0 deletions configure.in
Expand Up @@ -5890,6 +5890,11 @@ if test -n "$MOZ_CRASHREPORTER"; then
if (test "$OS_ARCH" != "$HOST_OS_ARCH"); then
AC_MSG_ERROR([Breakpad tools do not support compiling on $HOST_OS_ARCH while targeting $OS_ARCH. Use --disable-crashreporter.])
fi

if test "$OS_ARCH" == "WINNT" -a -z "$HAVE_64BIT_OS"; then
MOZ_CRASHREPORTER_INJECTOR=1
AC_DEFINE(MOZ_CRASHREPORTER_INJECTOR)
fi
fi

MOZ_ARG_WITH_STRING(crashreporter-enable-percent,
Expand Down Expand Up @@ -8359,6 +8364,7 @@ AC_SUBST(MOZ_SPELLCHECK)
AC_SUBST(MOZ_JAVA_COMPOSITOR)
AC_SUBST(MOZ_ONLY_TOUCH_EVENTS)
AC_SUBST(MOZ_CRASHREPORTER)
AC_SUBST(MOZ_CRASHREPORTER_INJECTOR)
AC_SUBST(MOZ_MAINTENANCE_SERVICE)
AC_SUBST(MOZ_VERIFY_MAR_SIGNATURE)
AC_SUBST(MOZ_ENABLE_SIGNMAR)
Expand Down
14 changes: 8 additions & 6 deletions toolkit/crashreporter/Makefile.in
Expand Up @@ -14,12 +14,10 @@ LIBXUL_LIBRARY = 1
LIBRARY_NAME = exception_handler_s

ifeq ($(OS_ARCH),WINNT)
DIRS += \
google-breakpad/src/common/windows \
google-breakpad/src/client/windows/handler \
google-breakpad/src/client/windows/sender \
google-breakpad/src/client/windows/crash_generation \
$(NULL)
DIRS += breakpad-windows-libxul
ifdef MOZ_CRASHREPORTER_INJECTOR
DIRS += breakpad-windows-standalone
endif
endif

ifeq ($(OS_ARCH),Darwin)
Expand Down Expand Up @@ -74,6 +72,10 @@ endif

DIRS += client

ifdef MOZ_CRASHREPORTER_INJECTOR
DIRS += injector
endif

LOCAL_INCLUDES = -I$(srcdir)/google-breakpad/src
DEFINES += -DUNICODE -D_UNICODE

Expand Down
41 changes: 41 additions & 0 deletions toolkit/crashreporter/breakpad-windows-libxul/Makefile.in
@@ -0,0 +1,41 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

LIBRARY_NAME = google_breakpad_libxul_s
FORCE_STATIC_LIB = 1

STL_FLAGS =

LOCAL_INCLUDES = -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src

include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/windows/objs.mk
include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/handler/objs.mk
include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/sender/objs.mk
include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation/objs.mk

VPATH += \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/windows \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/handler \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/sender \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation \
$(NULL)

CPPSRCS = \
$(objs_common) \
$(objs_handler) \
$(objs_sender) \
$(objs_crash_generation) \
http_upload.cc \ # required for the libxul version but not standalone
$(NULL)

DEFINES += -DUNICODE -DUNICODE_ -DBREAKPAD_NO_TERMINATE_THREAD -DNOMINMAX

include $(topsrcdir)/config/rules.mk
39 changes: 39 additions & 0 deletions toolkit/crashreporter/breakpad-windows-standalone/Makefile.in
@@ -0,0 +1,39 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

LIBRARY_NAME = google_breakpad_standalone_s
FORCE_STATIC_LIB = 1
USE_STATIC_LIBS = 1
MOZ_GLUE_LDFLAGS =

STL_FLAGS =

LOCAL_INCLUDES = -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src

include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/windows/objs.mk
include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/handler/objs.mk
include $(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation/objs.mk

VPATH += \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/common/windows \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/handler \
$(topsrcdir)/toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation \
$(NULL)

CPPSRCS = \
$(objs_common) \
$(objs_handler) \
$(objs_crash_generation) \
$(NULL)

DEFINES += -DUNICODE -DUNICODE_ -DBREAKPAD_NO_TERMINATE_THREAD -DNOMINMAX

include $(topsrcdir)/config/rules.mk
3 changes: 1 addition & 2 deletions toolkit/crashreporter/client/Makefile.in
Expand Up @@ -37,8 +37,7 @@ CPPSRCS = \
ifeq ($(OS_ARCH),WINNT)
CPPSRCS += crashreporter_win.cpp
LIBS += \
$(DEPTH)/toolkit/crashreporter/google-breakpad/src/client/windows/sender/$(LIB_PREFIX)crash_report_sender_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/windows/$(LIB_PREFIX)breakpad_windows_common_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/crashreporter/breakpad-windows-libxul/$(LIB_PREFIX)google_breakpad_libxul_s.$(LIB_SUFFIX)
$(NULL)
LOCAL_INCLUDES += -I$(srcdir)
RCINCLUDE = crashreporter.rc
Expand Down

This file was deleted.

@@ -0,0 +1,6 @@
objs_crash_generation = \
client_info.cc \
crash_generation_client.cc \
crash_generation_server.cc \
minidump_generator.cc \
$(NULL)

This file was deleted.

@@ -0,0 +1 @@
objs_handler = exception_handler.cc

This file was deleted.

@@ -0,0 +1 @@
objs_sender = crash_report_sender.cc

This file was deleted.

@@ -0,0 +1,4 @@
objs_common = \
guid_string.cc \
string_utils.cc \
$(NULL)
27 changes: 27 additions & 0 deletions toolkit/crashreporter/injector/Makefile.in
@@ -0,0 +1,27 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@

include $(DEPTH)/config/autoconf.mk

LIBRARY_NAME = breakpadinjector
FORCE_SHARED_LIB = 1
USE_STATIC_LIBS = 1
STL_FLAGS =
MOZ_GLUE_LDFLAGS =

CPPSRCS = injector.cpp

SHARED_LIBRARY_LIBS += ../breakpad-windows-standalone/$(LIB_PREFIX)google_breakpad_standalone_s.$(LIB_SUFFIX)

include $(topsrcdir)/config/config.mk
include $(topsrcdir)/ipc/chromium/chromium-config.mk
include $(topsrcdir)/config/rules.mk

LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/crashreporter/google-breakpad/src
LDFLAGS += -ENTRY:DummyEntryPoint
40 changes: 40 additions & 0 deletions toolkit/crashreporter/injector/injector.cpp
@@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include <windows.h>

#include "client/windows/handler/exception_handler.h"

using google_breakpad::ExceptionHandler;
using std::wstring;

BOOL WINAPI DummyEntryPoint(HINSTANCE instance,
DWORD reason,
void* reserved)
{
__debugbreak();

return FALSE; // We're being loaded remotely, this shouldn't happen!
}

// support.microsoft.com/kb/94248
extern "C" BOOL WINAPI _CRT_INIT(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved);

extern "C"
__declspec(dllexport) DWORD Start(void* context)
{
// Because the remote DLL injector does not call DllMain, we have to
// initialize the CRT manually
_CRT_INIT(NULL, DLL_PROCESS_ATTACH, NULL);

HANDLE hCrashPipe = reinterpret_cast<HANDLE>(context);

ExceptionHandler* e = new (std::nothrow)
ExceptionHandler(wstring(), NULL, NULL, NULL,
ExceptionHandler::HANDLER_ALL,
MiniDumpNormal, hCrashPipe, NULL);
if (e)
e->set_handle_debug_exceptions(true);
return 1;
}
7 changes: 3 additions & 4 deletions toolkit/toolkit-makefiles.sh
Expand Up @@ -1148,10 +1148,9 @@ if [ "$MOZ_CRASHREPORTER" ]; then
"
if [ "$OS_ARCH" = "WINNT" ]; then
add_makefiles "
toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation/Makefile
toolkit/crashreporter/google-breakpad/src/client/windows/handler/Makefile
toolkit/crashreporter/google-breakpad/src/client/windows/sender/Makefile
toolkit/crashreporter/google-breakpad/src/common/windows/Makefile
toolkit/crashreporter/breakpad-windows-libxul/Makefile
toolkit/crashreporter/breakpad-windows-standalone/Makefile
toolkit/crashreporter/injector/Makefile
"
elif [ "$OS_ARCH" = "Darwin" ]; then
add_makefiles "
Expand Down
4 changes: 1 addition & 3 deletions toolkit/xre/Makefile.in
Expand Up @@ -128,9 +128,7 @@ ifdef MOZ_CRASHREPORTER
SHARED_LIBRARY_LIBS += $(DEPTH)/toolkit/crashreporter/$(LIB_PREFIX)exception_handler_s.$(LIB_SUFFIX)
ifeq ($(OS_ARCH),WINNT)
SHARED_LIBRARY_LIBS += \
$(DEPTH)/toolkit/crashreporter/google-breakpad/src/client/windows/handler/$(LIB_PREFIX)exception_handler_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/crashreporter/google-breakpad/src/client/windows/crash_generation/$(LIB_PREFIX)crash_generation_s.$(LIB_SUFFIX) \
$(DEPTH)/toolkit/crashreporter/google-breakpad/src/common/windows/$(LIB_PREFIX)breakpad_windows_common_s.$(LIB_SUFFIX)
$(DEPTH)/toolkit/crashreporter/breakpad-windows-libxul/$(LIB_PREFIX)google_breakpad_libxul_s.$(LIB_SUFFIX)
endif

ifeq ($(OS_ARCH),Darwin)
Expand Down

0 comments on commit b9aa5ee

Please sign in to comment.