mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2025-09-15 08:27:08 +00:00
Add API on iOS to generate dump on demand.
Review URL: http://breakpad.appspot.com/331001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@893 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
50cfc4a091
commit
a42704eccc
|
@ -47,6 +47,10 @@ extern "C" {
|
||||||
|
|
||||||
#include <client/apple/Framework/BreakpadDefines.h>
|
#include <client/apple/Framework/BreakpadDefines.h>
|
||||||
|
|
||||||
|
// The keys in the dictionary returned by |BreakpadGenerateReport|.
|
||||||
|
#define BREAKPAD_OUTPUT_DUMP_FILE "BreakpadDumpFile"
|
||||||
|
#define BREAKPAD_OUTPUT_CONFIG_FILE "BreakpadConfigFile"
|
||||||
|
|
||||||
// Optional user-defined function to decide if we should handle this crash or
|
// Optional user-defined function to decide if we should handle this crash or
|
||||||
// forward it along.
|
// forward it along.
|
||||||
// Return true if you want Breakpad to handle it.
|
// Return true if you want Breakpad to handle it.
|
||||||
|
@ -201,6 +205,13 @@ void BreakpadUploadNextReport(BreakpadRef ref);
|
||||||
void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
||||||
NSDictionary *server_parameters);
|
NSDictionary *server_parameters);
|
||||||
|
|
||||||
|
// Generate a breakpad minidump and configuration file in the dump directory.
|
||||||
|
// The report will be available for uploading. The paths of the created files
|
||||||
|
// are returned in the dictionary. |server_parameters| is additional server
|
||||||
|
// parameters to add in the config file.
|
||||||
|
NSDictionary *BreakpadGenerateReport(BreakpadRef ref,
|
||||||
|
NSDictionary *server_parameters);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#import "client/mac/crash_generation/ConfigFile.h"
|
#import "client/mac/crash_generation/ConfigFile.h"
|
||||||
#import "client/mac/sender/uploader.h"
|
#import "client/mac/sender/uploader.h"
|
||||||
#import "client/mac/handler/exception_handler.h"
|
#import "client/mac/handler/exception_handler.h"
|
||||||
|
#import "client/mac/handler/minidump_generator.h"
|
||||||
#import "client/ios/Breakpad.h"
|
#import "client/ios/Breakpad.h"
|
||||||
#import "client/mac/handler/protected_memory_allocator.h"
|
#import "client/mac/handler/protected_memory_allocator.h"
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@ class Breakpad {
|
||||||
void UploadNextReport();
|
void UploadNextReport();
|
||||||
void UploadData(NSData *data, NSString *name,
|
void UploadData(NSData *data, NSString *name,
|
||||||
NSDictionary *server_parameters);
|
NSDictionary *server_parameters);
|
||||||
|
NSDictionary *GenerateReport(NSDictionary *server_parameters);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Breakpad()
|
Breakpad()
|
||||||
|
@ -418,9 +420,9 @@ NSString *Breakpad::NextCrashReportToUpload() {
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
void Breakpad::UploadNextReport() {
|
void Breakpad::UploadNextReport() {
|
||||||
NSString* configFile = NextCrashReportToUpload();
|
NSString *configFile = NextCrashReportToUpload();
|
||||||
if (configFile) {
|
if (configFile) {
|
||||||
Uploader* uploader = [[[Uploader alloc]
|
Uploader *uploader = [[[Uploader alloc]
|
||||||
initWithConfigFile:[configFile UTF8String]] autorelease];
|
initWithConfigFile:[configFile UTF8String]] autorelease];
|
||||||
if (uploader)
|
if (uploader)
|
||||||
[uploader report];
|
[uploader report];
|
||||||
|
@ -447,6 +449,40 @@ void Breakpad::UploadData(NSData *data, NSString *name,
|
||||||
[uploader uploadData:data name:name];
|
[uploader uploadData:data name:name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
NSDictionary *Breakpad::GenerateReport(NSDictionary *server_parameters) {
|
||||||
|
NSString *dumpDirAsNSString = KeyValue(@BREAKPAD_DUMP_DIRECTORY);
|
||||||
|
if (!dumpDirAsNSString)
|
||||||
|
return nil;
|
||||||
|
const char *dumpDir = [dumpDirAsNSString UTF8String];
|
||||||
|
|
||||||
|
google_breakpad::MinidumpGenerator generator(mach_task_self(),
|
||||||
|
MACH_PORT_NULL);
|
||||||
|
std::string dumpId;
|
||||||
|
std::string dumpFilename = generator.UniqueNameInDirectory(dumpDir, &dumpId);
|
||||||
|
bool success = generator.Write(dumpFilename.c_str());
|
||||||
|
if (!success)
|
||||||
|
return nil;
|
||||||
|
|
||||||
|
SimpleStringDictionary params = *config_params_;
|
||||||
|
for (NSString *key in server_parameters) {
|
||||||
|
params.SetKeyValue([key UTF8String],
|
||||||
|
[[server_parameters objectForKey:key] UTF8String]);
|
||||||
|
}
|
||||||
|
ConfigFile config_file;
|
||||||
|
config_file.WriteFile(dumpDir, ¶ms, dumpDir, dumpId.c_str());
|
||||||
|
|
||||||
|
// Handle results.
|
||||||
|
NSMutableDictionary *result = [NSMutableDictionary dictionary];
|
||||||
|
NSString *dumpFullPath = [dumpDirAsNSString stringByAppendingPathComponent:
|
||||||
|
[NSString stringWithUTF8String:dumpFilename.c_str()]];
|
||||||
|
[result setValue:dumpFullPath
|
||||||
|
forKey:@BREAKPAD_OUTPUT_DUMP_FILE];
|
||||||
|
[result setValue:[NSString stringWithUTF8String:config_file.GetFilePath()]
|
||||||
|
forKey:@BREAKPAD_OUTPUT_CONFIG_FILE];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
bool Breakpad::HandleMinidump(const char *dump_dir,
|
bool Breakpad::HandleMinidump(const char *dump_dir,
|
||||||
const char *minidump_id) {
|
const char *minidump_id) {
|
||||||
|
@ -718,3 +754,20 @@ void BreakpadUploadData(BreakpadRef ref, NSData *data, NSString *name,
|
||||||
fprintf(stderr, "BreakpadUploadData() : error\n");
|
fprintf(stderr, "BreakpadUploadData() : error\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=============================================================================
|
||||||
|
NSDictionary *BreakpadGenerateReport(BreakpadRef ref,
|
||||||
|
NSDictionary *server_parameters) {
|
||||||
|
try {
|
||||||
|
// Not called at exception time
|
||||||
|
Breakpad *breakpad = (Breakpad *)ref;
|
||||||
|
|
||||||
|
if (breakpad) {
|
||||||
|
return breakpad->GenerateReport(server_parameters);
|
||||||
|
} else {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
} catch(...) { // don't let exceptions leave this C API
|
||||||
|
fprintf(stderr, "BreakpadGenerateReport() : error\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue