From 5c7a1689f9e4a42a91351523dd471f08a14725a1 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Fri, 3 Jul 2020 14:13:25 -0400
Subject: [PATCH] Fix disabled debug macros in release build

---
 indra/llappearance/llpolyskeletaldistortion.cpp |  2 +-
 indra/llcharacter/lljoint.cpp                   | 10 +++++-----
 indra/llcommon/llcallstack.h                    |  2 +-
 indra/llcommon/llerror.h                        | 13 +++++++------
 indra/llrender/llgl.h                           |  2 +-
 indra/newview/llvoavatar.cpp                    | 14 +++++++-------
 indra/newview/llvovolume.cpp                    |  2 +-
 7 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/indra/llappearance/llpolyskeletaldistortion.cpp b/indra/llappearance/llpolyskeletaldistortion.cpp
index cf3d41cf6cf..d61d5c6491f 100644
--- a/indra/llappearance/llpolyskeletaldistortion.cpp
+++ b/indra/llappearance/llpolyskeletaldistortion.cpp
@@ -212,7 +212,7 @@ void LLPolySkeletalDistortion::apply( ESex avatar_sex )
         // needed? 
         // joint->storeScaleForReset( newScale );				
 
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
         // BENTO for detailed stack tracing of params.
         std::stringstream ostr;
         ostr << "LLPolySkeletalDistortion::apply, id " << getID() << " " << getName() << " effective wt " << effective_weight << " last wt " << mLastWeight << " scaleDelta " << scaleDelta << " offset " << offset;
