From 1cb4ad73a6b77f47dbec69dcb5551c16e37d267d Mon Sep 17 00:00:00 2001 From: nealsid Date: Wed, 22 Apr 2009 06:25:21 +0000 Subject: Fix to support extensible parameter handling, and add process crashtime/uptime support R=stuart morgan A=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@331 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/mac/crash_generation/Inspector.h | 2 ++ src/client/mac/crash_generation/Inspector.mm | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'src/client/mac/crash_generation') diff --git a/src/client/mac/crash_generation/Inspector.h b/src/client/mac/crash_generation/Inspector.h index 098c56e8..9ee5c48c 100644 --- a/src/client/mac/crash_generation/Inspector.h +++ b/src/client/mac/crash_generation/Inspector.h @@ -171,6 +171,8 @@ class Inspector { kern_return_t SendAcknowledgement(); void LaunchReporter(const char *inConfigFilePath); + void SetCrashTimeParameters(); + mach_port_t service_rcv_port_; int exception_type_; diff --git a/src/client/mac/crash_generation/Inspector.mm b/src/client/mac/crash_generation/Inspector.mm index b147a860..9ba38538 100644 --- a/src/client/mac/crash_generation/Inspector.mm +++ b/src/client/mac/crash_generation/Inspector.mm @@ -321,6 +321,30 @@ kern_return_t Inspector::ReadMessages() { } //============================================================================= +// Sets keys in the parameters dictionary that are specific to process uptime. +// The two we set are process up time, and process crash time. +void Inspector::SetCrashTimeParameters() { + // Set process uptime parameter + struct timeval tv; + gettimeofday(&tv, NULL); + + char processUptimeString[32], processCrashtimeString[32]; + const char *processStartTimeString = + config_params_.GetValueForKey(BREAKPAD_PROCESS_START_TIME); + + // Set up time if we've received the start time. + if (processStartTimeString) { + time_t processStartTime = strtol(processStartTimeString, NULL, 10); + time_t processUptime = tv.tv_sec - processStartTime; + sprintf(processUptimeString, "%d", processUptime); + config_params_.SetKeyValue(BREAKPAD_PROCESS_UP_TIME, processUptimeString); + } + + sprintf(processCrashtimeString, "%d", tv.tv_sec); + config_params_.SetKeyValue(BREAKPAD_PROCESS_CRASH_TIME, + processCrashtimeString); +} + bool Inspector::InspectTask() { // keep the task quiet while we're looking at it task_suspend(remote_task_); @@ -330,6 +354,7 @@ bool Inspector::InspectTask() { const char *minidumpDirectory = config_params_.GetValueForKey(BREAKPAD_DUMP_DIRECTORY); + SetCrashTimeParameters(); // If the client app has not specified a minidump directory, // use a default of Library// if (0 == strlen(minidumpDirectory)) { -- cgit v1.2.1