49 #if defined(Q_OS_WIN32)
50 #include <client/windows/handler/exception_handler.h>
51 #elif defined(Q_OS_MAC)
52 #include <client/mac/handler/exception_handler.h>
55 #elif defined(Q_OS_LINUX)
56 #include <client/linux/handler/exception_handler.h>
59 #elif defined(Q_OS_SOLARIS)
60 #include <client/solaris/handler/exception_handler.h>
64 #include <QStringList>
73 #if defined(Q_OS_WIN32)
76 #define PATH_SEPARATOR TEXT("\\")
77 # ifdef _USE_32BIT_TIME_T
78 # define TIME_TO_STRING(buf, buflen, t) \
79 _ltoa_s(t, buf, buflen, 10)
81 # define TIME_TO_STRING(buf, buflen, t) \
82 _i64toa_s(t, buf, buflen, 10)
87 #define PATH_SEPARATOR "/"
89 #define TIME_TO_STRING(buf, buflen, t) \
90 snprintf(buf, buflen, "%ld", t)
151 const _char_t *s = src;
156 while (n-- != 0 && *d !=
TEXT(
'\0'))
162 #if defined(Q_OS_WIN32)
163 return (dlen + wcslen(s));
165 return(dlen + strlen(s));
168 while (*s !=
TEXT(
'\0')) {
177 return(dlen + (s - src));
187 #if defined(Q_OS_WIN32)
189 WriteFile(hFile, key, strlen(key), &dwWritten, NULL);
190 WriteFile(hFile,
"=", 1, &dwWritten, NULL);
191 WriteFile(hFile, val, strlen(val), &dwWritten, NULL);
192 WriteFile(hFile,
"\n", 1, &dwWritten, NULL);
194 write(hFile, key, strlen(key));
195 write(hFile,
"=", 1);
196 write(hFile, val, strlen(val));
197 write(hFile,
"\n", 1);
212 static const char *KeyBuildVersion =
"BuildVersion";
213 static const char *KeyCrashTime =
"CrashTime";
214 static const char *KeyStartupTime =
"StartupTime";
215 static const char *KeyRestartExecutable =
"RestartExecutable";
216 static const char *KeyRestartExecutableArgs =
"RestartExecutableArgs";
226 #if defined(Q_OS_WIN32)
227 HANDLE hFile = CreateFile(extraInfoPath, GENERIC_WRITE, 0, NULL,
228 CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
229 if (hFile == INVALID_HANDLE_VALUE)
232 _file_handle_t hFile = creat(extraInfoPath, S_IRUSR | S_IWUSR);
238 char crashTimeString[24], startupTimeString[24];
248 #if defined(Q_OS_WIN32)
266 #
if defined(Q_OS_WIN32)
267 EXCEPTION_POINTERS *exInfo,
268 MDRawAssertionInfo *assertionInfo,
272 if (! succeeded || ! showCrashReporter)
279 #if defined(Q_OS_WIN32)
293 PROCESS_INFORMATION pi;
296 ZeroMemory(&pi,
sizeof(pi));
297 ZeroMemory(&si,
sizeof(si));
299 si.dwFlags = STARTF_USESHOWWINDOW;
300 si.wShowWindow = SW_SHOWDEFAULT;
302 BOOL rc = CreateProcess(NULL, (LPWSTR)commandLine, NULL, NULL, FALSE, 0,
303 NULL, NULL, &si, &pi);
305 CloseHandle(pi.hThread);
306 CloseHandle(pi.hProcess);
308 TerminateProcess(GetCurrentProcess(), 1);
324 pid_t
p = fork(), ret;
327 execv(crashReporterExecutable, nargs);
341 QDir dumpDir(dumpPath);
342 if (! dumpDir.exists() && ! dumpDir.mkdir(
"."))
346 exceptionHandler =
new google_breakpad::ExceptionHandler(
347 #
if defined(Q_OS_WIN32)
348 dumpDir.absolutePath().toStdWString(),
350 dumpDir.absolutePath().toStdString(),
355 #if defined(Q_OS_WIN32)
356 google_breakpad::ExceptionHandler::HANDLER_ALL);
360 if (! exceptionHandler)
363 startupTime = time(NULL);
370 if (exceptionHandler) {
372 exceptionHandler = 0;
379 #if defined(Q_OS_WIN32)
381 crashReporter.toWCharArray(crashReporterExecutable);
382 crashReporterExecutable[crashReporter.length()] = L
'\0';
384 QByteArray utf8 = crashReporter.toUtf8();
386 memcpy(crashReporterExecutable, utf8.constData(), utf8.length());
387 crashReporterExecutable[utf8.length()] =
'\0';
389 showCrashReporter =
true;
395 showCrashReporter =
false;
403 QByteArray exe = executable.toUtf8();
411 memcpy(restartExecutable, exe.constData(), exe.length());
412 restartExecutable[exe.length()] =
'\0';
414 memcpy(restartExecutableArgs, args.constData(), args.length());
415 restartExecutableArgs[args.length()] =
'\0';
426 QByteArray ascii = version.toAscii();
427 memcpy(buildVersion, ascii.constData(), ascii.length());
428 buildVersion[ascii.length()] =
'\0';
QString string_format_arguments(const QStringList &args)
bool install_exception_handler(const QString &dumpPath)
static bool showCrashReporter
void remove_exception_handler(void)
static const int MAX_PATH_LEN
static google_breakpad::ExceptionHandler * exceptionHandler
bool minidump_callback(const _char_t *path, const _char_t *id, void *context, bool succeeded)
static time_t startupTime
bool set_crash_reporter(const QString &crashReporter)
bool set_build_version(const QString &version)
static char buildVersion[MAX_VERSION_LEN+1]
static char restartExecutable[MAX_CMD_LEN+1]
static char restartExecutableArgs[MAX_CMD_LEN+1]
static _char_t crashReporterExecutable[MAX_PATH_LEN+1]
static size_t append_string(_char_t *dst, const _char_t *src, size_t siz)
static const int MAX_VERSION_LEN
bool set_restart_options(const QString &executable, const QStringList &arguments)
static const int MAX_CMD_LEN
static bool write_extra_dump_info(const _char_t *path, const _char_t *id, time_t crashTime)
static void write_keyval_to_file(_file_handle_t hFile, const char *key, const char *val)
#define TIME_TO_STRING(buf, buflen, t)