Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Olympe::DebugController Class Reference

Singleton that manages runtime debugging of VS graphs. More...

#include <DebugController.h>

+ Collaboration diagram for Olympe::DebugController:

Public Member Functions

void SetBreakpoint (int graphID, int nodeID, const std::string &graphName="", const std::string &nodeName="")
 Registers a breakpoint at (graphID, nodeID).
 
void ClearBreakpoint (int graphID, int nodeID)
 Removes the breakpoint at (graphID, nodeID) if it exists.
 
void ToggleBreakpoint (int graphID, int nodeID, const std::string &graphName="", const std::string &nodeName="")
 Toggles the breakpoint at (graphID, nodeID).
 
bool HasBreakpoint (int graphID, int nodeID) const
 Returns true if an enabled breakpoint exists at (graphID, nodeID).
 
void SetBreakpointEnabled (int graphID, int nodeID, bool enabled)
 Enables or disables an existing breakpoint.
 
std::vector< BreakpointInfoGetBreakpoints (int graphID) const
 Returns all registered breakpoints for graphID.
 
std::vector< BreakpointInfoGetAllBreakpoints () const
 Returns all registered breakpoints across all graphs.
 
void ClearAllBreakpoints ()
 Removes all breakpoints.
 
void StartDebugging (int graphID)
 Starts a debug session for the given graph.
 
void StopDebugging ()
 Stops the current debug session.
 
void Continue ()
 Resumes execution from Paused state.
 
void Pause ()
 Pauses execution.
 
void StepNext ()
 Executes the next node then pauses.
 
void StepInto ()
 Steps into a SubGraph if the next node is a SubGraph node.
 
void StepOut ()
 Runs until the current SubGraph returns.
 
DebugState GetState () const
 Returns the current debug state.
 
bool IsDebugging () const
 Returns true when a debug session is active.
 
int GetCurrentGraphID () const
 Returns the currently debugged graphID (-1 if none).
 
int GetCurrentNodeID () const
 Returns the node being executed (-1 if none).
 
LocalBlackboard GetCurrentBlackboard () const
 Returns a copy of the blackboard snapshot from the last OnNodeExecuting() call.
 
std::vector< SubGraphStackFrameGetCallStack () const
 Returns the current SubGraph call stack (most recent at front).
 
void OnNodeExecuting (int graphID, int nodeID, const LocalBlackboard *bb)
 Called by VSGraphExecutor before executing a node.
 
void PushCallFrame (int graphID, int nodeID, const std::string &graphName="", const std::string &nodeName="")
 Push a SubGraph frame onto the call stack.
 
void PopCallFrame ()
 Pop the top SubGraph frame from the call stack.
 
void SetHeadlessMode (bool headless)
 When true, OnNodeExecuting() never busy-waits on Paused.
 

Static Public Member Functions

static DebugControllerGet ()
 Returns the singleton instance (Meyers pattern).
 

Private Member Functions

 DebugController ()
 
 ~DebugController ()
 
 DebugController (const DebugController &)=delete
 
DebugControlleroperator= (const DebugController &)=delete
 
int MakeBreakpointKey (int graphID, int nodeID) const
 
bool HasBreakpointLocked (int graphID, int nodeID) const
 

Private Attributes

std::mutex m_mutex
 
DebugState m_state = DebugState::NotDebugging
 
int m_currentGraphID = -1
 
int m_currentNodeID = -1
 
bool m_headlessMode = false
 
LocalBlackboard m_bbSnapshot
 
std::unordered_map< int, BreakpointInfom_breakpoints
 Breakpoints keyed by (graphID * 100000 + nodeID)
 
std::vector< SubGraphStackFramem_callStack
 Call stack (index 0 = bottom / entry, back = current)
 

Detailed Description

Singleton that manages runtime debugging of VS graphs.

Usage:

// Editor side
// TaskSystem side (called from ExecuteFrame)
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void StartDebugging(int graphID)
Starts a debug session for the given graph.
static DebugController & Get()
Returns the singleton instance (Meyers pattern).
void SetBreakpoint(int graphID, int nodeID, const std::string &graphName="", const std::string &nodeName="")
Registers a breakpoint at (graphID, nodeID).
void OnNodeExecuting(int graphID, int nodeID, const LocalBlackboard *bb)
Called by VSGraphExecutor before executing a node.

