aboutsummaryrefslogtreecommitdiff
path: root/src/client/ios
diff options
context:
space:
mode:
authorYi Wang <jswang@google.com>2017-10-27 10:46:15 -0700
committerMark Mentovai <mark@chromium.org>2017-10-27 17:47:03 +0000
commitfd0a0d2b7ae9dd3d8a02b6a12e7941f7189fbb6c (patch)
tree14d56efa21d732a00e3d560025aa1fdb5e5db6e4 /src/client/ios
parentAvoid skipping an initializer with a goto (diff)
downloadbreakpad-fd0a0d2b7ae9dd3d8a02b6a12e7941f7189fbb6c.tar.xz
Create LongStringDictionary and replace SimpleStringDictionary usages in client/ios/Breakpad.mm.
Bug: Change-Id: I401028f5d90417d79fb109b510aaa9660a039b44 Reviewed-on: https://chromium-review.googlesource.com/688301 Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src/client/ios')
-rw-r--r--src/client/ios/Breakpad.mm40
-rw-r--r--src/client/ios/Breakpad.xcodeproj/project.pbxproj8
2 files changed, 29 insertions, 19 deletions
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm
index 88dd2870..ee36a04e 100644
--- a/src/client/ios/Breakpad.mm
+++ b/src/client/ios/Breakpad.mm
@@ -38,13 +38,15 @@
#include <sys/sysctl.h>
#include <TargetConditionals.h>
+#include <string>
+
#import "client/ios/handler/ios_exception_minidump_generator.h"
#import "client/mac/crash_generation/ConfigFile.h"
#import "client/mac/handler/exception_handler.h"
#import "client/mac/handler/minidump_generator.h"
-#import "client/mac/sender/uploader.h"
#import "client/mac/handler/protected_memory_allocator.h"
-#import "common/simple_string_dictionary.h"
+#import "client/mac/sender/uploader.h"
+#import "common/long_string_dictionary.h"
#if !TARGET_OS_TV && !TARGET_OS_WATCH
#import "client/mac/handler/exception_handler.h"
@@ -66,7 +68,7 @@
using google_breakpad::ConfigFile;
using google_breakpad::EnsureDirectoryPathExists;
-using google_breakpad::SimpleStringDictionary;
+using google_breakpad::LongStringDictionary;
//=============================================================================
// We want any memory allocations which are used by breakpad during the
@@ -197,7 +199,7 @@ class Breakpad {
// MachineExceptions.h, we have to explicitly name the handler.
google_breakpad::ExceptionHandler *handler_; // The actual handler (STRONG)
- SimpleStringDictionary *config_params_; // Create parameters (STRONG)
+ LongStringDictionary *config_params_; // Create parameters (STRONG)
ConfigFile config_file_;
@@ -313,7 +315,7 @@ Breakpad::~Breakpad() {
// since they were allocated by ProtectedMemoryAllocator objects.
//
if (config_params_) {
- config_params_->~SimpleStringDictionary();
+ config_params_->~LongStringDictionary();
}
if (handler_)
@@ -381,10 +383,10 @@ bool Breakpad::ExtractParameters(NSDictionary *parameters) {
}
config_params_ =
- new (gKeyValueAllocator->Allocate(sizeof(SimpleStringDictionary)) )
- SimpleStringDictionary();
+ new (gKeyValueAllocator->Allocate(sizeof(LongStringDictionary)))
+ LongStringDictionary();
- SimpleStringDictionary &dictionary = *config_params_;
+ LongStringDictionary &dictionary = *config_params_;
dictionary.SetKeyValue(BREAKPAD_SERVER_TYPE, [serverType UTF8String]);
dictionary.SetKeyValue(BREAKPAD_PRODUCT_DISPLAY, [display UTF8String]);
@@ -427,8 +429,8 @@ NSString *Breakpad::KeyValue(NSString *key) {
if (!config_params_ || !key)
return nil;
- const char *value = config_params_->GetValueForKey([key UTF8String]);
- return value ? [NSString stringWithUTF8String:value] : nil;
+ const std::string value = config_params_->GetValueForKey([key UTF8String]);
+ return value.empty() ? nil : [NSString stringWithUTF8String:value.c_str()];
}
//=============================================================================
@@ -502,8 +504,8 @@ void Breakpad::UploadData(NSData *data, NSString *name,
NSDictionary *server_parameters) {
NSMutableDictionary *config = [NSMutableDictionary dictionary];
- SimpleStringDictionary::Iterator it(*config_params_);
- while (const SimpleStringDictionary::Entry *next = it.Next()) {
+ LongStringDictionary::Iterator it(*config_params_);
+ while (const LongStringDictionary::Entry *next = it.Next()) {
[config setValue:[NSString stringWithUTF8String:next->value]
forKey:[NSString stringWithUTF8String:next->key]];
}
@@ -532,7 +534,7 @@ NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
if (!success)
return nil;
- SimpleStringDictionary params = *config_params_;
+ LongStringDictionary params = *config_params_;
for (NSString *key in server_parameters) {
params.SetKeyValue([key UTF8String],
[[server_parameters objectForKey:key] UTF8String]);
@@ -567,7 +569,7 @@ bool Breakpad::HandleMinidump(const char *dump_dir,
void Breakpad::HandleUncaughtException(NSException *exception) {
// Generate the minidump.
google_breakpad::IosExceptionMinidumpGenerator generator(exception);
- const char *minidump_path =
+ const std::string minidump_path =
config_params_->GetValueForKey(BREAKPAD_DUMP_DIRECTORY);
std::string minidump_id;
std::string minidump_filename = generator.UniqueNameInDirectory(minidump_path,
@@ -580,7 +582,7 @@ void Breakpad::HandleUncaughtException(NSException *exception) {
// 2- If the application crash while trying to handle this exception, a usual
// report will be generated. This report must not contain these special
// keys.
- SimpleStringDictionary params = *config_params_;
+ LongStringDictionary params = *config_params_;
params.SetKeyValue(BREAKPAD_SERVER_PARAMETER_PREFIX "type", "exception");
params.SetKeyValue(BREAKPAD_SERVER_PARAMETER_PREFIX "exceptionName",
[[exception name] UTF8String]);
@@ -589,9 +591,9 @@ void Breakpad::HandleUncaughtException(NSException *exception) {
// And finally write the config file.
ConfigFile config_file;
- config_file.WriteFile(minidump_path,
+ config_file.WriteFile(minidump_path.c_str(),
&params,
- minidump_path,
+ minidump_path.c_str(),
minidump_id.c_str());
}
@@ -619,9 +621,9 @@ BreakpadRef BreakpadCreate(NSDictionary *parameters) {
gKeyValueAllocator =
new (gMasterAllocator->Allocate(sizeof(ProtectedMemoryAllocator)))
- ProtectedMemoryAllocator(sizeof(SimpleStringDictionary));
+ ProtectedMemoryAllocator(sizeof(LongStringDictionary));
- // Create a mutex for use in accessing the SimpleStringDictionary
+ // Create a mutex for use in accessing the LongStringDictionary
int mutexResult = pthread_mutex_init(&gDictionaryMutex, NULL);
if (mutexResult == 0) {
diff --git a/src/client/ios/Breakpad.xcodeproj/project.pbxproj b/src/client/ios/Breakpad.xcodeproj/project.pbxproj
index e9fcae3f..e047b51b 100644
--- a/src/client/ios/Breakpad.xcodeproj/project.pbxproj
+++ b/src/client/ios/Breakpad.xcodeproj/project.pbxproj
@@ -57,6 +57,8 @@
1EEEB6101720821900F7E689 /* simple_string_dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EEEB60D1720821900F7E689 /* simple_string_dictionary.h */; };
AA747D9F0F9514B9006C5449 /* Breakpad_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* Breakpad_Prefix.pch */; };
AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; };
+ CF6D547D1F9E6FFE00E95174 /* long_string_dictionary.cc in Sources */ = {isa = PBXBuildFile; fileRef = CF6D547C1F9E6FFE00E95174 /* long_string_dictionary.cc */; };
+ CF706DC11F7C6EFB002C54C7 /* long_string_dictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = CF706DC01F7C6EFB002C54C7 /* long_string_dictionary.h */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -111,6 +113,8 @@
1EEEB60D1720821900F7E689 /* simple_string_dictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simple_string_dictionary.h; sourceTree = "<group>"; };
AA747D9E0F9514B9006C5449 /* Breakpad_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Breakpad_Prefix.pch; sourceTree = SOURCE_ROOT; };
AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ CF6D547C1F9E6FFE00E95174 /* long_string_dictionary.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = long_string_dictionary.cc; sourceTree = "<group>"; };
+ CF706DC01F7C6EFB002C54C7 /* long_string_dictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = long_string_dictionary.h; sourceTree = "<group>"; };
D2AAC07E0554694100DB518D /* libBreakpad.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBreakpad.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -264,6 +268,8 @@
16C7CC47147D4A4300776EAD /* common */ = {
isa = PBXGroup;
children = (
+ CF706DC01F7C6EFB002C54C7 /* long_string_dictionary.h */,
+ CF6D547C1F9E6FFE00E95174 /* long_string_dictionary.cc */,
1EEEB60C1720821900F7E689 /* simple_string_dictionary.cc */,
1EEEB60D1720821900F7E689 /* simple_string_dictionary.h */,
16C7CC4A147D4A4300776EAD /* convert_UTF.c */,
@@ -339,6 +345,7 @@
16C7CEA8147D4A4300776EAD /* string_conversion.h in Headers */,
16BFA67014E195E9009704F8 /* ios_exception_minidump_generator.h in Headers */,
16C92FAD150DF8330053D7BA /* BreakpadController.h in Headers */,
+ CF706DC11F7C6EFB002C54C7 /* long_string_dictionary.h in Headers */,
1EEEB6101720821900F7E689 /* simple_string_dictionary.h in Headers */,
14569323182CE2C10029C465 /* mach_vm_compat.h in Headers */,
);
@@ -416,6 +423,7 @@
16C7CDFC147D4A4300776EAD /* minidump_generator.cc in Sources */,
16C7CDFE147D4A4300776EAD /* protected_memory_allocator.cc in Sources */,
16C7CE09147D4A4300776EAD /* uploader.mm in Sources */,
+ CF6D547D1F9E6FFE00E95174 /* long_string_dictionary.cc in Sources */,
16C7CE19147D4A4300776EAD /* minidump_file_writer.cc in Sources */,
16C7CE40147D4A4300776EAD /* convert_UTF.c in Sources */,
16C7CE79147D4A4300776EAD /* GTMLogger.m in Sources */,