[vlc-devel] [PATCH 3/3] macOS: Add initialization of breakpad crash reporter

Marvin Scholz epirat07 at gmail.com
Fri Feb 17 00:36:05 CET 2017


---
 bin/darwinvlc.m                            | 42 ++++++++++++++++++++++++++++++
 modules/gui/macosx/Resources/Info.plist.in |  6 +++++
 2 files changed, 48 insertions(+)

diff --git a/bin/darwinvlc.m b/bin/darwinvlc.m
index 93314c8..981d7a9 100644
--- a/bin/darwinvlc.m
+++ b/bin/darwinvlc.m
@@ -35,6 +35,10 @@
 #import <CoreFoundation/CoreFoundation.h>
 #import <Cocoa/Cocoa.h>
 
+#ifdef HAVE_BREAKPAD
+#import <Breakpad/Breakpad.h>
+#endif
+
 
 /**
  * Handler called when VLC asks to terminate the program.
@@ -75,6 +79,36 @@ static void vlc_terminate(void *data)
     });
 }
 
+#ifdef HAVE_BREAKPAD
+BreakpadRef initBreakpad()
+{
+    BreakpadRef bp = nil;
+
+    /* Create caches directory in case it does not exist */
+    NSFileManager *fileManager = [NSFileManager defaultManager];
+    NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
+    NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
+    NSString *cacheAppPath = [cachePath stringByAppendingPathComponent:bundleName];
+    if (![fileManager fileExistsAtPath:cacheAppPath]) {
+        [fileManager createDirectoryAtPath:cacheAppPath withIntermediateDirectories:NO attributes:nil error:nil];
+    }
+
+    /* Get Info.plist config */
+    NSMutableDictionary *breakpad_config = [[[NSBundle mainBundle] infoDictionary] mutableCopy];
+
+    /* Use in-process reporting */
+    [breakpad_config setObject:[NSNumber numberWithBool:YES]
+                        forKey:@BREAKPAD_IN_PROCESS];
+
+    /* Set dump location */
+    [breakpad_config setObject:cacheAppPath
+                        forKey:@BREAKPAD_DUMP_DIRECTORY];
+
+    bp = BreakpadCreate(breakpad_config);
+    return bp;
+}
+#endif
+
 /*****************************************************************************
  * main: parse command line, start interface and spawn threads.
  *****************************************************************************/
@@ -259,6 +293,10 @@ int main(int i_argc, const char *ppsz_argv[])
      * runloop is used. Otherwise, [NSApp run] needs to be called, which setups more stuff
      * before actually starting the loop.
      */
+#ifdef HAVE_BREAKPAD
+    BreakpadRef breakpad;
+    breakpad = initBreakpad();
+#endif
     @autoreleasepool {
         if(NSApp == nil) {
             CFRunLoopRun();
@@ -277,5 +315,9 @@ int main(int i_argc, const char *ppsz_argv[])
 
     libvlc_release(vlc);
 
+#ifdef HAVE_BREAKPAD
+    BreakpadRelease(breakpad);
+#endif
+
     return ret;
 }
diff --git a/modules/gui/macosx/Resources/Info.plist.in b/modules/gui/macosx/Resources/Info.plist.in
index 28e6738..d018b1f 100644
--- a/modules/gui/macosx/Resources/Info.plist.in
+++ b/modules/gui/macosx/Resources/Info.plist.in
@@ -1477,6 +1477,12 @@
 	<string>@VERSION@</string>
 	<key>CFBundleSignature</key>
 	<string>VLC#</string>
+	<key>BreakpadProduct</key>
+	<string>VLC-macOS</string>
+	<key>BreakpadVendor</key>
+	<string>VideoLAN</string>
+	<key>BreakpadRequestComments</key>
+	<string>1</string>
 	<key>CFBundleURLTypes</key>
 	<array>
 		<dict>
-- 
2.10.1 (Apple Git-78)



More information about the vlc-devel mailing list