From 2a7030992faa12c362d3eb9365080efd8265e15f Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 9 Jul 2024 17:53:43 -0400 Subject: Update tracy profiler to 0.10 (#1946) --- indra/llcommon/llerror.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index a45bc32028..800586b6a6 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -167,7 +167,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; @@ -234,7 +234,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: @@ -274,7 +274,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 @@ -311,7 +311,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); } @@ -338,7 +338,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); } }; @@ -1215,7 +1215,7 @@ 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(); @@ -1346,7 +1346,7 @@ namespace LLError bool Log::shouldLog(CallSite& site) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; LLMutexTrylock lock(getMutex(), 5); if (!lock.isLocked()) { @@ -1391,7 +1391,7 @@ namespace LLError void Log::flush(const std::ostringstream& out, const CallSite& site) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING + LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; LLMutexTrylock lock(getMutex(),5); if (!lock.isLocked()) { -- cgit v1.2.3 From 8b59d9bb42f7a0421c27daa75672ae775bb8927f Mon Sep 17 00:00:00 2001 From: nat-goodspeed Date: Wed, 10 Jul 2024 11:15:51 -0400 Subject: Introduce LLCoros::RMutex, use for SettingsConfig::mRecorderMutex (#1980) in llerror.cpp. --- indra/llcommon/llerror.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index ff80863497..6c3b9c9542 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -55,7 +55,6 @@ #include "llsingleton.h" #include "llstl.h" #include "lltimer.h" -#include // On Mac, got: // #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define @@ -507,7 +506,7 @@ namespace LLError::TimeFunction mTimeFunction; Recorders mRecorders; - boost::fibers::recursive_mutex mRecorderMutex; + LLCoros::RMutex mRecorderMutex; int mShouldLogCallCounter; -- cgit v1.2.3 From 70f455347eafa802036cf4a90d903d139a0fd7e9 Mon Sep 17 00:00:00 2001 From: Rye Mutt Date: Tue, 13 Aug 2024 17:26:19 -0400 Subject: Introduce tracy instrumentation of mutex in LLSingleton, LLInstanceTracker and logging --- indra/llcommon/llerror.cpp | 55 ++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 29 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 6c3b9c9542..41c69ba194 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -55,6 +55,7 @@ #include "llsingleton.h" #include "llstl.h" #include "lltimer.h" +#include "llprofiler.h" // On Mac, got: // #error "Boost.Stacktrace requires `_Unwind_Backtrace` function. Define @@ -506,7 +507,7 @@ namespace LLError::TimeFunction mTimeFunction; Recorders mRecorders; - LLCoros::RMutex mRecorderMutex; + LL_PROFILE_MUTEX_NAMED(LLCoros::RMutex, mRecorderMutex, "Log Recorders"); int mShouldLogCallCounter; @@ -529,7 +530,6 @@ namespace mCrashFunction(NULL), mTimeFunction(NULL), mRecorders(), - mRecorderMutex(), mShouldLogCallCounter(0) { } @@ -1044,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); } @@ -1055,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()); } @@ -1104,7 +1104,7 @@ namespace LLError std::shared_ptr 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(s).first; } @@ -1115,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(s); if (found.first) { @@ -1221,7 +1221,7 @@ namespace 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()) @@ -1280,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 - LLMutex* getMutex() + auto getLogMutex() + { + // guaranteed to be initialized the first time control reaches here + 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 LLMutex sMutex; - return &sMutex; + static LL_PROFILE_MUTEX_NAMED(std::recursive_mutex, sStacksMutex, "Stacks Mutex"); + return &sStacksMutex; } bool checkLevelMap(const LevelMap& map, const std::string& key, @@ -1347,8 +1344,8 @@ namespace LLError bool Log::shouldLog(CallSite& site) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; - LLMutexTrylock lock(getMutex(), 5); - if (!lock.isLocked()) + std::unique_lock lock(*getLogMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getLogMutex()); + if (!lock) { return false; } @@ -1392,8 +1389,8 @@ namespace LLError void Log::flush(const std::ostringstream& out, const CallSite& site) { LL_PROFILE_ZONE_SCOPED_CATEGORY_LOGGING; - LLMutexTrylock lock(getMutex(),5); - if (!lock.isLocked()) + std::unique_lock lock(*getLogMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getLogMutex()); + if (!lock) { return; } @@ -1523,8 +1520,8 @@ namespace LLError //static void LLCallStacks::push(const char* function, const int line) { - LLMutexTrylock lock(getMutex(), 5); - if (!lock.isLocked()) + std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex()); + if (!lock) { return; } @@ -1548,8 +1545,8 @@ namespace LLError //static void LLCallStacks::end(const std::ostringstream& out) { - LLMutexTrylock lock(getMutex(), 5); - if (!lock.isLocked()) + std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex()); + if (!lock) { return; } @@ -1565,8 +1562,8 @@ namespace LLError //static void LLCallStacks::print() { - LLMutexTrylock lock(getMutex(), 5); - if (!lock.isLocked()) + std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex()); + if (!lock) { return; } -- cgit v1.2.3 From f15228023f3a1094f69891a5f431cff3d895515a Mon Sep 17 00:00:00 2001 From: Brad Linden <46733234+brad-linden@users.noreply.github.com> Date: Wed, 28 Aug 2024 16:20:25 -0700 Subject: Attempt to get better file/line info for LL_ERRS crahses in bugsplat. (#2447) secondlife/viewer#2445 --- indra/llcommon/llerror.cpp | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 41c69ba194..ad35bc84f2 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -1641,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); -} -- cgit v1.2.3 From 953f7c9c1da4b83cabbf91f281445c3704a2f229 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 5 Sep 2024 12:33:47 -0400 Subject: Fix build errors from merging develop into release/luau-scripting. --- indra/llcommon/llerror.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'indra/llcommon/llerror.cpp') diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp index 8705758d3f..e6fe1eca75 100644 --- a/indra/llcommon/llerror.cpp +++ b/indra/llcommon/llerror.cpp @@ -64,6 +64,8 @@ #define BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED #include +#include LLCOROS_RMUTEX_HEADER + namespace { #if LL_WINDOWS void debugger_print(const std::string& s) -- cgit v1.2.3