Skip to content

Commit

Permalink
Support object inspection through DAP evaluate request
Browse files Browse the repository at this point in the history
  • Loading branch information
rsubtil committed Sep 30, 2024
1 parent 91cedc1 commit 870254b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions editor/debugger/debug_adapter/debug_adapter_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, DebugAdapterProtocol::DAPVarID>::ConstIterator variableID = DebugAdapterProtocol::get_singleton()->variable_eval_list.find(eval);

body["result"] = value;
body["variablesReference"] = 0;
body["variablesReference"] = variableID ? variableID->value : 0;

return response;
}
Expand Down
4 changes: 4 additions & 0 deletions editor/debugger/debug_adapter/debug_adapter_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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--;
Expand Down
1 change: 1 addition & 0 deletions editor/debugger/debug_adapter/debug_adapter_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class DebugAdapterProtocol : public Object {
List<DAP::Breakpoint> breakpoint_list;
HashMap<DAP::StackFrame, List<int>, DAP::StackFrame> stackframe_list;
HashMap<DAPVarID, Array> variable_list;
HashMap<String, DAPVarID> variable_eval_list;

HashMap<ObjectID, DAPVarID> object_list;
HashSet<ObjectID> object_pending_set;
Expand Down

0 comments on commit 870254b

Please sign in to comment.