summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-08-20 06:29:21 +0300
committerAndrey Lihatskiy <alihatskiy@productengine.com>2024-08-20 06:29:21 +0300
commit3a4720d1f523ca8ebee0d963604c236c08980eae (patch)
treeff5c6adb045d104aa3cce6c6c68e63e3c55659cb /indra/llcommon
parent34c13264f33d9bbfc73302b84c8fade1b115fb93 (diff)
parent169599fd2f211d66f80a54e13daf975229607022 (diff)
Merge branch 'develop' into marchcat/b-develop
# Conflicts: # .github/workflows/build.yaml # autobuild.xml # indra/cmake/Copy3rdPartyLibs.cmake # indra/cmake/FreeType.cmake # indra/newview/llappviewer.cpp # indra/newview/skins/default/xui/en/floater_fast_timers.xml # indra/newview/viewer_manifest.py # indra/test/test.cpp
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/CMakeLists.txt8
-rw-r--r--indra/llcommon/llallocator.cpp58
-rw-r--r--indra/llcommon/llallocator.h51
-rw-r--r--indra/llcommon/llallocator_heap_profile.cpp145
-rw-r--r--indra/llcommon/llallocator_heap_profile.h71
-rw-r--r--indra/llcommon/llerror.cpp55
-rw-r--r--indra/llcommon/llerrorcontrol.h2
-rw-r--r--indra/llcommon/llevents.h10
-rw-r--r--indra/llcommon/llfile.cpp4
-rw-r--r--indra/llcommon/llfile.h8
-rw-r--r--indra/llcommon/llfindlocale.cpp2
-rw-r--r--indra/llcommon/llinstancetracker.h22
-rw-r--r--indra/llcommon/llprofiler.cpp30
-rw-r--r--indra/llcommon/llprofiler.h24
-rw-r--r--indra/llcommon/llsdjson.cpp9
-rw-r--r--indra/llcommon/llsingleton.cpp5
-rw-r--r--indra/llcommon/llsingleton.h18
-rw-r--r--indra/llcommon/llstacktrace.cpp3
-rw-r--r--indra/llcommon/llstring.cpp5
-rw-r--r--indra/llcommon/llstring.h5
-rw-r--r--indra/llcommon/lluuid.cpp1
-rw-r--r--indra/llcommon/tests/commonmisc_test.cpp6
22 files changed, 121 insertions, 421 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 8e43627a5f..c4041f0c79 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -18,8 +18,6 @@ set(llcommon_SOURCE_FILES
commoncontrol.cpp
indra_constants.cpp
lazyeventapi.cpp
- llallocator.cpp
- llallocator_heap_profile.cpp
llapp.cpp
llapr.cpp
llassettype.cpp
@@ -127,8 +125,6 @@ set(llcommon_HEADER_FILES
lazyeventapi.h
linden_common.h
llalignedarray.h
- llallocator.h
- llallocator_heap_profile.h
llapp.h
llapr.h
llassettype.h
@@ -267,6 +263,10 @@ if (DARWIN)
list(APPEND llcommon_SOURCE_FILES llsys_objc.mm)
endif (DARWIN)
+if (USE_TRACY)
+ list(APPEND llcommon_SOURCE_FILES llprofiler.cpp)
+endif ()
+
list(APPEND llcommon_SOURCE_FILES ${llcommon_HEADER_FILES})
add_library (llcommon ${llcommon_SOURCE_FILES})
diff --git a/indra/llcommon/llallocator.cpp b/indra/llcommon/llallocator.cpp
deleted file mode 100644
index abe3779b85..0000000000
--- a/indra/llcommon/llallocator.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @file llallocator.cpp
- * @brief Implementation of the LLAllocator class.
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * 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.
- *
- * 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.
- *
- * 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$
- */
-
-#include "linden_common.h"
-#include "llallocator.h"
-
-//
-// stub implementations for when tcmalloc is disabled
-//
-
-void LLAllocator::setProfilingEnabled(bool should_enable)
-{
-}
-
-// static
-bool LLAllocator::isProfiling()
-{
- return false;
-}
-
-std::string LLAllocator::getRawProfile()
-{
- return std::string();
-}
-
-LLAllocatorHeapProfile const & LLAllocator::getProfile()
-{
- mProf.mLines.clear();
-
- // *TODO - avoid making all these extra copies of things...
- std::string prof_text = getRawProfile();
- //std::cout << prof_text << std::endl;
- mProf.parse(prof_text);
- return mProf;
-}
diff --git a/indra/llcommon/llallocator.h b/indra/llcommon/llallocator.h
deleted file mode 100644
index aa3eead546..0000000000
--- a/indra/llcommon/llallocator.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * @file llallocator.h
- * @brief Declaration of the LLAllocator class.
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * 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.
- *
- * 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.
- *
- * 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$
- */
-
-#ifndef LL_LLALLOCATOR_H
-#define LL_LLALLOCATOR_H
-
-#include <string>
-
-#include "llallocator_heap_profile.h"
-
-class LL_COMMON_API LLAllocator {
- friend class LLMemoryView;
-
-public:
- void setProfilingEnabled(bool should_enable);
-
- static bool isProfiling();
-
- LLAllocatorHeapProfile const & getProfile();
-
-private:
- std::string getRawProfile();
-
-private:
- LLAllocatorHeapProfile mProf;
-};
-
-#endif // LL_LLALLOCATOR_H
diff --git a/indra/llcommon/llallocator_heap_profile.cpp b/indra/llcommon/llallocator_heap_profile.cpp
deleted file mode 100644
index 85e56b4db4..0000000000
--- a/indra/llcommon/llallocator_heap_profile.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/**
- * @file llallocator_heap_profile.cpp
- * @brief Implementation of the parser for tcmalloc heap profile data.
- * @author Brad Kittenbrink
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * 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.
- *
- * 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.
- *
- * 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$
- */
-
-#include "linden_common.h"
-#include "llallocator_heap_profile.h"
-
-#if LL_MSVC
-// disable warning about boost::lexical_cast returning uninitialized data
-// when it fails to parse the string
-#pragma warning (disable:4701)
-#pragma warning (disable:4702)
-#endif
-
-#include <boost/algorithm/string/split.hpp>
-#include <boost/bind.hpp>
-#include <boost/lexical_cast.hpp>
-#include <boost/range/iterator_range.hpp>
-
-static const std::string HEAP_PROFILE_MAGIC_STR = "heap profile:";
-
-static bool is_separator(char c)
-{
- return isspace(c) || c == '[' || c == ']' || c == ':';
-}
-
-void LLAllocatorHeapProfile::parse(std::string const & prof_text)
-{
- // a typedef for handling a token in the string buffer
- // it's a begin/end pair of string::const_iterators
- typedef boost::iterator_range<std::string::const_iterator> range_t;
-
- mLines.clear();
-
- if(prof_text.compare(0, HEAP_PROFILE_MAGIC_STR.length(), HEAP_PROFILE_MAGIC_STR) != 0)
- {
- // *TODO - determine if there should be some better error state than
- // mLines being empty. -brad
- LL_WARNS() << "invalid heap profile data passed into parser." << LL_ENDL;
- return;
- }
-
- std::vector< range_t > prof_lines;
-
- std::string::const_iterator prof_begin = prof_text.begin() + HEAP_PROFILE_MAGIC_STR.length();
-
- range_t prof_range(prof_begin, prof_text.end());
- boost::algorithm::split(prof_lines,
- prof_range,
- boost::bind(std::equal_to<llwchar>(), '\n', _1));
-
- std::vector< range_t >::const_iterator i;
- for(i = prof_lines.begin(); i != prof_lines.end() && !i->empty(); ++i)
- {
- range_t const & line_text = *i;
-
- std::vector<range_t> line_elems;
-
- boost::algorithm::split(line_elems,
- line_text,
- is_separator);
-
- std::vector< range_t >::iterator j;
- j = line_elems.begin();
-
- while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
- llassert_always(j != line_elems.end());
- U32 live_count = boost::lexical_cast<U32>(*j);
- ++j;
-
- while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
- llassert_always(j != line_elems.end());
- U64 live_size = boost::lexical_cast<U64>(*j);
- ++j;
-
- while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
- llassert_always(j != line_elems.end());
- U32 tot_count = boost::lexical_cast<U32>(*j);
- ++j;
-
- while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
- llassert_always(j != line_elems.end());
- U64 tot_size = boost::lexical_cast<U64>(*j);
- ++j;
-
- while(j != line_elems.end() && j->empty()) { ++j; } // skip any separator tokens
- llassert(j != line_elems.end());
- if (j != line_elems.end())
- {
- ++j; // skip the '@'
-
- mLines.push_back(line(live_count, live_size, tot_count, tot_size));
- line & current_line = mLines.back();
-
- for(; j != line_elems.end(); ++j)
- {
- if(!j->empty())
- {
- U32 marker = boost::lexical_cast<U32>(*j);
- current_line.mTrace.push_back(marker);
- }
- }
- }
- }
- // *TODO - parse MAPPED_LIBRARIES section here if we're ever interested in it
-}
-
-void LLAllocatorHeapProfile::dump(std::ostream & out) const
-{
- for (const LLAllocatorHeapProfile::line& line : mLines)
- {
- out << line.mLiveCount << ": " << line.mLiveSize << '[' << line.mTotalCount << ": " << line.mTotalSize << "] @";
-
- for (const stack_marker marker : line.mTrace)
- {
- out << ' ' << marker;
- }
- out << '\n';
- }
- out.flush();
-}
-
diff --git a/indra/llcommon/llallocator_heap_profile.h b/indra/llcommon/llallocator_heap_profile.h
deleted file mode 100644
index 22f284b703..0000000000
--- a/indra/llcommon/llallocator_heap_profile.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * @file llallocator_heap_profile.h
- * @brief Declaration of the parser for tcmalloc heap profile data.
- * @author Brad Kittenbrink
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * 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.
- *
- * 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.
- *
- * 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$
- */
-
-#ifndef LL_LLALLOCATOR_HEAP_PROFILE_H
-#define LL_LLALLOCATOR_HEAP_PROFILE_H
-
-#include "stdtypes.h"
-
-#include <map>
-#include <vector>
-
-class LLAllocatorHeapProfile
-{
-public:
- typedef int stack_marker;
-
- typedef std::vector<stack_marker> stack_trace;
-
- struct line {
- line(U32 live_count, U64 live_size, U32 tot_count, U64 tot_size) :
- mLiveSize(live_size),
- mTotalSize(tot_size),
- mLiveCount(live_count),
- mTotalCount(tot_count)
- {
- }
- U64 mLiveSize, mTotalSize;
- U32 mLiveCount, mTotalCount;
- stack_trace mTrace;
- };
-
- typedef std::vector<line> lines_t;
-
- LLAllocatorHeapProfile()
- {
- }
-
- void parse(std::string const & prof_text);
-
- void dump(std::ostream & out) const;
-
-public:
- lines_t mLines;
-};
-
-
-#endif // LL_LLALLOCATOR_HEAP_PROFILE_H
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 237f07288e..c6080a7f9f 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<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;
}
@@ -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<RECORDER>(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 <MutexDiscriminator MTX>
- 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<LOG_MUTEX>(), 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<LOG_MUTEX>(),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<STACKS_MUTEX>(), 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<STACKS_MUTEX>(), 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<STACKS_MUTEX>(), 5);
- if (!lock.isLocked())
+ std::unique_lock lock(*getStacksMutex(), std::try_to_lock); LL_PROFILE_MUTEX_LOCK(*getStacksMutex());
+ if (!lock)
{
return;
}
diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h
index 2be443ca37..1845fc42db 100644
--- a/indra/llcommon/llerrorcontrol.h
+++ b/indra/llcommon/llerrorcontrol.h
@@ -198,7 +198,7 @@ namespace LLError
};
/**
- * @NOTE: addRecorder() and removeRecorder() uses the boost::shared_ptr to allow for shared ownership
+ * @NOTE: addRecorder() and removeRecorder() uses the std::shared_ptr to allow for shared ownership
* while still ensuring that the allocated memory is eventually freed
*/
LL_COMMON_API void addRecorder(RecorderPtr);
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index f97fca0a32..4bf1fa07a2 100644
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -38,16 +38,8 @@
#include <vector>
#include <deque>
#include <functional>
-#if LL_WINDOWS
- #pragma warning (push)
- #pragma warning (disable : 4263) // boost::signals2::expired_slot::what() has const mismatch
- #pragma warning (disable : 4264)
-#endif
-#include <boost/signals2.hpp>
-#if LL_WINDOWS
- #pragma warning (pop)
-#endif
+#include <boost/signals2.hpp>
#include <boost/bind.hpp>
#include <boost/utility.hpp> // noncopyable
#include <boost/optional/optional.hpp>
diff --git a/indra/llcommon/llfile.cpp b/indra/llcommon/llfile.cpp
index 9045324bf2..ed94ef21ef 100644
--- a/indra/llcommon/llfile.cpp
+++ b/indra/llcommon/llfile.cpp
@@ -293,7 +293,7 @@ int LLFile::rename(const std::string& filename, const std::string& newname, int
return warnif(STRINGIZE("rename to '" << newname << "' from"), filename, rc, supress_error);
}
-bool LLFile::copy(const std::string from, const std::string to)
+bool LLFile::copy(const std::string& from, const std::string& to)
{
bool copied = false;
LLFILE* in = LLFile::fopen(from, "rb"); /* Flawfinder: ignore */
@@ -424,7 +424,7 @@ LLFILE * LLFile::_Fiopen(const std::string& filename,
if (valid[n] == 0)
return (0); // no valid mode
- else if (norepflag && mode & (ios_base::out || ios_base::app)
+ else if (norepflag && mode & (ios_base::out | ios_base::app)
&& (fp = LLFile::fopen(filename, "r")) != 0) /* Flawfinder: ignore */
{ // file must not exist, close and fail
fclose(fp);
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 74110343fc..1661cbeb55 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -77,7 +77,7 @@ public:
static int rmdir(const std::string& filename);
static int remove(const std::string& filename, int supress_error = 0);
static int rename(const std::string& filename,const std::string& newname, int supress_error = 0);
- static bool copy(const std::string from, const std::string to);
+ static bool copy(const std::string& from, const std::string& to);
static int stat(const std::string& filename,llstat* file_status);
static bool isdir(const std::string& filename);
@@ -160,7 +160,7 @@ private:
* Does The Right Thing when passed a non-ASCII pathname. Sadly, that isn't
* true of Microsoft's std::ifstream.
*/
-class LL_COMMON_API llifstream : public std::ifstream
+class LL_COMMON_API llifstream : public std::ifstream
{
// input stream associated with a C stream
public:
@@ -205,7 +205,7 @@ class LL_COMMON_API llifstream : public std::ifstream
* Right Thing when passed a non-ASCII pathname. Sadly, that isn't true of
* Microsoft's std::ofstream.
*/
-class LL_COMMON_API llofstream : public std::ofstream
+class LL_COMMON_API llofstream : public std::ofstream
{
public:
// Constructors:
@@ -241,7 +241,7 @@ class LL_COMMON_API llofstream : public std::ofstream
/**
- * @breif filesize helpers.
+ * @brief filesize helpers.
*
* The file size helpers are not considered particularly efficient,
* and should only be used for config files and the like -- not in a
diff --git a/indra/llcommon/llfindlocale.cpp b/indra/llcommon/llfindlocale.cpp
index ac52f90c9f..b4bcc80ac4 100644
--- a/indra/llcommon/llfindlocale.cpp
+++ b/indra/llcommon/llfindlocale.cpp
@@ -185,7 +185,7 @@ canonise_fl(FL_Locale *l) {
#define RML(pn,sn) MAKELANGID(LANG_##pn, SUBLANG_##sn)
struct IDToCode {
LANGID id;
- char* code;
+ const char* code;
};
static const IDToCode both_to_code[] = {
{ML(ENGLISH,US), "en_US.ISO_8859-1"},
diff --git a/indra/llcommon/llinstancetracker.h b/indra/llcommon/llinstancetracker.h
index 3232a0e219..92b26354a1 100644
--- a/indra/llcommon/llinstancetracker.h
+++ b/indra/llcommon/llinstancetracker.h
@@ -52,7 +52,7 @@ namespace LLInstanceTrackerPrivate
struct StaticBase
{
// We need to be able to lock static data while manipulating it.
- std::mutex mMutex;
+ LL_PROFILE_MUTEX_NAMED(std::mutex, mMutex, "InstanceTracker Data");
};
void logerrs(const char* cls, const std::string&, const std::string&, const std::string&);
@@ -101,7 +101,8 @@ public:
static size_t instanceCount()
{
- return LockStatic()->mMap.size();
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
+ return lock->mMap.size();
}
// snapshot of std::pair<const KEY, std::shared_ptr<SUBCLASS>> pairs, for
@@ -236,7 +237,7 @@ public:
static ptr_t getInstance(const KEY& k)
{
- LockStatic lock;
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
const InstanceMap& map(lock->mMap);
typename InstanceMap::const_iterator found = map.find(k);
return (found == map.end()) ? NULL : found->second;
@@ -252,19 +253,19 @@ protected:
ptr_t ptr(static_cast<T*>(this), [](T*){});
// save corresponding weak_ptr for future reference
mSelf = ptr;
- LockStatic lock;
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
add_(lock, key, ptr);
}
public:
virtual ~LLInstanceTracker()
{
- LockStatic lock;
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
remove_(lock);
}
protected:
virtual void setKey(KEY key)
{
- LockStatic lock;
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
// Even though the shared_ptr we store in our map has a no-op deleter
// for T itself, letting the use count decrement to 0 will still
// delete the use-count object. Capture the shared_ptr we just removed
@@ -376,7 +377,8 @@ public:
static size_t instanceCount()
{
- return LockStatic()->mSet.size();
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
+ return lock->mSet.size();
}
// snapshot of std::shared_ptr<SUBCLASS> pointers
@@ -488,14 +490,16 @@ protected:
// save corresponding weak_ptr for future reference
mSelf = ptr;
// Also store it in our class-static set to track this instance.
- LockStatic()->mSet.emplace(ptr);
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
+ lock->mSet.emplace(ptr);
}
public:
virtual ~LLInstanceTracker()
{
// convert weak_ptr to shared_ptr because that's what we store in our
// InstanceSet
- LockStatic()->mSet.erase(mSelf.lock());
+ LockStatic lock; LL_PROFILE_MUTEX_LOCK(lock->mMutex);
+ lock->mSet.erase(mSelf.lock());
}
protected:
LLInstanceTracker(const LLInstanceTracker& other):
diff --git a/indra/llcommon/llprofiler.cpp b/indra/llcommon/llprofiler.cpp
new file mode 100644
index 0000000000..bdddabf977
--- /dev/null
+++ b/indra/llcommon/llprofiler.cpp
@@ -0,0 +1,30 @@
+/**
+* @file llprofiler.cpp
+* @brief Implementation of llprofiler
+* @author Rye Cogtail
+*
+* $LicenseInfo:firstyear=2024&license=viewerlgpl$
+* Second Life Viewer Source Code
+* Copyright (C) 2024, Linden Research, Inc.
+*
+* 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.
+*
+* 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.
+*
+* 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$
+*/
+
+#include "linden_common.h"
+
+#include "TracyClient.cpp"
diff --git a/indra/llcommon/llprofiler.h b/indra/llcommon/llprofiler.h
index 732436cc4f..f6a4d24747 100644
--- a/indra/llcommon/llprofiler.h
+++ b/indra/llcommon/llprofiler.h
@@ -78,12 +78,6 @@ extern thread_local bool gProfilerEnabled;
#if defined(LL_PROFILER_CONFIGURATION) && (LL_PROFILER_CONFIGURATION > LL_PROFILER_CONFIG_NONE)
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY || LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER
- #define TRACY_ENABLE 1
-// Normally these would be enabled but we want to be able to build any viewer with Tracy enabled and run the Tracy server on another machine
-// They must be undefined in order to work across multiple machines
-// #define TRACY_NO_BROADCAST 1
-// #define TRACY_ONLY_LOCALHOST 1
- #define TRACY_ONLY_IPV4 1
#include "tracy/Tracy.hpp"
// Enable OpenGL profiling
@@ -108,6 +102,12 @@ extern thread_local bool gProfilerEnabled;
#define LL_PROFILE_ZONE_ERR(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0XFF0000 ) // RGB yellow
#define LL_PROFILE_ZONE_INFO(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0X00FFFF ) // RGB cyan
#define LL_PROFILE_ZONE_WARN(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0x0FFFF00 ) // RGB red
+
+ #define LL_PROFILE_MUTEX(type, varname) TracyLockable(type, varname)
+ #define LL_PROFILE_MUTEX_NAMED(type, varname, desc) TracyLockableN(type, varname, desc)
+ #define LL_PROFILE_MUTEX_SHARED(type, varname) TracySharedLockable(type, varname)
+ #define LL_PROFILE_MUTEX_SHARED_NAMED(type, varname, desc) TracySharedLockableN(type, varname, desc)
+ #define LL_PROFILE_MUTEX_LOCK(varname) { auto& mutex = varname; LockMark(mutex); }
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_FAST_TIMER
#define LL_PROFILER_FRAME_END
@@ -124,6 +124,12 @@ extern thread_local bool gProfilerEnabled;
#define LL_PROFILE_ZONE_ERR(name) (void)(name); // Not supported
#define LL_PROFILE_ZONE_INFO(name) (void)(name); // Not supported
#define LL_PROFILE_ZONE_WARN(name) (void)(name); // Not supported
+
+ #define LL_PROFILE_MUTEX(type, varname) type varname
+ #define LL_PROFILE_MUTEX_NAMED(type, varname, desc) type varname
+ #define LL_PROFILE_MUTEX_SHARED(type, varname) type varname
+ #define LL_PROFILE_MUTEX_SHARED_NAMED(type, varname, desc) type varname
+ #define LL_PROFILE_MUTEX_LOCK(varname) // LL_PROFILE_MUTEX_LOCK is a no-op when Tracy is disabled
#endif
#if LL_PROFILER_CONFIGURATION == LL_PROFILER_CONFIG_TRACY_FAST_TIMER
#define LL_PROFILER_FRAME_END FrameMark
@@ -139,6 +145,12 @@ extern thread_local bool gProfilerEnabled;
#define LL_PROFILE_ZONE_ERR(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0XFF0000 ) // RGB yellow
#define LL_PROFILE_ZONE_INFO(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0X00FFFF ) // RGB cyan
#define LL_PROFILE_ZONE_WARN(name) LL_PROFILE_ZONE_NAMED_COLOR( name, 0x0FFFF00 ) // RGB red
+
+ #define LL_PROFILE_MUTEX(type, varname) TracyLockable(type, varname)
+ #define LL_PROFILE_MUTEX_NAMED(type, varname, desc) TracyLockableN(type, varname, desc)
+ #define LL_PROFILE_MUTEX_SHARED(type, varname) TracySharedLockable(type, varname)
+ #define LL_PROFILE_MUTEX_SHARED_NAMED(type, varname, desc) TracySharedLockableN(type, varname, desc)
+ #define LL_PROFILE_MUTEX_LOCK(varname) { auto& mutex = varname; LockMark(mutex); } // see https://github.com/wolfpld/tracy/issues/575
#endif
#else
#define LL_PROFILER_FRAME_END
diff --git a/indra/llcommon/llsdjson.cpp b/indra/llcommon/llsdjson.cpp
index e95d2e6c1c..5d38e55686 100644
--- a/indra/llcommon/llsdjson.cpp
+++ b/indra/llcommon/llsdjson.cpp
@@ -35,16 +35,7 @@
#include "llerror.h"
#include "../llmath/llmath.h"
-#if LL_WINDOWS
-#pragma warning (push)
-#pragma warning (disable : 4702) // compiler thinks unreachable code
-#endif
#include <boost/json/src.hpp>
-#if LL_WINDOWS
-#pragma warning (pop)
-#endif
-
-
//=========================================================================
LLSD LlsdFromJson(const boost::json::value& val)
diff --git a/indra/llcommon/llsingleton.cpp b/indra/llcommon/llsingleton.cpp
index d00e703a10..05dc3cde79 100644
--- a/indra/llcommon/llsingleton.cpp
+++ b/indra/llcommon/llsingleton.cpp
@@ -59,9 +59,8 @@ private:
// it's safe to log -- which involves querying a different LLSingleton --
// which requires accessing the master list.
typedef std::recursive_mutex mutex_t;
- typedef std::unique_lock<mutex_t> lock_t;
-
- mutex_t mMutex;
+ LL_PROFILE_MUTEX_NAMED(mutex_t, mMutex, "Singleton MasterList");
+ typedef std::unique_lock<decltype(mMutex)> lock_t;
public:
// Instantiate this to both obtain a reference to MasterList::instance()
diff --git a/indra/llcommon/llsingleton.h b/indra/llcommon/llsingleton.h
index 316831cd74..b5659e053c 100644
--- a/indra/llcommon/llsingleton.h
+++ b/indra/llcommon/llsingleton.h
@@ -35,6 +35,8 @@
#include "lockstatic.h"
#include "llthread.h" // on_main_thread()
#include "llmainthreadtask.h"
+#include "llprofiler.h"
+#include "llerror.h"
#ifdef LL_WINDOWS
#pragma warning(push)
@@ -298,7 +300,7 @@ private:
// Use a recursive_mutex in case of constructor circularity. With a
// non-recursive mutex, that would result in deadlock.
typedef std::recursive_mutex mutex_t;
- mutex_t mMutex; // LockStatic looks for mMutex
+ LL_PROFILE_MUTEX_NAMED(mutex_t, mMutex, "Singleton Data"); // LockStatic looks for mMutex
EInitState mInitState{UNINITIALIZED};
DERIVED_TYPE* mInstance{nullptr};
@@ -420,7 +422,7 @@ protected:
// deleteSingleton() to defend against manual deletion. When we moved
// cleanup to deleteSingleton(), we hit crashes due to dangling
// pointers in the MasterList.
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
lk->mInstance = nullptr;
lk->mInitState = DELETED;
@@ -448,7 +450,7 @@ public:
// Hold the lock while we call cleanupSingleton() and the destructor.
// Our destructor also instantiates LockStatic, requiring a recursive
// mutex.
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
// of course, only cleanup and delete if there's something there
if (lk->mInstance)
{
@@ -505,7 +507,7 @@ public:
{ // nested scope for 'lk'
// In case racing threads call getInstance() at the same moment,
// serialize the calls.
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
switch (lk->mInitState)
{
@@ -595,7 +597,7 @@ public:
static bool instanceExists()
{
// defend any access to sData from racing threads
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
return lk->mInitState == INITIALIZED;
}
@@ -605,7 +607,7 @@ public:
static bool wasDeleted()
{
// defend any access to sData from racing threads
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
return lk->mInitState == DELETED;
}
};
@@ -644,7 +646,7 @@ private:
// In case racing threads both call initParamSingleton() at the same
// time, serialize them. One should initialize; the other should see
// mInitState already set.
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
// For organizational purposes this function shouldn't be called twice
if (lk->mInitState != super::UNINITIALIZED)
{
@@ -708,7 +710,7 @@ public:
{
// In case racing threads call getInstance() at the same moment as
// initParamSingleton(), serialize the calls.
- LockStatic lk;
+ LockStatic lk; LL_PROFILE_MUTEX_LOCK(lk->mMutex);
switch (lk->mInitState)
{
diff --git a/indra/llcommon/llstacktrace.cpp b/indra/llcommon/llstacktrace.cpp
index bda3579f60..ca8f4299d9 100644
--- a/indra/llcommon/llstacktrace.cpp
+++ b/indra/llcommon/llstacktrace.cpp
@@ -33,10 +33,7 @@
#include <sstream>
#include "llwin32headerslean.h"
-#pragma warning (push)
-#pragma warning (disable:4091) // a microsoft header has warnings. Very nice.
#include <dbghelp.h>
-#pragma warning (pop)
typedef USHORT NTAPI RtlCaptureStackBackTrace_Function(
IN ULONG frames_to_skip,
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index c57f8b1e96..505789f9ea 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -900,6 +900,11 @@ void HeapFree_deleter(void* ptr)
} // anonymous namespace
+unsigned long windows_get_last_error()
+{
+ return GetLastError();
+}
+
template<>
std::wstring windows_message<std::wstring>(DWORD error)
{
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index b69a068830..db716b1431 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -46,7 +46,6 @@
#endif
#include <string.h>
-#include <boost/scoped_ptr.hpp>
const char LL_UNKNOWN_CHAR = '?';
class LLSD;
@@ -832,8 +831,10 @@ template<>
LL_COMMON_API std::wstring windows_message<std::wstring>(unsigned long error);
/// Get Windows message string, implicitly calling GetLastError()
+LL_COMMON_API unsigned long windows_get_last_error();
+
template<typename STRING>
-STRING windows_message() { return windows_message<STRING>(GetLastError()); }
+STRING windows_message() { return windows_message<STRING>(windows_get_last_error()); }
//@}
diff --git a/indra/llcommon/lluuid.cpp b/indra/llcommon/lluuid.cpp
index 3b37365ec7..7aeabc3c4a 100644
--- a/indra/llcommon/lluuid.cpp
+++ b/indra/llcommon/lluuid.cpp
@@ -31,6 +31,7 @@
// ugh, this is ugly. We need to straighten out our linking for this library
#pragma comment(lib, "IPHLPAPI.lib")
#include <iphlpapi.h>
+#include <nb30.h>
#endif
#include "llapp.h"
diff --git a/indra/llcommon/tests/commonmisc_test.cpp b/indra/llcommon/tests/commonmisc_test.cpp
index 0057a1f639..b1a284225e 100644
--- a/indra/llcommon/tests/commonmisc_test.cpp
+++ b/indra/llcommon/tests/commonmisc_test.cpp
@@ -46,12 +46,6 @@
#include "../test/lltut.h"
-
-#if LL_WINDOWS
-// disable overflow warnings
-#pragma warning(disable: 4307)
-#endif
-
namespace tut
{
struct sd_data