Meyers singleton pattern (local static in Get()). Thread-safe via std::mutex.

Definition at line 109 of file DebugController.h.

Constructor & Destructor Documentation

◆ DebugController() [1/2]

Olympe::DebugController::DebugController ( )
private

Definition at line 28 of file DebugController.cpp.

◆ ~DebugController()

Olympe::DebugController::~DebugController ( )
private

Definition at line 32 of file DebugController.cpp.

◆ DebugController() [2/2]

Olympe::DebugController::DebugController ( const DebugController )
privatedelete

Member Function Documentation

◆ ClearAllBreakpoints()

void Olympe::DebugController::ClearAllBreakpoints ( )

Removes all breakpoints.

Definition at line 145 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, and m_mutex.

+ Here is the call graph for this function:

◆ ClearBreakpoint()

void Olympe::DebugController::ClearBreakpoint ( int  graphID,
int  nodeID 
)

Removes the breakpoint at (graphID, nodeID) if it exists.

Definition at line 75 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, m_mutex, and MakeBreakpointKey().

+ Here is the call graph for this function:

◆ Continue()

void Olympe::DebugController::Continue ( )

Resumes execution from Paused state.

Transitions Paused -> Running.

Definition at line 173 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, Olympe::Paused, and Olympe::Running.

+ Here is the call graph for this function:

◆ Get()

DebugController & Olympe::DebugController::Get ( )
static

◆ GetAllBreakpoints()

std::vector< BreakpointInfo > Olympe::DebugController::GetAllBreakpoints ( ) const

Returns all registered breakpoints across all graphs.

Definition at line 134 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, and m_mutex.

+ Here is the call graph for this function:

◆ GetBreakpoints()

std::vector< BreakpointInfo > Olympe::DebugController::GetBreakpoints ( int  graphID) const

Returns all registered breakpoints for graphID.

Definition at line 122 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, and m_mutex.

+ Here is the call graph for this function:

◆ GetCallStack()

std::vector< SubGraphStackFrame > Olympe::DebugController::GetCallStack ( ) const

Returns the current SubGraph call stack (most recent at front).

Definition at line 252 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_callStack, and m_mutex.

+ Here is the call graph for this function:

◆ GetCurrentBlackboard()

LocalBlackboard Olympe::DebugController::GetCurrentBlackboard ( ) const

Returns a copy of the blackboard snapshot from the last OnNodeExecuting() call.

Definition at line 246 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_bbSnapshot, and m_mutex.

+ Here is the call graph for this function:

◆ GetCurrentGraphID()

int Olympe::DebugController::GetCurrentGraphID ( ) const

Returns the currently debugged graphID (-1 if none).

Definition at line 234 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_currentGraphID, and m_mutex.

+ Here is the call graph for this function:

◆ GetCurrentNodeID()

int Olympe::DebugController::GetCurrentNodeID ( ) const

Returns the node being executed (-1 if none).

Definition at line 240 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_currentNodeID, and m_mutex.

+ Here is the call graph for this function:

◆ GetState()

DebugState Olympe::DebugController::GetState ( ) const

Returns the current debug state.

Definition at line 222 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, and m_state.

+ Here is the call graph for this function:

◆ HasBreakpoint()

bool Olympe::DebugController::HasBreakpoint ( int  graphID,
int  nodeID 
) const

Returns true if an enabled breakpoint exists at (graphID, nodeID).

Definition at line 105 of file DebugController.cpp.

References GetComponentTypeID_Static(), HasBreakpointLocked(), and m_mutex.

Referenced by Olympe::VisualScriptEditorPanel::RenderNodePropertiesPanelContent(), and Olympe::VisualScriptEditorPanel::RenderSwitchNodeProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasBreakpointLocked()

bool Olympe::DebugController::HasBreakpointLocked ( int  graphID,
int  nodeID 
) const
private

Definition at line 47 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, and MakeBreakpointKey().

