Support multiple debug protocols.
This commit is contained in:
parent
ed225faf31
commit
d79e28c302
@ -173,7 +173,7 @@ ScriptEditorDebugger *EditorDebuggerNode::get_default_debugger() const {
|
|||||||
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
|
return Object::cast_to<ScriptEditorDebugger>(tabs->get_tab_control(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Error EditorDebuggerNode::start() {
|
Error EditorDebuggerNode::start(const String &p_protocol) {
|
||||||
stop();
|
stop();
|
||||||
if (EDITOR_GET("run/output/always_open_output_on_play")) {
|
if (EDITOR_GET("run/output/always_open_output_on_play")) {
|
||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(EditorNode::get_log());
|
||||||
@ -181,7 +181,7 @@ Error EditorDebuggerNode::start() {
|
|||||||
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
EditorNode::get_singleton()->make_bottom_panel_item_visible(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create_default());
|
server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create(p_protocol));
|
||||||
const Error err = server->start();
|
const Error err = server->start();
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
return err;
|
return err;
|
||||||
@ -213,14 +213,6 @@ void EditorDebuggerNode::stop() {
|
|||||||
|
|
||||||
void EditorDebuggerNode::_notification(int p_what) {
|
void EditorDebuggerNode::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
|
||||||
EditorNode::get_singleton()->connect("play_pressed", callable_mp(this, &EditorDebuggerNode::start));
|
|
||||||
EditorNode::get_singleton()->connect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop));
|
|
||||||
} break;
|
|
||||||
case NOTIFICATION_EXIT_TREE: {
|
|
||||||
EditorNode::get_singleton()->disconnect("play_pressed", callable_mp(this, &EditorDebuggerNode::start));
|
|
||||||
EditorNode::get_singleton()->disconnect("stop_pressed", callable_mp(this, &EditorDebuggerNode::stop));
|
|
||||||
} break;
|
|
||||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||||
if (tabs->get_tab_count() > 1) {
|
if (tabs->get_tab_count() > 1) {
|
||||||
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
|
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_theme_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT));
|
||||||
|
@ -183,7 +183,7 @@ public:
|
|||||||
void set_camera_override(CameraOverride p_override) { camera_override = p_override; }
|
void set_camera_override(CameraOverride p_override) { camera_override = p_override; }
|
||||||
CameraOverride get_camera_override() { return camera_override; }
|
CameraOverride get_camera_override() { return camera_override; }
|
||||||
|
|
||||||
Error start();
|
Error start(const String &p_protocol = "tcp://");
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
};
|
};
|
||||||
|
@ -44,6 +44,7 @@ private:
|
|||||||
Ref<TCP_Server> server;
|
Ref<TCP_Server> server;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static EditorDebuggerServer *create(const String &p_protocol);
|
||||||
virtual void poll() {}
|
virtual void poll() {}
|
||||||
virtual Error start();
|
virtual Error start();
|
||||||
virtual void stop();
|
virtual void stop();
|
||||||
@ -54,6 +55,11 @@ public:
|
|||||||
EditorDebuggerServerTCP();
|
EditorDebuggerServerTCP();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
EditorDebuggerServer *EditorDebuggerServerTCP::create(const String &p_protocol) {
|
||||||
|
ERR_FAIL_COND_V(p_protocol != "tcp://", nullptr);
|
||||||
|
return memnew(EditorDebuggerServerTCP);
|
||||||
|
}
|
||||||
|
|
||||||
EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
|
EditorDebuggerServerTCP::EditorDebuggerServerTCP() {
|
||||||
server.instance();
|
server.instance();
|
||||||
}
|
}
|
||||||
@ -85,6 +91,23 @@ Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() {
|
|||||||
return memnew(RemoteDebuggerPeerTCP(server->take_connection()));
|
return memnew(RemoteDebuggerPeerTCP(server->take_connection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
EditorDebuggerServer *EditorDebuggerServer::create_default() {
|
/// EditorDebuggerServer
|
||||||
return memnew(EditorDebuggerServerTCP);
|
Map<StringName, EditorDebuggerServer::CreateServerFunc> EditorDebuggerServer::protocols;
|
||||||
|
|
||||||
|
EditorDebuggerServer *EditorDebuggerServer::create(const String &p_protocol) {
|
||||||
|
ERR_FAIL_COND_V(!protocols.has(p_protocol), nullptr);
|
||||||
|
return protocols[p_protocol](p_protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorDebuggerServer::register_protocol_handler(const String &p_protocol, CreateServerFunc p_func) {
|
||||||
|
ERR_FAIL_COND(protocols.has(p_protocol));
|
||||||
|
protocols[p_protocol] = p_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorDebuggerServer::initialize() {
|
||||||
|
register_protocol_handler("tcp://", EditorDebuggerServerTCP::create);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditorDebuggerServer::deinitialize() {
|
||||||
|
protocols.clear();
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,17 @@
|
|||||||
class EditorDebuggerServer : public Reference {
|
class EditorDebuggerServer : public Reference {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static EditorDebuggerServer *create_default();
|
typedef EditorDebuggerServer *(*CreateServerFunc)(const String &p_uri);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static Map<StringName, CreateServerFunc> protocols;
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void initialize();
|
||||||
|
static void deinitialize();
|
||||||
|
|
||||||
|
static void register_protocol_handler(const String &p_protocol, CreateServerFunc p_func);
|
||||||
|
static EditorDebuggerServer *create(const String &p_protocol);
|
||||||
virtual void poll() = 0;
|
virtual void poll() = 0;
|
||||||
virtual Error start() = 0;
|
virtual Error start() = 0;
|
||||||
virtual void stop() = 0;
|
virtual void stop() = 0;
|
||||||
|
@ -846,6 +846,8 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
|||||||
|
|
||||||
if (is_session_active()) {
|
if (is_session_active()) {
|
||||||
|
|
||||||
|
peer->poll();
|
||||||
|
|
||||||
if (camera_override == CameraOverride::OVERRIDE_2D) {
|
if (camera_override == CameraOverride::OVERRIDE_2D) {
|
||||||
CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
|
CanvasItemEditor *editor = CanvasItemEditor::get_singleton();
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ void EditorExportPlatform::gen_debug_flags(Vector<String> &r_flags, int p_flags)
|
|||||||
|
|
||||||
r_flags.push_back("--remote-debug");
|
r_flags.push_back("--remote-debug");
|
||||||
|
|
||||||
r_flags.push_back(host + ":" + String::num(remote_port));
|
r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
|
||||||
|
|
||||||
List<String> breakpoints;
|
List<String> breakpoints;
|
||||||
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
|
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
|
||||||
@ -1127,7 +1127,7 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
|
|||||||
|
|
||||||
r_flags.push_back("--remote-debug");
|
r_flags.push_back("--remote-debug");
|
||||||
|
|
||||||
r_flags.push_back(host + ":" + String::num(remote_port));
|
r_flags.push_back(get_debug_protocol() + host + ":" + String::num(remote_port));
|
||||||
|
|
||||||
List<String> breakpoints;
|
List<String> breakpoints;
|
||||||
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
|
ScriptEditor::get_singleton()->get_breakpoints(&breakpoints);
|
||||||
|
@ -270,6 +270,7 @@ public:
|
|||||||
virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
virtual Error export_zip(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0);
|
||||||
virtual void get_platform_features(List<String> *r_features) = 0;
|
virtual void get_platform_features(List<String> *r_features) = 0;
|
||||||
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0;
|
virtual void resolve_platform_feature_priorities(const Ref<EditorExportPreset> &p_preset, Set<String> &p_features) = 0;
|
||||||
|
virtual String get_debug_protocol() const { return "tcp://"; }
|
||||||
|
|
||||||
EditorExportPlatform();
|
EditorExportPlatform();
|
||||||
};
|
};
|
||||||
|
@ -2072,9 +2072,11 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||||||
args = ProjectSettings::get_singleton()->get("editor/main_run_args");
|
args = ProjectSettings::get_singleton()->get("editor/main_run_args");
|
||||||
skip_breakpoints = EditorDebuggerNode::get_singleton()->is_skip_breakpoints();
|
skip_breakpoints = EditorDebuggerNode::get_singleton()->is_skip_breakpoints();
|
||||||
|
|
||||||
|
EditorDebuggerNode::get_singleton()->start();
|
||||||
Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
|
Error error = editor_run.run(run_filename, args, breakpoints, skip_breakpoints);
|
||||||
if (error != OK) {
|
if (error != OK) {
|
||||||
|
|
||||||
|
EditorDebuggerNode::get_singleton()->stop();
|
||||||
show_accept(TTR("Could not start subprocess!"), TTR("OK"));
|
show_accept(TTR("Could not start subprocess!"), TTR("OK"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2096,6 +2098,24 @@ void EditorNode::_run(bool p_current, const String &p_custom) {
|
|||||||
_playing_edited = p_current;
|
_playing_edited = p_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_run_native(const Ref<EditorExportPreset> &p_preset) {
|
||||||
|
|
||||||
|
bool autosave = EDITOR_GET("run/auto_save/save_before_running");
|
||||||
|
if (autosave) {
|
||||||
|
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
|
||||||
|
}
|
||||||
|
if (run_native->is_deploy_debug_remote_enabled()) {
|
||||||
|
_menu_option_confirm(RUN_STOP, true);
|
||||||
|
|
||||||
|
if (!call_build())
|
||||||
|
return; // build failed
|
||||||
|
|
||||||
|
EditorDebuggerNode::get_singleton()->start(p_preset->get_platform()->get_debug_protocol());
|
||||||
|
emit_signal("play_pressed");
|
||||||
|
editor_run.run_native_notify();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
||||||
|
|
||||||
if (!p_confirmed) //this may be a hack..
|
if (!p_confirmed) //this may be a hack..
|
||||||
@ -2464,6 +2484,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EditorDebuggerNode::get_singleton()->stop();
|
||||||
emit_signal("stop_pressed");
|
emit_signal("stop_pressed");
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
@ -2482,22 +2503,6 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
|
|||||||
_run(true);
|
_run(true);
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
case RUN_PLAY_NATIVE: {
|
|
||||||
|
|
||||||
bool autosave = EDITOR_GET("run/auto_save/save_before_running");
|
|
||||||
if (autosave) {
|
|
||||||
_menu_option_confirm(FILE_SAVE_ALL_SCENES, false);
|
|
||||||
}
|
|
||||||
if (run_native->is_deploy_debug_remote_enabled()) {
|
|
||||||
_menu_option_confirm(RUN_STOP, true);
|
|
||||||
|
|
||||||
if (!call_build())
|
|
||||||
break; // build failed
|
|
||||||
|
|
||||||
emit_signal("play_pressed");
|
|
||||||
editor_run.run_native_notify();
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case RUN_SCENE_SETTINGS: {
|
case RUN_SCENE_SETTINGS: {
|
||||||
|
|
||||||
run_settings_dialog->popup_run_settings();
|
run_settings_dialog->popup_run_settings();
|
||||||
@ -6346,7 +6351,7 @@ EditorNode::EditorNode() {
|
|||||||
|
|
||||||
run_native = memnew(EditorRunNative);
|
run_native = memnew(EditorRunNative);
|
||||||
play_hb->add_child(run_native);
|
play_hb->add_child(run_native);
|
||||||
run_native->connect("native_run", callable_mp(this, &EditorNode::_menu_option), varray(RUN_PLAY_NATIVE));
|
run_native->connect("native_run", callable_mp(this, &EditorNode::_run_native));
|
||||||
|
|
||||||
play_scene_button = memnew(ToolButton);
|
play_scene_button = memnew(ToolButton);
|
||||||
play_hb->add_child(play_scene_button);
|
play_hb->add_child(play_scene_button);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#define EDITOR_NODE_H
|
#define EDITOR_NODE_H
|
||||||
|
|
||||||
#include "editor/editor_data.h"
|
#include "editor/editor_data.h"
|
||||||
|
#include "editor/editor_export.h"
|
||||||
#include "editor/editor_folding.h"
|
#include "editor/editor_folding.h"
|
||||||
#include "editor/editor_run.h"
|
#include "editor/editor_run.h"
|
||||||
#include "editor/inspector_dock.h"
|
#include "editor/inspector_dock.h"
|
||||||
@ -161,7 +162,6 @@ private:
|
|||||||
|
|
||||||
RUN_STOP,
|
RUN_STOP,
|
||||||
RUN_PLAY_SCENE,
|
RUN_PLAY_SCENE,
|
||||||
RUN_PLAY_NATIVE,
|
|
||||||
RUN_PLAY_CUSTOM_SCENE,
|
RUN_PLAY_CUSTOM_SCENE,
|
||||||
RUN_SCENE_SETTINGS,
|
RUN_SCENE_SETTINGS,
|
||||||
RUN_SETTINGS,
|
RUN_SETTINGS,
|
||||||
@ -492,6 +492,7 @@ private:
|
|||||||
void _quick_run();
|
void _quick_run();
|
||||||
|
|
||||||
void _run(bool p_current = false, const String &p_custom = "");
|
void _run(bool p_current = false, const String &p_custom = "");
|
||||||
|
void _run_native(const Ref<EditorExportPreset> &p_preset);
|
||||||
|
|
||||||
void _save_optimized();
|
void _save_optimized();
|
||||||
void _import_action(const String &p_action);
|
void _import_action(const String &p_action);
|
||||||
|
@ -53,7 +53,7 @@ Error EditorRun::run(const String &p_scene, const String &p_custom_args, const L
|
|||||||
}
|
}
|
||||||
|
|
||||||
args.push_back("--remote-debug");
|
args.push_back("--remote-debug");
|
||||||
args.push_back(remote_host + ":" + String::num(remote_port));
|
args.push_back("tcp://" + remote_host + ":" + String::num(remote_port));
|
||||||
|
|
||||||
args.push_back("--allow_focus_steal_pid");
|
args.push_back("--allow_focus_steal_pid");
|
||||||
args.push_back(itos(OS::get_singleton()->get_process_id()));
|
args.push_back(itos(OS::get_singleton()->get_process_id()));
|
||||||
|
@ -133,7 +133,7 @@ void EditorRunNative::_run_native(int p_idx, int p_platform) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit_signal("native_run");
|
emit_signal("native_run", preset);
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ void EditorRunNative::resume_run_native() {
|
|||||||
|
|
||||||
void EditorRunNative::_bind_methods() {
|
void EditorRunNative::_bind_methods() {
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("native_run"));
|
ADD_SIGNAL(MethodInfo("native_run", PropertyInfo(Variant::OBJECT, "preset", PROPERTY_HINT_RESOURCE_TYPE, "EditorExportPreset")));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditorRunNative::is_deploy_debug_remote_enabled() const {
|
bool EditorRunNative::is_deploy_debug_remote_enabled() const {
|
||||||
|
@ -32,11 +32,14 @@
|
|||||||
|
|
||||||
#include "core/os/keyboard.h"
|
#include "core/os/keyboard.h"
|
||||||
#include "editor/debugger/editor_debugger_node.h"
|
#include "editor/debugger/editor_debugger_node.h"
|
||||||
|
#include "editor/debugger/editor_debugger_server.h"
|
||||||
#include "editor/editor_node.h"
|
#include "editor/editor_node.h"
|
||||||
#include "editor/fileserver/editor_file_server.h"
|
#include "editor/fileserver/editor_file_server.h"
|
||||||
#include "scene/gui/menu_button.h"
|
#include "scene/gui/menu_button.h"
|
||||||
|
|
||||||
DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_debug_menu) {
|
DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_debug_menu) {
|
||||||
|
EditorDebuggerServer::initialize();
|
||||||
|
|
||||||
ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11);
|
ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11);
|
||||||
ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10);
|
ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10);
|
||||||
ED_SHORTCUT("debugger/break", TTR("Break"));
|
ED_SHORTCUT("debugger/break", TTR("Break"));
|
||||||
@ -96,6 +99,7 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(EditorNode *p_editor, MenuButton *p_d
|
|||||||
}
|
}
|
||||||
|
|
||||||
DebuggerEditorPlugin::~DebuggerEditorPlugin() {
|
DebuggerEditorPlugin::~DebuggerEditorPlugin() {
|
||||||
|
EditorDebuggerServer::deinitialize();
|
||||||
memdelete(file_server);
|
memdelete(file_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ void Main::print_help(const char *p_binary) {
|
|||||||
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
|
OS::get_singleton()->print(" -b, --breakpoints Breakpoint list as source::line comma-separated pairs, no spaces (use %%20 instead).\n");
|
||||||
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
|
OS::get_singleton()->print(" --profiling Enable profiling in the script debugger.\n");
|
||||||
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
|
OS::get_singleton()->print(" --gpu-abort Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.\n");
|
||||||
OS::get_singleton()->print(" --remote-debug <address> Remote debug (<host/IP>:<port> address).\n");
|
OS::get_singleton()->print(" --remote-debug <uri> Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).\n");
|
||||||
#if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED)
|
#if defined(DEBUG_ENABLED) && !defined(SERVER_ENABLED)
|
||||||
OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n");
|
OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n");
|
||||||
OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n");
|
OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n");
|
||||||
@ -844,11 +844,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
|||||||
if (I->next()) {
|
if (I->next()) {
|
||||||
|
|
||||||
debug_uri = I->next()->get();
|
debug_uri = I->next()->get();
|
||||||
if (debug_uri.find(":") == -1) { // wrong address
|
if (debug_uri.find("://") == -1) { // wrong address
|
||||||
OS::get_singleton()->print("Invalid debug host address, it should be of the form <host/IP>:<port>.\n");
|
OS::get_singleton()->print("Invalid debug host address, it should be of the form <protocol>://<host/IP>:<port>.\n");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
debug_uri = "tcp://" + debug_uri; // will support multiple protocols eventually.
|
|
||||||
N = I->next()->next();
|
N = I->next()->next();
|
||||||
} else {
|
} else {
|
||||||
OS::get_singleton()->print("Missing remote debug host address, aborting.\n");
|
OS::get_singleton()->print("Missing remote debug host address, aborting.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user