[tor-commits] [vidalia/master] Add breakpad for *nix

chiiph at torproject.org chiiph at torproject.org
Thu May 5 18:53:25 UTC 2011


commit 75d7d200f799919ce144d7618ab646377dbd433a
Author: Tomas Touceda <chiiph at gentoo.org>
Date:   Fri Apr 22 03:11:49 2011 -0300

    Add breakpad for *nix
---
 cmake/FindBreakpad.cmake         |    3 --
 src/crashreporter/CMakeLists.txt |    1 +
 src/vidalia/CMakeLists.txt       |    2 +-
 src/vidalia/CrashReporter.cpp    |   39 ++++++++++++++++++++++++++++++++-----
 src/vidalia/main.cpp             |    2 +
 5 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/cmake/FindBreakpad.cmake b/cmake/FindBreakpad.cmake
index 607d054..c2e622f 100644
--- a/cmake/FindBreakpad.cmake
+++ b/cmake/FindBreakpad.cmake
@@ -43,8 +43,5 @@ if (WIN32)
     message(FATAL_ERROR
             "Breakpad support on Windows currently requires Visual Studio.")
   endif(MSVC)
-else(WIN32)
-  message(FATAL_ERROR
-          "Breakpad support is not currently available on your platform.")
 endif(WIN32)
 
diff --git a/src/crashreporter/CMakeLists.txt b/src/crashreporter/CMakeLists.txt
index f396d9a..8fa72bf 100644
--- a/src/crashreporter/CMakeLists.txt
+++ b/src/crashreporter/CMakeLists.txt
@@ -57,6 +57,7 @@ target_link_libraries(crashreporter
   ${QT_QTCORE_LIBRARY}
   ${QT_QTGUI_LIBRARY}
   ${QT_QTNETWORK_LIBRARY}
+  ${BREAKPAD_LIBRARY}
   common
 )
 if (WIN32)
diff --git a/src/vidalia/CMakeLists.txt b/src/vidalia/CMakeLists.txt
index 15eac34..8d52368 100644
--- a/src/vidalia/CMakeLists.txt
+++ b/src/vidalia/CMakeLists.txt
@@ -467,7 +467,7 @@ if (USE_MINIUPNPC)
   target_link_libraries(${vidalia_BIN} miniupnpc)
 endif(USE_MINIUPNPC)
 if (USE_BREAKPAD)
-  target_link_libraries(${vidalia_BIN} ${BREAKPAD_LIBRARIES})
+  target_link_libraries(${vidalia_BIN} ${BREAKPAD_LIBRARY})
 endif(USE_BREAKPAD)
 if (USE_MARBLE)
   target_link_libraries(${vidalia_BIN}
diff --git a/src/vidalia/CrashReporter.cpp b/src/vidalia/CrashReporter.cpp
index b3a06fe..471632e 100644
--- a/src/vidalia/CrashReporter.cpp
+++ b/src/vidalia/CrashReporter.cpp
@@ -50,8 +50,12 @@
 #include <client/windows/handler/exception_handler.h>
 #elif defined(Q_OS_MAC)
 #include <client/mac/handler/exception_handler.h>
+#include <sys/wait.h>
+#include <fcntl.h>
 #elif defined(Q_OS_LINUX)
 #include <client/linux/handler/exception_handler.h>
+#include <sys/wait.h>
+#include <fcntl.h>
 #elif defined(Q_OS_SOLARIS)
 #include <client/solaris/handler/exception_handler.h>
 #endif
@@ -225,7 +229,10 @@ write_extra_dump_info(const _char_t *path, const _char_t *id, time_t crashTime)
   if (hFile == INVALID_HANDLE_VALUE)
     return false;
 #else
-  /* TODO: Implement for non-Windowses */
+  _file_handle_t hFile = creat(extraInfoPath, S_IRUSR | S_IWUSR);
+  if(hFile == -1) {
+    return false;
+  }
 #endif
   
   char crashTimeString[24], startupTimeString[24];
@@ -241,8 +248,7 @@ write_extra_dump_info(const _char_t *path, const _char_t *id, time_t crashTime)
 #if defined(Q_OS_WIN32)
   CloseHandle(hFile);
 #else
-  /* TODO: Implement for non-Windowses */
-  /* close(hFile); */
+  close(hFile);
 #endif
   return true;
 }
@@ -270,6 +276,7 @@ minidump_callback(const _char_t *path,    // Path to the minidump file
    * restart, and any necessary restart arguments. */
   write_extra_dump_info(path, id, time(NULL));
 
+#if defined(Q_OS_WIN32)
   /* Format the command line used to launch the crash reporter */
   _char_t commandLine[MAX_CMD_LEN] = TEXT("");
   append_string(commandLine, TEXT("\""), MAX_CMD_LEN);
@@ -283,7 +290,6 @@ minidump_callback(const _char_t *path,    // Path to the minidump file
     return false;
 
   /* Launch the crash reporter with the name and location of the minidump */
-#if defined(Q_OS_WIN32)
   PROCESS_INFORMATION pi;
   STARTUPINFOW si;
 
@@ -302,8 +308,29 @@ minidump_callback(const _char_t *path,    // Path to the minidump file
   TerminateProcess(GetCurrentProcess(), 1);
   return true;
 #else
-  /* TODO: Implement for non-Windowses */
-  return false;
+  /* Format the command line used to launch the crash reporter */
+  _char_t args[MAX_CMD_LEN] = TEXT("");
+  size_t len;
+
+  append_string(args, path, MAX_CMD_LEN);
+  append_string(args, PATH_SEPARATOR, MAX_CMD_LEN);
+  append_string(args, id, MAX_CMD_LEN);
+  len = append_string(args, TEXT(".dmp"), MAX_CMD_LEN);
+  if (len >= MAX_CMD_LEN)
+    return false;
+
+  char *nargs[] = {crashReporterExecutable, args, NULL};
+
+  pid_t p = fork(), ret;
+  int status;
+  if(p == 0) {
+    execv(crashReporterExecutable, nargs);
+  } else {
+    ret = wait(&status);
+    if(ret == -1)
+      return false;
+  }
+  return true;
 #endif
 }
 
diff --git a/src/vidalia/main.cpp b/src/vidalia/main.cpp
index acb9d66..7536ebc 100644
--- a/src/vidalia/main.cpp
+++ b/src/vidalia/main.cpp
@@ -43,6 +43,8 @@ setup_crash_reporter()
   QString crashReporter = Vidalia::applicationDirPath() + "\\crashreporter.exe";
 #elif defined(Q_OS_MAC)
   QString crashReporter = Vidalia::applicationDirPath() + "/CrashReporter.app";
+#else
+  QString crashReporter = Vidalia::applicationDirPath() + "/crashreporter";
 #endif
   if (! QFileInfo(crashReporter).isExecutable()) {
     vWarn("Unable to find crash reporting application. Crash reporting will "





More information about the tor-commits mailing list