diff options
author | Ricardo Subtil <ricasubtil@gmail.com> | 2024-09-24 21:33:29 +0100 |
---|---|---|
committer | Ricardo Subtil <ricasubtil@gmail.com> | 2024-10-03 21:28:38 +0100 |
commit | 6aac039ee7803375bfc46f2c43794c9807ab9dd5 (patch) | |
tree | 0148ac06009162c130d45a92cd4c8084218ec41c /editor/debugger/debug_adapter/debug_adapter_parser.cpp | |
parent | 5ccbf6e4c794a4e47456edd9434b75fcd6096a2f (diff) | |
download | redot-engine-6aac039ee7803375bfc46f2c43794c9807ab9dd5.tar.gz |
Support object inspection through DAP `variables` request
Diffstat (limited to 'editor/debugger/debug_adapter/debug_adapter_parser.cpp')
-rw-r--r-- | editor/debugger/debug_adapter/debug_adapter_parser.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 4210baeed2..8e2f037a1c 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -442,26 +442,34 @@ Dictionary DebugAdapterParser::req_variables(const Dictionary &p_params) const { return Dictionary(); } - Dictionary response = prepare_success_response(p_params), body; - response["body"] = body; - Dictionary args = p_params["arguments"]; int variable_id = args["variablesReference"]; - HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); + if (HashMap<int, Array>::Iterator E = DebugAdapterProtocol::get_singleton()->variable_list.find(variable_id); E) { + Dictionary response = prepare_success_response(p_params); + Dictionary body; + response["body"] = body; - if (E) { if (!DebugAdapterProtocol::get_singleton()->get_current_peer()->supportsVariableType) { for (int i = 0; i < E->value.size(); i++) { Dictionary variable = E->value[i]; variable.erase("type"); } } + body["variables"] = E ? E->value : Array(); return response; } else { - return Dictionary(); + // If the requested variable is an object, it needs to be requested from the debuggee. + ObjectID object_id = DebugAdapterProtocol::get_singleton()->search_object_id(variable_id); + + if (object_id.is_null()) { + return prepare_error_response(p_params, DAP::ErrorType::UNKNOWN); + } + + DebugAdapterProtocol::get_singleton()->request_remote_object(object_id); } + return Dictionary(); } Dictionary DebugAdapterParser::req_next(const Dictionary &p_params) const { |