EditorDebuggerSession in Godot – Complete Guide

Are you ready to take your Godot game development skills to the next level? Understanding and utilizing the Godot Editor is crucial, and today we’re diving into a specialized aspect of it: the EditorDebuggerSession class in Godot 4. This powerful class holds the key to interacting with the editor debugger, allowing for a more refined and in-depth development process. Let’s unpack what EditorDebuggerSession is, what it’s for, and why it’s an essential tool in your Godot toolkit.

What is EditorDebuggerSession?

EditorDebuggerSession is a non-instantiable class that forms an integral part of the debugging process within the Godot editor. It’s used to communicate with the debugger and manipulate various debugging features programmatically. This class is accessed through an EditorDebuggerPlugin, providing a range of methods to enhance your interaction with the editor’s debug functionalities.

What is EditorDebuggerSession for?

The primary use of the EditorDebuggerSession is to provide a way to extend and customize the debugging environment. You can add custom tabs to the debugger’s UI, send tailored messages, manage EngineProfilers, and more. These functionalities allow developers to create a personalized debugging interface that caters to their specific needs or the requirements of their projects.

Why Should I Learn EditorDebuggerSession?

As a game developer, mastering the tools at your disposal is crucial for efficiency and effectiveness. Learning how to manipulate the EditorDebuggerSession gives you more control over the debugging process, thereby reducing the time spent on finding and fixing bugs. Moreover, it enables you to tailor the debugger to fit your workflow, which can simplify complex game development scenarios and help you maintain a clear headspace while squashing bugs and refining gameplay.

CTA Small Image

Working with Breakpoints

Breakpoints are essential for inspecting the state of your game at specific code points. With the EditorDebuggerSession, you can programmatically add or remove breakpoints, enabling dynamic debugging scenarios.

// Add a breakpoint to line 42 of the "player.gd" script.
EditorDebugger.get_main_editor_debugger().add_breakpoint("res://player.gd", 42)

// Remove the breakpoint from line 42 of the "player.gd" script.
EditorDebugger.get_main_editor_debugger().remove_breakpoint("res://player.gd", 42)

This approach to handling breakpoints can be particularly useful when wanting to automate debugging tasks or when setting conditional breakpoints based on certain runtime conditions.

Customizing the Debugger Interface

The EditorDebuggerSession allows you to customize the debugger interface by adding custom panels. This can help you display information relevant to your game directly in the editor.

// Create a custom panel in the debugger interface.
var custom_panel = Panel.new()
var debugger = EditorDebugger.get_main_editor_debugger()

// Assuming you've removed or replaced a panel, here you'd remove it. 
// Make sure to keep a reference to your custom panel if you need to remove it later.

Adding custom panels can be extremely useful for displaying game-specific information, such as AI state, network status, or custom performance metrics, right within the Godot editor debug interface.

Manipulating the Running Game’s Scene Tree

At times, it might be necessary to alter the running game’s scene tree directly from the EditorDebuggerSession. Here’s how to retrieve and manipulate nodes:

// Retrieve the root node of the running game's scene tree.
var remote_tree = EditorDebugger.get_main_editor_debugger().get_remote_tree()

// Access a specific node called "Player" and change its position.
var player_node = remote_tree.get_node("Player")
player_node.set_position(Vector2(100, 100))

Being able to interact with the scene tree like this can be a game-changer for testing and debugging complex in-game interactions on the fly.

Profiling and Performance Analysis

Godot’s debugger has powerful profiling tools, which you can leverage via the EditorDebuggerSession class for a more detailed analysis of your game’s performance.

// Start profiling the game performance.

// After some time or certain events, stop the profiler.

// Extract the profiling information.
var profiler_data = EditorDebugger.get_main_editor_debugger().get_profiler_data()

Performance profiling is instrumental in identifying bottlenecks in your game. With programmatic control, you can start and stop the profiler at precise moments, making your performance tuning much more targeted and efficient.

Mastering the use of EditorDebuggerSession can elevate your debugging practices to new heights, allowing for a more streamlined and powerful development process in Godot 4. Stay tuned for the next part of our tutorial where we’ll continue exploring the capabilities of this class with practical examples.

In the wonderful world of game development, having nuanced control over your debugging process can be the difference between a good game and a great one. With the EditorDebuggerSession class in Godot 4, we have the power to execute commands, inspect live objects, capture screenshots, and more. Let’s explore a few more practical examples to demonstrate the capabilities of this versatile class.

Executing Commands

Godot offers various commands for debugging, which can be executed through the EditorDebuggerSession. This allows for actions such as pausing or resuming the game to be performed programmatically.

// Pausing the game from the editor

// Resuming the game

Controlling the game state like this is especially useful when setting up automated tests or during presentations where you might need to stop at certain points without manual intervention.

Inspecting Live Objects

Object inspection is a critical part of debugging, allowing developers to examine object properties, script variables, and more in real-time.

// Inspect a particular node to view its properties and methods.
var player_node = EditorDebugger.get_main_editor_debugger().get_inspected_object("Player")

// Output the object's script for review.

Live object inspection while the game is running can reveal dynamic changes to properties or verify if the node is operating correctly within its scene.

Capturing Screenshots

Sometimes, you may need to capture what’s happening on screen, especially when encountering a visual bug that’s hard to replicate. EditorDebuggerSession makes it easy to take screenshots programmatically.

// Take a screenshot of the game view.

// You should listen for "scene_tree_frame" signal to receive the image data.
EditorDebugger.get_main_editor_debugger().connect("scene_tree_frame", self, "_on_scene_tree_frame")