Referenced by HasBreakpoint(), and OnNodeExecuting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsDebugging()

bool Olympe::DebugController::IsDebugging ( ) const

Returns true when a debug session is active.

Definition at line 228 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, and Olympe::NotDebugging.

+ Here is the call graph for this function:

◆ MakeBreakpointKey()

int Olympe::DebugController::MakeBreakpointKey ( int  graphID,
int  nodeID 
) const
private

Definition at line 40 of file DebugController.cpp.

Referenced by ClearBreakpoint(), HasBreakpointLocked(), SetBreakpoint(), SetBreakpointEnabled(), and ToggleBreakpoint().

+ Here is the caller graph for this function:

◆ OnNodeExecuting()

void Olympe::DebugController::OnNodeExecuting ( int  graphID,
int  nodeID,
const LocalBlackboard bb 
)

Called by VSGraphExecutor before executing a node.

Updates the current node/graph and blackboard snapshot. If a breakpoint is hit and state is Running, transitions to Paused. If state is StepNext, transitions to Paused after the first call.

Note
This method may busy-wait when the state is Paused (in debug mode with the UI thread calling Continue/StepNext). In a headless test context, busy-wait is skipped.
Parameters
graphIDGraph being executed.
nodeIDNode about to be executed.
bbLive blackboard pointer (snapshot is copied).

Definition at line 262 of file DebugController.cpp.

References GetComponentTypeID_Static(), HasBreakpointLocked(), m_bbSnapshot, m_currentGraphID, m_currentNodeID, m_headlessMode, m_mutex, m_state, Olympe::NotDebugging, Olympe::Paused, Olympe::Running, Olympe::StepInto, and Olympe::StepNext.

+ Here is the call graph for this function:

◆ operator=()

DebugController & Olympe::DebugController::operator= ( const DebugController )
privatedelete

◆ Pause()

void Olympe::DebugController::Pause ( )

Pauses execution.

Transitions Running -> Paused.

Definition at line 182 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, Olympe::Paused, and Olympe::Running.

+ Here is the call graph for this function:

◆ PopCallFrame()

void Olympe::DebugController::PopCallFrame ( )

Pop the top SubGraph frame from the call stack.

Called by VSGraphExecutor when returning from a SubGraph.

Definition at line 341 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_callStack, m_mutex, m_state, Olympe::Paused, and Olympe::StepOut.

+ Here is the call graph for this function:

◆ PushCallFrame()

void Olympe::DebugController::PushCallFrame ( int  graphID,
int  nodeID,
const std::string &  graphName = "",
const std::string &  nodeName = "" 
)

Push a SubGraph frame onto the call stack.

Called by VSGraphExecutor when entering a SubGraph.

Definition at line 322 of file DebugController.cpp.

References GetComponentTypeID_Static(), Olympe::SubGraphStackFrame::graphID, Olympe::SubGraphStackFrame::graphName, Olympe::SubGraphStackFrame::isCurrent, m_callStack, m_mutex, Olympe::SubGraphStackFrame::nodeID, and Olympe::SubGraphStackFrame::nodeName.

+ Here is the call graph for this function:

◆ SetBreakpoint()

void Olympe::DebugController::SetBreakpoint ( int  graphID,
int  nodeID,
const std::string &  graphName = "",
const std::string &  nodeName = "" 
)

Registers a breakpoint at (graphID, nodeID).

Safe to call multiple times — idempotent.

Definition at line 60 of file DebugController.cpp.

References GetComponentTypeID_Static(), Olympe::BreakpointInfo::graphID, m_breakpoints, m_mutex, and MakeBreakpointKey().

+ Here is the call graph for this function:

◆ SetBreakpointEnabled()

void Olympe::DebugController::SetBreakpointEnabled ( int  graphID,
int  nodeID,
bool  enabled 
)

Enables or disables an existing breakpoint.

Definition at line 111 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_breakpoints, m_mutex, and MakeBreakpointKey().

+ Here is the call graph for this function:

◆ SetHeadlessMode()

void Olympe::DebugController::SetHeadlessMode ( bool  headless)

