From 881bdec4b356ede32b0d0896334f7d6addac6c54 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 21 May 2018 13:07:44 -0400 Subject: SL-821: Introduce macOS BugSplat initialization. --- indra/newview/llappdelegate-objc.mm | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index aebae4c434..2fa8319260 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -25,6 +25,9 @@ */ #import "llappdelegate-objc.h" +#if defined(LL_BUGSPLAT) +#import BugsplatMac; +#endif #include "llwindowmacosx-objc.h" #include // Used for Text Input Services ("Safe" API - it's supported) @@ -64,6 +67,11 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil]; // [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; + +#if defined(LL_BUGSPLAT) + // https://www.bugsplat.com/docs/platforms/os-x#initialization + [[BugsplatStartupManager sharedManager] start]; +#endif } - (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { -- cgit v1.2.3 From 3a885e9cb7bb86e82036b217e2aaf2d96106be43 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 21 May 2018 13:29:16 -0400 Subject: SL-821: Use @import, not #import. --- indra/newview/llappdelegate-objc.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 2fa8319260..e8b4272e51 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -26,7 +26,7 @@ #import "llappdelegate-objc.h" #if defined(LL_BUGSPLAT) -#import BugsplatMac; +@import BugsplatMac; #endif #include "llwindowmacosx-objc.h" #include // Used for Text Input Services ("Safe" API - it's supported) -- cgit v1.2.3 From 63fe7d802aad177107ef8e3bc0c9b7ea5118ad61 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 25 May 2018 12:09:50 -0400 Subject: SL-821, SL-826: Use BUGSPLAT_DB from environment on Windows and Mac. On TeamCity, set BUGSPLAT_DB from build-secrets. Use the presence of $BUGSPLAT_DB, rather than a new CMake BUGSPLAT option, to control whether CMake searches for BugSplat -- and passes LL_BUGSPLAT into C++. When BUGSPLAT_DB is present, make viewer_manifest.py set "BugSplat DB" in build_data.json, and "BugsplatServerURL" in Mac Info.plist. Make llappviewerwin32.cpp read "BugSplat DB" from build_data.json. Add placeholders for Mac hooks to suppress BugSplat prompt and send SecondLife.log. --- indra/newview/llappdelegate-objc.mm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index e8b4272e51..8e1ad169c9 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -70,6 +70,8 @@ #if defined(LL_BUGSPLAT) // https://www.bugsplat.com/docs/platforms/os-x#initialization +// [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; +// [BugsplatStartupManager sharedManager].askUserDetails = NO; [[BugsplatStartupManager sharedManager] start]; #endif } @@ -187,4 +189,21 @@ return true; } +#if 0 // defined(LL_BUGSPLAT) + +@implementation BugsplatStartupManagerDelegate + +- (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { + NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"example" withExtension:@"json"]; + NSData *data = [NSData dataWithContentsOfURL:fileURL]; + + BugsplatAttachment *attachment = + [[BugsplatAttachment alloc] initWithFilename:@"example.json" + attachmentData:data + contentType:@"application/json"]; + return attachment; +} + +#endif // LL_BUGSPLAT + @end -- cgit v1.2.3 From 448e82f39c472c82620bb52e0644e258b363d562 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 15 Jun 2018 16:48:20 -0400 Subject: SL-821: Try to add SecondLife.log file to Mac BugSplat crash report. Introduce new header file llappviewermacosx-for-objc.h to publish for llappdelegate-objc.mm and other Objective-C++ consumers the free functions in llappviewermacosx.cpp they consume. These were never before declared in any header file. Apparently, to date, we've been trusting to luck that Objective-C++ will infer the correct signature from calls -- and that the calls are correct with respect to the function definitions. :-P This gives us a place to introduce a new getLogFilePathname() function to query LLDir. (We don't simply #include "lldir.h" because of the pervasive use of BOOL in viewer headers; BOOL means something very different in Objective-C++.) --- indra/newview/llappdelegate-objc.mm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 8e1ad169c9..ad5398721b 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -29,6 +29,7 @@ @import BugsplatMac; #endif #include "llwindowmacosx-objc.h" +#include "llappviewermacosx-for-objc.h" #include // Used for Text Input Services ("Safe" API - it's supported) @implementation LLAppDelegate @@ -189,18 +190,22 @@ return true; } -#if 0 // defined(LL_BUGSPLAT) +#if defined(LL_BUGSPLAT) @implementation BugsplatStartupManagerDelegate - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - NSURL *fileURL = [[NSBundle mainBundle] URLForResource:@"example" withExtension:@"json"]; - NSData *data = [NSData dataWithContentsOfURL:fileURL]; - + std::string logfile = getLogFilePathname(); + NSString *ns_logfile = [NSString stringWithCString:logfile->c_str() + encoding:NSUTF8StringEncoding]; + NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; + + // Apologies for the hard-coded log-file basename, but I do not know the + // incantation for "$(basename "$logfile")" in this language. BugsplatAttachment *attachment = - [[BugsplatAttachment alloc] initWithFilename:@"example.json" + [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log" attachmentData:data - contentType:@"application/json"]; + contentType:@"text/plain"]; return attachment; } -- cgit v1.2.3 From 1d7687efb2bb8785b6a2a2f620d05fe1cb84f922 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 15 Jun 2018 17:58:00 -0400 Subject: SL-821: Fix up Objective-C++ syntax errors. --- indra/newview/llappdelegate-objc.mm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index ad5398721b..008203fd32 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -190,13 +190,15 @@ return true; } +@end + #if defined(LL_BUGSPLAT) @implementation BugsplatStartupManagerDelegate - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { std::string logfile = getLogFilePathname(); - NSString *ns_logfile = [NSString stringWithCString:logfile->c_str() + NSString *ns_logfile = [NSString stringWithCString:logfile.c_str() encoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; @@ -209,6 +211,6 @@ return attachment; } -#endif // LL_BUGSPLAT - @end + +#endif // LL_BUGSPLAT -- cgit v1.2.3 From b889c15cddccdfa5dd164388a566e4c63bbdf6f3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 18 Jun 2018 12:57:12 -0400 Subject: SL-821: Fix BugSplat attachment method override per BugSplat support. The example code on the BugSplat documentation page https://www.bugsplat.com/docs/platforms/os-x#configuration omits certain essential Objective-C++ boilerplate incantations. Adding them at least compiles successfully. --- indra/newview/llappdelegate-objc.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 008203fd32..11a4b5d48e 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -194,7 +194,11 @@ #if defined(LL_BUGSPLAT) -@implementation BugsplatStartupManagerDelegate +// per Geoff at BugSplat support +@interface AppDelegate : NSObject +@end + +@implementation AppDelegate - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { std::string logfile = getLogFilePathname(); -- cgit v1.2.3 From 6e790fc27d22e80527789cf8e783be6c90a23505 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 18 Jun 2018 16:38:49 -0400 Subject: SL-821: Add logging in the macOS BugSplat attachment override. --- indra/newview/llappdelegate-objc.mm | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 11a4b5d48e..2c2302ecfb 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -202,9 +202,12 @@ - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { std::string logfile = getLogFilePathname(); + infos("Reached attachmentForBugsplatStartupManager with:"); + infos(logfile); NSString *ns_logfile = [NSString stringWithCString:logfile.c_str() encoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; + infos("Read logfile"); // Apologies for the hard-coded log-file basename, but I do not know the // incantation for "$(basename "$logfile")" in this language. @@ -212,6 +215,7 @@ [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log" attachmentData:data contentType:@"text/plain"]; + infos("returning attachment"); return attachment; } -- cgit v1.2.3 From c9898f1b69a53cd5d3e7bb49f77a764dde43772e Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jun 2018 09:37:28 -0400 Subject: SL-821: Try again to override BugSplat Obj-C methods. --- indra/newview/llappdelegate-objc.mm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 2c2302ecfb..68b803c367 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -27,6 +27,9 @@ #import "llappdelegate-objc.h" #if defined(LL_BUGSPLAT) @import BugsplatMac; +// derived from BugsplatMac's BugsplatTester/AppDelegate.m +@interface LLAppDelegate () +@end #endif #include "llwindowmacosx-objc.h" #include "llappviewermacosx-for-objc.h" @@ -190,15 +193,14 @@ return true; } -@end - #if defined(LL_BUGSPLAT) -// per Geoff at BugSplat support -@interface AppDelegate : NSObject -@end - -@implementation AppDelegate +- (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager +{ +// return NSStringFromSelector(_cmd); + infos("Reached applicationLogForBugsplatStartupManager"); + return @"[contents of SecondLife.log]"; +} - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { std::string logfile = getLogFilePathname(); @@ -219,6 +221,6 @@ return attachment; } -@end - #endif // LL_BUGSPLAT + +@end -- cgit v1.2.3 From 3376b2acfbea2f6d2d8f79ecf890702e1ab60ae3 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jun 2018 13:34:08 -0400 Subject: SL-821: Another Objective-C++ magic incantation from BugSplat support. --- indra/newview/llappdelegate-objc.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 68b803c367..2ee294e1e6 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -76,6 +76,7 @@ // https://www.bugsplat.com/docs/platforms/os-x#initialization // [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; // [BugsplatStartupManager sharedManager].askUserDetails = NO; + [BugsplatStartupManager sharedManager].delegate = self; [[BugsplatStartupManager sharedManager] start]; #endif } -- cgit v1.2.3 From d26c931ae2c5d33adc5fc20842b7be838a2822b4 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Jun 2018 15:08:56 -0400 Subject: SL-821: Send the SecondLife.log from the previous (crashed) run. Also clean up log messages. --- indra/newview/llappdelegate-objc.mm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 2ee294e1e6..4510f4070f 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -196,21 +196,27 @@ #if defined(LL_BUGSPLAT) +#if 0 +// Apparently this override method only contributes the User Description field +// of BugSplat's All Crashes table. Despite the method name, it would seem to +// be a bad place to try to stuff all of SecondLife.log. - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { // return NSStringFromSelector(_cmd); infos("Reached applicationLogForBugsplatStartupManager"); return @"[contents of SecondLife.log]"; } +#endif - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - std::string logfile = getLogFilePathname(); - infos("Reached attachmentForBugsplatStartupManager with:"); - infos(logfile); + // We get the *old* log file pathname (for SecondLife.old) because it's on + // the run *following* the crash that BugsplatStartupManager notices that + // the previous run crashed and calls this override. By that time, we've + // already renamed SecondLife.log to SecondLife.old. + std::string logfile = getOldLogFilePathname(); NSString *ns_logfile = [NSString stringWithCString:logfile.c_str() encoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; - infos("Read logfile"); // Apologies for the hard-coded log-file basename, but I do not know the // incantation for "$(basename "$logfile")" in this language. @@ -218,7 +224,7 @@ [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log" attachmentData:data contentType:@"text/plain"]; - infos("returning attachment"); + infos("attachmentForBugsplatStartupManager: attaching " + logfile); return attachment; } -- cgit v1.2.3 From cd52724ef8f8a19ebe28c73f39a582b56fb58093 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 28 Jun 2018 21:49:07 -0400 Subject: DRTVWR-447: Suppress BugSplat UI; auto-fill certain BugSplat data. Direct BugSplat to send crash reports without prompting, on both Windows and Mac. Add a mechanism by which code called after LL_ERRS() can retrieve the fatal log message string. (How did the crash logger extract that for Linden crash logging?) Add that fatal message to crash reports on Windows. But as BugsplatMac is engaged only on the run _after_ the crash, we no longer have that message in memory. Also add user name and region location to Windows crash reports. On Mac, (a) we don't have the information from the previous run and (b) BugsplatMac doesn't provide an API to attach that information to the crash report. Add Mac logging to indicate the success or failure of sending the crash report. Add Windows logging to indicate we're about to send. --- indra/newview/llappdelegate-objc.mm | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 4510f4070f..82e49540a4 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -74,9 +74,9 @@ #if defined(LL_BUGSPLAT) // https://www.bugsplat.com/docs/platforms/os-x#initialization -// [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; -// [BugsplatStartupManager sharedManager].askUserDetails = NO; - [BugsplatStartupManager sharedManager].delegate = self; + [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; + [BugsplatStartupManager sharedManager].askUserDetails = NO; + [BugsplatStartupManager sharedManager].delegate = self; [[BugsplatStartupManager sharedManager] start]; #endif } @@ -196,17 +196,20 @@ #if defined(LL_BUGSPLAT) -#if 0 -// Apparently this override method only contributes the User Description field -// of BugSplat's All Crashes table. Despite the method name, it would seem to -// be a bad place to try to stuff all of SecondLife.log. - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { -// return NSStringFromSelector(_cmd); infos("Reached applicationLogForBugsplatStartupManager"); - return @"[contents of SecondLife.log]"; + // Apparently this override method only contributes the User Description + // field of BugSplat's All Crashes table. Despite the method name, it + // would seem to be a bad place to try to stuff all of SecondLife.log. + return [NSString stringWithCString:getFatalMessage().c_str() + encoding:NSUTF8StringEncoding]; +} + +- (void)bugsplatStartupManagerWillSendCrashReport:(BugsplatStartupManager *)bugsplatStartupManager +{ + infos("Reached bugsplatStartupManagerWillSendCrashReport"); } -#endif - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { // We get the *old* log file pathname (for SecondLife.old) because it's on @@ -228,6 +231,17 @@ return attachment; } +- (void)bugsplatStartupManagerDidFinishSendingCrashReport:(BugsplatStartupManager *)bugsplatStartupManager +{ + infos("Sent crash report to BugSplat"); +} + +- (void)bugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager didFailWithError:(NSError *)error +{ + // TODO: message string from NSError + infos("Could not send crash report to BugSplat"); +} + #endif // LL_BUGSPLAT @end -- cgit v1.2.3 From 7dc014474de0c2d83a3cd314acd9dc0882622299 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 22 Aug 2018 10:48:29 -0400 Subject: DRTVWR-447: Attempt to post BugSplat metadata with Mac crash reports. Introduce CrashMetadata, an LLSingleton in llappviewermacosx.cpp, declared in llappviewermacosx-for-objc.h and accessed by the various BugsplatStartupManagerDelegate override methods. CrashMetadata is populated by reading the previous (presumably crashed) run's static_debug_info.log file. This replaces the previous getOldLogFilePathname(), getFatalMessage() and getAgentFullname() functions. To extend that suite for additional metadata, not only would we have to keep adding new free functions, but we'd have to keep rereading the static_debug_info.log file. Override the new applicationKeyForBugsplatStartupManager, defaultUserNameForBugsplatStartupManager, defaultUserEmailForBugsplatStartupManager methods to extract relevant fields from CrashMetadata. Change applicationLogForBugsplatStartupManager and attachmentForBugsplatStartupManager to do the same. Enhance llviewerregion.cpp to update the static_debug_info.log file every time we enter a new region. --- indra/newview/llappdelegate-objc.mm | 43 +++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 82e49540a4..ba697d0f77 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -199,10 +199,34 @@ - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { infos("Reached applicationLogForBugsplatStartupManager"); - // Apparently this override method only contributes the User Description - // field of BugSplat's All Crashes table. Despite the method name, it - // would seem to be a bad place to try to stuff all of SecondLife.log. - return [NSString stringWithCString:getFatalMessage().c_str() + // This strangely-named override method contributes the User Description + // metadata field. + return [NSString stringWithCString:CrashMetadata_instance().fatalMessage.c_str() + encoding:NSUTF8StringEncoding]; +} + +- (NSString *)applicationKeyForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager signal:(NSString *)signal exceptionName:(NSString *)exceptionName exceptionReason:(NSString *)exceptionReason { + // TODO: exceptionName, exceptionReason + + // Windows sends location within region as well, but that's because + // BugSplat for Windows intercepts crashes during the same run, and that + // information can be queried once. On the Mac, any metadata we have is + // written (and rewritten) to the static_debug_info.log file that we read + // at the start of the next viewer run. It seems ridiculously expensive to + // rewrite that file on every frame in which the avatar moves. + return [NSString stringWithCString:CrashMetadata_instance().regionName.c_str() + encoding:NSUTF8StringEncoding]; +} + +- (NSString *)defaultUserNameForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { + return [NSString stringWithCString:CrashMetadata_instance().agentFullname.c_str() + encoding:NSUTF8StringEncoding]; +} + +- (NSString *)defaultUserEmailForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { + // Use the email field for OS version, just as we do on Windows, until + // BugSplat provides more metadata fields. + return [NSString stringWithCString:CrashMetadata_instance().OSInfo.c_str() encoding:NSUTF8StringEncoding]; } @@ -212,11 +236,12 @@ } - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - // We get the *old* log file pathname (for SecondLife.old) because it's on - // the run *following* the crash that BugsplatStartupManager notices that - // the previous run crashed and calls this override. By that time, we've - // already renamed SecondLife.log to SecondLife.old. - std::string logfile = getOldLogFilePathname(); + std::string logfile = CrashMetadata_instance().logFilePathname; + // Still to do: + // userSettingsPathname + // staticDebugPathname + // but the BugsplatMac version 1.0.5 BugsplatStartupManagerDelegate API + // doesn't yet provide a way to attach more than one file. NSString *ns_logfile = [NSString stringWithCString:logfile.c_str() encoding:NSUTF8StringEncoding]; NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; -- cgit v1.2.3 From 787053ffeb70f4e3d7ade36290ad7e75f1146b74 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 22 Aug 2018 13:26:19 -0400 Subject: DRTVWR-447: Add logging to BugsplatMac override methods. --- indra/newview/llappdelegate-objc.mm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index ba697d0f77..66bcf58961 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -198,10 +198,11 @@ - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - infos("Reached applicationLogForBugsplatStartupManager"); + std::string fatalMessage(CrashMetadata_instance().fatalMessage); + infos("applicationLogForBugsplatStartupManager -> '" + fatalMessage + "'"); // This strangely-named override method contributes the User Description // metadata field. - return [NSString stringWithCString:CrashMetadata_instance().fatalMessage.c_str() + return [NSString stringWithCString:fatalMessage.c_str() encoding:NSUTF8StringEncoding]; } @@ -214,25 +215,31 @@ // written (and rewritten) to the static_debug_info.log file that we read // at the start of the next viewer run. It seems ridiculously expensive to // rewrite that file on every frame in which the avatar moves. - return [NSString stringWithCString:CrashMetadata_instance().regionName.c_str() + std::string regionName(CrashMetadata_instance().regionName); + infos("applicationKeyForBugsplatStartupManager -> '" + regionName + "'"); + return [NSString stringWithCString:regionName.c_str() encoding:NSUTF8StringEncoding]; } - (NSString *)defaultUserNameForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - return [NSString stringWithCString:CrashMetadata_instance().agentFullname.c_str() + std::string agentFullname(CrashMetadata_instance().agentFullname); + infos("defaultUserNameForBugsplatStartupManager -> '" + agentFullname + "'"); + return [NSString stringWithCString:agentFullname.c_str() encoding:NSUTF8StringEncoding]; } - (NSString *)defaultUserEmailForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { // Use the email field for OS version, just as we do on Windows, until // BugSplat provides more metadata fields. - return [NSString stringWithCString:CrashMetadata_instance().OSInfo.c_str() + std::string OSInfo(CrashMetadata_instance().OSInfo); + infos("defaultUserEmailForBugsplatStartupManager -> '" + OSInfo + "'"); + return [NSString stringWithCString:OSInfo.c_str() encoding:NSUTF8StringEncoding]; } - (void)bugsplatStartupManagerWillSendCrashReport:(BugsplatStartupManager *)bugsplatStartupManager { - infos("Reached bugsplatStartupManagerWillSendCrashReport"); + infos("bugsplatStartupManagerWillSendCrashReport"); } - (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { @@ -252,7 +259,7 @@ [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log" attachmentData:data contentType:@"text/plain"]; - infos("attachmentForBugsplatStartupManager: attaching " + logfile); + infos("attachmentForBugsplatStartupManager attaching " + logfile); return attachment; } -- cgit v1.2.3 From e674f11757ab55c5ca7aab4cb1c8e059fa98f466 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 23 Aug 2018 12:31:54 -0400 Subject: DRTVWR-447: Add (some) metadata to Mac crash reports. This required reordering certain operations during Mac viewer startup. Split llappviewermacosx.cpp's initViewer() function into constructViewer() (which instantiates LLAppViewerMacOSX) and initViewer() (which calls LLAppViewerMacOSX::init()). llappdelegate-objc.mm's applicationDidFinishLaunching override now calls [BugsplatStartupManager start] between constructViewer() and initViewer(): we want constructViewer() to have set up the logging subsystem so we can log the actions of BugsplatStartupManagerDelegate override methods, but otherwise we want BugsplatStartupManager in place as early as possible to catch any early crashes. Besides, initViewer() ends up overwriting the static_debug_info.log on which we depend for the *previous* run's crash metadata. Move the code that initializes the pathname of the static_debug_info.log file from LLAppViewerMacOSX::init() to the LLAppViewerMacOSX() constructor, since BugsplatStartupManagerDelegate override methods need to read (the previous run's) file. Add code to applicationLogForBugsplatStartupManager override to set new BugsplatMac 1.0.6 properties userName and userEmail. Don't log empty fields from static_debug_info.log if we couldn't read it. --- indra/newview/llappdelegate-objc.mm | 55 ++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 13 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index 66bcf58961..f55304f30b 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -54,6 +54,25 @@ - (void) applicationDidFinishLaunching:(NSNotification *)notification { + // Call constructViewer() first so our logging subsystem is in place. This + // risks missing crashes in the LLAppViewerMacOSX constructor, but for + // present purposes it's more important to get the startup sequence + // properly logged. + // Someday I would like to modify the logging system so that calls before + // it's initialized are cached in a std::ostringstream and then, once it's + // initialized, "played back" into whatever handlers have been set up. + constructViewer(); + +#if defined(LL_BUGSPLAT) + // Engage BugsplatStartupManager *before* calling initViewer() to handle + // any crashes during initialization. + // https://www.bugsplat.com/docs/platforms/os-x#initialization + [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; + [BugsplatStartupManager sharedManager].askUserDetails = NO; + [BugsplatStartupManager sharedManager].delegate = self; + [[BugsplatStartupManager sharedManager] start]; +#endif + frameTimer = nil; [self languageUpdated]; @@ -71,14 +90,6 @@ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(languageUpdated) name:@"NSTextInputContextKeyboardSelectionDidChangeNotification" object:nil]; // [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self andSelector:@selector(handleGetURLEvent:withReplyEvent:) forEventClass:kInternetEventClass andEventID:kAEGetURL]; - -#if defined(LL_BUGSPLAT) - // https://www.bugsplat.com/docs/platforms/os-x#initialization - [BugsplatStartupManager sharedManager].autoSubmitCrashReport = YES; - [BugsplatStartupManager sharedManager].askUserDetails = NO; - [BugsplatStartupManager sharedManager].delegate = self; - [[BugsplatStartupManager sharedManager] start]; -#endif } - (void) handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent { @@ -198,11 +209,29 @@ - (NSString *)applicationLogForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - std::string fatalMessage(CrashMetadata_instance().fatalMessage); - infos("applicationLogForBugsplatStartupManager -> '" + fatalMessage + "'"); - // This strangely-named override method contributes the User Description - // metadata field. - return [NSString stringWithCString:fatalMessage.c_str() + CrashMetadata& meta(CrashMetadata_instance()); + // As of BugsplatMac 1.0.6, userName and userEmail properties are now + // exposed by the BugsplatStartupManager. Set them here, since the + // defaultUserNameForBugsplatStartupManager and + // defaultUserEmailForBugsplatStartupManager methods are called later, for + // the *current* run, rather than for the previous crashed run whose crash + // report we are about to send. + infos("applicationLogForBugsplatStartupManager setting userName = '" + + meta.agentFullname + '"'); + bugsplatStartupManager.userName = + [NSString stringWithCString:meta.agentFullname.c_str() + encoding:NSUTF8StringEncoding]; + // Use the email field for OS version, just as we do on Windows, until + // BugSplat provides more metadata fields. + infos("applicationLogForBugsplatStartupManager setting userEmail = '" + + meta.OSInfo + '"'); + bugsplatStartupManager.userEmail = + [NSString stringWithCString:meta.OSInfo.c_str() + encoding:NSUTF8StringEncoding]; + // This strangely-named override method's return value contributes the + // User Description metadata field. + infos("applicationLogForBugsplatStartupManager -> '" + meta.fatalMessage + "'"); + return [NSString stringWithCString:meta.fatalMessage.c_str() encoding:NSUTF8StringEncoding]; } -- cgit v1.2.3 From 9cdcef4d501f4a7fec3b1c7051037df9db082278 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 16 Oct 2018 16:53:06 -0400 Subject: DRTVWR-447: Use new attachmentsForBugsplatStartupManager SDK method to attach user settings file and static debug info file to Mac crash reports, as well as SecondLife.log, just like Windows crash reports. --- indra/newview/llappdelegate-objc.mm | 74 +++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 19 deletions(-) (limited to 'indra/newview/llappdelegate-objc.mm') diff --git a/indra/newview/llappdelegate-objc.mm b/indra/newview/llappdelegate-objc.mm index f55304f30b..1d55537427 100644 --- a/indra/newview/llappdelegate-objc.mm +++ b/indra/newview/llappdelegate-objc.mm @@ -26,6 +26,8 @@ #import "llappdelegate-objc.h" #if defined(LL_BUGSPLAT) +#include +#include @import BugsplatMac; // derived from BugsplatMac's BugsplatTester/AppDelegate.m @interface LLAppDelegate () @@ -271,25 +273,59 @@ infos("bugsplatStartupManagerWillSendCrashReport"); } -- (BugsplatAttachment *)attachmentForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager { - std::string logfile = CrashMetadata_instance().logFilePathname; - // Still to do: - // userSettingsPathname - // staticDebugPathname - // but the BugsplatMac version 1.0.5 BugsplatStartupManagerDelegate API - // doesn't yet provide a way to attach more than one file. - NSString *ns_logfile = [NSString stringWithCString:logfile.c_str() - encoding:NSUTF8StringEncoding]; - NSData *data = [NSData dataWithContentsOfFile:ns_logfile]; - - // Apologies for the hard-coded log-file basename, but I do not know the - // incantation for "$(basename "$logfile")" in this language. - BugsplatAttachment *attachment = - [[BugsplatAttachment alloc] initWithFilename:@"SecondLife.log" - attachmentData:data - contentType:@"text/plain"]; - infos("attachmentForBugsplatStartupManager attaching " + logfile); - return attachment; +struct AttachmentInfo +{ + AttachmentInfo(const std::string& path, const std::string& type): + pathname(path), + basename(boost::filesystem::path(path).filename().string()), + mimetype(type) + {} + + std::string pathname, basename, mimetype; +}; + +- (NSArray *)attachmentsForBugsplatStartupManager:(BugsplatStartupManager *)bugsplatStartupManager +{ + const CrashMetadata& metadata(CrashMetadata_instance()); + + // Since we must do very similar processing for each of several file + // pathnames, start by collecting them into a vector so we can iterate + // instead of spelling out the logic for each. + std::vector info{ + AttachmentInfo(metadata.logFilePathname, "text/plain"), + AttachmentInfo(metadata.userSettingsPathname, "text/xml"), + AttachmentInfo(metadata.staticDebugPathname, "text/xml") + }; + + // We "happen to know" that info[0].basename is "SecondLife.old" -- due to + // the fact that BugsplatMac only notices a crash during the viewer run + // following the crash. Replace .old with .log to reduce confusion. + info[0].basename = + boost::filesystem::path(info[0].pathname).stem().string() + ".log"; + + NSMutableArray *attachments = [[NSMutableArray alloc] init]; + + // Iterate over each AttachmentInfo in info vector + for (const AttachmentInfo& attach : info) + { + NSString *nspathname = [NSString stringWithCString:attach.pathname.c_str() + encoding:NSUTF8StringEncoding]; + NSString *nsbasename = [NSString stringWithCString:attach.basename.c_str() + encoding:NSUTF8StringEncoding]; + NSString *nsmimetype = [NSString stringWithCString:attach.mimetype.c_str() + encoding:NSUTF8StringEncoding]; + NSData *nsdata = [NSData dataWithContentsOfFile:nspathname]; + + BugsplatAttachment *attachment = + [[BugsplatAttachment alloc] initWithFilename:nsbasename + attachmentData:nsdata + contentType:nsmimetype]; + + [attachments addObject:attachment]; + infos("attachmentsForBugsplatStartupManager attaching " + attach.pathname); + } + + return attachments; } - (void)bugsplatStartupManagerDidFinishSendingCrashReport:(BugsplatStartupManager *)bugsplatStartupManager -- cgit v1.2.3