@kognifai/cogsengine
    Preparing search index...

    Debugging

    Due to the dynamic nature of composing entities from components, and the use of untyped backing-stores for several types of objects in the engine, debugging can have some different challenges that the developer may not be used to handling.

    This page contains useful information when debugging Cogs.Core based applications.

    Custom visualizers for Visual Studio 2022+ are found in the directory

    Quick install script:

    %COGSROOT%Cogs.Core\Documentation\InstallVisualizers.bat
    
    /Cogs.Foundation/Tools/Visualizers/
    /Cogs.Core/Tools/Visualizers/
    /Tools/rvmparser/Tools/Visualizers/

    The install script copies .natvis files to the directory:

    %UserProfile%/Documents/Visual Studio 2022/Visualizers
    

    This allows the inspector in Visual Studio to pickup some additional information on how to display types from Cogs.Foundation and Cogs.Core properly (in addition to glm).

    See the .natvis files and Create custom views of native objects in the debugger on MSDN for more information on how to create and/or modify the visualizers.

    Entities, components, resources, render resources and variables all have complex backing storage with different behavior as far as pointer invalidation, modification behavior, queued deletion etc. Understanding the different behaviors and how they affect our ability to track an object through its lifetime is very useful.

    A lot of the time we handle objects through handles which do not necessarily carry type information in themselves, and often carry a untyped or base type pointer, making it hard to inspect the contents of the object pointed to. Using the Watch window in Visual Studio (or similar in other IDEs or debuggers) we can usually typecast the pointers to what we want to inspect.

    As an example, we might want to inspect the contents of a TransformComponent, but all we have is a Component pointer. What we can then do is copy the hexadecimal address of the Component pointer (e.g 0x00aabbccddeeff00) into the watch window and surround it with the following incantation:

    (Cogs::Core::TransformComponent *)0x00aabbccddeeff00
    

    If done correctly, this will enable the expansion menu for our item and allow us to inspect for example the position field of the TransformComponent.