When true, OnNodeExecuting() never busy-waits on Paused.

Useful for unit tests where there is no UI thread to call Continue().

Definition at line 362 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_headlessMode, and m_mutex.

+ Here is the call graph for this function:

◆ StartDebugging()

void Olympe::DebugController::StartDebugging ( int  graphID)

Starts a debug session for the given graph.

Transitions from NotDebugging -> Running.

Definition at line 155 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_callStack, m_currentGraphID, m_currentNodeID, m_mutex, m_state, and Olympe::Running.

+ Here is the call graph for this function:

◆ StepInto()

void Olympe::DebugController::StepInto ( )

Steps into a SubGraph if the next node is a SubGraph node.

Transitions Paused -> StepInto.

Definition at line 200 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, Olympe::Paused, and Olympe::StepInto.

+ Here is the call graph for this function:

◆ StepNext()

void Olympe::DebugController::StepNext ( )

Executes the next node then pauses.

Transitions Paused -> StepNext.

Definition at line 191 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, Olympe::Paused, and Olympe::StepNext.

+ Here is the call graph for this function:

◆ StepOut()

void Olympe::DebugController::StepOut ( )

Runs until the current SubGraph returns.

Transitions Paused -> StepOut.

Definition at line 209 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_mutex, m_state, Olympe::Paused, and Olympe::StepOut.

+ Here is the call graph for this function:

◆ StopDebugging()

void Olympe::DebugController::StopDebugging ( )

Stops the current debug session.

Transitions to NotDebugging from any state.

Definition at line 164 of file DebugController.cpp.

References GetComponentTypeID_Static(), m_callStack, m_currentGraphID, m_currentNodeID, m_mutex, m_state, and Olympe::NotDebugging.

+ Here is the call graph for this function:

◆ ToggleBreakpoint()

void Olympe::DebugController::ToggleBreakpoint ( int  graphID,
int  nodeID,
const std::string &  graphName = "",
const std::string &  nodeName = "" 
)

Toggles the breakpoint at (graphID, nodeID).

Adds it if absent, removes it if present.

Definition at line 82 of file DebugController.cpp.

References GetComponentTypeID_Static(), Olympe::BreakpointInfo::graphID, m_breakpoints, m_mutex, and MakeBreakpointKey().

Referenced by Olympe::VisualScriptEditorPanel::RenderNodePropertiesPanelContent(), and Olympe::VisualScriptEditorPanel::RenderSwitchNodeProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_bbSnapshot

LocalBlackboard Olympe::DebugController::m_bbSnapshot
private

Definition at line 312 of file DebugController.h.

Referenced by GetCurrentBlackboard(), and OnNodeExecuting().

◆ m_breakpoints

std::unordered_map<int, BreakpointInfo> Olympe::DebugController::m_breakpoints
private

Breakpoints keyed by (graphID * 100000 + nodeID)

Definition at line 315 of file DebugController.h.

Referenced by ClearAllBreakpoints(), ClearBreakpoint(), GetAllBreakpoints(), GetBreakpoints(), HasBreakpointLocked(), SetBreakpoint(), SetBreakpointEnabled(), and ToggleBreakpoint().

◆ m_callStack

std::vector<SubGraphStackFrame> Olympe::DebugController::m_callStack
private

Call stack (index 0 = bottom / entry, back = current)

Definition at line 318 of file DebugController.h.

Referenced by GetCallStack(), PopCallFrame(), PushCallFrame(), StartDebugging(), and StopDebugging().

◆ m_currentGraphID

int Olympe::DebugController::m_currentGraphID = -1
private

◆ m_currentNodeID

int Olympe::DebugController::m_currentNodeID = -1
private

◆ m_headlessMode

bool Olympe::DebugController::m_headlessMode = false
private

Definition at line 310 of file DebugController.h.

Referenced by OnNodeExecuting(), and SetHeadlessMode().

◆ m_mutex

std::mutex Olympe::DebugController::m_mutex
mutableprivate

◆ m_state

DebugState Olympe::DebugController::m_state = DebugState::NotDebugging
private

The documentation for this class was generated from the following files: