Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 Breakpad() | 166 Breakpad() |
| 167 : handler_(NULL), | 167 : handler_(NULL), |
| 168 config_params_(NULL), | 168 config_params_(NULL), |
| 169 send_and_exit_(true), | 169 send_and_exit_(true), |
| 170 filter_callback_(NULL), | 170 filter_callback_(NULL), |
| 171 filter_callback_context_(NULL) { | 171 filter_callback_context_(NULL) { |
| 172 inspector_path_[0] = 0; | 172 inspector_path_[0] = 0; |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool Initialize(NSDictionary *parameters); | 175 bool Initialize(NSDictionary *parameters); |
| 176 bool InitializeInProcess(NSDictionary *parameters); | |
| 177 bool InitializeOutOfProcess(NSDictionary *parameters); | |
| 176 | 178 |
| 177 bool ExtractParameters(NSDictionary *parameters); | 179 bool ExtractParameters(NSDictionary *parameters); |
| 178 | 180 |
| 179 // Dispatches to HandleException() | 181 // Dispatches to HandleException() |
| 180 static bool ExceptionHandlerDirectCallback(void *context, | 182 static bool ExceptionHandlerDirectCallback(void *context, |
| 181 int exception_type, | 183 int exception_type, |
| 182 int exception_code, | 184 int exception_code, |
| 183 int exception_subcode, | 185 int exception_subcode, |
| 184 mach_port_t crashing_thread); | 186 mach_port_t crashing_thread); |
| 185 | 187 |
| 186 bool HandleException(int exception_type, | 188 bool HandleException(int exception_type, |
| 187 int exception_code, | 189 int exception_code, |
| 188 int exception_subcode, | 190 int exception_subcode, |
| 189 mach_port_t crashing_thread); | 191 mach_port_t crashing_thread); |
| 190 | 192 |
| 193 // Dispatches to HandleMinidump() | |
| 194 static bool HandleMinidumpCallback(const char *dump_dir, | |
| 195 const char *minidump_id, | |
| 196 void *context, bool succeeded); | |
| 197 | |
| 198 bool HandleMinidump(const char *dump_dir, | |
| 199 const char *minidump_id); | |
| 200 | |
| 191 // Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's | 201 // Since ExceptionHandler (w/o namespace) is defined as typedef in OSX's |
| 192 // MachineExceptions.h, we have to explicitly name the handler. | 202 // MachineExceptions.h, we have to explicitly name the handler. |
| 193 google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG) | 203 google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG) |
| 194 | 204 |
| 195 char inspector_path_[PATH_MAX]; // Path to inspector tool | 205 char inspector_path_[PATH_MAX]; // Path to inspector tool |
| 196 | 206 |
| 197 SimpleStringDictionary *config_params_; // Create parameters (STRONG) | 207 SimpleStringDictionary *config_params_; // Create parameters (STRONG) |
| 198 | 208 |
| 199 OnDemandServer inspector_; | 209 OnDemandServer inspector_; |
| 200 | 210 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 if (!breakpad) | 269 if (!breakpad) |
| 260 return false; | 270 return false; |
| 261 | 271 |
| 262 return breakpad->HandleException( exception_type, | 272 return breakpad->HandleException( exception_type, |
| 263 exception_code, | 273 exception_code, |
| 264 exception_subcode, | 274 exception_subcode, |
| 265 crashing_thread); | 275 crashing_thread); |
| 266 } | 276 } |
| 267 | 277 |
| 268 //============================================================================= | 278 //============================================================================= |
| 279 bool Breakpad::HandleMinidumpCallback(const char *dump_dir, | |
| 280 const char *minidump_id, | |
| 281 void *context, bool succeeded) { | |
| 282 Breakpad *breakpad = (Breakpad *)context; | |
| 283 | |
| 284 // If our context is damaged or something, just return false to indicate that | |
| 285 // the handler should continue without us. | |
| 286 if (!breakpad || !succeeded) | |
| 287 return false; | |
| 288 | |
| 289 return breakpad->HandleMinidump(dump_dir, minidump_id); | |
| 290 } | |
| 291 | |
| 292 //============================================================================= | |
| 269 #pragma mark - | 293 #pragma mark - |
| 270 | 294 |
| 271 #include <dlfcn.h> | 295 #include <dlfcn.h> |
| 272 | 296 |
| 273 //============================================================================= | 297 //============================================================================= |
| 274 // Returns the pathname to the Resources directory for this version of | 298 // Returns the pathname to the Resources directory for this version of |
| 275 // Breakpad which we are now running. | 299 // Breakpad which we are now running. |
| 276 // | 300 // |
| 277 // Don't make the function static, since _dyld_lookup_and_bind_fully needs a | 301 // Don't make the function static, since _dyld_lookup_and_bind_fully needs a |
| 278 // simple non-static C name | 302 // simple non-static C name |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 // Check for debugger | 343 // Check for debugger |
| 320 if (IsDebuggerActive()) { | 344 if (IsDebuggerActive()) { |
| 321 return true; | 345 return true; |
| 322 } | 346 } |
| 323 | 347 |
| 324 // Gather any user specified parameters | 348 // Gather any user specified parameters |
| 325 if (!ExtractParameters(parameters)) { | 349 if (!ExtractParameters(parameters)) { |
| 326 return false; | 350 return false; |
| 327 } | 351 } |
| 328 | 352 |
| 353 if ([[parameters objectForKey:@BREAKPAD_IN_PROCESS] boolValue]) | |
| 354 return InitializeInProcess(parameters); | |
| 355 else | |
| 356 return InitializeOutOfProcess(parameters); | |
| 357 } | |
| 358 | |
| 359 //============================================================================= | |
| 360 bool Breakpad::InitializeInProcess(NSDictionary* parameters) { | |
| 361 handler_ = | |
| 362 new (gBreakpadAllocator->Allocate( | |
| 363 sizeof(google_breakpad::ExceptionHandler))) | |
| 364 google_breakpad::ExceptionHandler( | |
| 365 config_params_->GetValueForKey(BREAKPAD_DUMP_DIRECTORY), | |
| 366 0, &HandleMinidumpCallback, this, true, 0); | |
| 367 return true; | |
| 368 } | |
| 369 | |
| 370 //============================================================================= | |
| 371 bool Breakpad::InitializeOutOfProcess(NSDictionary* parameters) { | |
| 329 // Get path to Inspector executable. | 372 // Get path to Inspector executable. |
| 330 NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION); | 373 NSString *inspectorPathString = KeyValue(@BREAKPAD_INSPECTOR_LOCATION); |
| 331 | 374 |
| 332 // Standardize path (resolve symlinkes, etc.) and escape spaces | 375 // Standardize path (resolve symlinkes, etc.) and escape spaces |
| 333 inspectorPathString = [inspectorPathString stringByStandardizingPath]; | 376 inspectorPathString = [inspectorPathString stringByStandardizingPath]; |
| 334 inspectorPathString = [[inspectorPathString componentsSeparatedByString:@" "] | 377 inspectorPathString = [[inspectorPathString componentsSeparatedByString:@" "] |
| 335 componentsJoinedByString:@"\\ "]; | 378 componentsJoinedByString:@"\\ "]; |
| 336 | 379 |
| 337 // Create an on-demand server object representing the Inspector. | 380 // Create an on-demand server object representing the Inspector. |
| 338 // In case of a crash, we simply need to call the LaunchOnDemand() | 381 // In case of a crash, we simply need to call the LaunchOnDemand() |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 704 #endif | 747 #endif |
| 705 | 748 |
| 706 // If we don't want any forwarding, return true here to indicate that we've | 749 // If we don't want any forwarding, return true here to indicate that we've |
| 707 // processed things as much as we want. | 750 // processed things as much as we want. |
| 708 if (send_and_exit_) return true; | 751 if (send_and_exit_) return true; |
| 709 | 752 |
| 710 return false; | 753 return false; |
| 711 } | 754 } |
| 712 | 755 |
| 713 //============================================================================= | 756 //============================================================================= |
| 757 bool Breakpad::HandleMinidump(const char *dump_dir, | |
| 758 const char *minidump_id) { | |
| 759 // google_breakpad::ConfigFile config_file; | |
| 760 // config_file.WriteFile(dump_dir, config_params_, dump_dir, minidump_id); | |
| 761 // google_breakpad::Inspector::LaunchReporter( | |
| 762 // config_params_->GetValueForKey(BREAKPAD_REPORTER_EXE_LOCATION), | |
| 763 // config_file.GetFilePath()); | |
|
Andre
2014/09/12 18:04:59
This was my first naive attempt, but it didn't lin
Andre
2014/09/12 18:22:00
I'm considering promoting ConfigFile and LaunchRep
| |
| 764 return true; | |
| 765 } | |
| 766 | |
| 767 //============================================================================= | |
| 714 //============================================================================= | 768 //============================================================================= |
| 715 | 769 |
| 716 #pragma mark - | 770 #pragma mark - |
| 717 #pragma mark Public API | 771 #pragma mark Public API |
| 718 | 772 |
| 719 //============================================================================= | 773 //============================================================================= |
| 720 BreakpadRef BreakpadCreate(NSDictionary *parameters) { | 774 BreakpadRef BreakpadCreate(NSDictionary *parameters) { |
| 721 try { | 775 try { |
| 722 // This is confusing. Our two main allocators for breakpad memory are: | 776 // This is confusing. Our two main allocators for breakpad memory are: |
| 723 // - gKeyValueAllocator for the key/value memory | 777 // - gKeyValueAllocator for the key/value memory |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 976 } | 1030 } |
| 977 logFileCounter++; | 1031 logFileCounter++; |
| 978 logFileKey = [NSString stringWithFormat:@"%@%d", | 1032 logFileKey = [NSString stringWithFormat:@"%@%d", |
| 979 @BREAKPAD_LOGFILE_KEY_PREFIX, | 1033 @BREAKPAD_LOGFILE_KEY_PREFIX, |
| 980 logFileCounter]; | 1034 logFileCounter]; |
| 981 existingLogFilename = BreakpadKeyValue(ref, logFileKey); | 1035 existingLogFilename = BreakpadKeyValue(ref, logFileKey); |
| 982 } | 1036 } |
| 983 | 1037 |
| 984 BreakpadSetKeyValue(ref, logFileKey, logPathname); | 1038 BreakpadSetKeyValue(ref, logFileKey, logPathname); |
| 985 } | 1039 } |
| OLD | NEW |