diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-09 19:08:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 19:08:07 +0100 |
commit | 478337c412f767b908820d7bb56c786bf0b909cb (patch) | |
tree | 019ee1871f24bed0b9c56391830a48583dd15a54 /editor | |
parent | 640169da5b20538c2d5c1106957461a3c988e2bc (diff) | |
parent | 3b47eb51e4025fae6dd63eb405dee54c49281a5f (diff) |
Merge pull request #36751 from Faless/debugger/threads_and_profilers
ScriptDebugger refactor, threading, profilers.
Diffstat (limited to 'editor')
16 files changed, 378 insertions, 252 deletions
diff --git a/editor/debugger/editor_debugger_inspector.cpp b/editor/debugger/editor_debugger_inspector.cpp index 1506d64b63..9587daf93e 100644 --- a/editor/debugger/editor_debugger_inspector.cpp +++ b/editor/debugger/editor_debugger_inspector.cpp @@ -30,8 +30,8 @@ #include "editor_debugger_inspector.h" +#include "core/debugger/debugger_marshalls.h" #include "core/io/marshalls.h" -#include "core/script_debugger_remote.h" #include "editor/editor_node.h" #include "scene/debugger/scene_debugger.h" @@ -226,7 +226,7 @@ Object *EditorDebuggerInspector::get_object(ObjectID p_id) { void EditorDebuggerInspector::add_stack_variable(const Array &p_array) { - ScriptDebuggerRemote::ScriptStackVariable var; + DebuggerMarshalls::ScriptStackVariable var; var.deserialize(p_array); String n = var.name; Variant v = var.value; diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index fba86f2954..f4a8102b79 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -31,9 +31,12 @@ #include "editor_debugger_node.h" #include "editor/debugger/editor_debugger_tree.h" +#include "editor/debugger/script_editor_debugger.h" #include "editor/editor_log.h" #include "editor/editor_node.h" #include "editor/plugins/script_editor_plugin.h" +#include "scene/gui/menu_button.h" +#include "scene/gui/tab_container.h" template <typename Func> void _for_all(TabContainer *p_node, const Func &p_func) { @@ -49,7 +52,6 @@ EditorDebuggerNode *EditorDebuggerNode::singleton = NULL; EditorDebuggerNode::EditorDebuggerNode() { if (!singleton) singleton = this; - server.instance(); add_constant_override("margin_left", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_LEFT)); add_constant_override("margin_right", -EditorNode::get_singleton()->get_gui_base()->get_stylebox("BottomPanelDebuggerOverride", "EditorStyles")->get_margin(MARGIN_RIGHT)); @@ -179,10 +181,9 @@ Error EditorDebuggerNode::start() { EditorNode::get_singleton()->make_bottom_panel_item_visible(this); } - int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); - const Error err = server->listen(remote_port); + server = Ref<EditorDebuggerServer>(EditorDebuggerServer::create_default()); + const Error err = server->start(); if (err != OK) { - EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), EditorLog::MSG_TYPE_ERROR); return err; } set_process(true); @@ -191,9 +192,10 @@ Error EditorDebuggerNode::start() { } void EditorDebuggerNode::stop() { - if (server->is_listening()) { + if (server.is_valid()) { server->stop(); EditorNode::get_log()->add_message("--- Debugging process stopped ---", EditorLog::MSG_TYPE_EDITOR); + server.unref(); } // Also close all debugging sessions. _for_all(tabs, [&](ScriptEditorDebugger *dbg) { @@ -231,9 +233,15 @@ void EditorDebuggerNode::_notification(int p_what) { break; } - if (p_what != NOTIFICATION_PROCESS || !server->is_listening()) + if (p_what != NOTIFICATION_PROCESS || !server.is_valid()) return; + if (!server.is_valid() || !server->is_active()) { + stop(); + return; + } + server->poll(); + // Errors and warnings int error_count = 0; int warning_count = 0; @@ -293,9 +301,8 @@ void EditorDebuggerNode::_notification(int p_what) { if (tabs->get_tab_count() <= 4) { // Max 4 debugging sessions active. debugger = _add_debugger(); } else { - // We already have too many sessions, disconnecting new clients to prevent it from hanging. - // (Not keeping a reference to the connection will disconnect it) - server->take_connection(); + // We already have too many sessions, disconnecting new clients to prevent them from hanging. + server->take_connection()->close(); return; // Can't add, stop here. } } @@ -462,6 +469,26 @@ void EditorDebuggerNode::reload_scripts() { }); } +void EditorDebuggerNode::debug_next() { + get_default_debugger()->debug_next(); +} + +void EditorDebuggerNode::debug_step() { + get_default_debugger()->debug_step(); +} + +void EditorDebuggerNode::debug_break() { + get_default_debugger()->debug_break(); +} + +void EditorDebuggerNode::debug_continue() { + get_default_debugger()->debug_continue(); +} + +String EditorDebuggerNode::get_var_value(const String &p_var) const { + return get_default_debugger()->get_var_value(p_var); +} + // LiveEdit/Inspector void EditorDebuggerNode::request_remote_tree() { get_current_debugger()->request_remote_tree(); diff --git a/editor/debugger/editor_debugger_node.h b/editor/debugger/editor_debugger_node.h index 13a1d6dcb3..6181ccdb5f 100644 --- a/editor/debugger/editor_debugger_node.h +++ b/editor/debugger/editor_debugger_node.h @@ -31,17 +31,30 @@ #ifndef EDITOR_DEBUGGER_NODE_H #define EDITOR_DEBUGGER_NODE_H -#include "core/io/tcp_server.h" -#include "editor/debugger/script_editor_debugger.h" -#include "scene/gui/button.h" -#include "scene/gui/tab_container.h" +#include "editor/debugger/editor_debugger_server.h" +#include "scene/gui/margin_container.h" +class Button; class EditorDebuggerTree; +class EditorDebuggerRemoteObject; +class MenuButton; +class ScriptEditorDebugger; +class TabContainer; class EditorDebuggerNode : public MarginContainer { GDCLASS(EditorDebuggerNode, MarginContainer); +public: + enum CameraOverride { + OVERRIDE_NONE, + OVERRIDE_2D, + OVERRIDE_3D_1, // 3D Viewport 1 + OVERRIDE_3D_2, // 3D Viewport 2 + OVERRIDE_3D_3, // 3D Viewport 3 + OVERRIDE_3D_4 // 3D Viewport 4 + }; + private: enum Options { DEBUG_NEXT, @@ -71,7 +84,7 @@ private: } }; - Ref<TCP_Server> server = NULL; + Ref<EditorDebuggerServer> server; TabContainer *tabs = NULL; Button *debugger_button = NULL; MenuButton *script_menu = NULL; @@ -87,7 +100,7 @@ private: bool auto_switch_remote_scene_tree = false; bool debug_with_external_editor = false; bool hide_on_stop = true; - ScriptEditorDebugger::CameraOverride camera_override = ScriptEditorDebugger::OVERRIDE_NONE; + CameraOverride camera_override = OVERRIDE_NONE; Map<Breakpoint, bool> breakpoints; ScriptEditorDebugger *_add_debugger(); @@ -130,10 +143,10 @@ public: ScriptEditorDebugger *get_default_debugger() const; ScriptEditorDebugger *get_debugger(int p_debugger) const; - void debug_next() { get_default_debugger()->debug_next(); } - void debug_step() { get_default_debugger()->debug_step(); } - void debug_break() { get_default_debugger()->debug_break(); } - void debug_continue() { get_default_debugger()->debug_continue(); } + void debug_next(); + void debug_step(); + void debug_break(); + void debug_continue(); void set_script_debug_button(MenuButton *p_button); @@ -141,7 +154,7 @@ public: debugger_button = p_button; } - String get_var_value(const String &p_var) const { return get_default_debugger()->get_var_value(p_var); } + String get_var_value(const String &p_var) const; Ref<Script> get_dump_stack_script() const { return stack_script; } // Why do we need this? bool get_debug_with_external_editor() { return debug_with_external_editor; } @@ -167,8 +180,8 @@ public: void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos); // Camera - void set_camera_override(ScriptEditorDebugger::CameraOverride p_override) { camera_override = p_override; } - ScriptEditorDebugger::CameraOverride get_camera_override() { return camera_override; } + void set_camera_override(CameraOverride p_override) { camera_override = p_override; } + CameraOverride get_camera_override() { return camera_override; } Error start(); diff --git a/editor/debugger/editor_debugger_server.cpp b/editor/debugger/editor_debugger_server.cpp new file mode 100644 index 0000000000..c80988a662 --- /dev/null +++ b/editor/debugger/editor_debugger_server.cpp @@ -0,0 +1,90 @@ +/*************************************************************************/ +/* editor_debugger_server.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "editor_debugger_server.h" + +#include "core/io/marshalls.h" +#include "core/io/tcp_server.h" +#include "core/os/mutex.h" +#include "core/os/thread.h" +#include "editor/editor_log.h" +#include "editor/editor_node.h" +#include "editor/editor_settings.h" + +class EditorDebuggerServerTCP : public EditorDebuggerServer { + +private: + Ref<TCP_Server> server; + +public: + virtual void poll() {} + virtual Error start(); + virtual void stop(); + virtual bool is_active() const; + virtual bool is_connection_available() const; + virtual Ref<RemoteDebuggerPeer> take_connection(); + + EditorDebuggerServerTCP(); +}; + +EditorDebuggerServerTCP::EditorDebuggerServerTCP() { + server.instance(); +} + +Error EditorDebuggerServerTCP::start() { + int remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + const Error err = server->listen(remote_port); + if (err != OK) { + EditorNode::get_log()->add_message(String("Error listening on port ") + itos(remote_port), EditorLog::MSG_TYPE_ERROR); + return err; + } + return err; +} + +void EditorDebuggerServerTCP::stop() { + server->stop(); +} + +bool EditorDebuggerServerTCP::is_active() const { + return server->is_listening(); +} + +bool EditorDebuggerServerTCP::is_connection_available() const { + return server->is_listening() && server->is_connection_available(); +} + +Ref<RemoteDebuggerPeer> EditorDebuggerServerTCP::take_connection() { + ERR_FAIL_COND_V(!is_connection_available(), Ref<RemoteDebuggerPeer>()); + return memnew(RemoteDebuggerPeerTCP(server->take_connection())); +} + +EditorDebuggerServer *EditorDebuggerServer::create_default() { + return memnew(EditorDebuggerServerTCP); +} diff --git a/editor/debugger/editor_debugger_server.h b/editor/debugger/editor_debugger_server.h new file mode 100644 index 0000000000..e9798c90b3 --- /dev/null +++ b/editor/debugger/editor_debugger_server.h @@ -0,0 +1,49 @@ +/*************************************************************************/ +/* editor_debugger_server.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef EDITOR_DEBUGGER_CONNECTION_H +#define EDITOR_DEBUGGER_CONNECTION_H + +#include "core/debugger/remote_debugger_peer.h" +#include "core/reference.h" + +class EditorDebuggerServer : public Reference { + +public: + static EditorDebuggerServer *create_default(); + virtual void poll() = 0; + virtual Error start() = 0; + virtual void stop() = 0; + virtual bool is_active() const = 0; + virtual bool is_connection_available() const = 0; + virtual Ref<RemoteDebuggerPeer> take_connection() = 0; +}; + +#endif // EDITOR_DEBUGGER_CONNECTION_H diff --git a/editor/editor_network_profiler.cpp b/editor/debugger/editor_network_profiler.cpp index a9ef21bb87..21ef66d1aa 100644 --- a/editor/editor_network_profiler.cpp +++ b/editor/debugger/editor_network_profiler.cpp @@ -31,8 +31,8 @@ #include "editor_network_profiler.h" #include "core/os/os.h" -#include "editor_scale.h" -#include "editor_settings.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" void EditorNetworkProfiler::_bind_methods() { ADD_SIGNAL(MethodInfo("enable_profiling", PropertyInfo(Variant::BOOL, "enable"))); @@ -58,7 +58,7 @@ void EditorNetworkProfiler::_update_frame() { TreeItem *root = counters_display->create_item(); - for (Map<ObjectID, MultiplayerAPI::ProfilingInfo>::Element *E = nodes_data.front(); E; E = E->next()) { + for (Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo>::Element *E = nodes_data.front(); E; E = E->next()) { TreeItem *node = counters_display->create_item(root); @@ -95,7 +95,7 @@ void EditorNetworkProfiler::_clear_pressed() { } } -void EditorNetworkProfiler::add_node_frame_data(const MultiplayerAPI::ProfilingInfo p_frame) { +void EditorNetworkProfiler::add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame) { if (!nodes_data.has(p_frame.node)) { nodes_data.insert(p_frame.node, p_frame); diff --git a/editor/editor_network_profiler.h b/editor/debugger/editor_network_profiler.h index 680131c288..f532dc5dd0 100644 --- a/editor/editor_network_profiler.h +++ b/editor/debugger/editor_network_profiler.h @@ -31,6 +31,7 @@ #ifndef EDITORNETWORKPROFILER_H #define EDITORNETWORKPROFILER_H +#include "core/debugger/debugger_marshalls.h" #include "scene/gui/box_container.h" #include "scene/gui/button.h" #include "scene/gui/label.h" @@ -50,7 +51,7 @@ private: Timer *frame_delay; - Map<ObjectID, MultiplayerAPI::ProfilingInfo> nodes_data; + Map<ObjectID, DebuggerMarshalls::MultiplayerNodeInfo> nodes_data; void _update_frame(); @@ -62,7 +63,7 @@ protected: static void _bind_methods(); public: - void add_node_frame_data(const MultiplayerAPI::ProfilingInfo p_frame); + void add_node_frame_data(const DebuggerMarshalls::MultiplayerNodeInfo p_frame); void set_bandwidth(int p_incoming, int p_outgoing); bool is_profiling(); diff --git a/editor/editor_profiler.cpp b/editor/debugger/editor_profiler.cpp index 64b633e656..2f3ad210b2 100644 --- a/editor/editor_profiler.cpp +++ b/editor/debugger/editor_profiler.cpp @@ -31,8 +31,8 @@ #include "editor_profiler.h" #include "core/os/os.h" -#include "editor_scale.h" -#include "editor_settings.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" void EditorProfiler::_make_metric_ptrs(Metric &m) { diff --git a/editor/editor_profiler.h b/editor/debugger/editor_profiler.h index 0a442ddd5c..0a442ddd5c 100644 --- a/editor/editor_profiler.h +++ b/editor/debugger/editor_profiler.h diff --git a/editor/editor_visual_profiler.cpp b/editor/debugger/editor_visual_profiler.cpp index e9638148e2..52aa418922 100644 --- a/editor/editor_visual_profiler.cpp +++ b/editor/debugger/editor_visual_profiler.cpp @@ -31,8 +31,8 @@ #include "editor_visual_profiler.h" #include "core/os/os.h" -#include "editor_scale.h" -#include "editor_settings.h" +#include "editor/editor_scale.h" +#include "editor/editor_settings.h" void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) { diff --git a/editor/editor_visual_profiler.h b/editor/debugger/editor_visual_profiler.h index 5194c08b96..5194c08b96 100644 --- a/editor/editor_visual_profiler.h +++ b/editor/debugger/editor_visual_profiler.h diff --git a/editor/debugger/script_editor_debugger.cpp b/editor/debugger/script_editor_debugger.cpp index 169ff61e71..920f4d858a 100644 --- a/editor/debugger/script_editor_debugger.cpp +++ b/editor/debugger/script_editor_debugger.cpp @@ -30,21 +30,22 @@ #include "script_editor_debugger.h" +#include "core/debugger/debugger_marshalls.h" #include "core/io/marshalls.h" #include "core/project_settings.h" -#include "core/script_debugger_remote.h" #include "core/ustring.h" +#include "editor/debugger/editor_network_profiler.h" +#include "editor/debugger/editor_profiler.h" +#include "editor/debugger/editor_visual_profiler.h" #include "editor/editor_log.h" -#include "editor/editor_network_profiler.h" #include "editor/editor_node.h" -#include "editor/editor_profiler.h" #include "editor/editor_scale.h" #include "editor/editor_settings.h" -#include "editor/editor_visual_profiler.h" #include "editor/plugins/canvas_item_editor_plugin.h" #include "editor/plugins/spatial_editor_plugin.h" #include "editor/property_editor.h" #include "main/performance.h" +#include "scene/3d/camera.h" #include "scene/debugger/scene_debugger.h" #include "scene/gui/dialogs.h" #include "scene/gui/label.h" @@ -58,12 +59,14 @@ #include "scene/gui/tree.h" #include "scene/resources/packed_scene.h" +using CameraOverride = EditorDebuggerNode::CameraOverride; + void ScriptEditorDebugger::_put_msg(String p_message, Array p_data) { if (is_session_active()) { Array msg; msg.push_back(p_message); msg.push_back(p_data); - ppeer->put_var(msg); + peer->put_message(msg); } } @@ -141,7 +144,7 @@ void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) { Array msg; msg.push_back(p_id); msg.push_back(p_file); - _put_msg("save_node", msg); + _put_msg("scene:save_node", msg); } void ScriptEditorDebugger::_file_selected(const String &p_file) { @@ -183,7 +186,7 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) { void ScriptEditorDebugger::request_remote_tree() { - _put_msg("request_scene_tree", Array()); + _put_msg("scene:request_scene_tree", Array()); } const SceneDebuggerTree *ScriptEditorDebugger::get_remote_tree() { @@ -196,7 +199,7 @@ void ScriptEditorDebugger::update_remote_object(ObjectID p_obj_id, const String msg.push_back(p_obj_id); msg.push_back(p_prop); msg.push_back(p_value); - _put_msg("set_object_property", msg); + _put_msg("scene:set_object_property", msg); } void ScriptEditorDebugger::request_remote_object(ObjectID p_obj_id) { @@ -204,7 +207,7 @@ void ScriptEditorDebugger::request_remote_object(ObjectID p_obj_id) { ERR_FAIL_COND(p_obj_id.is_null()); Array msg; msg.push_back(p_obj_id); - _put_msg("inspect_object", msg); + _put_msg("scene:inspect_object", msg); } Object *ScriptEditorDebugger::get_remote_object(ObjectID p_id) { @@ -226,7 +229,7 @@ void ScriptEditorDebugger::_remote_object_property_updated(ObjectID p_id, const void ScriptEditorDebugger::_video_mem_request() { - _put_msg("request_video_mem", Array()); + _put_msg("core:memory", Array()); } Size2 ScriptEditorDebugger::get_minimum_size() const { @@ -267,36 +270,36 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da emit_signal("breaked", false, false); profiler->set_enabled(true); profiler->disable_seeking(); - } else if (p_msg == "message:set_pid") { + } else if (p_msg == "set_pid") { ERR_FAIL_COND(p_data.size() < 1); remote_pid = p_data[0]; - } else if (p_msg == "message:click_ctrl") { + } else if (p_msg == "scene:click_ctrl") { ERR_FAIL_COND(p_data.size() < 2); clicked_ctrl->set_text(p_data[0]); clicked_ctrl_type->set_text(p_data[1]); - } else if (p_msg == "message:scene_tree") { + } else if (p_msg == "scene:scene_tree") { scene_tree->nodes.clear(); scene_tree->deserialize(p_data); emit_signal("remote_tree_updated"); _update_buttons_state(); - } else if (p_msg == "message:inspect_object") { + } else if (p_msg == "scene:inspect_object") { ObjectID id = inspector->add_object(p_data); if (id.is_valid()) emit_signal("remote_object_updated", id); - } else if (p_msg == "message:video_mem") { + } else if (p_msg == "memory:usage") { vmem_tree->clear(); TreeItem *root = vmem_tree->create_item(); - ScriptDebuggerRemote::ResourceUsage usage; + DebuggerMarshalls::ResourceUsage usage; usage.deserialize(p_data); int total = 0; - for (List<ScriptDebuggerRemote::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { + for (List<DebuggerMarshalls::ResourceInfo>::Element *E = usage.infos.front(); E; E = E->next()) { TreeItem *it = vmem_tree->create_item(root); String type = E->get().type; @@ -316,7 +319,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "stack_dump") { - ScriptDebuggerRemote::ScriptStackDump stack; + DebuggerMarshalls::ScriptStackDump stack; stack.deserialize(p_data); stack_dump->clear(); @@ -349,10 +352,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da } else if (p_msg == "output") { ERR_FAIL_COND(p_data.size() < 1); - String t = p_data[0]; - EditorNode::get_log()->add_message(t); - - } else if (p_msg == "performance") { + ERR_FAIL_COND(p_data[0].get_type() != Variant::PACKED_STRING_ARRAY); + Vector<String> strings = p_data[0]; + EditorNode::get_log()->add_message(String("\n").join(strings)); + } else if (p_msg == "performance:profile_frame") { Vector<float> p; p.resize(p_data.size()); for (int i = 0; i < p_data.size(); i++) { @@ -385,36 +388,28 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da perf_history.push_front(p); perf_draw->update(); - } else if (p_msg == "visual_profile") { - // TODO check me. - uint64_t frame = p_data[0]; - Vector<String> names = p_data[1]; - Vector<real_t> values = p_data[2]; + } else if (p_msg == "visual:profile_frame") { + DebuggerMarshalls::VisualProfilerFrame frame; + frame.deserialize(p_data); EditorVisualProfiler::Metric metric; - metric.areas.resize(names.size()); - metric.frame_number = frame; + metric.areas.resize(frame.areas.size()); + metric.frame_number = frame.frame_number; metric.valid = true; { EditorVisualProfiler::Metric::Area *areas_ptr = metric.areas.ptrw(); - int metric_count = names.size(); - - const String *rs = names.ptr(); - const real_t *rr = values.ptr(); - - for (int i = 0; i < metric_count; i++) { - - areas_ptr[i].name = rs[i]; - areas_ptr[i].cpu_time = rr[i * 2 + 0]; - areas_ptr[i].gpu_time = rr[i * 2 + 1]; + for (int i = 0; i < frame.areas.size(); i++) { + areas_ptr[i].name = frame.areas[i].name; + areas_ptr[i].cpu_time = frame.areas[i].cpu_msec; + areas_ptr[i].gpu_time = frame.areas[i].gpu_msec; } } visual_profiler->add_frame_metric(metric); } else if (p_msg == "error") { - ScriptDebuggerRemote::OutputError oe; + DebuggerMarshalls::OutputError oe; ERR_FAIL_COND_MSG(oe.deserialize(p_data) == false, "Failed to deserialize error message"); // Format time. @@ -520,15 +515,15 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da else error_count++; - } else if (p_msg == "profile_sig") { + } else if (p_msg == "servers:function_signature") { // Cache a profiler signature. - ScriptDebuggerRemote::ProfilerSignature sig; + DebuggerMarshalls::ScriptFunctionSignature sig; sig.deserialize(p_data); profiler_signature[sig.id] = sig.name; - } else if (p_msg == "profile_frame" || p_msg == "profile_total") { + } else if (p_msg == "servers:profile_frame" || p_msg == "servers:profile_total") { EditorProfiler::Metric metric; - ScriptDebuggerRemote::ProfilerFrame frame; + DebuggerMarshalls::ServersProfilerFrame frame; frame.deserialize(p_data); metric.valid = true; metric.frame_number = frame.frame_number; @@ -536,10 +531,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da metric.idle_time = frame.idle_time; metric.physics_time = frame.physics_time; metric.physics_frame_time = frame.physics_frame_time; - int frame_data_amount = frame.frames_data.size(); - int frame_function_amount = frame.frame_functions.size(); - if (frame_data_amount) { + if (frame.servers.size()) { EditorProfiler::Metric::Category frame_time; frame_time.signature = "category_frame_time"; frame_time.name = "Frame Time"; @@ -573,42 +566,42 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da metric.categories.push_back(frame_time); } - for (int i = 0; i < frame_data_amount; i++) { + for (int i = 0; i < frame.servers.size(); i++) { + const DebuggerMarshalls::ServerInfo &srv = frame.servers[i]; EditorProfiler::Metric::Category c; - String name = frame.frames_data[i].name; - Array values = frame.frames_data[i].data; + const String name = srv.name; c.name = name.capitalize(); - c.items.resize(values.size() / 2); + c.items.resize(srv.functions.size()); c.total_time = 0; c.signature = "categ::" + name; - for (int j = 0; j < values.size(); j += 2) { + for (int j = 0; j < srv.functions.size(); j++) { EditorProfiler::Metric::Category::Item item; item.calls = 1; item.line = 0; - item.name = values[j]; - item.self = values[j + 1]; + item.name = srv.functions[j].name; + item.self = srv.functions[j].time; item.total = item.self; item.signature = "categ::" + name + "::" + item.name; item.name = item.name.capitalize(); c.total_time += item.total; - c.items.write[j / 2] = item; + c.items.write[j] = item; } metric.categories.push_back(c); } EditorProfiler::Metric::Category funcs; funcs.total_time = frame.script_time; - funcs.items.resize(frame_function_amount); + funcs.items.resize(frame.script_functions.size()); funcs.name = "Script Functions"; funcs.signature = "script_functions"; - for (int i = 0; i < frame_function_amount; i++) { + for (int i = 0; i < frame.script_functions.size(); i++) { - int signature = frame.frame_functions[i].sig_id; - int calls = frame.frame_functions[i].call_count; - float total = frame.frame_functions[i].total_time; - float self = frame.frame_functions[i].self_time; + int signature = frame.script_functions[i].sig_id; + int calls = frame.script_functions[i].call_count; + float total = frame.script_functions[i].total_time; + float self = frame.script_functions[i].self_time; EditorProfiler::Metric::Category::Item item; if (profiler_signature.has(signature)) { @@ -639,24 +632,28 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da metric.categories.push_back(funcs); - if (p_msg == "profile_frame") + if (p_msg == "servers:profile_frame") profiler->add_frame_metric(metric, false); else profiler->add_frame_metric(metric, true); - } else if (p_msg == "network_profile") { - ScriptDebuggerRemote::NetworkProfilerFrame frame; + } else if (p_msg == "network:profile_frame") { + DebuggerMarshalls::NetworkProfilerFrame frame; frame.deserialize(p_data); for (int i = 0; i < frame.infos.size(); i++) { network_profiler->add_node_frame_data(frame.infos[i]); } - } else if (p_msg == "network_bandwidth") { + + } else if (p_msg == "network:bandwidth") { ERR_FAIL_COND(p_data.size() < 2); network_profiler->set_bandwidth(p_data[0], p_data[1]); - } else if (p_msg == "kill_me") { + } else if (p_msg == "request_quit") { emit_signal("stop_requested"); _stop_and_notify(); + + } else { + WARN_PRINT("unknown message " + p_msg); } } @@ -776,7 +773,7 @@ void ScriptEditorDebugger::_notification(int p_what) { if (is_session_active()) { - if (camera_override == OVERRIDE_2D) { + if (camera_override == CameraOverride::OVERRIDE_2D) { CanvasItemEditor *editor = CanvasItemEditor::get_singleton(); Dictionary state = editor->get_state(); @@ -789,10 +786,10 @@ void ScriptEditorDebugger::_notification(int p_what) { Array msg; msg.push_back(transform); - _put_msg("override_camera_2D:transform", msg); + _put_msg("scene:override_camera_2D:transform", msg); - } else if (camera_override >= OVERRIDE_3D_1) { - int viewport_idx = camera_override - OVERRIDE_3D_1; + } else if (camera_override >= CameraOverride::OVERRIDE_3D_1) { + int viewport_idx = camera_override - CameraOverride::OVERRIDE_3D_1; SpatialEditorViewport *viewport = SpatialEditor::get_singleton()->get_editor_viewport(viewport_idx); Camera *const cam = viewport->get_camera(); @@ -807,34 +804,15 @@ void ScriptEditorDebugger::_notification(int p_what) { } msg.push_back(cam->get_znear()); msg.push_back(cam->get_zfar()); - _put_msg("override_camera_3D:transform", msg); + _put_msg("scene:override_camera_3D:transform", msg); } } - if (!is_session_active()) { - _stop_and_notify(); - break; - }; - - if (ppeer->get_available_packet_count() <= 0) { - break; - }; - const uint64_t until = OS::get_singleton()->get_ticks_msec() + 20; - while (ppeer->get_available_packet_count() > 0) { + while (peer->has_message()) { - Variant cmd; - Error ret = ppeer->get_var(cmd); - if (ret != OK) { - _stop_and_notify(); - ERR_FAIL_MSG("Error decoding variant from peer"); - } - if (cmd.get_type() != Variant::ARRAY) { - _stop_and_notify(); - ERR_FAIL_MSG("Invalid message format received from peer"); - } - Array arr = cmd; + Array arr = peer->get_message(); if (arr.size() != 2 || arr[0].get_type() != Variant::STRING || arr[1].get_type() != Variant::ARRAY) { _stop_and_notify(); ERR_FAIL_MSG("Invalid message format received from peer"); @@ -844,6 +822,10 @@ void ScriptEditorDebugger::_notification(int p_what) { if (OS::get_singleton()->get_ticks_msec() > until) break; } + if (!is_session_active()) { + _stop_and_notify(); + break; + }; } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { @@ -875,14 +857,14 @@ void ScriptEditorDebugger::_clear_execution() { inspector->clear_stack_variables(); } -void ScriptEditorDebugger::start(Ref<StreamPeerTCP> p_connection) { +void ScriptEditorDebugger::start(Ref<RemoteDebuggerPeer> p_peer) { error_count = 0; warning_count = 0; stop(); - connection = p_connection; - ppeer->set_stream_peer(connection); + peer = p_peer; + ERR_FAIL_COND(p_peer.is_null()); perf_history.clear(); for (int i = 0; i < Performance::MONITOR_MAX; i++) { @@ -893,19 +875,11 @@ void ScriptEditorDebugger::start(Ref<StreamPeerTCP> p_connection) { set_process(true); breaked = false; can_debug = true; - camera_override = OVERRIDE_NONE; + camera_override = CameraOverride::OVERRIDE_NONE; tabs->set_current_tab(0); _set_reason_text(TTR("Debug session started."), MESSAGE_SUCCESS); _update_buttons_state(); - - if (profiler->is_profiling()) { - _profiler_activate(true); - } - - if (network_profiler->is_profiling()) { - _network_profiler_activate(true); - } } void ScriptEditorDebugger::_update_buttons_state() { @@ -936,10 +910,10 @@ void ScriptEditorDebugger::stop() { _clear_execution(); inspector->clear_cache(); - ppeer->set_stream_peer(Ref<StreamPeer>()); - if (connection.is_valid()) { - connection.unref(); + if (peer.is_valid()) { + peer->close(); + peer.unref(); reason->set_text(""); reason->set_tooltip(""); } @@ -952,49 +926,31 @@ void ScriptEditorDebugger::stop() { _update_buttons_state(); } -void ScriptEditorDebugger::_profiler_activate(bool p_enable) { - - if (p_enable) { - profiler_signature.clear(); - Array msg; - int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions"); - max_funcs = CLAMP(max_funcs, 16, 512); - msg.push_back(max_funcs); - _put_msg("start_profiling", msg); - print_verbose("Starting profiling."); - - } else { - _put_msg("stop_profiling", Array()); - print_verbose("Ending profiling."); - } -} - -void ScriptEditorDebugger::_visual_profiler_activate(bool p_enable) { +void ScriptEditorDebugger::_profiler_activate(bool p_enable, int p_type) { - if (!connection.is_valid()) - return; - - if (p_enable) { - profiler_signature.clear(); - _put_msg("start_visual_profiling", Array()); - print_verbose("Starting visual profiling."); - - } else { - _put_msg("stop_visual_profiling", Array()); - print_verbose("Ending visual profiling."); - } -} - -void ScriptEditorDebugger::_network_profiler_activate(bool p_enable) { - - if (p_enable) { - profiler_signature.clear(); - _put_msg("start_network_profiling", Array()); - print_verbose("Starting network profiling."); - - } else { - _put_msg("stop_network_profiling", Array()); - print_verbose("Ending network profiling."); + Array data; + data.push_back(p_enable); + switch (p_type) { + case PROFILER_NETWORK: + _put_msg("profiler:network", data); + break; + case PROFILER_VISUAL: + _put_msg("profiler:visual", data); + break; + case PROFILER_SCRIPTS_SERVERS: + if (p_enable) { + // Clear old script signatures. (should we move all this into the profiler?) + profiler_signature.clear(); + // Add max funcs options to request. + Array opts; + int max_funcs = EditorSettings::get_singleton()->get("debugger/profiler_frame_max_functions"); + opts.push_back(CLAMP(max_funcs, 16, 512)); + data.push_back(opts); + } + _put_msg("profiler:servers", data); + break; + default: + ERR_FAIL_MSG("Invalid profiler type"); } } @@ -1045,7 +1001,7 @@ int ScriptEditorDebugger::_get_node_path_cache(const NodePath &p_path) { Array msg; msg.push_back(p_path); msg.push_back(last_path_id); - _put_msg("live_node_path", msg); + _put_msg("scene:live_node_path", msg); return last_path_id; } @@ -1063,7 +1019,7 @@ int ScriptEditorDebugger::_get_res_path_cache(const String &p_path) { Array msg; msg.push_back(p_path); msg.push_back(last_path_id); - _put_msg("live_res_path", msg); + _put_msg("scene:live_res_path", msg); return last_path_id; } @@ -1095,7 +1051,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n //no pointers, sorry msg.push_back(*argptr[i]); } - _put_msg("live_node_call", msg); + _put_msg("scene:live_node_call", msg); return; } @@ -1114,7 +1070,7 @@ void ScriptEditorDebugger::_method_changed(Object *p_base, const StringName &p_n //no pointers, sorry msg.push_back(*argptr[i]); } - _put_msg("live_res_call", msg); + _put_msg("scene:live_res_call", msg); return; } @@ -1140,7 +1096,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p msg.push_back(pathid); msg.push_back(p_property); msg.push_back(res->get_path()); - _put_msg("live_node_prop_res", msg); + _put_msg("scene:live_node_prop_res", msg); } } else { @@ -1148,7 +1104,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p msg.push_back(pathid); msg.push_back(p_property); msg.push_back(p_value); - _put_msg("live_node_prop", msg); + _put_msg("scene:live_node_prop", msg); } return; @@ -1169,7 +1125,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p msg.push_back(pathid); msg.push_back(p_property); msg.push_back(res2->get_path()); - _put_msg("live_res_prop_res", msg); + _put_msg("scene:live_res_prop_res", msg); } } else { @@ -1177,7 +1133,7 @@ void ScriptEditorDebugger::_property_changed(Object *p_base, const StringName &p msg.push_back(pathid); msg.push_back(p_property); msg.push_back(p_value); - _put_msg("live_res_prop", msg); + _put_msg("scene:live_res_prop", msg); } return; @@ -1255,7 +1211,7 @@ void ScriptEditorDebugger::update_live_edit_root() { msg.push_back(editor->get_edited_scene()->get_filename()); else msg.push_back(""); - _put_msg("live_set_root", msg); + _put_msg("scene:live_set_root", msg); live_edit_root->set_text(np); } @@ -1266,7 +1222,7 @@ void ScriptEditorDebugger::live_debug_create_node(const NodePath &p_parent, cons msg.push_back(p_parent); msg.push_back(p_type); msg.push_back(p_name); - _put_msg("live_create_node", msg); + _put_msg("scene:live_create_node", msg); } } @@ -1277,7 +1233,7 @@ void ScriptEditorDebugger::live_debug_instance_node(const NodePath &p_parent, co msg.push_back(p_parent); msg.push_back(p_path); msg.push_back(p_name); - _put_msg("live_instance_node", msg); + _put_msg("scene:live_instance_node", msg); } } void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) { @@ -1285,7 +1241,7 @@ void ScriptEditorDebugger::live_debug_remove_node(const NodePath &p_at) { if (live_debug) { Array msg; msg.push_back(p_at); - _put_msg("live_remove_node", msg); + _put_msg("scene:live_remove_node", msg); } } void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, ObjectID p_keep_id) { @@ -1294,7 +1250,7 @@ void ScriptEditorDebugger::live_debug_remove_and_keep_node(const NodePath &p_at, Array msg; msg.push_back(p_at); msg.push_back(p_keep_id); - _put_msg("live_remove_and_keep_node", msg); + _put_msg("scene:live_remove_and_keep_node", msg); } } void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath &p_at, int p_at_pos) { @@ -1304,7 +1260,7 @@ void ScriptEditorDebugger::live_debug_restore_node(ObjectID p_id, const NodePath msg.push_back(p_id); msg.push_back(p_at); msg.push_back(p_at_pos); - _put_msg("live_restore_node", msg); + _put_msg("scene:live_restore_node", msg); } } void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name) { @@ -1313,7 +1269,7 @@ void ScriptEditorDebugger::live_debug_duplicate_node(const NodePath &p_at, const Array msg; msg.push_back(p_at); msg.push_back(p_new_name); - _put_msg("live_duplicate_node", msg); + _put_msg("scene:live_duplicate_node", msg); } } void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos) { @@ -1324,32 +1280,32 @@ void ScriptEditorDebugger::live_debug_reparent_node(const NodePath &p_at, const msg.push_back(p_new_place); msg.push_back(p_new_name); msg.push_back(p_at_pos); - _put_msg("live_reparent_node", msg); + _put_msg("scene:live_reparent_node", msg); } } -ScriptEditorDebugger::CameraOverride ScriptEditorDebugger::get_camera_override() const { +CameraOverride ScriptEditorDebugger::get_camera_override() const { return camera_override; } void ScriptEditorDebugger::set_camera_override(CameraOverride p_override) { - if (p_override == OVERRIDE_2D && camera_override != OVERRIDE_2D) { + if (p_override == CameraOverride::OVERRIDE_2D && camera_override != CameraOverride::OVERRIDE_2D) { Array msg; msg.push_back(true); - _put_msg("override_camera_2D:set", msg); - } else if (p_override != OVERRIDE_2D && camera_override == OVERRIDE_2D) { + _put_msg("scene:override_camera_2D:set", msg); + } else if (p_override != CameraOverride::OVERRIDE_2D && camera_override == CameraOverride::OVERRIDE_2D) { Array msg; msg.push_back(false); - _put_msg("override_camera_2D:set", msg); - } else if (p_override >= OVERRIDE_3D_1 && camera_override < OVERRIDE_3D_1) { + _put_msg("scene:override_camera_2D:set", msg); + } else if (p_override >= CameraOverride::OVERRIDE_3D_1 && camera_override < CameraOverride::OVERRIDE_3D_1) { Array msg; msg.push_back(true); - _put_msg("override_camera_3D:set", msg); - } else if (p_override < OVERRIDE_3D_1 && camera_override >= OVERRIDE_3D_1) { + _put_msg("scene:override_camera_3D:set", msg); + } else if (p_override < CameraOverride::OVERRIDE_3D_1 && camera_override >= CameraOverride::OVERRIDE_3D_1) { Array msg; msg.push_back(false); - _put_msg("override_camera_3D:set", msg); + _put_msg("scene:override_camera_3D:set", msg); } camera_override = p_override; @@ -1423,7 +1379,6 @@ void ScriptEditorDebugger::_clear_errors_list() { error_tree->clear(); error_count = 0; warning_count = 0; - update_tabs(); } // Right click on specific file(s) or folder(s). @@ -1502,8 +1457,6 @@ void ScriptEditorDebugger::_bind_methods() { ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { - ppeer = Ref<PacketPeerStream>(memnew(PacketPeerStream)); - ppeer->set_input_buffer_max_size((1024 * 1024 * 8) - 4); // 8 MiB should be enough, minus 4 bytes for separator. editor = p_editor; tabs = memnew(TabContainer); @@ -1655,7 +1608,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { profiler = memnew(EditorProfiler); profiler->set_name(TTR("Profiler")); tabs->add_child(profiler); - profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate)); + profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_SCRIPTS_SERVERS)); profiler->connect("break_request", callable_mp(this, &ScriptEditorDebugger::_profiler_seeked)); } @@ -1663,14 +1616,14 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { visual_profiler = memnew(EditorVisualProfiler); visual_profiler->set_name(TTR("Visual Profiler")); tabs->add_child(visual_profiler); - visual_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_visual_profiler_activate)); + visual_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_VISUAL)); } { //network profiler network_profiler = memnew(EditorNetworkProfiler); network_profiler->set_name(TTR("Network Profiler")); tabs->add_child(network_profiler); - network_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_network_profiler_activate)); + network_profiler->connect("enable_profiling", callable_mp(this, &ScriptEditorDebugger::_profiler_activate), varray(PROFILER_NETWORK)); } { //monitors @@ -1824,7 +1777,7 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { add_child(msgdialog); live_debug = true; - camera_override = OVERRIDE_NONE; + camera_override = CameraOverride::OVERRIDE_NONE; last_path_id = false; error_count = 0; warning_count = 0; @@ -1833,6 +1786,9 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { ScriptEditorDebugger::~ScriptEditorDebugger() { - ppeer->set_stream_peer(Ref<StreamPeer>()); + if (peer.is_valid()) { + peer->close(); + peer.unref(); + } memdelete(scene_tree); } diff --git a/editor/debugger/script_editor_debugger.h b/editor/debugger/script_editor_debugger.h index fd034ba983..e7ce917543 100644 --- a/editor/debugger/script_editor_debugger.h +++ b/editor/debugger/script_editor_debugger.h @@ -31,14 +31,13 @@ #ifndef SCRIPT_EDITOR_DEBUGGER_H #define SCRIPT_EDITOR_DEBUGGER_H -#include "core/io/packet_peer.h" -#include "core/io/stream_peer_tcp.h" +#include "core/os/os.h" #include "editor/debugger/editor_debugger_inspector.h" -#include "editor/editor_inspector.h" -#include "editor/property_editor.h" -#include "scene/3d/camera.h" -#include "scene/gui/box_container.h" +#include "editor/debugger/editor_debugger_node.h" +#include "editor/debugger/editor_debugger_server.h" +#include "editor/editor_file_dialog.h" #include "scene/gui/button.h" +#include "scene/gui/margin_container.h" class Tree; class EditorNode; @@ -61,16 +60,6 @@ class ScriptEditorDebugger : public MarginContainer { friend class EditorDebuggerNode; -public: - enum CameraOverride { - OVERRIDE_NONE, - OVERRIDE_2D, - OVERRIDE_3D_1, // 3D Viewport 1 - OVERRIDE_3D_2, // 3D Viewport 2 - OVERRIDE_3D_3, // 3D Viewport 3 - OVERRIDE_3D_4 // 3D Viewport 4 - }; - private: enum MessageType { MESSAGE_ERROR, @@ -78,6 +67,12 @@ private: MESSAGE_SUCCESS, }; + enum ProfilerType { + PROFILER_NETWORK, + PROFILER_VISUAL, + PROFILER_SCRIPTS_SERVERS + }; + AcceptDialog *msgdialog; LineEdit *clicked_ctrl; @@ -132,8 +127,7 @@ private: EditorDebuggerInspector *inspector; SceneDebuggerTree *scene_tree; - Ref<StreamPeerTCP> connection; - Ref<PacketPeerStream> ppeer; + Ref<RemoteDebuggerPeer> peer; HashMap<NodePath, int> node_path_cache; int last_path_id; @@ -151,7 +145,7 @@ private: bool live_debug; - CameraOverride camera_override; + EditorDebuggerNode::CameraOverride camera_override; void _performance_draw(); void _performance_select(); @@ -183,12 +177,9 @@ private: void _expand_errors_list(); void _collapse_errors_list(); - void _visual_profiler_activate(bool p_enable); - void _profiler_activate(bool p_enable); + void _profiler_activate(bool p_enable, int p_profiler); void _profiler_seeked(); - void _network_profiler_activate(bool p_enable); - void _clear_errors_list(); void _error_tree_item_rmb_selected(const Vector2 &p_pos); @@ -216,7 +207,7 @@ public: void request_remote_tree(); const SceneDebuggerTree *get_remote_tree(); - void start(Ref<StreamPeerTCP> p_connection); + void start(Ref<RemoteDebuggerPeer> p_peer); void stop(); void debug_skip_breakpoints(); @@ -228,7 +219,7 @@ public: void debug_continue(); bool is_breaked() const { return breaked; } bool is_debuggable() const { return can_debug; } - bool is_session_active() { return connection.is_valid() && connection->is_connected_to_host(); }; + bool is_session_active() { return peer.is_valid() && peer->is_peer_connected(); }; int get_remote_pid() const { return remote_pid; } int get_error_count() const { return error_count; } @@ -252,8 +243,8 @@ public: void live_debug_duplicate_node(const NodePath &p_at, const String &p_new_name); void live_debug_reparent_node(const NodePath &p_at, const NodePath &p_new_place, const String &p_new_name, int p_at_pos); - CameraOverride get_camera_override() const; - void set_camera_override(CameraOverride p_override); + EditorDebuggerNode::CameraOverride get_camera_override() const; + void set_camera_override(EditorDebuggerNode::CameraOverride p_override); void set_breakpoint(const String &p_path, int p_line, bool p_enabled); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index af7f8cf5d6..4bfe633494 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3992,7 +3992,7 @@ void CanvasItemEditor::_notification(int p_what) { if (!is_visible() && override_camera_button->is_pressed()) { EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE); + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); override_camera_button->set_pressed(false); } } @@ -4348,9 +4348,9 @@ void CanvasItemEditor::_button_override_camera(bool p_pressed) { EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); if (p_pressed) { - debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_2D); + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_2D); } else { - debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE); + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); } } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 60bed10351..bb03cad285 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -37,7 +37,6 @@ #include "core/os/os.h" #include "core/project_settings.h" #include "editor/debugger/editor_debugger_node.h" -#include "editor/debugger/script_editor_debugger.h" #include "editor/editor_node.h" #include "editor/editor_run_script.h" #include "editor/editor_scale.h" diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 4b0cbdb4e7..647d64c627 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4773,12 +4773,12 @@ void SpatialEditor::_menu_item_toggled(bool pressed, int p_option) { case MENU_TOOL_OVERRIDE_CAMERA: { EditorDebuggerNode *const debugger = EditorDebuggerNode::get_singleton(); + using Override = EditorDebuggerNode::CameraOverride; if (pressed) { - using Override = ScriptEditorDebugger::CameraOverride; debugger->set_camera_override((Override)(Override::OVERRIDE_3D_1 + camera_override_viewport_id)); } else { - debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE); + debugger->set_camera_override(Override::OVERRIDE_NONE); } } break; @@ -4831,8 +4831,8 @@ void SpatialEditor::_update_camera_override_viewport(Object *p_viewport) { EditorDebuggerNode *const debugger = EditorDebuggerNode::get_singleton(); camera_override_viewport_id = current_viewport->index; - if (debugger->get_camera_override() >= ScriptEditorDebugger::OVERRIDE_3D_1) { - using Override = ScriptEditorDebugger::CameraOverride; + if (debugger->get_camera_override() >= EditorDebuggerNode::OVERRIDE_3D_1) { + using Override = EditorDebuggerNode::CameraOverride; debugger->set_camera_override((Override)(Override::OVERRIDE_3D_1 + camera_override_viewport_id)); } @@ -5789,7 +5789,7 @@ void SpatialEditor::_notification(int p_what) { if (!is_visible() && tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->is_pressed()) { EditorDebuggerNode *debugger = EditorDebuggerNode::get_singleton(); - debugger->set_camera_override(ScriptEditorDebugger::OVERRIDE_NONE); + debugger->set_camera_override(EditorDebuggerNode::OVERRIDE_NONE); tool_option_button[TOOL_OPT_OVERRIDE_CAMERA]->set_pressed(false); } } |