diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2018-08-22 10:48:29 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2018-08-22 10:48:29 -0400 |
commit | 7dc014474de0c2d83a3cd314acd9dc0882622299 (patch) | |
tree | 9f72ece0fde5764a41733d6853992dc0196bce78 /indra/newview/llappviewermacosx.cpp | |
parent | 302052700b4605605808b90bed8fb1c5a93ece22 (diff) |
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.
Diffstat (limited to 'indra/newview/llappviewermacosx.cpp')
-rw-r--r-- | indra/newview/llappviewermacosx.cpp | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/indra/newview/llappviewermacosx.cpp b/indra/newview/llappviewermacosx.cpp index c3a3c3284a..7f7284a796 100644 --- a/indra/newview/llappviewermacosx.cpp +++ b/indra/newview/llappviewermacosx.cpp @@ -39,6 +39,7 @@ #include "llappviewermacosx-for-objc.h" #include "llwindowmacosx-objc.h" #include "llcommandlineparser.h" +#include "llsdserialize.h" #include "llviewernetwork.h" #include "llviewercontrol.h" @@ -53,6 +54,7 @@ #endif #include <vector> #include <exception> +#include <fstream> #include "lldir.h" #include <signal.h> @@ -150,19 +152,48 @@ void cleanupViewer() gViewerAppPtr = NULL; } -std::string getOldLogFilePathname() +// The BugsplatMac API is structured as a number of different method +// overrides, each returning a different piece of metadata. But since we +// obtain such metadata by opening and parsing a file, it seems ridiculous to +// reopen and reparse it for every individual string desired. What we want is +// to open and parse the file once, retaining the data for subsequent +// requests. That's why this is an LLSingleton. +// Another approach would be to provide a function that simply returns +// CrashMetadata, storing the struct in LLAppDelegate, but nat doesn't know +// enough Objective-C++ to code that. We'd still have to detect which of the +// method overrides is called first so that the results are order-insensitive. +class CrashMetadataSingleton: public CrashMetadata, public LLSingleton<CrashMetadataSingleton> { - return gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.old"); -} + LLSINGLETON(CrashMetadataSingleton); +}; -std::string getFatalMessage() +// Populate the fields of our public base-class struct. +CrashMetadataSingleton::CrashMetadataSingleton() { - return LLError::getFatalMessage(); + // Note: we depend on being able to read the static_debug_info.log file + // from the *previous* run before we overwrite it with the new one for + // *this* run. LLAppViewer initialization must happen in the Right Order. + staticDebugPathname = *gViewerAppPtr->getStaticDebugFile(); + std::ifstream static_file(staticDebugPathname); + LLSD info; + if (static_file.is_open() && + LLSDSerialize::deserialize(info, static_file, LLSDSerialize::SIZE_UNLIMITED)) + { + logFilePathname = info["SLLog"].asString(); + userSettingsPathname = info["SettingsFilename"].asString(); + OSInfo = info["OSInfo"].asString(); + agentFullname = info["LoginName"].asString(); + // Translate underscores back to spaces + LLStringUtil::replaceChar(agentFullname, '_', ' '); + regionName = info["CurrentRegion"].asString(); + fatalMessage = info["FatalMessage"].asString(); + } } -std::string getAgentFullname() +// Avoid having to compile all of our LLSingleton machinery in Objective-C++. +CrashMetadata& CrashMetadata_instance() { - return gAgentAvatarp? gAgentAvatarp->getFullname() : std::string(); + return CrashMetadataSingleton::instance(); } void infos(const std::string& message) |