func _on_scene_tree_frame(image):

Screenshots can be used not only for bug tracking but also for creating automated visual tests, ensuring consistency as your game evolves.

Monitoring Network Messages

For multiplayer games or those that include network communication, monitoring the messages being sent and received can be immensely helpful.

// Start capturing network messages.

// Later, access the captured messages.
var messages = EditorDebugger.get_main_editor_debugger().get_captured_messages()

for message in messages:
    print("Received message: %s" % [message])

// Stop capturing messages to avoid filling up memory.

By capturing network messages, you can debug the communication between clients and servers, assess message frequency, and ensure data integrity.

Incorporating these functions into your Godot 4 workflow will significantly streamline your debugging process. The idea is to create a development environment that is as responsive and intuitive as possible, so you can focus more on the creative aspects of game development and spend less time fixing issues.

As always, we urge you to explore these functionalities in your own projects and experience the power and flexibility that Godot 4 provides with the EditorDebuggerSession class. For further learning and to delve deeper into Godot and game development, stick with us and check out our latest courses and tutorials. Happy coding!

Continuing our journey through the capabilities of the EditorDebuggerSession in Godot 4, we’re going to delve into additional practical features that can enhance your development process. These include real-time variable tracking, remote method invocation, and more. Let’s explore these with some code examples:

Real-Time Variable Tracking:

Stay on top of your game’s state with real-time tracking of any variable.

// Track a player's health variable in real-time.
EditorDebugger.get_main_editor_debugger().watch_variable("Player", "health")

This enables you to monitor how variables change over time, particularly useful for fine-tuning gameplay mechanics or investigating unexpected behaviors.

Remote Method Invocation:

Invoke methods on objects from the editor with ease, providing a handy way to test functions without needing to trigger them in-game.

// Call the 'respawn' method on the 'Player' node from the editor.
EditorDebugger.get_main_editor_debugger().remote_call("Player", "respawn", [])

Remote method invocation can be an incredibly time-saving feature when testing specific parts of your game’s code that are normally triggered under specific conditions.

Monitoring Memory Usage:

Keep an eye on your game’s memory usage directly from the Godot editor, helping you to identify potential memory leaks and optimize resource allocation.

// Keep track of the allocated and used memory.
var memory_info = EditorDebugger.get_main_editor_debugger().get_monitored_memory()
print("Total Memory Allocated: %s" % [memory_info.total_memory])
print("Total Memory Used: %s" % [memory_info.used_memory])

Given that memory management is a vital aspect of game development, especially for complex or resource-intensive games, a real-time view of your memory usage can be crucial.

Script Profiling:

Profile specific areas of your code to understand performance characteristics and optimize your script’s execution.

// Start profiling a specific function in a script.

// Extract the profiling information.
var profiling_info = EditorDebugger.get_main_editor_debugger().get_script_profiler_data()

for info in profiling_info:
    print("Function %s took %d microseconds." % [info.function_name, info.time_taken])
// Stop profiling once done.

Script profiling ensures that you focus on optimizing parts of your code that significantly affect the game’s performance.

Error and Warning Monitoring:

Keep track of any errors and warnings that occur during game execution so you can debug proactively and maintain a stable build.

// Monitoring errors and warnings in real-time.
EditorDebugger.get_main_editor_debugger().connect("error_catched", self, "_on_error_catched")

func _on_error_catched(error, description, type, backtrace):
    print("Error occurred: %s - %s" % [error, description])

Error monitoring is a crucial aspect of maintaining high code quality, ensuring that you’re alerted to issues as they arise.

Harnessing these features with the EditorDebuggerSession in Godot 4 will sharpen your debugging skills and contribute to a more robust and refined game development process. Remember that while each of these snippets demonstrates individual features, the true power comes from integrating them into a cohesive debugging strategy tailored to your specific game and workflow. Keep tuning in for more insights and expert tutorials to help elevate your Godot game development to unprecedented levels.

Continue Your Godot Learning Journey

Your adventure with Godot doesn’t have to end here! If you’ve enjoyed diving into the intricacies of the EditorDebuggerSession and want to broaden your game development skills, our Godot Game Development Mini-Degree is the perfect next step. This comprehensive learning path will guide you through the process of building cross-platform games using the versatile Godot 4 engine, from the ground up.

The Godot 4 engine is an incredible tool – free, open-source, and backed by a strong community. Our mini-degree will help you hone your skills in 2D and 3D asset creation, establish solid gameplay control flows, and delve into creating intricate UI systems. You’ll learn by doing, building a portfolio of real Godot projects as you progress through the courses. Whether you’re a beginner or looking to level up your existing knowledge, this educational pathway is flexible, accessible on-demand, and accommodating to your pace of learning.

For those seeking an even broader collection of resources and topics, explore all of our Godot courses. Embark on this journey with Zenva, and transform your passion for game development into a tangible skill set that you can showcase to the world.


In the landscape of game development, tools like EditorDebuggerSession in Godot 4 provide a canvas for both the art and science that game creation entails. By mastering its features, you not only streamline the debugging process but also synthesize complex interactive experiences with precision and flair. As you continue to explore and experiment with Godot 4, remember that every function and class you master is a step towards becoming not just a game developer, but a game craftsman.

At Zenva, we believe in the potential of every aspiring developer. Our Godot Game Development Mini-Degree is designed as a stepping stone to elevate your talents and bring your gaming visions to life. So why wait? Join us and turn the complexity of game development into your playground of creativity!

Python Blog Image

FINAL DAYS: Unlock coding courses in Unity, Godot, Unreal, Python and more.