Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(10)

Side by Side Diff: client/mac/Framework/Breakpad.mm

Issue 386001: A hackish patch to make Breakpad upload the log if it's impossible to create a file in the crashed … Base URL: http://google-breakpad.googlecode.com/svn/trunk/src/
Patch Set: Created 12 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return breakpad; 149 return breakpad;
150 } 150 }
151 151
152 ~Breakpad(); 152 ~Breakpad();
153 153
154 void SetKeyValue(NSString *key, NSString *value); 154 void SetKeyValue(NSString *key, NSString *value);
155 NSString *KeyValue(NSString *key); 155 NSString *KeyValue(NSString *key);
156 void RemoveKeyValue(NSString *key); 156 void RemoveKeyValue(NSString *key);
157 157
158 void GenerateAndSendReport(); 158 void GenerateAndSendReport();
159 void SetCrashLogData(void* data, size_t size) {
160 extra_crash_log_data_ = data;
161 extra_crash_log_size_ = size;
162 assert(strlen(extra_crash_log_data_) == extra_crash_log_size_);
jeremy 2012/05/16 08:13:07 * Are we sure we want to limit input data to a c-s
glider 2012/05/17 12:15:12 Probably no. Removed this check. You're right, I'd
163 }
164
165 void *GetCrashLogData() {
166 return extra_crash_log_data_;
167 }
159 168
160 void SetFilterCallback(BreakpadFilterCallback callback, void *context) { 169 void SetFilterCallback(BreakpadFilterCallback callback, void *context) {
161 filter_callback_ = callback; 170 filter_callback_ = callback;
162 filter_callback_context_ = context; 171 filter_callback_context_ = context;
163 } 172 }
164 173
165 private: 174 private:
166 Breakpad() 175 Breakpad()
167 : handler_(NULL), 176 : handler_(NULL),
168 config_params_(NULL), 177 config_params_(NULL),
169 send_and_exit_(true), 178 send_and_exit_(true),
170 filter_callback_(NULL), 179 filter_callback_(NULL),
171 filter_callback_context_(NULL) { 180 filter_callback_context_(NULL),
181 extra_crash_log_data_(NULL),
182 extra_crash_log_size_(0) {
172 inspector_path_[0] = 0; 183 inspector_path_[0] = 0;
173 } 184 }
174 185
175 bool Initialize(NSDictionary *parameters); 186 bool Initialize(NSDictionary *parameters);
176 187
177 bool ExtractParameters(NSDictionary *parameters); 188 bool ExtractParameters(NSDictionary *parameters);
178 189
179 // Dispatches to HandleException() 190 // Dispatches to HandleException()
180 static bool ExceptionHandlerDirectCallback(void *context, 191 static bool ExceptionHandlerDirectCallback(void *context,
181 int exception_type, 192 int exception_type,
(...skipping 13 matching lines...) Expand all
195 char inspector_path_[PATH_MAX]; // Path to inspector tool 206 char inspector_path_[PATH_MAX]; // Path to inspector tool
196 207
197 SimpleStringDictionary *config_params_; // Create parameters (STRONG) 208 SimpleStringDictionary *config_params_; // Create parameters (STRONG)
198 209
199 OnDemandServer inspector_; 210 OnDemandServer inspector_;
200 211
201 bool send_and_exit_; // Exit after sending, if true 212 bool send_and_exit_; // Exit after sending, if true
202 213
203 BreakpadFilterCallback filter_callback_; 214 BreakpadFilterCallback filter_callback_;
204 void *filter_callback_context_; 215 void *filter_callback_context_;
216
217 void *extra_crash_log_data_; // Extra crash log, if presen t
218 size_t extra_crash_log_size_;
205 }; 219 };
206 220
207 #pragma mark - 221 #pragma mark -
208 #pragma mark Helper functions 222 #pragma mark Helper functions
209 223
210 //============================================================================= 224 //=============================================================================
211 // Helper functions 225 // Helper functions
212 226
213 //============================================================================= 227 //=============================================================================
214 static BOOL IsDebuggerActive() { 228 static BOOL IsDebuggerActive() {
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 MachSendMessage keyvalue_message(kMsgType_InspectorKeyValuePair); 707 MachSendMessage keyvalue_message(kMsgType_InspectorKeyValuePair);
694 keyvalue_message.SetData(&keyvalue_data, sizeof(keyvalue_data)); 708 keyvalue_message.SetData(&keyvalue_data, sizeof(keyvalue_data));
695 709
696 result = sender.SendMessage(keyvalue_message, 2000); 710 result = sender.SendMessage(keyvalue_message, 2000);
697 711
698 if (result != KERN_SUCCESS) { 712 if (result != KERN_SUCCESS) {
699 break; 713 break;
700 } 714 }
701 } 715 }
702 716
717 if (result == KERN_SUCCESS && extra_crash_log_data_) {
718 // Pass the log pointer to the inspector process that is able to create
719 // log files.
720 MachSendMessage logptr_message(kMsgType_InspectorLogStringPtr);
721 size_t crash_len = strlen((char*)extra_crash_log_data_);
722 size_t min_len = (crash_len < extra_crash_log_size_) ?
723 crash_len : extra_crash_log_size_;
jeremy 2012/05/16 08:13:07 Why is this min(strlen(data), data_len) rather tha
glider 2012/05/17 12:15:12 Done.
724 logptr_message.AddOOLDescriptor(
725 extra_crash_log_data_, min_len,
726 /* deallocate */ 0, /* copy options */ 0);
727 logptr_message.SetData(&extra_crash_log_data_,
728 sizeof(extra_crash_log_data_)); // sizeof(void*)
729 result = sender.SendMessage(logptr_message, 2000);
730 }
731
703 if (result == KERN_SUCCESS) { 732 if (result == KERN_SUCCESS) {
704 // Wait for acknowledgement that the inspection has finished. 733 // Wait for acknowledgement that the inspection has finished.
705 MachReceiveMessage acknowledge_messsage; 734 MachReceiveMessage acknowledge_messsage;
706 result = acknowledge_port.WaitForMessage(&acknowledge_messsage, 5000); 735 result = acknowledge_port.WaitForMessage(&acknowledge_messsage, 5000);
707 } 736 }
708 } 737 }
709 738
710 #if VERBOSE 739 #if VERBOSE
711 PRINT_MACH_RESULT(result, "Breakpad: SendMessage "); 740 PRINT_MACH_RESULT(result, "Breakpad: SendMessage ");
712 printf("Breakpad: Inspector service port = %#x\n", 741 printf("Breakpad: Inspector service port = %#x\n",
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 } 1015 }
987 logFileCounter++; 1016 logFileCounter++;
988 logFileKey = [NSString stringWithFormat:@"%@%d", 1017 logFileKey = [NSString stringWithFormat:@"%@%d",
989 @BREAKPAD_LOGFILE_KEY_PREFIX, 1018 @BREAKPAD_LOGFILE_KEY_PREFIX,
990 logFileCounter]; 1019 logFileCounter];
991 existingLogFilename = BreakpadKeyValue(ref, logFileKey); 1020 existingLogFilename = BreakpadKeyValue(ref, logFileKey);
992 } 1021 }
993 1022
994 BreakpadSetKeyValue(ref, logFileKey, logPathname); 1023 BreakpadSetKeyValue(ref, logFileKey, logPathname);
995 } 1024 }
1025
1026 //=============================================================================
1027 void BreakpadCreateAndAddLogFile(BreakpadRef ref,
1028 void *logContents,
1029 size_t size) {
jeremy 2012/05/16 08:13:07 Size should also undergo a sanity check.
glider 2012/05/17 12:15:12 This is done in SetCrashLogData
1030 if (logContents) {
1031 ProtectedMemoryLocker locker(&gDictionaryMutex, gBreakpadAllocator);
1032 Breakpad *breakpad = (Breakpad *)ref;
1033 breakpad->SetCrashLogData(logContents, size);
1034 NSString *key = @BREAKPAD_HAS_EXTRA_LOG;
1035 NSString *value = @"YES";
1036 BreakpadSetKeyValue(ref, key, value);
1037 }
1038 }
1039
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 1004:630ec63f810e-tainted