summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/CMakeLists.txt9
-rw-r--r--indra/llcommon/llerror.cpp21
-rw-r--r--indra/llcommon/llerror.h20
-rw-r--r--indra/llcommon/llerrorcontrol.h14
-rw-r--r--indra/llcommon/llleap.cpp30
-rw-r--r--indra/llcommon/tests/wrapllerrs.h5
6 files changed, 46 insertions, 53 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index af41b9e460..e3afa5eca4 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -5,6 +5,7 @@ project(llcommon)
include(00-Common)
include(LLCommon)
+include(bugsplat)
include(Linking)
include(Boost)
include(LLSharedLibs)
@@ -257,10 +258,10 @@ set(llcommon_HEADER_FILES
set_source_files_properties(${llcommon_HEADER_FILES}
PROPERTIES HEADER_FILE_ONLY TRUE)
-if (BUGSPLAT_DB)
- set_source_files_properties(llapp.cpp
- PROPERTIES COMPILE_DEFINITIONS "LL_BUGSPLAT")
-endif (BUGSPLAT_DB)
+if (USE_BUGSPLAT)
+ set_source_files_properties(${llcommon_SOURCE_FILES}
+ PROPERTIES COMPILE_DEFINITIONS "${BUGSPLAT_DEFINE}")
+endif (USE_BUGSPLAT)
list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES})
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 0ddce353f1..77d7fe1b24 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -25,6 +25,7 @@
* $/LicenseInfo$
*/
+#define _LLERROR_CPP_
#include "linden_common.h"
#include "llerror.h"
@@ -724,7 +725,7 @@ namespace LLError
s->mCrashFunction = fatal_function;
}
- void restoreCrashOnError()
+ void restoreCrashOnError()
{
SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig();
s->mCrashFunction = NULL;
@@ -1310,7 +1311,7 @@ namespace LLError
LLMutexTrylock lock(&gLogMutex,5);
if (!lock.isLocked())
{
- return true;
+ return false; // because this wasn't logged, it cannot be fatal
}
// If we hit a logging request very late during shutdown processing,
@@ -1318,7 +1319,7 @@ namespace LLError
// DO NOT resurrect them.
if (Settings::wasDeleted() || Globals::wasDeleted())
{
- return true;
+ return false; // because this wasn't logged, it cannot be fatal
}
Globals* g = Globals::getInstance();
@@ -1352,7 +1353,7 @@ namespace LLError
}
else
{
- return true;
+ return false; // because this wasn't logged, it cannot be fatal
}
}
else
@@ -1372,11 +1373,17 @@ namespace LLError
if (s->mCrashFunction)
{
s->mCrashFunction(message);
- return false;
+ return false; // because an override is in effect
+ }
+ else
+ {
+ return true; // calling macro should crash
}
}
-
- return true;
+ else
+ {
+ return false; // not ERROR, so do not crash
+ }
}
}
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index cbade88f61..07aa5c6f8b 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -202,7 +202,7 @@ namespace LLError
static void flush(std::ostringstream* out, char* message);
- // returns false iff there is a fatal crash override in effect
+ // returns false iff the calling macro should crash
static bool flush(std::ostringstream*, const CallSite&);
static std::string demangle(const char* mangled);
@@ -371,18 +371,22 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
#define LL_NEWLINE '\n'
+#ifdef _LLERROR_CPP_
+volatile int* gCauseCrash = NULL;
+#else
+volatile extern int* gCauseCrash;
+#endif // _LLERROR_CPP_
+
// Use this only in LL_ERRS or in a place that LL_ERRS may not be used
-#define LLERROR_CRASH \
-{ \
- int* make_me_crash = NULL;\
- *make_me_crash = 0; \
- exit(*make_me_crash); \
+#define LLERROR_CRASH \
+{ \
+ *gCauseCrash = 0; \
+ exit(*gCauseCrash); \
}
#define LL_ENDL \
LLError::End(); \
- if (LLError::Log::flush(_out, _site) \
- && _site.mLevel == LLError::LEVEL_ERROR) \
+ if (LLError::Log::flush(_out, _site)) \
LLERROR_CRASH \
} \
} while(0)
diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h
index 7ca6ddb737..af46430f74 100644
--- a/indra/llcommon/llerrorcontrol.h
+++ b/indra/llcommon/llerrorcontrol.h
@@ -92,11 +92,19 @@ namespace LLError
/*
Control functions.
*/
+
typedef boost::function<void(const std::string&)> FatalFunction;
- LL_COMMON_API void overrideCrashOnError(const FatalFunction&);
- LL_COMMON_API void restoreCrashOnError();
-
+ /// Override the default behavior of crashing on LL_ERRS; this should NEVER be used except in test code
+ LL_COMMON_API void overrideCrashOnError(const FatalFunction&);
+ // The fatal function will be called when an message of LEVEL_ERROR
+ // is logged. Note: supressing a LEVEL_ERROR message from being logged
+ // (by, for example, setting a class level to LEVEL_NONE), will keep
+ // the that message from causing the fatal funciton to be invoked.
+
+ /// Undo the effect of the overrideCrashOnError above
+ LL_COMMON_API void restoreCrashOnError();
+
LL_COMMON_API std::string getFatalMessage();
// Retrieve the message last passed to LL_ERRS, if any
diff --git a/indra/llcommon/llleap.cpp b/indra/llcommon/llleap.cpp
index f7bfa36bb5..bf20c87c89 100644
--- a/indra/llcommon/llleap.cpp
+++ b/indra/llcommon/llleap.cpp
@@ -59,6 +59,7 @@ public:
// pump name -- so it should NOT need tweaking for uniqueness.
mReplyPump(LLUUID::generateNewID().asString()),
mExpect(0),
+
// Instantiate a distinct LLLeapListener for this plugin. (Every
// plugin will want its own collection of managed listeners, etc.)
// Pass it a callback to our connect() method, so it can send events
@@ -144,9 +145,6 @@ public:
mStderrConnection = childerr.getPump()
.listen("LLLeap", boost::bind(&LLLeapImpl::rstderr, this, _1));
- // For our lifespan, intercept any LL_ERRS so we can notify plugin
- LLError::overrideCrashOnError(boost::bind(&LLLeapImpl::fatalFunction, this, _1));
-
// Send child a preliminary event reporting our own reply-pump name --
// which would otherwise be pretty tricky to guess!
wstdin(mReplyPump.getName(),
@@ -161,8 +159,6 @@ public:
virtual ~LLLeapImpl()
{
LL_DEBUGS("LLLeap") << "destroying LLLeap(\"" << mDesc << "\")" << LL_ENDL;
- // Restore original fatal crash behavior for LL_ERRS
- LLError::restoreCrashOnError();
}
// Listener for failed launch attempt
@@ -376,30 +372,6 @@ public:
return false;
}
- void fatalFunction(const std::string& error)
- {
- // Notify plugin
- LLSD event;
- event["type"] = "error";
- event["error"] = error;
- mReplyPump.post(event);
-
- // All the above really accomplished was to buffer the serialized
- // event in our WritePipe. Have to pump mainloop a couple times to
- // really write it out there... but time out in case we can't write.
- LLProcess::WritePipe& childin(mChild->getWritePipe(LLProcess::STDIN));
- LLEventPump& mainloop(LLEventPumps::instance().obtain("mainloop"));
- LLSD nop;
- F64 until = (LLTimer::getElapsedSeconds() + 2).value();
- while (childin.size() && LLTimer::getElapsedSeconds() < until)
- {
- mainloop.post(nop);
- }
-
- // go ahead and do the crash that LLError would have done
- LLERROR_CRASH
- }
-
private:
/// We always want to listen on mReplyPump with wstdin(); under some
/// circumstances we'll also echo other LLEventPumps to the plugin.
diff --git a/indra/llcommon/tests/wrapllerrs.h b/indra/llcommon/tests/wrapllerrs.h
index b280271476..fedc17dbe9 100644
--- a/indra/llcommon/tests/wrapllerrs.h
+++ b/indra/llcommon/tests/wrapllerrs.h
@@ -50,11 +50,11 @@ extern void wouldHaveCrashed(const std::string& message);
struct WrapLLErrs
{
- WrapLLErrs():
+ WrapLLErrs()
// Resetting Settings discards the default Recorder that writes to
// stderr. Otherwise, expected llerrs (LL_ERRS) messages clutter the
// console output of successful tests, potentially confusing things.
- mPriorErrorSettings(LLError::saveAndResetSettings())
+ :mPriorErrorSettings(LLError::saveAndResetSettings())
{
// Make LL_ERRS call our own operator() method
LLError::overrideCrashOnError(boost::bind(&WrapLLErrs::operator(), this, _1));
@@ -210,6 +210,7 @@ public:
{
LLError::removeRecorder(mRecorder);
LLError::restoreSettings(mOldSettings);
+ LLError::restoreCrashOnError();
}
/// Don't assume the message we want is necessarily the LAST log message