DEBUG

DEBUG

#Overview

name: DEBUG

This variable is created as a Console Variable (cvar).

It is referenced in 27 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of DEBUG is to serve as a preprocessor macro for conditional compilation of debug-related code in various parts of the Unreal Engine 5 codebase. It is typically used to include additional logging, error checking, or diagnostic features that are only needed during development and debugging phases.

This variable is utilized across multiple Unreal Engine subsystems, plugins, and modules, including:

  1. Animation system (RigLogic plugin)
  2. Texture formatting (TextureFormatOodle plugin)
  3. Online framework (Party module)
  4. Analytics (Adjust plugin)
  5. Shader compilation (ShaderFormatOpenGL)
  6. Datasmith exporter (for ARCHICAD)
  7. Core engine functionality

The value of this variable is typically set by the build configuration. It is usually defined in debug builds and undefined in release builds.

DEBUG often interacts with other debugging macros and logging functions, such as UE_LOG, to control the verbosity of debug output.

Developers should be aware that:

  1. Code within #ifdef DEBUG blocks will only be compiled in debug builds.
  2. Overuse of DEBUG checks can impact performance in debug builds.
  3. Critical error checking should not rely solely on DEBUG, as it won’t be present in release builds.

Best practices when using this variable include:

  1. Use it for non-critical debugging information that isn’t needed in release builds.
  2. Combine it with more specific debug flags for granular control over debug output.
  3. Ensure that removal of DEBUG code doesn’t affect the core functionality of the program.
  4. Use logging categories and verbosity levels for more flexible debug output control.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Animation/RigLogic/Source/RigLogicModule/Private/DNAToSkelMeshMap.cpp:129

Scope (from outer to inner):

file
function     void FDNAToSkelMeshMap::InitVertexMap

Source code excerpt:

			if (!bFound)
			{
#ifdef DEBUG
				UE_LOG(LogDNAToSkelMeshMap, Warning, TEXT("Not sorted fbx vertex found %d"), FbxVertexIndex);
#endif
				ImportVtxToDNAMeshIndex[LODIndex][LODMeshVtxIndex] = INDEX_NONE;
				ImportVtxToDNAVtxIndex[LODIndex][LODMeshVtxIndex] = INDEX_NONE;
			}
		}

#Loc: <Workspace>/Engine/Plugins/Animation/RigLogic/Source/RigLogicModule/Private/DNAToSkelMeshMap.cpp:257

Scope (from outer to inner):

file
function     void FDNAToSkelMeshMap::MapMorphTargets

Source code excerpt:

			else
			{
#ifdef DEBUG
				UE_LOG(LogDNAToSkelMeshMap, Error, TEXT("Could not find morph target %s (probably below threshold) Channel %d, Target %d"), *MorphTargetStr, ChannelIndex, TargetIndex);
#endif
			}
		}
	}

#Loc: <Workspace>/Engine/Plugins/Animation/RigLogic/Source/RigLogicModule/Private/SkelMeshDNAUtils.cpp:273

Scope (from outer to inner):

file
function     void USkelMeshDNAUtils::UpdateMorphTargets
lambda-function

Source code excerpt:

					MorphLODModel.Reset();
				}
#ifdef DEBUG
				UE_LOG(LogDNAUtils, Warning, TEXT(" 0 deltas found for mesh %d and blend shape target %d"), MeshTarget.MeshIndex, MeshTarget.TargetIndex);
#endif 
			}
		});
}

#Loc: <Workspace>/Engine/Plugins/Developer/TextureFormatOodle/Source/Private/Jobify/example_jobify_win32tp.inl:44

Scope: file

Source code excerpt:


//#define DEBUG printf
#define DEBUG(...)

class JobContext
{
	struct DepLink
	{
		JobContext * job;

#Loc: <Workspace>/Engine/Plugins/Developer/TextureFormatOodle/Source/Private/Jobify/example_jobify_win32tp.inl:95

Scope (from outer to inner):

file
class        class JobContext
function     void notify_dep_satisfied

Source code excerpt:

		if (deps_before == num_deps)
		{
			DEBUG("submit 0x%p\n", work_handle);
			SubmitThreadpoolWork(work_handle);
		}
	}

