Created
October 15, 2014 15:54
-
-
Save jjgod/59818235baaf276ccdc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 9b95e1237d6f4bba8fa1a5f9e16e439ef3c902d2 Mon Sep 17 00:00:00 2001 | |
From: Jiang Jiang <[email protected]> | |
Date: Wed, 15 Oct 2014 15:54:58 +0200 | |
Subject: [PATCH] Breakpad: Support passing direct callback for in process | |
handling | |
--- | |
.../src/client/apple/Framework/BreakpadDefines.h | 1 + | |
breakpad/src/client/mac/Framework/Breakpad.h | 16 ++++++++++++++++ | |
breakpad/src/client/mac/Framework/Breakpad.mm | 21 ++++++++++++++++++++- | |
3 files changed, 37 insertions(+), 1 deletion(-) | |
diff --git a/breakpad/src/client/apple/Framework/BreakpadDefines.h b/breakpad/src/client/apple/Framework/BreakpadDefines.h | |
index 410a5a6..2c445b3 100644 | |
--- a/breakpad/src/client/apple/Framework/BreakpadDefines.h | |
+++ b/breakpad/src/client/apple/Framework/BreakpadDefines.h | |
@@ -63,6 +63,7 @@ | |
#define BREAKPAD_SERVER_TYPE "BreakpadServerType" | |
#define BREAKPAD_SERVER_PARAMETER_DICT "BreakpadServerParameters" | |
#define BREAKPAD_IN_PROCESS "BreakpadInProcess" | |
+#define BREAKPAD_IN_PROCESS_DIRECT_CALLBACK "BreakpadInProcessDirectCallback" | |
// The keys below are NOT user supplied, and are used internally. | |
#define BREAKPAD_PROCESS_START_TIME "BreakpadProcStartTime" | |
diff --git a/breakpad/src/client/mac/Framework/Breakpad.h b/breakpad/src/client/mac/Framework/Breakpad.h | |
index dc7e45d..480f958 100644 | |
--- a/breakpad/src/client/mac/Framework/Breakpad.h | |
+++ b/breakpad/src/client/mac/Framework/Breakpad.h | |
@@ -67,6 +67,12 @@ typedef bool (*BreakpadFilterCallback)(int exception_type, | |
mach_port_t crashing_thread, | |
void *context); | |
+typedef bool (*BreakpadDirectCallback)(void *context, | |
+ int exception_type, | |
+ int exception_code, | |
+ int exception_subcode, | |
+ mach_port_t thread_name); | |
+ | |
// Create a new BreakpadRef object and install it as an exception | |
// handler. The |parameters| will typically be the contents of your | |
// bundle's Info.plist. | |
@@ -163,6 +169,11 @@ typedef bool (*BreakpadFilterCallback)(int exception_type, | |
// will write the dump file in-process and then | |
// launch the reporter executable as a child | |
// process. | |
+// | |
+// BREAKPAD_IN_PROCESS_DIRECT_CALLBACK A NSValue value pointing to a function | |
+// pointer, instead of writing minidump, a | |
+// direct callback specified in this value | |
+// will be called. | |
//============================================================================= | |
// The BREAKPAD_PRODUCT, BREAKPAD_VERSION and BREAKPAD_URL are | |
// required to have non-NULL values. By default, the BREAKPAD_PRODUCT | |
@@ -283,3 +294,8 @@ void BreakpadGenerateAndSendReport(BreakpadRef ref); | |
#ifdef __cplusplus | |
} | |
#endif | |
+ | |
+#import "common/simple_string_dictionary.h" | |
+ | |
+google_breakpad::SimpleStringDictionary* BreakpadGetConfigParams( | |
+ BreakpadRef ref); | |
diff --git a/breakpad/src/client/mac/Framework/Breakpad.mm b/breakpad/src/client/mac/Framework/Breakpad.mm | |
index 3b4b667..6229e97 100644 | |
--- a/breakpad/src/client/mac/Framework/Breakpad.mm | |
+++ b/breakpad/src/client/mac/Framework/Breakpad.mm | |
@@ -46,7 +46,6 @@ | |
#import "client/mac/handler/protected_memory_allocator.h" | |
#include "common/mac/launch_reporter.h" | |
#import "common/mac/MachIPC.h" | |
-#import "common/simple_string_dictionary.h" | |
#ifndef __EXCEPTIONS | |
// This file uses C++ try/catch (but shouldn't). Duplicate the macros from | |
@@ -156,6 +155,8 @@ class Breakpad { | |
NSString *KeyValue(NSString *key); | |
void RemoveKeyValue(NSString *key); | |
+ SimpleStringDictionary* config_params() const { return config_params_; } | |
+ | |
void GenerateAndSendReport(); | |
void SetFilterCallback(BreakpadFilterCallback callback, void *context) { | |
@@ -363,6 +364,18 @@ bool Breakpad::Initialize(NSDictionary *parameters) { | |
//============================================================================= | |
bool Breakpad::InitializeInProcess(NSDictionary* parameters) { | |
+ NSValue* directCallbackValue = | |
+ [parameters objectForKey:@BREAKPAD_IN_PROCESS_DIRECT_CALLBACK]; | |
+ if (directCallbackValue) { | |
+ BreakpadDirectCallback callback = | |
+ (BreakpadDirectCallback)[directCallbackValue pointerValue]; | |
+ handler_ = | |
+ new (gBreakpadAllocator->Allocate( | |
+ sizeof(google_breakpad::ExceptionHandler))) | |
+ google_breakpad::ExceptionHandler(callback, this, true); | |
+ return true; | |
+ } | |
+ | |
handler_ = | |
new (gBreakpadAllocator->Allocate( | |
sizeof(google_breakpad::ExceptionHandler))) | |
@@ -981,6 +994,12 @@ void BreakpadRemoveKeyValue(BreakpadRef ref, NSString *key) { | |
} | |
} | |
+google_breakpad::SimpleStringDictionary* BreakpadGetConfigParams( | |
+ BreakpadRef ref) { | |
+ Breakpad *breakpad = (Breakpad *)ref; | |
+ return breakpad->config_params(); | |
+} | |
+ | |
//============================================================================= | |
void BreakpadGenerateAndSendReport(BreakpadRef ref) { | |
try { | |
-- | |
2.1.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment