diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 8e2f037a1c3..02c414f13d1 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -492,9 +492,12 @@ Dictionary DebugAdapterParser::req_evaluate(const Dictionary &p_params) const { Dictionary args = p_params["arguments"]; - String value = EditorDebuggerNode::get_singleton()->get_var_value(args["expression"]); + String eval = args["expression"]; + String value = EditorDebuggerNode::get_singleton()->get_var_value(eval); + HashMap::ConstIterator variableID = DebugAdapterProtocol::get_singleton()->variable_eval_list.find(eval); + body["result"] = value; - body["variablesReference"] = 0; + body["variablesReference"] = variableID ? variableID->value : 0; return response; } diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp index f8f5584ba6d..51516effa5d 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.cpp @@ -186,6 +186,7 @@ void DebugAdapterProtocol::reset_stack_info() { stackframe_list.clear(); variable_list.clear(); + variable_eval_list.clear(); object_list.clear(); object_pending_set.clear(); } @@ -1131,6 +1132,9 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) { variable.value = stack_var.value; variable.type = Variant::get_type_name(stack_var.value.get_type()); variable.variablesReference = parse_variant(stack_var.value); + if (variable.variablesReference != 0) { + variable_eval_list.insert(variable.name, variable.variablesReference); + } variable_list.find(var_id)->value.push_back(variable.to_json()); _remaining_vars--; diff --git a/editor/debugger/debug_adapter/debug_adapter_protocol.h b/editor/debugger/debug_adapter/debug_adapter_protocol.h index 29d7457ee76..2a2591bea1b 100644 --- a/editor/debugger/debug_adapter/debug_adapter_protocol.h +++ b/editor/debugger/debug_adapter/debug_adapter_protocol.h @@ -125,6 +125,7 @@ private: List breakpoint_list; HashMap, DAP::StackFrame> stackframe_list; HashMap variable_list; + HashMap variable_eval_list; HashMap object_list; HashSet object_pending_set;