From da2bcda7bec65f8c9bedb0ca3b23fc802b277c9d Mon Sep 17 00:00:00 2001 From: geequlim Date: Mon, 29 May 2017 14:09:16 +0800 Subject: 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. --- modules/gdscript/gd_editor.cpp | 43 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'modules/gdscript/gd_editor.cpp') diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp index e8d1d9a66..7689172b4 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gd_editor.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "gd_compiler.h" #include "gd_script.h" +#include "global_constants.h" #include "globals.h" #include "os/file_access.h" @@ -242,9 +243,47 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List * p_values->push_back(instance->debug_get_member_by_index(E->get().index)); } } -void GDScriptLanguage::debug_get_globals(List *p_locals, List *p_values, int p_max_subitems, int p_max_depth) { - //no globals are really reachable in gdscript +ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) { + + ERR_FAIL_COND_V(_debug_parse_err_line >= 0, NULL); + ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, NULL); + + int l = _debug_call_stack_pos - p_level - 1; + GDInstance *instance = _call_stack[l].instance; + + return instance; +} + +void GDScriptLanguage::debug_get_globals(List *p_globals, List *p_values, int p_max_subitems, int p_max_depth) { + + const Map &name_idx = GDScriptLanguage::get_singleton()->get_global_map(); + const Variant *globals = GDScriptLanguage::get_singleton()->get_global_array(); + + for (const Map::Element *E = name_idx.front(); E; E = E->next()) { + + if (ObjectTypeDB::type_exists(E->key()) || Globals::get_singleton()->has_singleton(E->key()) || E->key() == "PI") + continue; + + const Variant &var = globals[E->value()]; + if (Object *obj = var) { + if (obj->cast_to()) + continue; + } + + bool skip = false; + for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) { + if (E->key() == GlobalConstants::get_global_constant_name(i)) { + skip = true; + break; + } + } + if (skip) + continue; + + p_globals->push_back(E->key()); + p_values->push_back(var); + } } String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) { -- cgit v1.2.3-70-g09d2