From da2bcda7bec65f8c9bedb0ca3b23fc802b277c9d Mon Sep 17 00:00:00 2001 From: geequlim Date: Mon, 29 May 2017 14:09:16 +0800 Subject: [PATCH] Enhanced debugger. ake 2.1 more productive! Allow access more informations from remote debugger. Refector more debugger related code to allow full access to variables. Array Property Editor now can edit with more objects including remote objects. Implements `GDInstance::debug_get_globals` to query all gloabl constants avaliable in GDScriptLanguage. Show globals in debug stack variable panel. Disabe capitalize property name for remote object. Add DictionaryPropertyEdit to edit with Dictionaries. The serialization/unserialization workflow use binary data instead of dictionary to avoid send too large data. Do not stop debugger if curent break point stack has error fix #9034. Don't send all content of strings but first 80 characters from remote debugger. Add constants into the break point stack tree and remote object instance edit inspector. Remote GDScript resource object instance list constants in the property inspector. Add `self` to the local in the break point stack as a remote object. Move some functions for GDScript related to thier base classes so debugger don't rely on the gdscript module any more. The slef in the debugger tree now expanded as the instance of script instead of the script resource. --- core/script_debugger_remote.cpp | 364 ++++++++++++++++++++------ core/script_debugger_remote.h | 4 +- core/script_language.h | 5 + editor/dictionary_property_edit.cpp | 187 +++++++++++++ editor/dictionary_property_edit.h | 62 +++++ editor/property_editor.cpp | 82 +++++- editor/property_editor.h | 2 + editor/script_editor_debugger.cpp | 390 +++++++++++++++++++--------- editor/script_editor_debugger.h | 8 +- modules/gdscript/gd_editor.cpp | 43 ++- modules/gdscript/gd_script.h | 9 +- 11 files changed, 936 insertions(+), 220 deletions(-) create mode 100644 editor/dictionary_property_edit.cpp create mode 100644 editor/dictionary_property_edit.h diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 190a2321ef9..801cb4254dc 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -28,10 +28,12 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "script_debugger_remote.h" +#include "core/io/marshalls.h" #include "globals.h" #include "io/ip.h" #include "os/input.h" #include "os/os.h" + void ScriptDebuggerRemote::_send_video_memory() { List usage; @@ -183,6 +185,8 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) ERR_CONTINUE(cmd.size() != 1); int lv = cmd[0]; + ScriptInstance *self_instance = p_script->debug_get_stack_level_instance(lv); + List members; List member_vals; @@ -197,47 +201,74 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) ERR_CONTINUE(locals.size() != local_vals.size()); + List globals; + List global_vals; + + p_script->debug_get_globals(&globals, &global_vals); + + ERR_CONTINUE(globals.size() != global_vals.size()); + packet_peer_stream->put_var("stack_frame_vars"); - packet_peer_stream->put_var(2 + locals.size() * 2 + members.size() * 2); + packet_peer_stream->put_var(locals.size() + members.size() + globals.size()); - { //members - packet_peer_stream->put_var(members.size()); - - List::Element *E = members.front(); - List::Element *F = member_vals.front(); + { //locals + List::Element *E = locals.front(); + List::Element *F = local_vals.front(); while (E) { - if (F->get().get_type() == Variant::OBJECT) { - packet_peer_stream->put_var("*" + E->get()); - String pretty_print = F->get().operator String(); - packet_peer_stream->put_var(pretty_print.ascii().get_data()); - } else { - packet_peer_stream->put_var(E->get()); - packet_peer_stream->put_var(F->get()); - } + PropertyInfo pi(var.get_type(), String("locals/") + E->get()); + packet_peer_stream->put_var(_serialize(F->get(), pi)); E = E->next(); F = F->next(); } } - { //locals - packet_peer_stream->put_var(locals.size()); + { //members - List::Element *E = locals.front(); - List::Element *F = local_vals.front(); + if (self_instance) { // self + + members.push_front("self"); + member_vals.push_front(self_instance->get_owner()); + } + + List::Element *E = members.front(); + List::Element *F = member_vals.front(); while (E) { - if (F->get().get_type() == Variant::OBJECT) { - packet_peer_stream->put_var("*" + E->get()); - String pretty_print = F->get().operator String(); - packet_peer_stream->put_var(pretty_print.ascii().get_data()); - } else { - packet_peer_stream->put_var(E->get()); - packet_peer_stream->put_var(F->get()); + PropertyInfo pi(var.get_type(), String("members/") + E->get()); + packet_peer_stream->put_var(_serialize(F->get(), pi)); + + E = E->next(); + F = F->next(); + } + } + + if (self_instance) { // constants + + Ref