[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3283: Add some CMake fu for building with Google Breakpad and my s (in vidalia/branches/breakpad: . cmake src/vidalia)
Author: edmanm
Date: 2008-11-02 23:17:29 -0500 (Sun, 02 Nov 2008)
New Revision: 3283
Added:
vidalia/branches/breakpad/cmake/FindBreakpad.cmake
Modified:
vidalia/branches/breakpad/CMakeLists.txt
vidalia/branches/breakpad/src/vidalia/CMakeLists.txt
vidalia/branches/breakpad/src/vidalia/main.cpp
Log:
Add some CMake fu for building with Google Breakpad and my
stub minidump handler.
Modified: vidalia/branches/breakpad/CMakeLists.txt
===================================================================
--- vidalia/branches/breakpad/CMakeLists.txt 2008-11-03 04:06:03 UTC (rev 3282)
+++ vidalia/branches/breakpad/CMakeLists.txt 2008-11-03 04:17:29 UTC (rev 3283)
@@ -75,6 +75,12 @@
## UPnP support is currently optional (enabled by default)
option(USE_MINIUPNPC "Enable UPnP support using the MiniUPnPc library." ON)
+## Crash reporting via Google Breakpad is optional (disabled by default)
+option(USE_BREAKPAD "Enable Google Breakpad crash reporting." OFF)
+if (USE_BREAKPAD)
+ include(${CMAKE_SOURCE_DIR}/cmake/FindBreakpad.cmake)
+endif(USE_BREAKPAD)
+
## Check for system header files
check_include_file("limits.h" HAVE_LIMITS_H)
check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
Added: vidalia/branches/breakpad/cmake/FindBreakpad.cmake
===================================================================
--- vidalia/branches/breakpad/cmake/FindBreakpad.cmake (rev 0)
+++ vidalia/branches/breakpad/cmake/FindBreakpad.cmake 2008-11-03 04:17:29 UTC (rev 3283)
@@ -0,0 +1,42 @@
+##
+## $Id$
+##
+## This file is part of Vidalia, and is subject to the license terms in the
+## LICENSE file, found in the top level directory of this distribution. If
+## you did not receive the LICENSE file with this file, you may obtain it
+## from the Vidalia source package distributed by the Vidalia Project at
+## http://www.vidalia-project.net/. No part of Vidalia, including this file,
+## may be copied, modified, propagated, or distributed except according to
+## the terms described in the LICENSE file.
+##
+
+## Tries to find the required Google Breakpad libraries. Once done this will
+## define the variable BREAKPAD_LIBRARIES.
+
+message(STATUS "Looking for Google Breakpad libraries")
+if (MSVC)
+ find_library(BREAKPAD_EXCEPTION_HANDLER_LIB
+ NAMES exception_handler
+ PATHS ${BREAKPAD_LIBRARY_DIR}
+ )
+ if (NOT BREAKPAD_EXCEPTION_HANDLER_LIB)
+ message(FATAL_ERROR
+ "Could not find Breakpad exception handler library")
+ endif(NOT BREAKPAD_EXCEPTION_HANDLER_LIB)
+
+ find_library(BREAKPAD_CRASH_GENERATION_LIB
+ NAMES crash_generation
+ PATHS ${BREAKPAD_LIBRARY_DIR}
+ )
+ if (NOT BREAKPAD_CRASH_GENERATION_LIB)
+ message(FATAL_ERROR
+ "Could not find Breakpad crash generation library")
+ endif(NOT BREAKPAD_CRASH_GENERATION_LIB)
+
+ set(BREAKPAD_LIBRARIES
+ ${BREAKPAD_EXCEPTION_HANDLER_LIB}
+ ${BREAKPAD_CRASH_GENERATION_LIB}
+ )
+ message(STATUS "Looking for Google Breakpad libraries - found")
+endif(MSVC)
+
Property changes on: vidalia/branches/breakpad/cmake/FindBreakpad.cmake
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: vidalia/branches/breakpad/src/vidalia/CMakeLists.txt
===================================================================
--- vidalia/branches/breakpad/src/vidalia/CMakeLists.txt 2008-11-03 04:06:03 UTC (rev 3282)
+++ vidalia/branches/breakpad/src/vidalia/CMakeLists.txt 2008-11-03 04:17:29 UTC (rev 3283)
@@ -17,6 +17,10 @@
${CMAKE_CURRENT_SOURCE_DIR}/config
${CMAKE_CURRENT_SOURCE_DIR}/help/browser
)
+if (USE_BREAKPAD AND BREAKPAD_INCLUDE_DIR)
+ include_directories(${BREAKPAD_INCLUDE_DIR})
+endif(USE_BREAKPAD AND BREAKPAD_INCLUDE_DIR)
+
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/res/vidalia_win.rc.in
${CMAKE_CURRENT_SOURCE_DIR}/res/vidalia_win.rc
@@ -275,6 +279,9 @@
if (USE_MINIUPNPC)
target_link_libraries(${vidalia_BIN} miniupnpc)
endif(USE_MINIUPNPC)
+if (USE_BREAKPAD)
+ target_link_libraries(${vidalia_BIN} ${BREAKPAD_LIBRARIES})
+endif(USE_BREAKPAD)
if (WIN32)
target_link_libraries(${vidalia_BIN}
Modified: vidalia/branches/breakpad/src/vidalia/main.cpp
===================================================================
--- vidalia/branches/breakpad/src/vidalia/main.cpp 2008-11-03 04:06:03 UTC (rev 3282)
+++ vidalia/branches/breakpad/src/vidalia/main.cpp 2008-11-03 04:17:29 UTC (rev 3283)
@@ -25,7 +25,52 @@
#include <QSysInfo>
#endif
+#if defined(USE_BREAKPAD)
+#if defined(Q_OS_WIN32)
+#include <client/windows/handler/exception_handler.h>
+#elif defined(Q_OS_MAC)
+#include <client/mac/handler/exception_handler.h>
+#elif defined(Q_OS_LINUX)
+#include <client/linux/handler/exception_handler.h>
+#elif defined(Q_OS_SOLARIS)
+#include <client/solaris/handler/exception_handler.h>
+#endif
+static google_breakpad::ExceptionHandler *gExceptionHandler = 0;
+#endif
+
+
+#if defined(USE_BREAKPAD)
+static bool
+minidump_callback(const wchar_t *dump, const wchar_t *id, void *context,
+#if defined(Q_OS_WIN32)
+ EXCEPTION_POINTERS *exInfo,
+ MDRawAssertionInfo *assertionInfo,
+#endif
+ bool succeeded)
+{
+ return succeeded;
+}
+#endif
+
+void
+set_exception_handler(const QString &dumpPath)
+{
+#if defined(USE_BREAKPAD)
+ /* XXX: Convert dumpPath to a wchar_t* and pass it to the handler */
+ Q_UNUSED(dumpPath);
+
+ gExceptionHandler = new google_breakpad::ExceptionHandler(
+ L".",
+ NULL,
+ minidump_callback,
+ NULL,
+ google_breakpad::ExceptionHandler::HANDLER_ALL);
+#else
+ Q_UNUSED(dumpPath);
+#endif
+}
+
/** Returns true if there is already another Vidalia process running. */
bool
is_vidalia_running(QString pidfile)
@@ -62,6 +107,9 @@
vNotice("Vidalia %1 using Qt %2").arg(Vidalia::version())
.arg(QT_VERSION_STR);
+ /* Set the location for crash dumps if we're built with Breakpad */
+ set_exception_handler(Vidalia::dataDirectory());
+
/* Validate any command-line arguments, or show usage message box, if
* necessary. */
QString errmsg;