diff options
Diffstat (limited to 'indra/llcommon/llapp.h')
-rwxr-xr-x[-rw-r--r--] | indra/llcommon/llapp.h | 122 |
1 files changed, 54 insertions, 68 deletions
diff --git a/indra/llcommon/llapp.h b/indra/llcommon/llapp.h index 27a52cdd99..d9933b3d36 100644..100755 --- a/indra/llcommon/llapp.h +++ b/indra/llcommon/llapp.h @@ -2,31 +2,25 @@ * @file llapp.h * @brief Declaration of the LLApp class. * - * $LicenseInfo:firstyear=2003&license=viewergpl$ - * - * Copyright (c) 2003-2009, Linden Research, Inc. - * + * $LicenseInfo:firstyear=2003&license=viewerlgpl$ * Second Life Viewer Source Code - * The source code in this file ("Source Code") is provided by Linden Lab - * to you under the terms of the GNU General Public License, version 2.0 - * ("GPL"), unless you have obtained a separate licensing agreement - * ("Other License"), formally executed by you and Linden Lab. Terms of - * the GPL can be found in doc/GPL-license.txt in this distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * Copyright (C) 2010, Linden Research, Inc. * - * There are special exceptions to the terms and conditions of the GPL as - * it is applied to this Source Code. View the full text of the exception - * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at - * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. * - * By copying, modifying or distributing this software, you acknowledge - * that you have read and understood your obligations described above, - * and agree to abide by those obligations. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. * - * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO - * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, - * COMPLETENESS OR PERFORMANCE. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -36,19 +30,16 @@ #include <map> #include "llrun.h" #include "llsd.h" -#include "lloptioninterface.h" - // Forward declarations template <typename Type> class LLAtomic32; typedef LLAtomic32<U32> LLAtomicU32; class LLErrorThread; class LLLiveFile; #if LL_LINUX -typedef struct siginfo siginfo_t; +#include <signal.h> #endif typedef void (*LLAppErrorHandler)(); -typedef void (*LLAppChildCallback)(int pid, bool exited, int status); #if !LL_WINDOWS extern S32 LL_SMACKDOWN_SIGNAL; @@ -57,16 +48,13 @@ extern S32 LL_HEARTBEAT_SIGNAL; // Clear all of the signal handlers (which we want to do for the child process when we fork void clear_signals(); -class LLChildInfo -{ -public: - LLChildInfo() : mGotSigChild(FALSE), mCallback(NULL) {} - BOOL mGotSigChild; - LLAppChildCallback mCallback; -}; #endif -class LL_COMMON_API LLApp : public LLOptionInterface +namespace google_breakpad { + class ExceptionHandler; // See exception_handler.h +} + +class LL_COMMON_API LLApp { friend class LLErrorThread; public: @@ -115,7 +103,7 @@ public: * @param name The name of the option. * @return Returns the option data. */ - virtual LLSD getOption(const std::string& name) const; + LLSD getOption(const std::string& name) const; /** * @brief Parse command line options and insert them into @@ -191,6 +179,11 @@ public: // virtual bool mainLoop() = 0; // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit. + // + // Crash logging + // + void disableCrashlogger(); // Let the OS handle the crashes + static bool isCrashloggerDisabled(); // Get the here above set value // // Application status @@ -203,10 +196,6 @@ public: static bool isQuitting(); static bool isError(); static bool isExiting(); // Either quitting or error (app is exiting, cleanly or not) -#if !LL_WINDOWS - static U32 getSigChildCount(); - static void incSigChildCount(); -#endif static int getPid(); /** @name Error handling methods */ @@ -224,31 +213,27 @@ public: * DO NOT call this method if your application has specialized * error handling code. */ - void setupErrorHandling(); + void setupErrorHandling(bool mSecondInstance=false); void setErrorHandler(LLAppErrorHandler handler); - void setSyncErrorHandler(LLAppErrorHandler handler); + static void runErrorHandler(); // run shortly after we detect an error, ran in the relatively robust context of the LLErrorThread - preferred. //@} - -#if !LL_WINDOWS - // - // Child process handling (Unix only for now) - // - // Set a callback to be run on exit of a child process - // WARNING! This callback is run from the signal handler due to the extreme crappiness of - // Linux threading requiring waitpid() to be called from the thread that spawned the process. - // At some point I will make this more behaved, but I'm not going to fix this right now - djs - void setChildCallback(pid_t pid, LLAppChildCallback callback); - - // The child callback to run if no specific handler is set - void setDefaultChildCallback(LLAppChildCallback callback); - // Fork and do the proper signal handling/error handling mojo - // *NOTE: You need to make sure your signal handling callback is - // correct after you fork, because not all threads are duplicated - // when you fork! - pid_t fork(); -#endif + // the maximum length of the minidump filename returned by getMiniDumpFilename() + static const U32 MAX_MINDUMP_PATH_LENGTH = 256; + + // change the directory where Breakpad minidump files are written to + void setMiniDumpDir(const std::string &path); + void setDebugFileNames(const std::string &path); + + // Return the Google Breakpad minidump filename after a crash. + char *getMiniDumpFilename() { return mMinidumpPath; } + std::string* getStaticDebugFile() { return &mStaticDebugFileName; } + std::string* getDynamicDebugFile() { return &mDynamicDebugFileName; } + + // Write out a Google Breakpad minidump file. + void writeMiniDump(); + /** * @brief Get a reference to the application runner @@ -270,13 +255,10 @@ protected: static void setStatus(EAppStatus status); // Use this to change the application status. static EAppStatus sStatus; // Reflects current application status static BOOL sErrorThreadRunning; // Set while the error thread is running + static BOOL sDisableCrashlogger; // Let the OS handle crashes for us. + std::wstring mCrashReportPipeStr; //Name of pipe to use for crash reporting. -#if !LL_WINDOWS - static LLAtomicU32* sSigChildCount; // Number of SIGCHLDs received. - typedef std::map<pid_t, LLChildInfo> child_map; // Map key is a PID - static child_map sChildMap; - static LLAppChildCallback sDefaultChildCallback; -#endif + std::string mDumpPath; //output path for google breakpad. Dependency workaround. /** * @brief This method is called once a frame to do once a frame tasks. @@ -286,15 +268,17 @@ protected: private: void startErrorThread(); - static void runErrorHandler(); // run shortly after we detect an error, ran in the relatively robust context of the LLErrorThread - preferred. - static void runSyncErrorHandler(); // run IMMEDIATELY when we get an error, ran in the context of the faulting thread. + // Contains the filename of the minidump file after a crash. + char mMinidumpPath[MAX_MINDUMP_PATH_LENGTH]; + + std::string mStaticDebugFileName; + std::string mDynamicDebugFileName; // *NOTE: On Windows, we need a routine to reset the structured // exception handler when some evil driver has taken it over for // their own purposes typedef int(*signal_handler_func)(int signum); static LLAppErrorHandler sErrorHandler; - static LLAppErrorHandler sSyncErrorHandler; // Default application threads LLErrorThread* mThreadErrorp; // Waits for app to go to status ERROR, then runs the error callback @@ -315,6 +299,8 @@ private: private: // the static application instance if it was created. static LLApp* sApplication; + + google_breakpad::ExceptionHandler * mExceptionHandler; #if !LL_WINDOWS |