From 05a3203d8274a0a0999faad128f629614b8d62c5 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Wed, 26 Sep 2012 17:04:57 -0700 Subject: SH-3275 WIP Run viewer metrics for object update messages fixed various issues related to unit tests and LLThreadLocalPtr initialization and teardown --- indra/test/test.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/test/test.cpp b/indra/test/test.cpp index dc8580fe69..2b66c6aa26 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -512,15 +512,10 @@ int main(int argc, char **argv) ctype_workaround(); #endif - apr_initialize(); - apr_pool_t* pool = NULL; - if(APR_SUCCESS != apr_pool_create(&pool, NULL)) - { - std::cerr << "Unable to initialize pool" << std::endl; - return 1; - } + ll_init_apr(); + apr_getopt_t* os = NULL; - if(APR_SUCCESS != apr_getopt_init(&os, pool, argc, argv)) + if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { std::cerr << "apr_getopt_init() failed" << std::endl; return 1; @@ -602,7 +597,7 @@ int main(int argc, char **argv) if (LOGFAIL) { LLError::ELevel level = LLError::decodeLevel(LOGFAIL); - replayer.reset(new LLReplayLogReal(level, pool)); + replayer.reset(new LLReplayLogReal(level, gAPRPoolp)); } else { @@ -646,7 +641,7 @@ int main(int argc, char **argv) s.close(); } - apr_terminate(); + ll_cleanup_apr(); int retval = (success ? 0 : 1); return retval; -- cgit v1.3 From c136b432140f892a56d4996d5ed77e903ff0b32d Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Thu, 15 Nov 2012 19:46:09 -0800 Subject: SH-3406 WIP convert fast timers to lltrace system eliminated min and max macros from windows.h got rest of viewer to compile against llfasttimer changes --- indra/cmake/00-Common.cmake | 1 + indra/llcommon/llapr.h | 1 + indra/llcommon/llfasttimer.cpp | 5 +++++ indra/llcommon/llfasttimer.h | 3 ++- indra/llcommon/llthread.h | 2 ++ indra/llcommon/lltrace.cpp | 1 - indra/llcommon/llwin32headers.h | 2 -- indra/llcommon/llwin32headerslean.h | 1 - indra/llmessage/lliopipe.h | 1 + indra/llmessage/lliosocket.h | 2 +- indra/newview/llappviewer.cpp | 2 +- indra/newview/llfasttimerview.cpp | 8 ++++---- indra/newview/llfloatermodelpreview.cpp | 2 -- indra/newview/llviewerstatsrecorder.h | 2 +- indra/newview/llxmlrpctransaction.cpp | 2 ++ indra/test/test.cpp | 4 +++- 16 files changed, 24 insertions(+), 15 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake index 21cb87237d..180714c9c9 100644 --- a/indra/cmake/00-Common.cmake +++ b/indra/cmake/00-Common.cmake @@ -58,6 +58,7 @@ if (WINDOWS) add_definitions( /DLL_WINDOWS=1 + /DNOMINMAX /DDOM_DYNAMIC /DUNICODE /D_UNICODE diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index c77d96c1c9..d9fe257e86 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -40,6 +40,7 @@ #include "apr_getopt.h" #include "apr_signal.h" #include "apr_atomic.h" + #include "llstring.h" #include "llinstancetracker.h" diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index d007f76e5f..4ecca12832 100644 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -121,6 +121,11 @@ void BlockTimer::pushLog(LLSD log) sLogQueue.push(log); } +void BlockTimer::setLogLock(LLMutex* lock) +{ + sLogLock = lock; +} + //static #if (LL_DARWIN || LL_LINUX || LL_SOLARIS) && !(defined(__i386__) || defined(__amd64__)) diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h index 69a6773b12..af9b360e01 100644 --- a/indra/llcommon/llfasttimer.h +++ b/indra/llcommon/llfasttimer.h @@ -98,6 +98,7 @@ public: static BlockTimer& getRootTimer(); static void pushLog(LLSD sd); + static void setLogLock(LLMutex* mutex); friend class Time; @@ -329,6 +330,6 @@ LL_FORCE_INLINE Time::~Time() } -typedef LLTrace::Time LLFastTimer; +typedef LLTrace::Time LLFastTimer; #endif // LL_LLFASTTIMER_H diff --git a/indra/llcommon/llthread.h b/indra/llcommon/llthread.h index 82ab5f47d2..93c752754d 100644 --- a/indra/llcommon/llthread.h +++ b/indra/llcommon/llthread.h @@ -32,6 +32,8 @@ #include "apr_thread_cond.h" #include "llmutex.h" +LL_COMMON_API void assert_main_thread(); + class LL_COMMON_API LLThread { private: diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9346aa7a45..9bf9ae6c8e 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -59,7 +59,6 @@ LLThreadLocalPointer& get_thread_recorder() { static LLThreadLocalPointer s_thread_recorder; return s_thread_recorder; - } } diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index 80fd2e1768..9c89b6b280 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,11 +28,9 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS -#define NOMINMAX #undef WIN32_LEAN_AND_MEAN #include #include -#undef NOMINMAX #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h index ab6e9c09e2..d3fb90d4b1 100644 --- a/indra/llcommon/llwin32headerslean.h +++ b/indra/llcommon/llwin32headerslean.h @@ -28,7 +28,6 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS -#define NOMINMAX #define WIN32_LEAN_AND_MEAN #include #include diff --git a/indra/llmessage/lliopipe.h b/indra/llmessage/lliopipe.h index cbd17b5a3d..9a0a427efd 100644 --- a/indra/llmessage/lliopipe.h +++ b/indra/llmessage/lliopipe.h @@ -31,6 +31,7 @@ #include #include +#include "llwin32headerslean.h" #include "apr_poll.h" #include "llsd.h" diff --git a/indra/llmessage/lliosocket.h b/indra/llmessage/lliosocket.h index 4e07963af8..ec998552d0 100644 --- a/indra/llmessage/lliosocket.h +++ b/indra/llmessage/lliosocket.h @@ -38,8 +38,8 @@ */ #include "lliopipe.h" -#include "apr_pools.h" #include "llwin32headerslean.h" +#include "apr_pools.h" #include "apr_network_io.h" #include "llchainio.h" diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index c6ed8d5071..9d4ed833b8 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -2033,7 +2033,7 @@ bool LLAppViewer::initThreads() if (LLTrace::BlockTimer::sLog || LLTrace::BlockTimer::sMetricLog) { - LLTrace::BlockTimer::sLogLock = new LLMutex(NULL); + LLTrace::BlockTimer::setLogLock(new LLMutex(NULL)); mFastTimerLogThread = new LLFastTimerLogThread(LLTrace::BlockTimer::sLogName); mFastTimerLogThread->start(); } diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index d0bb75225c..7a5c9dba46 100644 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -92,7 +92,7 @@ LLFastTimerView::LLFastTimerView(const LLSD& key) mScrollIndex = 0; mHoverID = NULL; mHoverBarIndex = -1; - FTV_NUM_TIMERS = LLTrace::BlockTimer::instanceCount(); + FTV_NUM_TIMERS = LLInstanceTracker::instanceCount(); mPrintStats = -1; } @@ -235,7 +235,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) if(LLTrace::BlockTimer::sPauseHistory && mBarRect.pointInRect(x, y)) { - mHoverBarIndex = llmin(LLFastTimer::getCurFrameIndex() - 1, + mHoverBarIndex = llmin(LLTrace::BlockTimer::getCurFrameIndex() - 1, MAX_VISIBLE_HISTORY - ((y - mBarRect.mBottom) * (MAX_VISIBLE_HISTORY + 2) / mBarRect.getHeight())); if (mHoverBarIndex == 0) { @@ -292,7 +292,7 @@ BOOL LLFastTimerView::handleHover(S32 x, S32 y, MASK mask) static std::string get_tooltip(LLTrace::BlockTimer& timer, S32 history_index = -1) { - F64 ms_multiplier = 1000.0 / (F64)LLFastTimer::countsPerSecond(); + F64 ms_multiplier = 1000.0 / (F64)LLTrace::BlockTimer::countsPerSecond(); std::string tooltip; if (history_index < 0) @@ -364,7 +364,7 @@ void LLFastTimerView::draw() std::string tdesc; - F64 clock_freq = (F64)LLFastTimer::countsPerSecond(); + F64 clock_freq = (F64)LLTrace::BlockTimer::countsPerSecond(); F64 iclock_freq = 1000.0 / clock_freq; S32 margin = 10; diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index a071f338ba..a5e3cd404d 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -113,8 +113,6 @@ #include "llviewernetwork.h" #include "llviewershadermgr.h" #include "glod/glod.h" -#include - const S32 SLM_SUPPORTED_VERSION = 3; diff --git a/indra/newview/llviewerstatsrecorder.h b/indra/newview/llviewerstatsrecorder.h index ce6dd63ec5..d1744f4910 100644 --- a/indra/newview/llviewerstatsrecorder.h +++ b/indra/newview/llviewerstatsrecorder.h @@ -32,7 +32,7 @@ // for analysis. // This is normally 0. Set to 1 to enable viewer stats recording -#define LL_RECORD_VIEWER_STATS 1 +#define LL_RECORD_VIEWER_STATS 0 #include "llframetimer.h" diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 0da70d398b..583196fb7a 100644 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -25,6 +25,8 @@ */ #include "llviewerprecompiledheaders.h" +// include this to get winsock2 because openssl attempts to include winsock1 +#include "llwin32headerslean.h" #include #include #include "llsecapi.h" diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 2b66c6aa26..8bd302ce7a 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -40,6 +40,7 @@ #include "tests/wrapllerrs.h" // RecorderProxy #include "stringize.h" #include "namedtempfile.h" +#include "lltrace.h" #include "apr_pools.h" #include "apr_getopt.h" @@ -513,7 +514,8 @@ int main(int argc, char **argv) #endif ll_init_apr(); - + LLTrace::init(); + apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { -- cgit v1.3 From 68413515029f50713c70e4adec3ce6fd1022d59f Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Sun, 6 Jan 2013 21:37:31 -0800 Subject: SH-3468 WIP add memory tracking base class fix for unit test failures...cleanup apr without destroying pools, allowing LLProxy to clean itself up as a singleton (and avoiding spurious dependencies associated with manually destorying singletons that rely on apr pools) --- indra/llcommon/llapr.cpp | 4 ++-- indra/llcommon/llapr.h | 2 +- indra/llcommon/lltracethreadrecorder.cpp | 2 +- indra/llimage/tests/llimageworker_test.cpp | 3 +++ indra/llkdu/tests/llimagej2ckdu_test.cpp | 4 +++- indra/llmessage/llproxy.cpp | 3 +-- indra/test/test.cpp | 2 +- 7 files changed, 12 insertions(+), 8 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index d911f258b6..8a87911315 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -60,7 +60,7 @@ void ll_init_apr() } -void ll_cleanup_apr() +void ll_cleanup_apr(bool destroy_pools) { LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; @@ -83,7 +83,7 @@ void ll_cleanup_apr() LLThreadLocalPointerBase::destroyAllThreadLocalStorage(); - if (gAPRPoolp) + if (gAPRPoolp && destroy_pools) { apr_pool_destroy(gAPRPoolp); gAPRPoolp = NULL; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index b3c9bfd58c..424ddc6505 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -70,7 +70,7 @@ void LL_COMMON_API ll_init_apr(); /** * @brief Cleanup those common apr constructs. */ -void LL_COMMON_API ll_cleanup_apr(); +void LL_COMMON_API ll_cleanup_apr(bool destroy_pools = true); // //LL apr_pool diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index 9fb789c62d..7b493a651e 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -127,7 +127,7 @@ std::list::iterator ThreadRecorder::update( Rec if (it == end_it) { - llerrs << "Recording not active on this thread" << llendl; + llwarns << "Recording not active on this thread" << llendl; } return it; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index 29497257ac..4118896768 100644 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,6 +44,9 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. +LLTrace::MemStat LLImageBase::sMemStat("LLImage"); + + LLImageBase::LLImageBase() : mData(NULL), mDataSize(0), diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 62c245f125..c28f121eb8 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -43,7 +43,9 @@ // End Stubbing // ------------------------------------------------------------------------------------------- -// Stubb the LL Image Classes +// Stub the LL Image Classes +LLTrace::MemStat LLImageBase::sMemStat("LLImage"); + LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } U8* LLImageRaw::allocateData(S32 ) { return NULL; } diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp index 9988fcd9c0..aa474fabd2 100644 --- a/indra/llmessage/llproxy.cpp +++ b/indra/llmessage/llproxy.cpp @@ -57,8 +57,7 @@ LLProxy::LLProxy(): mAuthMethodSelected(METHOD_NOAUTH), mSocksUsername(), mSocksPassword() -{ -} +{} LLProxy::~LLProxy() { diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 8bd302ce7a..d75040393c 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -643,7 +643,7 @@ int main(int argc, char **argv) s.close(); } - ll_cleanup_apr(); + ll_cleanup_apr(false); int retval = (success ? 0 : 1); return retval; -- cgit v1.3 From 3c341a11ab7b8f3fd18afcf3f50af6dfafa632c2 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Jan 2013 00:25:07 -0800 Subject: SH-3468 WIP add memory tracking base class more fixes for unit test crashes added llcommon initialization/teardown for unit tests that indirectly trigger lltrace changed access of atomic refcount to use preincrement/decrement operators to reflect desired semantics always call apr_initialize in LLCommon::initClass, even if already initialized...apr does internal reference counting to keep things straight --- indra/llcommon/llapr.cpp | 19 +++++++++++++++---- indra/llcommon/llapr.h | 5 ++++- indra/llcommon/llmutex.cpp | 11 +++++++---- indra/llcorehttp/_refcounted.h | 4 ++-- indra/llmessage/llproxy.cpp | 7 +++++-- indra/test/io.cpp | 11 ++++++++++- indra/test/llhttpdate_tut.cpp | 9 +++++++++ indra/test/lliohttpserver_tut.cpp | 7 +++++++ indra/test/test.cpp | 2 +- 9 files changed, 60 insertions(+), 15 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp index 8a87911315..0556fadb26 100644 --- a/indra/llcommon/llapr.cpp +++ b/indra/llcommon/llapr.cpp @@ -38,12 +38,15 @@ apr_thread_mutex_t *gCallStacksLogMutexp = NULL; const S32 FULL_VOLATILE_APR_POOL = 1024 ; //number of references to LLVolatileAPRPool +bool gAPRInitialized = false; + void ll_init_apr() { + // Initialize APR and create the global pool + apr_initialize(); + if (!gAPRPoolp) { - // Initialize APR and create the global pool - apr_initialize(); apr_pool_create(&gAPRPoolp, NULL); // Initialize the logging mutex @@ -57,11 +60,19 @@ void ll_init_apr() } LLThreadLocalPointerBase::initAllThreadLocalStorage(); + gAPRInitialized = true; } -void ll_cleanup_apr(bool destroy_pools) +bool ll_apr_is_initialized() +{ + return gAPRInitialized; +} + +void ll_cleanup_apr() { + gAPRInitialized = false; + LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL; if (gLogMutexp) @@ -83,7 +94,7 @@ void ll_cleanup_apr(bool destroy_pools) LLThreadLocalPointerBase::destroyAllThreadLocalStorage(); - if (gAPRPoolp && destroy_pools) + if (gAPRPoolp) { apr_pool_destroy(gAPRPoolp); gAPRPoolp = NULL; diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h index 424ddc6505..3b65c0dc34 100644 --- a/indra/llcommon/llapr.h +++ b/indra/llcommon/llapr.h @@ -70,7 +70,10 @@ void LL_COMMON_API ll_init_apr(); /** * @brief Cleanup those common apr constructs. */ -void LL_COMMON_API ll_cleanup_apr(bool destroy_pools = true); +void LL_COMMON_API ll_cleanup_apr(); + +bool LL_COMMON_API ll_apr_is_initialized(); + // //LL apr_pool diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp index b685bb4d60..ad0287c6d5 100644 --- a/indra/llcommon/llmutex.cpp +++ b/indra/llcommon/llmutex.cpp @@ -56,12 +56,15 @@ LLMutex::~LLMutex() //bad assertion, the subclass LLSignal might be "locked", and that's OK //llassert_always(!isLocked()); // better not be locked! #endif - apr_thread_mutex_destroy(mAPRMutexp); - mAPRMutexp = NULL; - if (mIsLocalPool) + if (ll_apr_is_initialized()) { - apr_pool_destroy(mAPRPoolp); + apr_thread_mutex_destroy(mAPRMutexp); + if (mIsLocalPool) + { + apr_pool_destroy(mAPRPoolp); + } } + mAPRMutexp = NULL; } diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h index 21a916b13b..402e725152 100644 --- a/indra/llcorehttp/_refcounted.h +++ b/indra/llcorehttp/_refcounted.h @@ -72,7 +72,7 @@ private: inline void RefCounted::addRef() const { - S32 count(mRefCount++); + S32 count(++mRefCount); llassert_always(count >= 0); } @@ -82,7 +82,7 @@ inline void RefCounted::release() const S32 count(mRefCount); llassert_always(count != NOT_REF_COUNTED); llassert_always(count > 0); - count = mRefCount--; + count = --mRefCount; // clean ourselves up if that was the last reference if (0 == count) diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp index aa474fabd2..9b8d19cc3e 100644 --- a/indra/llmessage/llproxy.cpp +++ b/indra/llmessage/llproxy.cpp @@ -61,8 +61,11 @@ LLProxy::LLProxy(): LLProxy::~LLProxy() { - stopSOCKSProxy(); - disableHTTPProxy(); + if (ll_apr_is_initialized()) + { + stopSOCKSProxy(); + disableHTTPProxy(); + } } /** diff --git a/indra/test/io.cpp b/indra/test/io.cpp index ce747f667d..f2b4a5339c 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -44,6 +44,7 @@ #include "llsdrpcclient.h" #include "llsdrpcserver.h" #include "llsdserialize.h" +#include "llcommon.h" #include "lluuid.h" #include "llinstantmessage.h" @@ -830,6 +831,7 @@ namespace tut public: PumpAndChainTestData() { + LLCommon::initClass(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); } @@ -839,6 +841,7 @@ namespace tut mChain.clear(); delete mPump; apr_pool_destroy(mPool); + LLCommon::cleanupClass(); } }; typedef test_group PumpAndChainTestGroup; @@ -909,6 +912,7 @@ namespace tut pipe_and_pump_fitness() { + LLCommon::initClass(); LLFrameTimer::updateFrameTime(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); @@ -923,6 +927,7 @@ namespace tut mSocket.reset(); delete mPump; apr_pool_destroy(mPool); + LLCommon::cleanupClass(); } protected: @@ -1186,8 +1191,12 @@ namespace tut LLSimpleRPCResponse(LLSD* response) : mResponsePtr(response) { + LLCommon::initClass(); + } + ~LLSimpleRPCResponse() + { + LLCommon::cleanupClass(); } - ~LLSimpleRPCResponse() {} virtual bool response(LLPumpIO* pump) { *mResponsePtr = mReturnValue; diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp index 46684bb9dc..d6f0ba5e66 100644 --- a/indra/test/llhttpdate_tut.cpp +++ b/indra/test/llhttpdate_tut.cpp @@ -29,6 +29,7 @@ #include "lltut.h" #include "lldate.h" +#include "llcommon.h" #include "llframetimer.h" #include @@ -38,6 +39,14 @@ namespace tut { struct httpdate_data { + httpdate_data() + { + LLCommon::initClass(); + } + ~httpdate_data() + { + LLCommon::cleanupClass(); + } LLDate some_date; }; typedef test_group httpdate_test; diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp index 2fdc455f45..e7af09f80b 100644 --- a/indra/test/lliohttpserver_tut.cpp +++ b/indra/test/lliohttpserver_tut.cpp @@ -31,6 +31,7 @@ #include "lliohttpserver.h" #include "llsdhttpserver.h" #include "llsdserialize.h" +#include "llcommon.h" #include "llpipeutil.h" @@ -76,11 +77,17 @@ namespace tut HTTPServiceTestData() : mResponse(NULL) { + LLCommon::initClass(); LLHTTPStandardServices::useServices(); LLHTTPRegistrar::buildAllServices(mRoot); mRoot.addNode("/delayed/echo", new DelayedEcho(this)); mRoot.addNode("/wire/hello", new LLHTTPNodeForPipe); } + + ~HTTPServiceTestData() + { + LLCommon::cleanupClass(); + } LLHTTPNode mRoot; LLHTTPNode::ResponsePtr mResponse; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index d75040393c..8bd302ce7a 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -643,7 +643,7 @@ int main(int argc, char **argv) s.close(); } - ll_cleanup_apr(false); + ll_cleanup_apr(); int retval = (success ? 0 : 1); return retval; -- cgit v1.3 From 0ba9a00c3116b69745f2d5070ce772d5d4965dbf Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Tue, 8 Jan 2013 23:50:27 -0800 Subject: SH-3468 WIP add memory tracking base class cleaned up hacks used to get unit tests working LLTrace::init now supports recursive initialization/cleanup put NOMINMAX back in win32 header wrappers --- indra/llcommon/lltrace.cpp | 17 +++++++++++------ indra/llcommon/llwin32headers.h | 4 ++++ indra/llcommon/llwin32headerslean.h | 4 ++++ indra/test/io.cpp | 6 ------ indra/test/llhttpdate_tut.cpp | 2 -- indra/test/lliohttpserver_tut.cpp | 2 -- indra/test/test.cpp | 2 +- indra/test_apps/llplugintest/llmediaplugintest.cpp | 1 - 8 files changed, 20 insertions(+), 18 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9cadd70dd8..463048008f 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,7 +30,7 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" -static bool sInitialized; +static S32 sInitializationCount = 0; namespace LLTrace { @@ -39,19 +39,24 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { - gMasterThreadRecorder = new MasterThreadRecorder(); - sInitialized = true; + if (sInitializationCount++ == 0) + { + gMasterThreadRecorder = new MasterThreadRecorder(); + } } bool isInitialized() { - return sInitialized; + return sInitializationCount > 0; } void cleanup() { - delete gMasterThreadRecorder; - gMasterThreadRecorder = NULL; + if (--sInitializationCount == 0) + { + delete gMasterThreadRecorder; + gMasterThreadRecorder = NULL; + } } MasterThreadRecorder& getMasterThreadRecorder() diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index 9c89b6b280..8534ed6298 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #undef WIN32_LEAN_AND_MEAN #include #include +#undef NOMINMAX #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h index d3fb90d4b1..f7e71301a8 100644 --- a/indra/llcommon/llwin32headerslean.h +++ b/indra/llcommon/llwin32headerslean.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #define WIN32_LEAN_AND_MEAN #include #include +#undef NOMINMAX #endif #endif diff --git a/indra/test/io.cpp b/indra/test/io.cpp index f2b4a5339c..b3eabc2e8a 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -831,7 +831,6 @@ namespace tut public: PumpAndChainTestData() { - LLCommon::initClass(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); } @@ -841,7 +840,6 @@ namespace tut mChain.clear(); delete mPump; apr_pool_destroy(mPool); - LLCommon::cleanupClass(); } }; typedef test_group PumpAndChainTestGroup; @@ -912,7 +910,6 @@ namespace tut pipe_and_pump_fitness() { - LLCommon::initClass(); LLFrameTimer::updateFrameTime(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); @@ -927,7 +924,6 @@ namespace tut mSocket.reset(); delete mPump; apr_pool_destroy(mPool); - LLCommon::cleanupClass(); } protected: @@ -1191,11 +1187,9 @@ namespace tut LLSimpleRPCResponse(LLSD* response) : mResponsePtr(response) { - LLCommon::initClass(); } ~LLSimpleRPCResponse() { - LLCommon::cleanupClass(); } virtual bool response(LLPumpIO* pump) { diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp index d6f0ba5e66..ecf734ee90 100644 --- a/indra/test/llhttpdate_tut.cpp +++ b/indra/test/llhttpdate_tut.cpp @@ -41,11 +41,9 @@ namespace tut { httpdate_data() { - LLCommon::initClass(); } ~httpdate_data() { - LLCommon::cleanupClass(); } LLDate some_date; }; diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp index e7af09f80b..3fa5c8dd42 100644 --- a/indra/test/lliohttpserver_tut.cpp +++ b/indra/test/lliohttpserver_tut.cpp @@ -77,7 +77,6 @@ namespace tut HTTPServiceTestData() : mResponse(NULL) { - LLCommon::initClass(); LLHTTPStandardServices::useServices(); LLHTTPRegistrar::buildAllServices(mRoot); mRoot.addNode("/delayed/echo", new DelayedEcho(this)); @@ -86,7 +85,6 @@ namespace tut ~HTTPServiceTestData() { - LLCommon::cleanupClass(); } LLHTTPNode mRoot; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 8bd302ce7a..28de88201c 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -514,8 +514,8 @@ int main(int argc, char **argv) #endif ll_init_apr(); - LLTrace::init(); + LLTrace::init(); apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp index 99a82ed555..fa4f5abd28 100644 --- a/indra/test_apps/llplugintest/llmediaplugintest.cpp +++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp @@ -41,7 +41,6 @@ #if LL_WINDOWS #pragma warning(disable: 4263) #pragma warning(disable: 4264) -#undef NOMINMAX #endif #if __APPLE__ -- cgit v1.3 From 04bdc8ba83c297945dd60489c241b88adf892ff4 Mon Sep 17 00:00:00 2001 From: Richard Linden Date: Mon, 1 Jul 2013 17:04:01 -0700 Subject: SH-4294 FIX Interesting: Statistics Texture cache hit rate is always 0% also, removed LLTrace::init and cleanup removed derived class implementation of memory stat for LLMemTrackable is automatic now --- indra/llcommon/llcommon.cpp | 14 ++++- indra/llcommon/llfasttimer.cpp | 2 +- indra/llcommon/llthread.cpp | 2 +- indra/llcommon/lltrace.cpp | 26 ++++------ indra/llcommon/lltrace.h | 68 +++++++++++++++---------- indra/llcommon/lltraceaccumulators.h | 7 +-- indra/llcommon/lltracethreadrecorder.cpp | 14 +++-- indra/llcommon/lltracethreadrecorder.h | 10 ++-- indra/llimage/llimage.cpp | 13 ++--- indra/llimage/llimage.h | 2 - indra/llimage/tests/llimageworker_test.cpp | 8 --- indra/llkdu/tests/llimagej2ckdu_test.cpp | 2 - indra/llui/llstatbar.cpp | 12 ++--- indra/llui/lltextbase.cpp | 2 - indra/llui/lltextbase.h | 2 - indra/llui/llview.cpp | 1 - indra/llui/llview.h | 1 - indra/llui/llviewmodel.cpp | 2 - indra/llui/llviewmodel.h | 2 - indra/newview/llappviewer.cpp | 2 +- indra/newview/lldrawable.cpp | 1 - indra/newview/lldrawable.h | 1 - indra/newview/llfasttimerview.cpp | 10 ++-- indra/newview/llviewerobject.cpp | 2 - indra/newview/llviewerobject.h | 1 - indra/newview/llvocache.cpp | 2 - indra/newview/llvocache.h | 3 -- indra/newview/tests/llviewerassetstats_test.cpp | 6 ++- indra/test/test.cpp | 9 +++- 29 files changed, 107 insertions(+), 120 deletions(-) (limited to 'indra/test/test.cpp') diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp index c720df7555..96ec0cdefe 100755 --- a/indra/llcommon/llcommon.cpp +++ b/indra/llcommon/llcommon.cpp @@ -30,10 +30,13 @@ #include "llmemory.h" #include "llthread.h" #include "lltrace.h" +#include "lltracethreadrecorder.h" //static BOOL LLCommon::sAprInitialized = FALSE; +static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; + //static void LLCommon::initClass() { @@ -45,13 +48,20 @@ void LLCommon::initClass() } LLTimer::initClass(); LLThreadSafeRefCount::initThreadSafeRefCount(); - LLTrace::init(); + + if (!sMasterThreadRecorder) + { + sMasterThreadRecorder = new LLTrace::ThreadRecorder(); + LLTrace::set_master_thread_recorder(sMasterThreadRecorder); + } } //static void LLCommon::cleanupClass() { - LLTrace::cleanup(); + delete sMasterThreadRecorder; + sMasterThreadRecorder = NULL; + LLTrace::set_master_thread_recorder(NULL); LLThreadSafeRefCount::cleanupThreadSafeRefCount(); LLTimer::cleanupClass(); if (sAprInitialized) diff --git a/indra/llcommon/llfasttimer.cpp b/indra/llcommon/llfasttimer.cpp index 7a7f1c79c1..a72f16d385 100755 --- a/indra/llcommon/llfasttimer.cpp +++ b/indra/llcommon/llfasttimer.cpp @@ -250,7 +250,7 @@ void TimeBlock::updateTimes() { // walk up stack of active timers and accumulate current time while leaving timing structures active BlockTimerStackRecord* stack_record = LLThreadLocalSingletonPointer::getInstance(); - if (stack_record) return; + if (!stack_record) return; U64 cur_time = getCPUClockCount64(); BlockTimer* cur_timer = stack_record->mActiveTimer; diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index d07cccdf15..166a4eb26d 100755 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -93,7 +93,7 @@ void *APR_THREAD_FUNC LLThread::staticRun(apr_thread_t *apr_threadp, void *datap { LLThread *threadp = (LLThread *)datap; - LLTrace::ThreadRecorder thread_recorder(LLTrace::getUIThreadRecorder()); + LLTrace::ThreadRecorder thread_recorder(*LLTrace::get_master_thread_recorder()); #if !LL_DARWIN sThreadID = threadp->mID; diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 26c19e5121..3dffbe6d4a 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,34 +30,26 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" -static S32 sInitializationCount = 0; - namespace LLTrace { -void init() +TraceBase::TraceBase( const char* name, const char* description ) +: mName(name), + mDescription(description ? description : "") { - if (sInitializationCount++ == 0) +#ifndef LL_RELEASE_FOR_DOWNLOAD + if (LLTrace::get_master_thread_recorder() != NULL) { - gUIThreadRecorder = new ThreadRecorder(); + llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; } +#endif } -bool isInitialized() +const char* TraceBase::getUnitLabel() { - return sInitializationCount > 0; + return ""; } -void cleanup() -{ - if (--sInitializationCount == 0) - { - delete gUIThreadRecorder; - gUIThreadRecorder = NULL; - } -} - - TimeBlockTreeNode::TimeBlockTreeNode() : mBlock(NULL), mParent(NULL), diff --git a/indra/llcommon/lltrace.h b/indra/llcommon/lltrace.h index 72ef51c232..1cde450dc2 100644 --- a/indra/llcommon/lltrace.h +++ b/indra/llcommon/lltrace.h @@ -53,19 +53,29 @@ STORAGE_TYPE storage_value(LLUnit val) { return val.val template STORAGE_TYPE storage_value(LLUnitImplicit val) { return val.value(); } -void init(); -void cleanup(); -bool isInitialized(); +class TraceBase +{ +public: + TraceBase(const char* name, const char* description); + virtual ~TraceBase() {}; + virtual const char* getUnitLabel(); + + const std::string& getName() const { return mName; } + +protected: + const std::string mName; + const std::string mDescription; +}; template class TraceType -: public LLInstanceTracker, std::string> +: public TraceBase, + public LLInstanceTracker, std::string> { public: TraceType(const char* name, const char* description = NULL) : LLInstanceTracker, std::string>(name), - mName(name), - mDescription(description ? description : ""), + TraceBase(name, description), mAccumulatorIndex(AccumulatorBuffer::getDefaultBuffer()->reserveSlot()) {} @@ -78,13 +88,7 @@ public: size_t getIndex() const { return mAccumulatorIndex; } static size_t getNumIndices() { return AccumulatorBuffer::getNumIndices(); } - virtual const char* getUnitLabel() { return ""; } - - const std::string& getName() const { return mName; } - -protected: - const std::string mName; - const std::string mDescription; +private: const size_t mAccumulatorIndex; }; @@ -320,7 +324,7 @@ class MemTrackable template struct TrackMemImpl; - typedef MemTrackable mem_trackable_t; + typedef MemTrackable mem_trackable_t; public: typedef void mem_trackable_tag_t; @@ -332,7 +336,7 @@ public: void* operator new(size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -344,7 +348,7 @@ public: void operator delete(void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -356,7 +360,7 @@ public: void *operator new [](size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); @@ -368,7 +372,7 @@ public: void operator delete[](void* ptr, size_t size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = mem_trackable_t::sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); @@ -394,14 +398,16 @@ public: } - void memClaimAmount(size_t size) + template + AMOUNT_T& memClaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); - mMemFootprint += size; + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); + mMemFootprint += (size_t)size; if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() + (F64)size); } + return size; } // remove memory we had claimed from our calculated footprint @@ -419,24 +425,28 @@ public: return value; } - void memDisclaimAmount(size_t size) + template + AMOUNT_T& memDisclaimAmount(AMOUNT_T& size) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mSize.sample(accumulator->mSize.getLastValue() - (F64)size); } + return size; } private: size_t mMemFootprint; + static MemStatHandle sMemStat; + template struct TrackMemImpl { static void claim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -447,7 +457,7 @@ private: static void disclaim(mem_trackable_t& tracker, const TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { size_t footprint = MemFootprint::measure(tracked); @@ -462,7 +472,7 @@ private: { static void claim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() + (F64)MemFootprint::measure(tracked)); @@ -471,7 +481,7 @@ private: static void disclaim(mem_trackable_t& tracker, TRACKED& tracked) { - MemStatAccumulator* accumulator = DERIVED::sMemStat.getPrimaryAccumulator(); + MemStatAccumulator* accumulator = sMemStat.getPrimaryAccumulator(); if (accumulator) { accumulator->mChildSize.sample(accumulator->mChildSize.getLastValue() - (F64)MemFootprint::measure(tracked)); @@ -480,5 +490,9 @@ private: }; }; +template +MemStatHandle MemTrackable::sMemStat(typeid(DERIVED).name()); + + } #endif // LL_LLTRACE_H diff --git a/indra/llcommon/lltraceaccumulators.h b/indra/llcommon/lltraceaccumulators.h index 825cc9e3a8..fac6347ff9 100644 --- a/indra/llcommon/lltraceaccumulators.h +++ b/indra/llcommon/lltraceaccumulators.h @@ -33,6 +33,7 @@ #include "llunit.h" #include "lltimer.h" #include "llrefcount.h" +#include "llthreadlocalstorage.h" namespace LLTrace { @@ -142,12 +143,6 @@ namespace LLTrace // NOTE: this is not thread-safe. We assume that slots are reserved in the main thread before any child threads are spawned size_t reserveSlot() { -#ifndef LL_RELEASE_FOR_DOWNLOAD - if (LLTrace::isInitialized()) - { - llerrs << "Attempting to declare trace object after program initialization. Trace objects should be statically initialized." << llendl; - } -#endif size_t next_slot = sNextStorageSlot++; if (next_slot >= mStorageSize) { diff --git a/indra/llcommon/lltracethreadrecorder.cpp b/indra/llcommon/lltracethreadrecorder.cpp index e88c5bf177..7ac0e75154 100644 --- a/indra/llcommon/lltracethreadrecorder.cpp +++ b/indra/llcommon/lltracethreadrecorder.cpp @@ -31,13 +31,14 @@ namespace LLTrace { -ThreadRecorder* gUIThreadRecorder = NULL; +static ThreadRecorder* sMasterThreadRecorder = NULL; /////////////////////////////////////////////////////////////////////// // ThreadRecorder /////////////////////////////////////////////////////////////////////// ThreadRecorder::ThreadRecorder() +: mMasterRecorder(NULL) { init(); } @@ -268,10 +269,15 @@ void ThreadRecorder::pullFromChildren() } -ThreadRecorder& getUIThreadRecorder() +void set_master_thread_recorder(ThreadRecorder* recorder) { - llassert(gUIThreadRecorder != NULL); - return *gUIThreadRecorder; + sMasterThreadRecorder = recorder; +} + + +ThreadRecorder* get_master_thread_recorder() +{ + return sMasterThreadRecorder; } LLThreadLocalPointer& get_thread_recorder_ptr() diff --git a/indra/llcommon/lltracethreadrecorder.h b/indra/llcommon/lltracethreadrecorder.h index b5ed77416c..535f855200 100644 --- a/indra/llcommon/lltracethreadrecorder.h +++ b/indra/llcommon/lltracethreadrecorder.h @@ -92,13 +92,11 @@ namespace LLTrace }; - //FIXME: let user code set up thread recorder topology - extern ThreadRecorder* gUIThreadRecorder ; - - const LLThreadLocalPointer& get_thread_recorder(); - void set_thread_recorder(class ThreadRecorder*); - ThreadRecorder& getUIThreadRecorder(); + const LLThreadLocalPointer& get_thread_recorder(); + void set_thread_recorder(ThreadRecorder*); + void set_master_thread_recorder(ThreadRecorder*); + ThreadRecorder* get_master_thread_recorder(); } #endif // LL_LLTRACETHREADRECORDER_H diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp index 50df2ebe55..395e6a6cc5 100755 --- a/indra/llimage/llimage.cpp +++ b/indra/llimage/llimage.cpp @@ -50,7 +50,6 @@ LLMutex* LLImage::sMutex = NULL; bool LLImage::sUseNewByteRange = false; S32 LLImage::sMinimalReverseByteRangePercent = 75; LLPrivateMemoryPool* LLImageBase::sPrivatePoolp = NULL ; -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); //static void LLImage::initClass(bool use_new_byte_range, S32 minimal_reverse_byte_range_percent) @@ -159,9 +158,8 @@ void LLImageBase::sanityCheck() void LLImageBase::deleteData() { FREE_MEM(sPrivatePoolp, mData) ; - memDisclaimAmount(mDataSize); + memDisclaimAmount(mDataSize) = 0; mData = NULL; - mDataSize = 0; } // virtual @@ -225,9 +223,7 @@ U8* LLImageBase::reallocateData(S32 size) FREE_MEM(sPrivatePoolp, mData) ; } mData = new_datap; - memDisclaimAmount(mDataSize); - mDataSize = size; - memClaimAmount(mDataSize); + memClaimAmount(memDisclaimAmount(mDataSize) = size); return mData; } @@ -1612,9 +1608,8 @@ static void avg4_colors2(const U8* a, const U8* b, const U8* c, const U8* d, U8* void LLImageBase::setDataAndSize(U8 *data, S32 size) { ll_assert_aligned(data, 16); - memDisclaimAmount(mDataSize); - mData = data; mDataSize = size; - memClaimAmount(mDataSize); + mData = data; + memClaimAmount(memDisclaimAmount(mDataSize) = size); } //static diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h index 504b7e4795..b2bfdba3f8 100755 --- a/indra/llimage/llimage.h +++ b/indra/llimage/llimage.h @@ -165,8 +165,6 @@ public: static void destroyPrivatePool() ; static LLPrivateMemoryPool* getPrivatePool() {return sPrivatePoolp;} - static LLTrace::MemStatHandle sMemStat; - private: U8 *mData; S32 mDataSize; diff --git a/indra/llimage/tests/llimageworker_test.cpp b/indra/llimage/tests/llimageworker_test.cpp index b6f2694742..7d7e9e036e 100755 --- a/indra/llimage/tests/llimageworker_test.cpp +++ b/indra/llimage/tests/llimageworker_test.cpp @@ -44,9 +44,6 @@ // * Do not make any assumption as to how those classes or methods work (i.e. don't copy/paste code) // * A simulator for a class can be implemented here. Please comment and document thoroughly. -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); - - LLImageBase::LLImageBase() : mData(NULL), mDataSize(0), @@ -115,17 +112,14 @@ namespace tut { // Instance to be tested LLImageDecodeThread* mThread; - // Constructor and destructor of the test wrapper imagedecodethread_test() { - LLTrace::init(); mThread = NULL; } ~imagedecodethread_test() { delete mThread; - LLTrace::cleanup(); } }; @@ -143,7 +137,6 @@ namespace tut imagerequest_test() { done = false; - LLTrace::init(); mRequest = new LLImageDecodeThread::ImageRequest(0, 0, LLQueuedThread::PRIORITY_NORMAL, 0, FALSE, @@ -154,7 +147,6 @@ namespace tut // We should delete the object *but*, because its destructor is protected, that cannot be // done from outside an LLImageDecodeThread instance... So we leak memory here... It's fine... //delete mRequest; - LLTrace::cleanup(); } }; diff --git a/indra/llkdu/tests/llimagej2ckdu_test.cpp b/indra/llkdu/tests/llimagej2ckdu_test.cpp index 14fbf344ab..0e73f33e04 100755 --- a/indra/llkdu/tests/llimagej2ckdu_test.cpp +++ b/indra/llkdu/tests/llimagej2ckdu_test.cpp @@ -44,8 +44,6 @@ // End Stubbing // ------------------------------------------------------------------------------------------- // Stub the LL Image Classes -LLTrace::MemStatHandle LLImageBase::sMemStat("LLImage"); - LLImageRaw::LLImageRaw() { } LLImageRaw::~LLImageRaw() { } U8* LLImageRaw::allocateData(S32 ) { return NULL; } diff --git a/indra/llui/llstatbar.cpp b/indra/llui/llstatbar.cpp index d3cc2733e6..fd88565de4 100755 --- a/indra/llui/llstatbar.cpp +++ b/indra/llui/llstatbar.cpp @@ -345,9 +345,9 @@ void LLStatBar::draw() else if (mSampleFloatp) { //rate isn't defined for sample stats, so use mean - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } else @@ -366,9 +366,9 @@ void LLStatBar::draw() } else if (mSampleFloatp) { - begin = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale); - end = ((recording.getMean(*mEventFloatp) - mMinBar) * value_scale) + 1; - num_samples = recording.getSampleCount(*mEventFloatp); + begin = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale); + end = ((recording.getMean(*mSampleFloatp) - mMinBar) * value_scale) + 1; + num_samples = recording.getSampleCount(*mSampleFloatp); } } diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index 7243931dbb..9845941778 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -48,8 +48,6 @@ const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds const S32 CURSOR_THICKNESS = 2; const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click. -LLTrace::MemStatHandle LLTextSegment::sMemStat("LLTextSegment"); - LLTextBase::line_info::line_info(S32 index_start, S32 index_end, LLRect rect, S32 line_num) : mDocIndexStart(index_start), mDocIndexEnd(index_end), diff --git a/indra/llui/lltextbase.h b/indra/llui/lltextbase.h index 74dc7f9693..3e93b7de65 100755 --- a/indra/llui/lltextbase.h +++ b/indra/llui/lltextbase.h @@ -100,8 +100,6 @@ public: S32 getEnd() const { return mEnd; } void setEnd( S32 end ) { mEnd = end; } - static LLTrace::MemStatHandle sMemStat; - protected: S32 mStart; S32 mEnd; diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp index daeb4d7939..b2805a32e8 100755 --- a/indra/llui/llview.cpp +++ b/indra/llui/llview.cpp @@ -69,7 +69,6 @@ LLView* LLView::sPreviewClickedElement = NULL; BOOL LLView::sDrawPreviewHighlights = FALSE; S32 LLView::sLastLeftXML = S32_MIN; S32 LLView::sLastBottomXML = S32_MIN; -LLTrace::MemStatHandle LLView::sMemStat("LLView"); std::vector LLViewDrawContext::sDrawContextStack; LLView::DrilldownFunc LLView::sDrilldown = diff --git a/indra/llui/llview.h b/indra/llui/llview.h index 0568fa889a..62bfb54566 100755 --- a/indra/llui/llview.h +++ b/indra/llui/llview.h @@ -675,7 +675,6 @@ public: static S32 sLastLeftXML; static S32 sLastBottomXML; static BOOL sForceReshape; - static LLTrace::MemStatHandle sMemStat; }; namespace LLInitParam diff --git a/indra/llui/llviewmodel.cpp b/indra/llui/llviewmodel.cpp index 901260bec8..dff0dcb2fd 100755 --- a/indra/llui/llviewmodel.cpp +++ b/indra/llui/llviewmodel.cpp @@ -35,8 +35,6 @@ // external library headers // other Linden headers -LLTrace::MemStatHandle LLViewModel::sMemStat("LLViewModel"); - /// LLViewModel::LLViewModel() : mDirty(false) diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index 2c016d2560..a2ca20c739 100755 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -83,8 +83,6 @@ public: // void setDirty() { mDirty = true; } - static LLTrace::MemStatHandle sMemStat; - protected: LLSD mValue; bool mDirty; diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 348eb43b5e..e77f793a43 100755 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -1297,7 +1297,7 @@ bool LLAppViewer::mainLoop() LLTrace::get_frame_recording().nextPeriod(); LLTrace::TimeBlock::logStats(); - LLTrace::getUIThreadRecorder().pullFromChildren(); + LLTrace::get_master_thread_recorder()->pullFromChildren(); //clear call stack records llclearcallstacks; diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 628f7f7bfb..3dddf4b554 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -59,7 +59,6 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f; static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); extern bool gShiftFrame; -LLTrace::MemStatHandle LLDrawable::sMemStat("LLDrawable"); //////////////////////// diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index b7c5aeb5a8..4558597d89 100755 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -293,7 +293,6 @@ public: F32 mDistanceWRTCamera; static F32 sCurPixelAngle; //current pixels per radian - static LLTrace::MemStatHandle sMemStat; private: typedef std::vector face_list_t; diff --git a/indra/newview/llfasttimerview.cpp b/indra/newview/llfasttimerview.cpp index 7a5e1dcad0..d922659435 100755 --- a/indra/newview/llfasttimerview.cpp +++ b/indra/newview/llfasttimerview.cpp @@ -430,18 +430,18 @@ void LLFastTimerView::draw() } void LLFastTimerView::onOpen(const LLSD& key) - { +{ setPauseState(false); mRecording.reset(); mRecording.appendPeriodicRecording(LLTrace::get_frame_recording()); for(std::deque::iterator it = mTimerBarRows.begin(), end_it = mTimerBarRows.end(); it != end_it; - ++it) - { + ++it) + { delete []it->mBars; it->mBars = NULL; - } - } + } +} void saveChart(const std::string& label, const char* suffix, LLImageRaw* scratch) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 4e514ddfd1..c633e3acdd 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -114,8 +114,6 @@ BOOL LLViewerObject::sMapDebug = TRUE; LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit S32 LLViewerObject::sAxisArrowLength(50); -LLTrace::MemStatHandle LLViewerObject::sMemStat("LLViewerObject"); - BOOL LLViewerObject::sPulseEnabled(FALSE); BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5556a4c7d3..63da7152b3 100755 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -661,7 +661,6 @@ public: LLPointer mIcon; static BOOL sUseSharedDrawables; - static LLTrace::MemStatHandle sMemStat; protected: // delete an item in the inventory, but don't tell the diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index 60d78890b5..d87eb5d3db 100755 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -34,8 +34,6 @@ #include "llviewerregion.h" #include "pipeline.h" -LLTrace::MemStatHandle LLVOCachePartition::sMemStat("LLVOCachePartition"); - BOOL check_read(LLAPRFile* apr_file, void* src, S32 n_bytes) { return apr_file->read(src, n_bytes) == n_bytes ; diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index bf75cafac5..c43c42908f 100755 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -35,7 +35,6 @@ //--------------------------------------------------------------------------- // Cache entries -class LLVOCacheEntry; class LLCamera; class LLVOCacheEntry : public LLViewerOctreeEntryData @@ -158,8 +157,6 @@ public: /*virtual*/ S32 cull(LLCamera &camera); void addOccluders(LLviewerOctreeGroup* gp); - static LLTrace::MemStatHandle sMemStat; - private: void processOccluders(LLCamera* camera, const LLVector3* region_agent); diff --git a/indra/newview/tests/llviewerassetstats_test.cpp b/indra/newview/tests/llviewerassetstats_test.cpp index b9712e5e9c..bd42b59df2 100755 --- a/indra/newview/tests/llviewerassetstats_test.cpp +++ b/indra/newview/tests/llviewerassetstats_test.cpp @@ -35,6 +35,7 @@ #include "lluuid.h" #include "llsdutil.h" #include "llregionhandle.h" +#include "lltracethreadrecorder.h" #include "../llvoavatar.h" namespace LLStatViewer @@ -231,14 +232,15 @@ namespace tut { tst_viewerassetstats_index() { - LLTrace::init(); + LLTrace::set_master_thread_recorder(&mThreadRecorder); } ~tst_viewerassetstats_index() { - LLTrace::cleanup(); + LLTrace::set_master_thread_recorder(NULL); } + LLTrace::ThreadRecorder mThreadRecorder; }; typedef test_group tst_viewerassetstats_index_t; typedef tst_viewerassetstats_index_t::object tst_viewerassetstats_index_object_t; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 28de88201c..10f71a2843 100755 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -41,6 +41,7 @@ #include "stringize.h" #include "namedtempfile.h" #include "lltrace.h" +#include "lltracethreadrecorder.h" #include "apr_pools.h" #include "apr_getopt.h" @@ -483,6 +484,8 @@ void wouldHaveCrashed(const std::string& message) tut::fail("llerrs message: " + message); } +static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL; + int main(int argc, char **argv) { // The following line must be executed to initialize Google Mock @@ -515,7 +518,11 @@ int main(int argc, char **argv) ll_init_apr(); - LLTrace::init(); + if (!sMasterThreadRecorder) + { + sMasterThreadRecorder = new LLTrace::ThreadRecorder(); + LLTrace::set_master_thread_recorder(sMasterThreadRecorder); + } apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { -- cgit v1.3