| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "components/crash/app/breakpad_mac.h" | 5 #import "components/crash/app/breakpad_mac.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #import <Foundation/Foundation.h> | 8 #import <Foundation/Foundation.h> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueImpl, | 245 base::debug::SetCrashKeyReportingFunctions(&SetCrashKeyValueImpl, |
| 246 &ClearCrashKeyValueImpl); | 246 &ClearCrashKeyValueImpl); |
| 247 GetCrashReporterClient()->RegisterCrashKeys(); | 247 GetCrashReporterClient()->RegisterCrashKeys(); |
| 248 | 248 |
| 249 // Set Breakpad metadata values. These values are added to Info.plist during | 249 // Set Breakpad metadata values. These values are added to Info.plist during |
| 250 // the branded Google Chrome.app build. | 250 // the branded Google Chrome.app build. |
| 251 SetCrashKeyValue(@"ver", [info_dictionary objectForKey:@BREAKPAD_VERSION]); | 251 SetCrashKeyValue(@"ver", [info_dictionary objectForKey:@BREAKPAD_VERSION]); |
| 252 SetCrashKeyValue(@"prod", [info_dictionary objectForKey:@BREAKPAD_PRODUCT]); | 252 SetCrashKeyValue(@"prod", [info_dictionary objectForKey:@BREAKPAD_PRODUCT]); |
| 253 SetCrashKeyValue(@"plat", @"OS X"); | 253 SetCrashKeyValue(@"plat", @"OS X"); |
| 254 | 254 |
| 255 if (!is_browser) { | |
| 256 // Get the guid from the command line switch. | |
| 257 std::string client_guid = | |
| 258 command_line->GetSwitchValueASCII(switches::kEnableCrashReporter); | |
| 259 GetCrashReporterClient()->SetCrashReporterClientIdFromGUID(client_guid); | |
| 260 } | |
| 261 | |
| 262 logging::SetLogMessageHandler(&FatalMessageHandler); | 255 logging::SetLogMessageHandler(&FatalMessageHandler); |
| 263 base::debug::SetDumpWithoutCrashingFunction(&DumpHelper::DumpWithoutCrashing); | 256 base::debug::SetDumpWithoutCrashingFunction(&DumpHelper::DumpWithoutCrashing); |
| 264 | 257 |
| 265 // abort() sends SIGABRT, which breakpad does not intercept. | 258 // abort() sends SIGABRT, which breakpad does not intercept. |
| 266 // Register a signal handler to crash in a way breakpad will | 259 // Register a signal handler to crash in a way breakpad will |
| 267 // intercept. | 260 // intercept. |
| 268 struct sigaction sigact; | 261 struct sigaction sigact; |
| 269 memset(&sigact, 0, sizeof(sigact)); | 262 memset(&sigact, 0, sizeof(sigact)); |
| 270 sigact.sa_handler = SIGABRTHandler; | 263 sigact.sa_handler = SIGABRTHandler; |
| 271 CHECK(0 == sigaction(SIGABRT, &sigact, NULL)); | 264 CHECK(0 == sigaction(SIGABRT, &sigact, NULL)); |
| 272 } | 265 } |
| 273 | 266 |
| 274 void InitCrashProcessInfo(const std::string& process_type_switch) { | 267 void InitCrashProcessInfo(const std::string& process_type_switch) { |
| 275 if (gBreakpadRef == NULL) { | 268 if (gBreakpadRef == NULL) { |
| 276 return; | 269 return; |
| 277 } | 270 } |
| 278 | 271 |
| 279 // Determine the process type. | 272 // Determine the process type. |
| 280 NSString* process_type = @"browser"; | 273 NSString* process_type = @"browser"; |
| 281 if (!process_type_switch.empty()) { | 274 if (!process_type_switch.empty()) { |
| 282 process_type = base::SysUTF8ToNSString(process_type_switch); | 275 process_type = base::SysUTF8ToNSString(process_type_switch); |
| 283 } | 276 } |
| 284 | 277 |
| 285 GetCrashReporterClient()->InstallAdditionalFilters(gBreakpadRef); | |
| 286 | |
| 287 // Store process type in crash dump. | 278 // Store process type in crash dump. |
| 288 SetCrashKeyValue(@"ptype", process_type); | 279 SetCrashKeyValue(@"ptype", process_type); |
| 289 | 280 |
| 290 NSString* pid_value = | 281 NSString* pid_value = |
| 291 [NSString stringWithFormat:@"%d", static_cast<unsigned int>(getpid())]; | 282 [NSString stringWithFormat:@"%d", static_cast<unsigned int>(getpid())]; |
| 292 SetCrashKeyValue(@"pid", pid_value); | 283 SetCrashKeyValue(@"pid", pid_value); |
| 293 } | 284 } |
| 294 | 285 |
| 295 } // namespace breakpad | 286 } // namespace breakpad |
| OLD | NEW |