diff --git a/indra/llcharacter/lljoint.cpp b/indra/llcharacter/lljoint.cpp
index 2eb52e3768a..51bc7077ab0 100644
--- a/indra/llcharacter/lljoint.cpp
+++ b/indra/llcharacter/lljoint.cpp
@@ -328,7 +328,7 @@ const LLVector3& LLJoint::getPosition()
 
 bool do_debug_joint(const std::string& name)
 {
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     if (std::find(LLJoint::s_debugJointNames.begin(), LLJoint::s_debugJointNames.end(),name) != LLJoint::s_debugJointNames.end())
     {
         return true;
@@ -350,7 +350,7 @@ void LLJoint::setPosition( const LLVector3& requested_pos, bool apply_attachment
     LLUUID mesh_id;
     if (apply_attachment_overrides && m_attachmentPosOverrides.findActiveOverride(mesh_id,active_override))
     {  
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
         if (pos != active_override && do_debug_joint(getName()))
         {
             LLScopedContextString str("setPosition");
@@ -360,7 +360,7 @@ void LLJoint::setPosition( const LLVector3& requested_pos, bool apply_attachment
 #endif
         pos = active_override;
     }
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
 	if ((pos != getPosition()) && do_debug_joint(getName()))
 	{
         LLScopedContextString str("setPosition");
@@ -897,7 +897,7 @@ void LLJoint::setScale( const LLVector3& requested_scale, bool apply_attachment_
     LLVector3 active_override;
     if (apply_attachment_overrides && m_attachmentScaleOverrides.findActiveOverride(mesh_id,active_override))
     {  
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
         if (scale != active_override && do_debug_joint(getName()))
         {
             LLScopedContextString str("setScale");
@@ -907,7 +907,7 @@ void LLJoint::setScale( const LLVector3& requested_scale, bool apply_attachment_
 #endif
         scale = active_override;
     }
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
 	if ((mXform.getScale() != scale) && do_debug_joint(getName()))
 	{	
         LLScopedContextString str("setScale");
diff --git a/indra/llcommon/llcallstack.h b/indra/llcommon/llcallstack.h
index edc0b6c6839..63a3ea10a57 100644
--- a/indra/llcommon/llcallstack.h
+++ b/indra/llcommon/llcallstack.h
@@ -79,7 +79,7 @@ struct LLContextStatus
 
 LL_COMMON_API std::ostream& operator<<(std::ostream& s, const LLContextStatus& context_status);
 
-#ifdef ENABLE_DEBUG
+#if ENABLE_DEBUG_MACRO
 #define dumpStack(tag) \
     static const bool enable_log = debugLoggingEnabled(tag); \
     if (enable_log) \
diff --git a/indra/llcommon/llerror.h b/indra/llcommon/llerror.h
index 1600064373d..d85f1a41558 100644
--- a/indra/llcommon/llerror.h
+++ b/indra/llcommon/llerror.h
@@ -42,10 +42,13 @@ const int LL_ERR_NOERR = 0;
 // #define RELEASE_SHOW_DEBUG // Define this if you want your release builds to show lldebug output.
 #define RELEASE_SHOW_INFO // Define this if you want your release builds to show llinfo output
 #define RELEASE_SHOW_WARN // Define this if you want your release builds to show llwarn output.
-#define ENABLE_DEBUG 1
+#if LL_TEST
+#define ENABLE_DEBUG_MACRO 1
+#else
+#define ENABLE_DEBUG_MACRO 0
+#endif
 
 #ifdef _DEBUG
-#define ENABLE_DEBUG 1
 #define SHOW_DEBUG
 #define SHOW_WARN
 #define SHOW_INFO
@@ -53,12 +56,10 @@ const int LL_ERR_NOERR = 0;
 #else // _DEBUG
 
 #ifdef LL_RELEASE_WITH_DEBUG_INFO
-#define ENABLE_DEBUG 1
 #define SHOW_ASSERT
 #endif // LL_RELEASE_WITH_DEBUG_INFO
 
 #ifdef RELEASE_SHOW_DEBUG
-#define ENABLE_DEBUG 1
 #define SHOW_DEBUG
 #endif
 
@@ -293,7 +294,7 @@ namespace LLError
 }
 
 //this is cheaper than llcallstacks if no need to output other variables to call stacks. 
-#if ENABLE_DEBUG
+#if ENABLE_DEBUG_MACRO
 #define LL_PUSH_CALLSTACKS() LLError::LLCallStacks::push(__FUNCTION__, __LINE__)
 
 #define llcallstacks                                                                      \
@@ -365,7 +366,7 @@ typedef LLError::NoClassInfo _LL_CLASS_TO_LOG;
 			std::ostringstream* _out = LLError::Log::out(); \
 			(*_out)
 
-#ifdef ENABLE_DEBUG
+#if ENABLE_DEBUG_MACRO
 
 #define lllog_debug(level, once, ...)                                         \
 	do {                                                                \
diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h
index f8cedd9f9a3..1ee2389be5f 100644
--- a/indra/llrender/llgl.h
+++ b/indra/llrender/llgl.h
@@ -193,7 +193,7 @@ void assert_glerror();
 
 void clear_glerror();
 
-#if ENABLE_DEBUG
+#ifdef SHOW_DEBUG
 # define stop_glerror() assert_glerror()
 # define llglassertok() assert_glerror()
 #else
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 3b24c6091e6..97a8679fade 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -2479,7 +2479,7 @@ void LLVOAvatar::idleUpdate(LLAgent &agent, const F64 &time)
 		mNeedsExtentUpdate = ((LLDrawable::getCurrentFrame()+mID.mData[0])%upd_freq==0);
 	}
     
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LLScopedContextString str("avatar_idle_update " + getFullname());
 #endif
     
@@ -4375,7 +4375,7 @@ BOOL LLVOAvatar::updateCharacter(LLAgent &agent)
 	}
 
 	BOOL visible = isVisible();
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     bool is_control_avatar = isControlAvatar(); // capture state to simplify tracing
 	bool is_attachment = false;
 	if (is_control_avatar)
@@ -6109,7 +6109,7 @@ bool LLVOAvatar::jointIsRiggedTo(const LLJoint *joint) const
 
 void LLVOAvatar::clearAttachmentOverrides()
 {
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LLScopedContextString str("clearAttachmentOverrides " + getFullname());
 #endif
 
@@ -6143,7 +6143,7 @@ void LLVOAvatar::clearAttachmentOverrides()
 //-----------------------------------------------------------------------------
 void LLVOAvatar::rebuildAttachmentOverrides()
 {
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LLScopedContextString str("rebuildAttachmentOverrides " + getFullname());
 
     LL_DEBUGS("AnimatedObjects") << "rebuilding" << LL_ENDL;
@@ -6195,7 +6195,7 @@ void LLVOAvatar::rebuildAttachmentOverrides()
 // -----------------------------------------------------------------------------
 void LLVOAvatar::updateAttachmentOverrides()
 {
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LLScopedContextString str("updateAttachmentOverrides " + getFullname());
 
     LL_DEBUGS("AnimatedObjects") << "updating" << LL_ENDL;
@@ -6319,7 +6319,7 @@ void LLVOAvatar::addAttachmentOverridesForObject(LLViewerObject *vo, std::set<LL
         return;
 	}
 
-#ifdef ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LLScopedContextString str("addAttachmentOverridesForObject " + getFullname());
     
     LL_DEBUGS("AnimatedObjects") << "adding" << LL_ENDL;
@@ -10185,7 +10185,7 @@ void LLVOAvatar::updateRiggingInfo()
     }
 
     //LL_INFOS() << "done update rig count is " << countRigInfoTab(mJointRiggingInfoTab) << LL_ENDL;
-#if ENABLE_DEBUG
+#ifdef SHOW_DEBUG
     LL_DEBUGS("RigSpammish") << getFullname() << " after update rig tab:" << LL_ENDL;
 
     S32 joint_count, box_count;
diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp
index 5af9cdacf42..ec778d82bf8 100644
--- a/indra/newview/llvovolume.cpp
+++ b/indra/newview/llvovolume.cpp
@@ -5524,7 +5524,7 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group)
 
             vobj->updateControlAvatar();
             
-#if ENABLE_DEBUG
+#ifdef SHOW_DEBUG
 			std::string vobj_name = llformat("Vol%p", vobj);
 
 			F32 est_tris = vobj->getEstTrianglesMax();
-- 
GitLab