You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-19 14:31:59 +00:00
[3.x] [Debugger] Add --debug-server CLI option.
Automatically starts the editor debug server at given <IP>:<PORT>. E.g.: # Run editor and debug server listening on any interface, port 8080 godot3 -e --path proj/proj_empty --debug-server *:8080 # Run the godot project connecting to that debug server. godot3 --path proj/proj_empty --remote-debug 127.0.0.1:8080
This commit is contained in:
@@ -1560,8 +1560,10 @@ void ScriptEditorDebugger::_clear_execution() {
|
|||||||
stack_script.unref();
|
stack_script.unref();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditorDebugger::start() {
|
void ScriptEditorDebugger::start(int p_port, const IP_Address &p_bind_address) {
|
||||||
|
if (is_inside_tree()) {
|
||||||
stop();
|
stop();
|
||||||
|
}
|
||||||
|
|
||||||
if (is_visible_in_tree()) {
|
if (is_visible_in_tree()) {
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
||||||
@@ -1573,7 +1575,11 @@ void ScriptEditorDebugger::start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int max_tries = 6;
|
const int max_tries = 6;
|
||||||
|
if (p_port < 0) {
|
||||||
remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
|
||||||
|
} else {
|
||||||
|
remote_port = p_port;
|
||||||
|
}
|
||||||
int current_try = 0;
|
int current_try = 0;
|
||||||
// Find first available port.
|
// Find first available port.
|
||||||
Error err = server->listen(remote_port);
|
Error err = server->listen(remote_port);
|
||||||
@@ -1582,7 +1588,7 @@ void ScriptEditorDebugger::start() {
|
|||||||
current_try++;
|
current_try++;
|
||||||
remote_port++;
|
remote_port++;
|
||||||
OS::get_singleton()->delay_usec(1000);
|
OS::get_singleton()->delay_usec(1000);
|
||||||
err = server->listen(remote_port);
|
err = server->listen(remote_port, p_bind_address);
|
||||||
}
|
}
|
||||||
// No suitable port found.
|
// No suitable port found.
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
@@ -1592,7 +1598,7 @@ void ScriptEditorDebugger::start() {
|
|||||||
EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons();
|
EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons();
|
||||||
|
|
||||||
auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree");
|
auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree");
|
||||||
if (auto_switch_remote_scene_tree) {
|
if (is_inside_tree() && auto_switch_remote_scene_tree) {
|
||||||
EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree();
|
EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,7 +244,7 @@ protected:
|
|||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void start();
|
void start(int p_port = -1, const IP_Address &p_bind_address = IP_Address("*"));
|
||||||
void pause();
|
void pause();
|
||||||
void unpause();
|
void unpause();
|
||||||
void stop();
|
void stop();
|
||||||
|
|||||||
@@ -80,6 +80,7 @@
|
|||||||
#include "editor/editor_translation.h"
|
#include "editor/editor_translation.h"
|
||||||
#include "editor/progress_dialog.h"
|
#include "editor/progress_dialog.h"
|
||||||
#include "editor/project_manager.h"
|
#include "editor/project_manager.h"
|
||||||
|
#include "editor/script_editor_debugger.h"
|
||||||
#ifndef NO_EDITOR_SPLASH
|
#ifndef NO_EDITOR_SPLASH
|
||||||
#include "main/splash_editor.gen.h"
|
#include "main/splash_editor.gen.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -133,6 +134,7 @@ static OS::ProcessID allow_focus_steal_pid = 0;
|
|||||||
static bool delta_sync_after_draw = false;
|
static bool delta_sync_after_draw = false;
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
static bool auto_build_solutions = false;
|
static bool auto_build_solutions = false;
|
||||||
|
static String debug_server_uri;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
@@ -257,6 +259,7 @@ void Main::print_help(const char *p_binary) {
|
|||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n");
|
OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n");
|
||||||
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
|
OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n");
|
||||||
|
OS::get_singleton()->print(" --debug-server <address> Start the editor debug server (<IP>:<port>, e.g. 127.0.0.1:6007)\n");
|
||||||
#endif
|
#endif
|
||||||
OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
|
OS::get_singleton()->print(" -q, --quit Quit after the first iteration.\n");
|
||||||
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
|
OS::get_singleton()->print(" -l, --language <locale> Use a specific locale (<locale> being a two-letter code).\n");
|
||||||
@@ -733,6 +736,19 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||||||
} else if (I->get() == "-p" || I->get() == "--project-manager") { // starts project manager
|
} else if (I->get() == "-p" || I->get() == "--project-manager") { // starts project manager
|
||||||
|
|
||||||
project_manager = true;
|
project_manager = true;
|
||||||
|
|
||||||
|
} else if (I->get() == "--debug-server") {
|
||||||
|
if (I->next()) {
|
||||||
|
debug_server_uri = I->next()->get();
|
||||||
|
if (debug_server_uri.find(":") == -1) { // wrong address
|
||||||
|
OS::get_singleton()->print("Invalid debug server address. It should be of the form <bind_address>:<port>.\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
N = I->next()->next();
|
||||||
|
} else {
|
||||||
|
OS::get_singleton()->print("Missing remote debug server server, aborting.\n");
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
} else if (I->get() == "--build-solutions") { // Build the scripting solution such C#
|
} else if (I->get() == "--build-solutions") { // Build the scripting solution such C#
|
||||||
|
|
||||||
auto_build_solutions = true;
|
auto_build_solutions = true;
|
||||||
@@ -2063,6 +2079,13 @@ bool Main::start() {
|
|||||||
ERR_PRINT("Failed to load scene");
|
ERR_PRINT("Failed to load scene");
|
||||||
}
|
}
|
||||||
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
|
OS::get_singleton()->set_context(OS::CONTEXT_EDITOR);
|
||||||
|
// Start debug server.
|
||||||
|
if (!debug_server_uri.empty()) {
|
||||||
|
int idx = debug_server_uri.rfind(":");
|
||||||
|
IP_Address addr = debug_server_uri.substr(0, idx);
|
||||||
|
int port = debug_server_uri.substr(idx + 1).to_int();
|
||||||
|
ScriptEditor::get_singleton()->get_debugger()->start(port, addr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user