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