summaryrefslogtreecommitdiff
path: root/indra/llcommon/llerror.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llerror.cpp')
-rw-r--r--indra/llcommon/llerror.cpp88
1 files changed, 34 insertions, 54 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index fa24987d1c..ad35bc84f2 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -55,7 +55,7 @@
#include "llsingleton.h"
#include "llstl.h"
#include "lltimer.h"
-#include <boost/fiber/recursive_mutex.hpp>
+#include "llprofiler.h"
// On Mac, got:
// #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define
@@ -168,7 +168,7 @@ namespace {
virtual void recordMessage(LLError::ELevel level,
const std::string& message) override
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
if (LLError::getAlwaysFlush())
{
mFile << message << std::endl;
@@ -235,7 +235,7 @@ namespace {
virtual void recordMessage(LLError::ELevel level,
const std::string& message) override
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
// The default colors for error, warn and debug are now a bit more pastel
// and easier to read on the default (black) terminal background but you
// now have the option to set the color of each via an environment variables:
@@ -275,7 +275,7 @@ namespace {
LL_FORCE_INLINE void writeANSI(const std::string& ansi_code, const std::string& message)
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
static std::string s_ansi_bold = createBoldANSI(); // bold text
static std::string s_ansi_reset = createResetANSI(); // reset
// ANSI color code escape sequence, message, and reset in one fprintf call
@@ -312,7 +312,7 @@ namespace {
virtual void recordMessage(LLError::ELevel level,
const std::string& message) override
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
mBuffer->addLine(message);
}
@@ -339,7 +339,7 @@ namespace {
virtual void recordMessage(LLError::ELevel level,
const std::string& message) override
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
debugger_print(message);
}
};
@@ -507,7 +507,7 @@ namespace
LLError::TimeFunction mTimeFunction;
Recorders mRecorders;
- boost::fibers::recursive_mutex mRecorderMutex;
+ LL_PROFILE_MUTEX_NAMED(LLCoros::RMutex, mRecorderMutex, "Log Recorders");
int mShouldLogCallCounter;
@@ -530,7 +530,6 @@ namespace
mCrashFunction(NULL),
mTimeFunction(NULL),
mRecorders(),
- mRecorderMutex(),
mShouldLogCallCounter(0)
{
}
@@ -1045,7 +1044,7 @@ namespace LLError
return;
}
SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
- std::unique_lock lock(s->mRecorderMutex);
+ std::unique_lock lock(s->mRecorderMutex); LL_PROFILE_MUTEX_LOCK(s->mRecorderMutex);
s->mRecorders.push_back(recorder);
}
@@ -1056,7 +1055,7 @@ namespace LLError
return;
}
SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
- std::unique_lock lock(s->mRecorderMutex);
+ std::unique_lock lock(s->mRecorderMutex); LL_PROFILE_MUTEX_LOCK(s->mRecorderMutex);
s->mRecorders.erase(std::remove(s->mRecorders.begin(), s->mRecorders.end(), recorder),
s->mRecorders.end());
}
@@ -1105,7 +1104,7 @@ namespace LLError
std::shared_ptr<RECORDER> findRecorder()
{
SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
- std::unique_lock lock(s->mRecorderMutex);
+ std::unique_lock lock(s->mRecorderMutex); LL_PROFILE_MUTEX_LOCK(s->mRecorderMutex);
return findRecorderPos<RECORDER>(s).first;
}
@@ -1116,7 +1115,7 @@ namespace LLError
bool removeRecorder()
{
SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
- std::unique_lock lock(s->mRecorderMutex);
+ std::unique_lock lock(s->mRecorderMutex); LL_PROFILE_MUTEX_LOCK(s->mRecorderMutex);
auto found = findRecorderPos<RECORDER>(s);
if (found.first)
{
@@ -1216,13 +1215,13 @@ namespace
void writeToRecorders(const LLError::CallSite& site, const std::string& message)
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
LLError::ELevel level = site.mLevel;
SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
std::string escaped_message;
- std::unique_lock lock(s->mRecorderMutex);
+ std::unique_lock lock(s->mRecorderMutex); LL_PROFILE_MUTEX_LOCK(s->mRecorderMutex);
for (LLError::RecorderPtr& r : s->mRecorders)
{
if (!r->enabled())
@@ -1281,24 +1280,21 @@ namespace
}
namespace {
- // We need a couple different mutexes, but we want to use the same mechanism
- // for both. Make getMutex() a template function with different instances
- // for different MutexDiscriminator values.
- enum MutexDiscriminator
- {
- LOG_MUTEX,
- STACKS_MUTEX
- };
// Some logging calls happen very early in processing -- so early that our
// module-static variables aren't yet initialized. getMutex() wraps a
// function-static LLMutex so that early calls can still have a valid
// LLMutex instance.
- template <MutexDiscriminator MTX>
- LLMutex* getMutex()
+ auto getLogMutex()
{
// guaranteed to be initialized the first time control reaches here
- static LLMutex sMutex;
- return &sMutex;
+ static LL_PROFILE_MUTEX_NAMED(std::recursive_mutex, sLogMutex, "Log Mutex");
+ return &sLogMutex;
+ }
+ auto getStacksMutex()
+ {
+ // guaranteed to be initialized the first time control reaches here
+ static LL_PROFILE_MUTEX_NAMED(std::recursive_mutex, sStacksMutex, "Stacks Mutex");
+ return &sStacksMutex;
}
bool checkLevelMap(const LevelMap& map, const std::string& key,
@@ -1347,9 +1343,9 @@ namespace LLError
bool Log::shouldLog(CallSite& site)
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
- LLMutexTrylock lock(getMutex<LOG_MUTEX>(), 5);
- if (!lock.isLocked())
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
+ std::unique_lock lock(*getLogMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getLogMutex());
+ if (!lock)
{
return false;
}
@@ -1392,9 +1388,9 @@ namespace LLError
void Log::flush(const std::ostringstream& out, const CallSite& site)
{
- LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING
- LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5);
- if (!lock.isLocked())
+ LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING;
+ std::unique_lock lock(*getLogMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getLogMutex());
+ if (!lock)
{
return;
}
@@ -1524,8 +1520,8 @@ namespace LLError
//static
void LLCallStacks::push(const char* function, const int line)
{
- LLMutexTrylock lock(getMutex<STACKS_MUTEX>(), 5);
- if (!lock.isLocked())
+ std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex());
+ if (!lock)
{
return;
}
@@ -1549,8 +1545,8 @@ namespace LLError
//static
void LLCallStacks::end(const std::ostringstream& out)
{
- LLMutexTrylock lock(getMutex<STACKS_MUTEX>(), 5);
- if (!lock.isLocked())
+ std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex());
+ if (!lock)
{
return;
}
@@ -1566,8 +1562,8 @@ namespace LLError
//static
void LLCallStacks::print()
{
- LLMutexTrylock lock(getMutex<STACKS_MUTEX>(), 5);
- if (!lock.isLocked())
+ std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex());
+ if (!lock)
{
return;
}
@@ -1645,19 +1641,3 @@ namespace LLError
sLocalizedOutOfMemoryWarning = message;
}
}
-
-void crashdriver(void (*callback)(int*))
-{
- // The LLERROR_CRASH macro used to have inline code of the form:
- //int* make_me_crash = NULL;
- //*make_me_crash = 0;
-
- // But compilers are getting smart enough to recognize that, so we must
- // assign to an address supplied by a separate source file. We could do
- // the assignment here in crashdriver() -- but then BugSplat would group
- // all LL_ERRS() crashes as the fault of this one function, instead of
- // identifying the specific LL_ERRS() source line. So instead, do the
- // assignment in a lambda in the caller's source. We just provide the
- // nullptr target.
- callback(nullptr);
-}