diff options
| author | Nat Goodspeed <nat@lindenlab.com> | 2018-05-17 06:53:42 -0400 | 
|---|---|---|
| committer | Nat Goodspeed <nat@lindenlab.com> | 2018-05-17 06:53:42 -0400 | 
| commit | c5f618d096f05bdff91a5d384c46e26840f5a771 (patch) | |
| tree | dc1299b8445c97c9bc165e2388a1b39d21dcddb1 /indra/newview | |
| parent | c45fc5a381de69ab95680f8902c4fdfddd7cd97a (diff) | |
SL-821: Move Windows BugSplat engagement from llcommon to newview.
Use WSTRINGIZE(), LL_TO_WSTRING(), wstringize() to produce required wide
strings. Use a lambda for callback that sends log file; use LLDir, if set, to
find the log file.
Introduce BUGSPLAT CMake variable to allow suppressing BugSplat.
Make BUGSPLAT CMake variable set LL_BUGSPLAT for C++ compilations.
Set viewer version macros on llappviewerwin32.cpp, llappviewerlinux.cpp and
llappdelegate-objc.mm -- because BugSplat needs the viewer version data, and
because the macOS BugSplat hook is engaged in an Objective-C++ function we
override in the app delegate.
Diffstat (limited to 'indra/newview')
| -rw-r--r-- | indra/newview/CMakeLists.txt | 23 | ||||
| -rw-r--r-- | indra/newview/llappviewerwin32.cpp | 49 | 
2 files changed, 67 insertions, 5 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 1fd0af0558..2592b532c4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1354,6 +1354,11 @@ if (DARWIN)    # This should be compiled with the viewer.    LIST(APPEND viewer_SOURCE_FILES llappdelegate-objc.mm) +  set_source_files_properties( +    llappdelegate-objc.mm +    PROPERTIES +    COMPILE_DEFINITIONS "${VIEWER_CHANNEL_VERSION_DEFINES}" +    )    find_library(AGL_LIBRARY AGL)    find_library(APPKIT_LIBRARY AppKit) @@ -1366,6 +1371,7 @@ if (DARWIN)      ${AGL_LIBRARY}      ${IOKIT_LIBRARY}      ${COREAUDIO_LIBRARY} +    ${BUGSPLAT_LIBRARIES}      )    # Add resource files to the project. @@ -1393,6 +1399,11 @@ endif (DARWIN)  if (LINUX)      LIST(APPEND viewer_SOURCE_FILES llappviewerlinux.cpp) +    set_source_files_properties( +      llappviewerlinux.cpp +      PROPERTIES +      COMPILE_DEFINITIONS "${VIEWER_CHANNEL_VERSION_DEFINES}" +      )      LIST(APPEND viewer_SOURCE_FILES llappviewerlinux_api_dbus.cpp)      SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") @@ -1409,6 +1420,11 @@ if (WINDOWS)           llappviewerwin32.cpp           llwindebug.cpp           ) +    set_source_files_properties( +      llappviewerwin32.cpp +      PROPERTIES +      COMPILE_DEFINITIONS "${VIEWER_CHANNEL_VERSION_DEFINES}" +      )      list(APPEND viewer_HEADER_FILES           llappviewerwin32.h @@ -1692,6 +1708,11 @@ if (SDL_FOUND)      )  endif (SDL_FOUND) +if (BUGSPLAT) +  set_property(TARGET ${VIEWER_BINARY_NAME} +    PROPERTY COMPILE_DEFINITIONS "LL_BUGSPLAT") +endif (BUGSPLAT) +  # add package files  file(GLOB EVENT_HOST_SCRIPT_GLOB_LIST       ${CMAKE_CURRENT_SOURCE_DIR}/../viewer_components/*.py) @@ -1790,7 +1811,7 @@ if (WINDOWS)             ${SHARED_LIB_STAGING_DIR}/Debug/fmodexL.dll            )      endif (FMODEX) -     +      add_custom_command(        OUTPUT  ${CMAKE_CFG_INTDIR}/copy_touched.bat        COMMAND ${PYTHON_EXECUTABLE} diff --git a/indra/newview/llappviewerwin32.cpp b/indra/newview/llappviewerwin32.cpp index 48b3a1c485..8a014c55d7 100644 --- a/indra/newview/llappviewerwin32.cpp +++ b/indra/newview/llappviewerwin32.cpp @@ -66,8 +66,18 @@  #endif  #include "stringize.h" +#include "lldir.h"  #include <exception> + +// Bugsplat (http://bugsplat.com) crash reporting tool +#ifdef LL_BUGSPLAT +#include "BugSplat.h" + +// FIXME: need a production BugSplat database name +static const wchar_t *bugdb_name = L"second_life_callum_test"; +#endif +  namespace  {      void (*gOldTerminateHandler)() = NULL; @@ -495,15 +505,46 @@ bool LLAppViewerWin32::init()  	LLWinDebug::instance();  #endif -#if LL_WINDOWS  #if LL_SEND_CRASH_REPORTS - +#if ! defined(LL_BUGSPLAT)  	LLAppViewer* pApp = LLAppViewer::instance();  	pApp->initCrashReporting(); -#endif -#endif +#else // LL_BUGSPLAT + +	std::wstring version_string(WSTRINGIZE(LL_VIEWER_VERSION_MAJOR << '.' << +										   LL_VIEWER_VERSION_MINOR << '.' << +										   LL_VIEWER_VERSION_PATCH << '.' << +										   LL_VIEWER_VERSION_BUILD)); + +	auto sender = new MiniDmpSender( +		bugdb_name, LL_TO_WSTRING(LL_VIEWER_CHANNEL), version_string.c_str(), nullptr); +	sender->setCallback( +		[sender](unsigned int nCode, void* lpVal1, void* lpVal2) +		{ +			// If we haven't yet initialized LLDir, don't bother trying to +			// find our log file. +			// Alternatively -- if we might encounter trouble trying to query +			// LLDir during crash cleanup -- consider making gDirUtilp an +			// LLPounceable, and attach a callback that stores the pathname to +			// the log file here. +			if (nCode == MDSCB_EXCEPTIONCODE && gDirUtilp) +			{ +				// send the main viewer log file +				// widen to wstring, then pass c_str() +				sender->sendAdditionalFile( +					wstringize(gDirUtilp->getExpandedFilename(LL_PATH_LOGS, "SecondLife.log")).c_str()); +			} + +			return false; +		}); + +	LL_INFOS() << "Engaged BugSplat(" << LL_TO_STRING(LL_VIEWER_CHANNEL) +			   << version_string << ')' << LL_ENDL; + +#endif // LL_BUGSPLAT +#endif // LL_SEND_CRASH_REPORTS  	bool success = LLAppViewer::init();  | 
