summaryrefslogtreecommitdiff
path: root/indra/llcommon/llerror.cpp
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2024-09-05 11:00:11 -0400
committerNat Goodspeed <nat@lindenlab.com>2024-09-05 11:00:11 -0400
commit000a23ba0534fdf9bfc4a1b051b7cee0adceef3e (patch)
tree776fe10c7aaf76371a889f79c48c3c9405fd5a4e /indra/llcommon/llerror.cpp
parent7ac4c3b56e5246fceaa73e7c9c665d3c04827d6c (diff)
parentbacf9cfeab90bd1ffad827fa3c34ced985c768a2 (diff)
Merge branch 'develop' into release/luau-scripting
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 51267c8e79..8705758d3f 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;
}
@@ -1525,8 +1521,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;
}
@@ -1550,8 +1546,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;
}
@@ -1567,8 +1563,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;
}
@@ -1646,19 +1642,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);
-}