From 5345d1e115fdf3fca7ea3e8330f1a23ad19257c8 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 26 Jan 2016 08:23:40 -0500 Subject: SL-315 WIP - added a call stack extractor for windows to help with tracing joint issues (of course, could be used for other things as well). --- indra/llcommon/llcallstack.cpp | 93 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 indra/llcommon/llcallstack.cpp (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp new file mode 100644 index 0000000000..87eb37de16 --- /dev/null +++ b/indra/llcommon/llcallstack.cpp @@ -0,0 +1,93 @@ +/** + * @file llcallstack.cpp + * @brief run-time extraction of the current callstack + * + * $LicenseInfo:firstyear=2016&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2016, 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 "llcommon.h" +#include "llcallstack.h" +#include "StackWalker.h" + +#if LL_WINDOWS +class LLCallStackImpl: public StackWalker +{ +public: + LLCallStackImpl(): + StackWalker(false,0) // non-verbose, options = 0 + { + } + ~LLCallStackImpl() + { + } + void getStack(std::vector& stack) + { + m_stack.clear(); + ShowCallstack(); + // Skip the first 2 lines because they're just bookkeeping for LLCallStack. + for (S32 i=3; i m_stack; +}; +#else +// Stub - not implemented currently on other platforms. +class LLCallStackImpl +{ +public: + LLCallStackImpl() {} + ~LLCallStackImpl() {} + void getStack(std::vector& stack) + { + stack.clear(); + } +}; +#endif + +LLCallStackImpl *LLCallStack::s_impl = NULL; + +LLCallStack::LLCallStack() +{ + if (!s_impl) + { + s_impl = new LLCallStackImpl; + } + LLTimer t; + s_impl->getStack(m_strings); +} + +std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) +{ + std::vector::const_iterator it; + for (it=call_stack.m_strings.begin(); it!=call_stack.m_strings.end(); ++it) + { + s << *it; + } + return s; +} -- cgit v1.2.3 From e91a192301db37f99a4f5a817f3b4c47b448417a Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Tue, 26 Jan 2016 11:11:52 -0500 Subject: SL-315 WIP - added callstack info to joint debugging. Made joint debugging run-time configurable via debug setting DebugAvatarJoints --- indra/llcommon/llcallstack.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 87eb37de16..02cf4d0173 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -39,12 +39,14 @@ public: ~LLCallStackImpl() { } - void getStack(std::vector& stack) + void getStack(std::vector& stack, S32 skip_count=0) { m_stack.clear(); ShowCallstack(); - // Skip the first 2 lines because they're just bookkeeping for LLCallStack. - for (S32 i=3; i& stack) + void getStack(std::vector& stack, S32 skip_count=0) { stack.clear(); } @@ -72,14 +74,15 @@ public: LLCallStackImpl *LLCallStack::s_impl = NULL; -LLCallStack::LLCallStack() +LLCallStack::LLCallStack(S32 skip_count): + m_skipCount(skip_count) { if (!s_impl) { s_impl = new LLCallStackImpl; } LLTimer t; - s_impl->getStack(m_strings); + s_impl->getStack(m_strings, m_skipCount); } std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) -- cgit v1.2.3 From c92079db31f60196c2c70d6733aeaaaa40f1f485 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 28 Jan 2016 10:40:38 -0500 Subject: SL-315 - verbose option for CallStack objects, doc headers in StackWalker.{h,cpp} --- indra/llcommon/llcallstack.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 02cf4d0173..e4b3cfeab5 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -39,10 +39,10 @@ public: ~LLCallStackImpl() { } - void getStack(std::vector& stack, S32 skip_count=0) + void getStack(std::vector& stack, S32 skip_count=0, bool verbose=false) { m_stack.clear(); - ShowCallstack(); + ShowCallstack(verbose); // Skip the first few lines because they're just bookkeeping for LLCallStack, // plus any additional lines requested to skip. S32 first_line = skip_count + 3; @@ -74,15 +74,16 @@ public: LLCallStackImpl *LLCallStack::s_impl = NULL; -LLCallStack::LLCallStack(S32 skip_count): - m_skipCount(skip_count) +LLCallStack::LLCallStack(S32 skip_count, bool verbose): + m_skipCount(skip_count), + m_verbose(verbose) { if (!s_impl) { s_impl = new LLCallStackImpl; } LLTimer t; - s_impl->getStack(m_strings, m_skipCount); + s_impl->getStack(m_strings, m_skipCount, m_verbose); } std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) -- cgit v1.2.3 From 8ab541532083c344a41e18c396b1bcb7fba19bb4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 28 Jan 2016 11:06:01 -0500 Subject: SL-315 - fix for LLCallStack stubs for mac/linux. --- indra/llcommon/llcallstack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index e4b3cfeab5..cb77591c7c 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -65,7 +65,7 @@ class LLCallStackImpl public: LLCallStackImpl() {} ~LLCallStackImpl() {} - void getStack(std::vector& stack, S32 skip_count=0) + void getStack(std::vector& stack, S32 skip_count=0, bool verbose=false) { stack.clear(); } -- cgit v1.2.3 From 674c68cc92ab8c3551fde4243562dfa401e868a1 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 29 Jan 2016 09:02:27 -0500 Subject: SL-315 test old stack trace --- indra/llcommon/llcallstack.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index cb77591c7c..7474d4708b 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -26,6 +26,7 @@ #include "llcommon.h" #include "llcallstack.h" +#include "llstacktrace.h" #include "StackWalker.h" #if LL_WINDOWS @@ -93,5 +94,13 @@ std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) { s << *it; } + std::vector og_lines; + ll_get_stack_trace(og_lines); + s << "\nOLD SCHOOL STACK\n"; + for (it=og_lines.begin(); it!=og_lines.end(); ++it) + { + s << *it; + } + return s; } -- cgit v1.2.3 From 19de8f3993da24d906a886b58125c4954ce4c79e Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 1 Feb 2016 08:27:58 -0500 Subject: SL-315 - untest old stack trace --- indra/llcommon/llcallstack.cpp | 9 --------- 1 file changed, 9 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 7474d4708b..cb77591c7c 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -26,7 +26,6 @@ #include "llcommon.h" #include "llcallstack.h" -#include "llstacktrace.h" #include "StackWalker.h" #if LL_WINDOWS @@ -94,13 +93,5 @@ std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) { s << *it; } - std::vector og_lines; - ll_get_stack_trace(og_lines); - s << "\nOLD SCHOOL STACK\n"; - for (it=og_lines.begin(); it!=og_lines.end(); ++it) - { - s << *it; - } - return s; } -- cgit v1.2.3 From ef02c9ea694a1f0ddc830a66f23555c6316afdc7 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 3 Feb 2016 08:59:25 -0500 Subject: SL-315 - context strings, comments, debugging. joint_test temporarily disabled. --- indra/llcommon/llcallstack.cpp | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index cb77591c7c..2409f7a876 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -24,6 +24,8 @@ * $/LicenseInfo$ */ +#include "linden_common.h" + #include "llcommon.h" #include "llcallstack.h" #include "StackWalker.h" @@ -95,3 +97,56 @@ std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) } return s; } + +#include "llthreadlocalstorage.h" + +LLContextStrings::LLContextStrings() +{ +} + +// static +LLContextStrings* LLContextStrings::getThreadLocalInstance() +{ + LLContextStrings *cons = LLThreadLocalSingletonPointer::getInstance(); + if (!cons) + { + LLThreadLocalSingletonPointer::setInstance(new LLContextStrings); + } + return LLThreadLocalSingletonPointer::getInstance(); +} + +// static +void LLContextStrings::addContextString(const std::string& str) +{ + LLContextStrings *cons = getThreadLocalInstance(); + //LL_INFOS() << "CTX " << (S32)cons << " ADD " << str << " CNT " << cons->m_contextStrings[str] << LL_ENDL; + cons->m_contextStrings[str]++; +} + +// static +void LLContextStrings::removeContextString(const std::string& str) +{ + LLContextStrings *cons = getThreadLocalInstance(); + cons->m_contextStrings[str]--; + //LL_INFOS() << "CTX " << (S32)cons << " REMOVE " << str << " CNT " << cons->m_contextStrings[str] << LL_ENDL; + if (cons->m_contextStrings[str] == 0) + { + cons->m_contextStrings.erase(str); + } +} + +// static +void LLContextStrings::output(std::ostream& os) +{ + const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; + for (std::map::const_iterator it = strings.begin(); it!=strings.end(); ++it) + { + os << it->first << "[" << it->second << "]" << "\n"; + } +} + +std::ostream& operator<<(std::ostream& s, const LLContextStatus& context_status) +{ + LLThreadLocalSingletonPointer::getInstance()->output(s); + return s; +} -- cgit v1.2.3 From 88cb6814f0883cdce15ca1942409da708ab07af5 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Mon, 7 Mar 2016 11:24:48 -0500 Subject: SL-315 WIP - more call stack tracing, initial hooks for avatar reset skeleton option. --- indra/llcommon/llcallstack.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 2409f7a876..9978645ff4 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -29,6 +29,7 @@ #include "llcommon.h" #include "llcallstack.h" #include "StackWalker.h" +#include "llthreadlocalstorage.h" #if LL_WINDOWS class LLCallStackImpl: public StackWalker @@ -88,6 +89,19 @@ LLCallStack::LLCallStack(S32 skip_count, bool verbose): s_impl->getStack(m_strings, m_skipCount, m_verbose); } +bool LLCallStack::contains(const std::string& str) +{ + for (std::vector::const_iterator it = m_strings.begin(); + it != m_strings.end(); ++it) + { + if (it->find(str) != std::string::npos) + { + return true; + } + } + return false; +} + std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) { std::vector::const_iterator it; @@ -98,8 +112,6 @@ std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) return s; } -#include "llthreadlocalstorage.h" - LLContextStrings::LLContextStrings() { } @@ -135,18 +147,40 @@ void LLContextStrings::removeContextString(const std::string& str) } } +// static +bool LLContextStrings::contains(const std::string& str) +{ + const std::map& strings = + LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; + for (std::map::const_iterator it = strings.begin(); it!=strings.end(); ++it) + { + if (it->first.find(str) != std::string::npos) + { + return true; + } + } + return false; +} + // static void LLContextStrings::output(std::ostream& os) { - const std::map& strings = LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; + const std::map& strings = + LLThreadLocalSingletonPointer::getInstance()->m_contextStrings; for (std::map::const_iterator it = strings.begin(); it!=strings.end(); ++it) { os << it->first << "[" << it->second << "]" << "\n"; } } +// static std::ostream& operator<<(std::ostream& s, const LLContextStatus& context_status) { LLThreadLocalSingletonPointer::getInstance()->output(s); return s; } + +bool LLContextStatus::contains(const std::string& str) +{ + return LLThreadLocalSingletonPointer::getInstance()->contains(str); +} -- cgit v1.2.3 From 78e9fb2614ce6bc72aad090baca63be7c673bd69 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 21 Apr 2016 10:55:08 -0400 Subject: SL-315 - disable call stack dumping in release, where we don't have the info anyway. --- indra/llcommon/llcallstack.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra/llcommon/llcallstack.cpp') diff --git a/indra/llcommon/llcallstack.cpp b/indra/llcommon/llcallstack.cpp index 9978645ff4..8db291eed1 100644 --- a/indra/llcommon/llcallstack.cpp +++ b/indra/llcommon/llcallstack.cpp @@ -104,11 +104,15 @@ bool LLCallStack::contains(const std::string& str) std::ostream& operator<<(std::ostream& s, const LLCallStack& call_stack) { +#ifndef LL_RELEASE_FOR_DOWNLOAD std::vector::const_iterator it; for (it=call_stack.m_strings.begin(); it!=call_stack.m_strings.end(); ++it) { s << *it; } +#else + s << "UNAVAILABLE IN RELEASE"; +#endif return s; } -- cgit v1.2.3