	void notify_completion()
	{

#Loc: <Workspace>/Engine/Plugins/Developer/TextureFormatOodle/Source/Private/Jobify/example_jobify_win32tp.inl:184

Scope (from outer to inner):

file
class        class JobContext
function     JobContext

Source code excerpt:


		work_handle = CreateThreadpoolWork(work_callback, this, tpenviron);
		DEBUG("create 0x%p\n", work_handle);

		// If the work item was created successfully, set up the dependencies
		if (work_handle)
		{
			// Initially, the only dependency we're going to release on completion
			// of setup is the explicit setup dependency.

#Loc: <Workspace>/Engine/Plugins/Developer/TextureFormatOodle/Source/Private/Jobify/example_jobify_win32tp.inl:207

Scope (from outer to inner):

file
class        class JobContext
function     ~JobContext

Source code excerpt:

	~JobContext()
	{
		DEBUG("close  0x%p\n", work_handle);
		if (work_handle)
			CloseThreadpoolWork(work_handle);
	}

	bool valid() const
	{

#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Party/Private/SocialDebugTools.cpp:50

Scope (from outer to inner):

file
function     bool USocialDebugTools::Exec

Source code excerpt:

bool USocialDebugTools::Exec(class UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Out)
{
	if (FParse::Command(&Cmd, TEXT("DEBUG")))
	{
		FString Instance;
		FParse::Value(Cmd, TEXT("CONTEXT="), Instance);
		if (FParse::Command(&Cmd, TEXT("HELP")))
		{
			PrintExecUsage();

#Loc: <Workspace>/Engine/Plugins/Runtime/Analytics/Adjust/Source/AdjustEditor/Private/AdjustEditor.cpp:118

Scope (from outer to inner):

file
function     void UAdjustSettings::WriteConfigSection

Source code excerpt:

	{
		case EAndroidAdjustLogging::verbose: LogLevelOut = TEXT("VERBOSE"); break;
		case EAndroidAdjustLogging::debug: LogLevelOut = TEXT("DEBUG"); break;
		case EAndroidAdjustLogging::info: LogLevelOut = TEXT("INFO"); break;
		case EAndroidAdjustLogging::warn: LogLevelOut = TEXT("WARN"); break;
		case EAndroidAdjustLogging::error: LogLevelOut = TEXT("ERROR"); break;
		case EAndroidAdjustLogging::assert: LogLevelOut = TEXT("ASSERT"); break;
		case EAndroidAdjustLogging::supress: LogLevelOut = TEXT("SUPRESS"); break;
	}

#Loc: <Workspace>/Engine/Source/Developer/ShaderFormatOpenGL/Private/GlslBackend.cpp:4106

Scope (from outer to inner):

file
function     static void ConfigureInOutVariableLayout

Source code excerpt:

		else
		{
#ifdef DEBUG
	#define _mesh_glsl_report _mesa_glsl_warning
#else
	#define _mesh_glsl_report _mesa_glsl_error
#endif
			_mesh_glsl_report(ParseState, "Vertex shader input semantic must be ATTRIBUTE and not \'%s\' in order to determine location/semantic index", Semantic);
#undef _mesh_glsl_report

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/AddOn.cpp:46

Scope (from outer to inner):

file
function     API_AddonType __ACENV_CALL CheckEnvironment

Source code excerpt:

	versStr += GetAddonVersionsStr();
	RSGetIndString(&envir->addOnInfo.name, IdDescription, 1, ACAPI_GetOwnResModule());
#ifdef DEBUG
	envir->addOnInfo.name += " d";
#endif
	RSGetIndString(&envir->addOnInfo.description, IdDescription, 2, ACAPI_GetOwnResModule());
	envir->addOnInfo.description += versStr;

	UE_AC_TraceF("<- UE_AC CheckEnvironment\n");

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Element2StaticMesh.cpp:268

Scope (from outer to inner):

file
function     void FElement2StaticMesh::AddVertex

Source code excerpt:

			CurrentTriangle.UV2 = ObjectUV;
			CurrentTriangle.Normals[2] = CurrentNormal;
#if defined(DEBUG)
			if (CurrentTriangle.V0 == CurrentTriangle.V1 || CurrentTriangle.V0 == CurrentTriangle.V2 ||
				CurrentTriangle.V1 == CurrentTriangle.V2)
			{
				static bool bVertexConfusedSignaled = false;
				if (!bVertexConfusedSignaled)
				{

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Element2StaticMesh.h:18

Scope: file

Source code excerpt:

BEGIN_NAMESPACE_UE_AC

#if defined(DEBUG)
	#define DUMP_GEOMETRY 1 // For debug purpose
#else
	#define DUMP_GEOMETRY 0
#endif

// Encapsulate ModelerAPI::TextureCoordinate to used as TMap Key

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/ReportWindow.cpp:213

Scope (from outer to inner):

file
function     void FTraceListener::NewTrace

Source code excerpt:

void FTraceListener::NewTrace(EP2DB InTraceLevel, const utf8_string& InMsg)
{
#ifdef DEBUG
	const EP2DB MessageLevel = kP2DB_Trace;
#else
	const EP2DB MessageLevel = kP2DB_Debug; // Put kP2DB_Report for final release
#endif

	if (InTraceLevel <= MessageLevel)

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/ResourcesIDs.h:66

Scope: file

Source code excerpt:

	#define H7 7

	#ifndef DEBUG
		#define kPaletteHSize 156
		#define kPaletteDevTools 0
	#else
		#define kPaletteHSize 218
		#define kPaletteDevTools 1
	#endif

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/ResourcesIDs.h:87

Scope: file

Source code excerpt:

	#define H7 6

	#ifndef DEBUG
		#define kPaletteHSize 126
		#define kPaletteDevTools 0
	#else
		#define kPaletteHSize 188
		#define kPaletteDevTools 1
	#endif

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/SyncDatabase.cpp:247

Scope: file

Source code excerpt:

}

#if defined(DEBUG) && 0
	#define UE_AC_DO_TRACE 1
#else
	#define UE_AC_DO_TRACE 0
#endif

// Constructor

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/SyncDatabase.cpp:620

Scope (from outer to inner):

file
function     void FSyncDatabase::ReportMeshClasses

Source code excerpt:

void FSyncDatabase::ReportMeshClasses() const
{
#if defined(DEBUG) && 1
	for (const auto& IterMeshClass : MeshClasses)
	{
		const FMeshClass& MeshClass = **IterMeshClass.value;
		if (MeshClass.InstancesCount > 1)
		{
			if (MeshClass.InstancesCount != MeshClass.TransformCount)

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/SyncDatabase.cpp:754

Scope: file

Source code excerpt:

}

#if defined(DEBUG) && 0
	#define UE_AC_DO_TRACE_LIGHTS 1
#else
	#define UE_AC_DO_TRACE_LIGHTS 0
#endif

// Scan all lights of this element

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Synchronizer.cpp:3

Scope: file

Source code excerpt:

#include "MaterialsDatabase.h"
#include "Commander.h"
#ifdef DEBUG
#include "ISceneValidator.h"
#endif
#include "Utils/TimeStat.h"
#include "Utils/Error.h"
#include "Utils/CurrentOS.h"

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Synchronizer.cpp:389

Scope (from outer to inner):

file
function     void FSynchronizer::DoSnapshot

Source code excerpt:

	bool OutUserCancelled = false;
	int	 NbPhases = kSyncWaitPreviousSync - kCommonProjectInfos + 1;
#if defined(DEBUG)
	++NbPhases;
#endif
	FProgression Progression(kStrListProgression, kSyncTitle, NbPhases, FProgression::kSetFlags, &OutUserCancelled);

	GS::UniString ExportPath = FSyncDatabase::GetCachePath();

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Synchronizer.cpp:485

Scope (from outer to inner):

file
function     void FSynchronizer::DumpAndValidate

Source code excerpt:

void FSynchronizer::DumpAndValidate()
{
#ifdef DEBUG
	if (!FCommander::IsAutoSyncEnabled()) // In Auto Sync mode we don't do scene dump or validation
	{
		FTimeStat DumpAndValidateStart;
		DumpScene(SyncDatabase->GetScene());
        TSharedRef< Validator::ISceneValidator > Validator = Validator::ISceneValidator::CreateForScene(SyncDatabase->GetScene());
		Validator->CheckElementsName();

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Utils/ShellOpenDocument.cpp:29

Scope (from outer to inner):

file
function     void UE_AC::ShellOpenDocument

Source code excerpt:

		// wait for child process.
		waitpid(ForkResult, &status, 0);
	#ifdef DEBUG
		printf("ShellOpenDocument returned %d for document %s", status, InDocRef);
	#endif
	}
#else
	::ShellExecuteA(NULL, "open", InDocRef, NULL, NULL, SW_SHOW);
#endif

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Utils/ShellOpenDocument.cpp:56

Scope (from outer to inner):

file
function     void UE_AC::ShellStartProductManager

Source code excerpt:

		// wait for child process.
		waitpid(ForkResult, &status, 0);
	#ifdef DEBUG
		printf("ShellStartProductManager returned %d\n", status);
	#endif
	}
#else
	wchar_t keyValue[MAX_PATH];
	DWORD	DataSize = MAX_PATH;

#Loc: <Workspace>/Engine/Source/Programs/Enterprise/Datasmith/DatasmithARCHICADExporter/Private/Utils/WinOS.cpp:101

Scope (from outer to inner):

file
function     void SetThreadName

Source code excerpt:

void SetThreadName(const char* InName)
{
#if defined(DEBUG) || 1
	const DWORD MS_VC_EXCEPTION = 0x406D1388;

	#pragma pack(push, 8)
	typedef struct tagTHREADNAME_INFO
	{
		DWORD  dwType; // Must be 0x1000.

#Loc: <Workspace>/Engine/Source/Runtime/Core/Public/FramePro/FramePro.h:916

Scope: file

Source code excerpt:

// enable debug here to get FramePro asserts
#ifndef FRAMEPRO_DEBUG
	#if defined(DEBUG) || defined(_DEBUG)
		#define FRAMEPRO_DEBUG 1
	#else
		#define FRAMEPRO_DEBUG 0
	#endif
#endif

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:5156

Scope: file

Source code excerpt:

		return HandleLogoutStatLevelsCommand( Cmd, Ar, InWorld );
	}
	else if( FParse::Command( &Cmd, TEXT("DEBUG") ) )
	{
		return HandleDebugCommand( Cmd, Ar );
	}
	else if (FParse::Command(&Cmd,TEXT("MERGEMESH")))
	{
		return HandleMergeMeshCommand( Cmd, Ar, InWorld );