diff options
Diffstat (limited to 'indra/win_crash_logger')
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/CMakeLists.txt | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/StdAfx.cpp | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/StdAfx.h | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/ll_icon.ico | bin | 2238 -> 2238 bytes | |||
-rw-r--r-- | indra/win_crash_logger/llcrashloggerwindows.cpp | 196 | ||||
-rw-r--r-- | indra/win_crash_logger/llcrashloggerwindows.h | 35 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/resource.h | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/win_crash_logger.cpp | 45 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/win_crash_logger.h | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/win_crash_logger.ico | bin | 1078 -> 1078 bytes | |||
-rwxr-xr-x[-rw-r--r--] | indra/win_crash_logger/win_crash_logger.rc | 0 |
11 files changed, 244 insertions, 43 deletions
diff --git a/indra/win_crash_logger/CMakeLists.txt b/indra/win_crash_logger/CMakeLists.txt index 990dc6783e..c6070020db 100644..100755 --- a/indra/win_crash_logger/CMakeLists.txt +++ b/indra/win_crash_logger/CMakeLists.txt @@ -12,6 +12,7 @@ include(LLWindow) include(LLXML) include(Linking) include(LLSharedLibs) +include(GoogleBreakpad) include_directories( ${LLCOMMON_INCLUDE_DIRS} @@ -20,6 +21,11 @@ include_directories( ${LLWINDOW_INCLUDE_DIRS} ${LLXML_INCLUDE_DIRS} ${LLVFS_INCLUDE_DIRS} + ${BREAKPAD_INCLUDE_DIRECTORIES} + ) +include_directories(SYSTEM + ${LLCOMMON_SYSTEM_INCLUDE_DIRS} + ${LLXML_SYSTEM_INCLUDE_DIRS} ) set(win_crash_logger_SOURCE_FILES @@ -64,6 +70,7 @@ find_library(DXGUID_LIBRARY dxguid ${DIRECTX_LIBRARY_DIR}) add_executable(windows-crash-logger WIN32 ${win_crash_logger_SOURCE_FILES}) target_link_libraries(windows-crash-logger + ${BREAKPAD_EXCEPTION_HANDLER_LIBRARIES} ${LLCRASHLOGGER_LIBRARIES} ${LLWINDOW_LIBRARIES} ${LLVFS_LIBRARIES} @@ -78,6 +85,7 @@ target_link_libraries(windows-crash-logger gdi32 ole32 oleaut32 + wininet Wldap32 ) @@ -89,4 +97,4 @@ if (WINDOWS) ) endif (WINDOWS) -ll_deploy_sharedlibs_command(windows-crash-logger)
\ No newline at end of file +ll_deploy_sharedlibs_command(windows-crash-logger) diff --git a/indra/win_crash_logger/StdAfx.cpp b/indra/win_crash_logger/StdAfx.cpp index f56711af73..f56711af73 100644..100755 --- a/indra/win_crash_logger/StdAfx.cpp +++ b/indra/win_crash_logger/StdAfx.cpp diff --git a/indra/win_crash_logger/StdAfx.h b/indra/win_crash_logger/StdAfx.h index ce70fe2994..35976658ac 100644..100755 --- a/indra/win_crash_logger/StdAfx.h +++ b/indra/win_crash_logger/StdAfx.h @@ -38,7 +38,6 @@ #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - // Windows Header Files: #include <windows.h> diff --git a/indra/win_crash_logger/ll_icon.ico b/indra/win_crash_logger/ll_icon.ico Binary files differindex 566346dfe3..566346dfe3 100644..100755 --- a/indra/win_crash_logger/ll_icon.ico +++ b/indra/win_crash_logger/ll_icon.ico diff --git a/indra/win_crash_logger/llcrashloggerwindows.cpp b/indra/win_crash_logger/llcrashloggerwindows.cpp index 354b7e6cc3..51e70f95b6 100644 --- a/indra/win_crash_logger/llcrashloggerwindows.cpp +++ b/indra/win_crash_logger/llcrashloggerwindows.cpp @@ -34,7 +34,6 @@ #include "boost/tokenizer.hpp" -#include "dbghelp.h" #include "indra_constants.h" // CRASH_BEHAVIOR_ASK, CRASH_SETTING_NAME #include "llerror.h" #include "llfile.h" @@ -43,6 +42,11 @@ #include "lldxhardware.h" #include "lldir.h" #include "llsdserialize.h" +#include "llsdutil.h" +#include "stringize.h" + +#include <client/windows/crash_generation/crash_generation_server.h> +#include <client/windows/crash_generation/client_info.h> #define MAX_LOADSTRING 100 #define MAX_STRING 2048 @@ -65,6 +69,7 @@ BOOL gFirstDialog = TRUE; // Are we currently handling the Send/Don't Send dialo std::stringstream gDXInfo; bool gSendLogs = false; +LLCrashLoggerWindows* LLCrashLoggerWindows::sInstance = NULL; //Conversion from char* to wchar* //Replacement for ATL macros, doesn't allocate memory @@ -241,10 +246,178 @@ LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam LLCrashLoggerWindows::LLCrashLoggerWindows(void) { + if (LLCrashLoggerWindows::sInstance==NULL) + { + sInstance = this; + } } LLCrashLoggerWindows::~LLCrashLoggerWindows(void) { + sInstance = NULL; +} + +bool LLCrashLoggerWindows::getMessageWithTimeout(MSG *msg, UINT to) +{ + bool res; + UINT_PTR timerID = SetTimer(NULL, NULL, to, NULL); + res = GetMessage(msg, NULL, 0, 0); + KillTimer(NULL, timerID); + if (!res) + return false; + if (msg->message == WM_TIMER && msg->hwnd == NULL && msg->wParam == 1) + return false; //TIMEOUT! You could call SetLastError() or something... + return true; +} + +int LLCrashLoggerWindows::processingLoop() { + const int millisecs=1000; + int retries = 0; + const int max_retries = 60; + + LL_DEBUGS("CRASHREPORT") << "Entering processing loop for OOP server" << LL_ENDL; + + LLSD options = getOptionData( LLApp::PRIORITY_COMMAND_LINE ); + + MSG msg; + + bool result; + + while (1) + { + result = getMessageWithTimeout(&msg, millisecs); + if ( result ) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + if ( retries < max_retries ) //Wait up to 1 minute for the viewer to say hello. + { + if (mClientsConnected == 0) + { + LL_DEBUGS("CRASHREPORT") << "Waiting for client to connect." << LL_ENDL; + ++retries; + } + else + { + LL_INFOS("CRASHREPORT") << "Client has connected!" << LL_ENDL; + retries = max_retries; + } + } + else + { + if (mClientsConnected == 0) + { + break; + } + if (!mKeyMaster.isProcessAlive(mPID, mProcName) ) + { + break; + } + } + } + + LL_INFOS() << "session ending.." << LL_ENDL; + + std::string per_run_dir = options["dumpdir"].asString(); + std::string per_run_file = per_run_dir + "\\SecondLife.log"; + std::string log_file = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,"SecondLife.log"); + + if (gDirUtilp->fileExists(per_run_dir)) + { + LL_INFOS ("CRASHREPORT") << "Copying " << log_file << " to " << per_run_file << LL_ENDL; + LLFile::copy(log_file, per_run_file); + } + return 0; +} + + +void LLCrashLoggerWindows::OnClientConnected(void* context, + const google_breakpad::ClientInfo* client_info) +{ + sInstance->mClientsConnected++; + LL_INFOS("CRASHREPORT") << "Client connected. pid = " << client_info->pid() << " total clients " << sInstance->mClientsConnected << LL_ENDL; +} + +void LLCrashLoggerWindows::OnClientExited(void* context, + const google_breakpad::ClientInfo* client_info) +{ + sInstance->mClientsConnected--; + LL_INFOS("CRASHREPORT") << "Client disconnected. pid = " << client_info->pid() << " total clients " << sInstance->mClientsConnected << LL_ENDL; +} + + +void LLCrashLoggerWindows::OnClientDumpRequest(void* context, + const google_breakpad::ClientInfo* client_info, + const std::wstring* file_path) +{ + if (!file_path) + { + LL_WARNS() << "dump with no file path" << LL_ENDL; + return; + } + if (!client_info) + { + LL_WARNS() << "dump with no client info" << LL_ENDL; + return; + } + + LLCrashLoggerWindows* self = static_cast<LLCrashLoggerWindows*>(context); + if (!self) + { + LL_WARNS() << "dump with no context" << LL_ENDL; + return; + } + + //DWORD pid = client_info->pid(); +} + + +bool LLCrashLoggerWindows::initCrashServer() +{ + //For Breakpad on Windows we need a full Out of Process service to get good data. + //This routine starts up the service on a named pipe that the viewer will then + //communicate with. + using namespace google_breakpad; + + LLSD options = getOptionData( LLApp::PRIORITY_COMMAND_LINE ); + std::string dump_path = options["dumpdir"].asString(); + mClientsConnected = 0; + mPID = options["pid"].asInteger(); + mProcName = options["procname"].asString(); + + //Generate a quasi-uniq name for the named pipe. For our purposes + //this is unique-enough with least hassle. Worst case for duplicate name + //is a second instance of the viewer will not do crash reporting. + std::wstring wpipe_name; + wpipe_name = mCrashReportPipeStr + std::wstring(wstringize(mPID)); + + std::wstring wdump_path( wstringize(dump_path) ); + + //Pipe naming conventions: http://msdn.microsoft.com/en-us/library/aa365783%28v=vs.85%29.aspx + mCrashHandler = new CrashGenerationServer( wpipe_name, + NULL, + &LLCrashLoggerWindows::OnClientConnected, this, + /*NULL, NULL, */ &LLCrashLoggerWindows::OnClientDumpRequest, this, + &LLCrashLoggerWindows::OnClientExited, this, + NULL, NULL, + true, &wdump_path); + + if (!mCrashHandler) { + //Failed to start the crash server. + LL_WARNS() << "Failed to init crash server." << LL_ENDL; + return false; + } + + // Start servicing clients. + if (!mCrashHandler->Start()) { + LL_WARNS() << "Failed to start crash server." << LL_ENDL; + return false; + } + + LL_INFOS("CRASHREPORT") << "Initialized OOP server with pipe named " << stringize(wpipe_name) << LL_ENDL; + return true; } bool LLCrashLoggerWindows::init(void) @@ -252,13 +425,15 @@ bool LLCrashLoggerWindows::init(void) bool ok = LLCrashLogger::init(); if(!ok) return false; + initCrashServer(); + /* mbstowcs( gProductName, mProductName.c_str(), LL_ARRAY_SIZE(gProductName) ); gProductName[ LL_ARRY_SIZE(gProductName) - 1 ] = 0; - swprintf(gProductName, L"Second Life"); + swprintf(gProductName, L"Second Life"); */ - llinfos << "Loading dialogs" << llendl; + LL_INFOS() << "Loading dialogs" << LL_ENDL; // Initialize global strings LoadString(mhInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); @@ -292,24 +467,25 @@ void LLCrashLoggerWindows::gatherPlatformSpecificFiles() SetCursor(gCursorWait); // At this point we're responsive enough the user could click the close button SetCursor(gCursorArrow); - mDebugLog["DisplayDeviceInfo"] = gDXHardware.getDisplayInfo(); + //mDebugLog["DisplayDeviceInfo"] = gDXHardware.getDisplayInfo(); //Not initialized. } bool LLCrashLoggerWindows::mainLoop() { + LL_INFOS() << "CrashSubmitBehavior is " << mCrashBehavior << LL_ENDL; // Note: parent hwnd is 0 (the desktop). No dlg proc. See Petzold (5th ed) HexCalc example, Chapter 11, p529 // win_crash_logger.rc has been edited by hand. // Dialogs defined with CLASS "WIN_CRASH_LOGGER" (must be same as szWindowClass) gProductName = mProductName; - gHwndProgress = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PROGRESS), 0, NULL); ProcessCaption(gHwndProgress); ShowWindow(gHwndProgress, SW_HIDE ); if (mCrashBehavior == CRASH_BEHAVIOR_ALWAYS_SEND) { - ShowWindow(gHwndProgress, SW_SHOW ); + LL_INFOS() << "Showing crash report submit progress window." << LL_ENDL; + //ShowWindow(gHwndProgress, SW_SHOW ); Maint-5707 sendCrashLogs(); } else if (mCrashBehavior == CRASH_BEHAVIOR_ASK) @@ -347,7 +523,7 @@ bool LLCrashLoggerWindows::mainLoop() } else { - llwarns << "Unknown crash behavior " << mCrashBehavior << llendl; + LL_WARNS() << "Unknown crash behavior " << mCrashBehavior << LL_ENDL; return 1; } return 0; @@ -355,7 +531,7 @@ bool LLCrashLoggerWindows::mainLoop() void LLCrashLoggerWindows::updateApplication(const std::string& message) { - LLCrashLogger::updateApplication(); + LLCrashLogger::updateApplication(message); if(!message.empty()) show_progress(message); update_messages(); } @@ -369,8 +545,8 @@ bool LLCrashLoggerWindows::cleanup() sleep_and_pump_messages(3); } PostQuitMessage(0); + commonCleanup(); + mKeyMaster.releaseMaster(); return true; } - - diff --git a/indra/win_crash_logger/llcrashloggerwindows.h b/indra/win_crash_logger/llcrashloggerwindows.h index 24c564457c..1812e2737e 100644 --- a/indra/win_crash_logger/llcrashloggerwindows.h +++ b/indra/win_crash_logger/llcrashloggerwindows.h @@ -31,21 +31,54 @@ #include "windows.h" #include "llstring.h" +class LLSD; + +namespace google_breakpad { + class CrashGenerationServer; + class ClientInfo; +} + class LLCrashLoggerWindows : public LLCrashLogger { public: LLCrashLoggerWindows(void); ~LLCrashLoggerWindows(void); + static LLCrashLoggerWindows* sInstance; + virtual bool init(); virtual bool mainLoop(); virtual void updateApplication(const std::string& message = LLStringUtil::null); virtual bool cleanup(); virtual void gatherPlatformSpecificFiles(); - //void annotateCallStack(); void setHandle(HINSTANCE hInst) { mhInst = hInst; } + int clients_connected() const { + return mClientsConnected; + } + bool getMessageWithTimeout(MSG *msg, UINT to); + + // Starts the processing loop. This function does not return unless the + // user is logging off or the user closes the crash service window. The + // return value is a good number to pass in ExitProcess(). + int processingLoop(); private: void ProcessDlgItemText(HWND hWnd, int nIDDlgItem); void ProcessCaption(HWND hWnd); + bool initCrashServer(); + google_breakpad::CrashGenerationServer* mCrashHandler; + static void OnClientConnected(void* context, + const google_breakpad::ClientInfo* client_info); + + static void OnClientDumpRequest( + void* context, + const google_breakpad::ClientInfo* client_info, + const std::wstring* file_path); + + static void OnClientExited(void* context, + const google_breakpad::ClientInfo* client_info); + int mClientsConnected; + int mPID; + std::string mProcName; + HINSTANCE mhInst; }; diff --git a/indra/win_crash_logger/resource.h b/indra/win_crash_logger/resource.h index 37a387275e..37a387275e 100644..100755 --- a/indra/win_crash_logger/resource.h +++ b/indra/win_crash_logger/resource.h diff --git a/indra/win_crash_logger/win_crash_logger.cpp b/indra/win_crash_logger/win_crash_logger.cpp index 5c22053317..366edd894b 100644..100755 --- a/indra/win_crash_logger/win_crash_logger.cpp +++ b/indra/win_crash_logger/win_crash_logger.cpp @@ -24,51 +24,36 @@ * $/LicenseInfo$ */ -// win_crash_logger.cpp : Defines the entry point for the application. -// - -// Must be first include, precompiled headers. #include "linden_common.h" - #include "stdafx.h" - #include <stdlib.h> - #include "llcrashloggerwindows.h" - - -// -// Implementation -// - int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - llinfos << "Starting crash reporter" << llendl; - + LL_INFOS() << "Starting crash reporter with args" << &lpCmdLine << LL_ENDL; LLCrashLoggerWindows app; app.setHandle(hInstance); - bool ok = app.init(); - if(!ok) + app.parseCommandOptions(__argc, __argv); + + LLSD options = LLApp::instance()->getOptionData( + LLApp::PRIORITY_COMMAND_LINE); + if (!(options.has("pid") && options.has("dumpdir"))) + { + LL_WARNS() << "Insufficient parameters to crash report." << LL_ENDL; + } + if (! app.init()) { - llwarns << "Unable to initialize application." << llendl; + LL_WARNS() << "Unable to initialize application." << LL_ENDL; return -1; } - // Run the application main loop - if(!LLApp::isQuitting()) app.mainLoop(); - - if (!app.isError()) - { - // - // We don't want to do cleanup here if the error handler got called - - // the assumption is that the error handler is responsible for doing - // app cleanup if there was a problem. - // - app.cleanup(); - } + app.processingLoop(); + app.mainLoop(); + app.cleanup(); + LL_INFOS() << "Crash reporter finished normally." << LL_ENDL; return 0; } diff --git a/indra/win_crash_logger/win_crash_logger.h b/indra/win_crash_logger/win_crash_logger.h index 2cc2cf3dcf..2cc2cf3dcf 100644..100755 --- a/indra/win_crash_logger/win_crash_logger.h +++ b/indra/win_crash_logger/win_crash_logger.h diff --git a/indra/win_crash_logger/win_crash_logger.ico b/indra/win_crash_logger/win_crash_logger.ico Binary files differindex 386883523b..386883523b 100644..100755 --- a/indra/win_crash_logger/win_crash_logger.ico +++ b/indra/win_crash_logger/win_crash_logger.ico diff --git a/indra/win_crash_logger/win_crash_logger.rc b/indra/win_crash_logger/win_crash_logger.rc index 2819722f63..2819722f63 100644..100755 --- a/indra/win_crash_logger/win_crash_logger.rc +++ b/indra/win_crash_logger/win_crash_logger.rc |