[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:
Fabio Alessandrelli 2022-05-06 13:53:20 +02:00
parent db48b80707
commit 225e75daba
3 changed files with 35 additions and 6 deletions

View file

@ -1560,8 +1560,10 @@ void ScriptEditorDebugger::_clear_execution() {
stack_script.unref();
}
void ScriptEditorDebugger::start() {
stop();
void ScriptEditorDebugger::start(int p_port, const IP_Address &p_bind_address) {
if (is_inside_tree()) {
stop();
}
if (is_visible_in_tree()) {
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
@ -1573,7 +1575,11 @@ void ScriptEditorDebugger::start() {
}
const int max_tries = 6;
remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
if (p_port < 0) {
remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port");
} else {
remote_port = p_port;
}
int current_try = 0;
// Find first available port.
Error err = server->listen(remote_port);
@ -1582,7 +1588,7 @@ void ScriptEditorDebugger::start() {
current_try++;
remote_port++;
OS::get_singleton()->delay_usec(1000);
err = server->listen(remote_port);
err = server->listen(remote_port, p_bind_address);
}
// No suitable port found.
if (err != OK) {
@ -1592,7 +1598,7 @@ void ScriptEditorDebugger::start() {
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");
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();
}