feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
from misc.utility.scons_hints import *
|
||||
|
||||
Import("env")
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "debug_adapter_parser.h"
|
||||
|
||||
#include "editor/debugger/debug_adapter/debug_adapter_types.h"
|
||||
#include "editor/debugger/editor_debugger_node.h"
|
||||
#include "editor/debugger/script_editor_debugger.h"
|
||||
#include "editor/export/editor_export_platform.h"
|
||||
|
|
@ -146,7 +147,7 @@ Dictionary DebugAdapterParser::req_initialize(const Dictionary &p_params) const
|
|||
for (List<String>::Element *E = breakpoints.front(); E; E = E->next()) {
|
||||
String breakpoint = E->get();
|
||||
|
||||
String path = breakpoint.left(breakpoint.find(":", 6)); // Skip initial part of path, aka "res://"
|
||||
String path = breakpoint.left(breakpoint.find_char(':', 6)); // Skip initial part of path, aka "res://"
|
||||
int line = breakpoint.substr(path.size()).to_int();
|
||||
|
||||
DebugAdapterProtocol::get_singleton()->on_debug_breakpoint_toggled(path, line, true);
|
||||
|
|
@ -358,7 +359,7 @@ Dictionary DebugAdapterParser::req_setBreakpoints(const Dictionary &p_params) co
|
|||
}
|
||||
|
||||
// If path contains \, it's a Windows path, so we need to convert it to /, and make the drive letter uppercase
|
||||
if (source.path.contains("\\")) {
|
||||
if (source.path.contains_char('\\')) {
|
||||
source.path = source.path.replace("\\", "/");
|
||||
source.path = source.path.substr(0, 1).to_upper() + source.path.substr(1);
|
||||
}
|
||||
|
|
@ -442,26 +443,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 {
|
||||
|
|
@ -479,16 +488,27 @@ Dictionary DebugAdapterParser::req_stepIn(const Dictionary &p_params) const {
|
|||
}
|
||||
|
||||
Dictionary DebugAdapterParser::req_evaluate(const Dictionary &p_params) const {
|
||||
Dictionary response = prepare_success_response(p_params), body;
|
||||
response["body"] = body;
|
||||
|
||||
Dictionary args = p_params["arguments"];
|
||||
String expression = args["expression"];
|
||||
int frame_id = args.has("frameId") ? static_cast<int>(args["frameId"]) : DebugAdapterProtocol::get_singleton()->_current_frame;
|
||||
|
||||
String value = EditorDebuggerNode::get_singleton()->get_var_value(args["expression"]);
|
||||
body["result"] = value;
|
||||
body["variablesReference"] = 0;
|
||||
if (HashMap<String, DAP::Variable>::Iterator E = DebugAdapterProtocol::get_singleton()->eval_list.find(expression); E) {
|
||||
Dictionary response = prepare_success_response(p_params);
|
||||
Dictionary body;
|
||||
response["body"] = body;
|
||||
|
||||
return response;
|
||||
DAP::Variable var = E->value;
|
||||
|
||||
body["result"] = var.value;
|
||||
body["variablesReference"] = var.variablesReference;
|
||||
|
||||
// Since an evaluation can alter the state of the debuggee, they are volatile, and should only be used once
|
||||
DebugAdapterProtocol::get_singleton()->eval_list.erase(E->key);
|
||||
return response;
|
||||
} else {
|
||||
DebugAdapterProtocol::get_singleton()->request_remote_evaluate(expression, frame_id);
|
||||
}
|
||||
return Dictionary();
|
||||
}
|
||||
|
||||
Dictionary DebugAdapterParser::req_godot_put_msg(const Dictionary &p_params) const {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ private:
|
|||
|
||||
_FORCE_INLINE_ bool is_valid_path(const String &p_path) const {
|
||||
// If path contains \, it's a Windows path, so we need to convert it to /, and check as case-insensitive.
|
||||
if (p_path.contains("\\")) {
|
||||
if (p_path.contains_char('\\')) {
|
||||
String project_path = ProjectSettings::get_singleton()->get_resource_path();
|
||||
String path = p_path.replace("\\", "/");
|
||||
return path.containsn(project_path);
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@
|
|||
#include "core/config/project_settings.h"
|
||||
#include "core/debugger/debugger_marshalls.h"
|
||||
#include "core/io/json.h"
|
||||
#include "core/io/marshalls.h"
|
||||
#include "editor/debugger/script_editor_debugger.h"
|
||||
#include "editor/doc_tools.h"
|
||||
#include "editor/editor_log.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
|
@ -186,6 +186,8 @@ void DebugAdapterProtocol::reset_stack_info() {
|
|||
|
||||
stackframe_list.clear();
|
||||
variable_list.clear();
|
||||
object_list.clear();
|
||||
object_pending_set.clear();
|
||||
}
|
||||
|
||||
int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
|
||||
|
|
@ -671,12 +673,194 @@ int DebugAdapterProtocol::parse_variant(const Variant &p_var) {
|
|||
variable_list.insert(id, arr);
|
||||
return id;
|
||||
}
|
||||
case Variant::OBJECT: {
|
||||
// Objects have to be requested from the debuggee. This has do be done
|
||||
// in a lazy way, as retrieving object properties takes time.
|
||||
EncodedObjectAsID *encoded_obj = Object::cast_to<EncodedObjectAsID>(p_var);
|
||||
|
||||
// Object may be null; in that case, return early.
|
||||
if (!encoded_obj) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Object may have been already requested.
|
||||
ObjectID object_id = encoded_obj->get_object_id();
|
||||
if (object_list.has(object_id)) {
|
||||
return object_list[object_id];
|
||||
}
|
||||
|
||||
// Queue requesting the object.
|
||||
int id = variable_id++;
|
||||
object_list.insert(object_id, id);
|
||||
return id;
|
||||
}
|
||||
default:
|
||||
// Simple atomic stuff, or too complex to be manipulated
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void DebugAdapterProtocol::parse_object(SceneDebuggerObject &p_obj) {
|
||||
// If the object is not on the pending list, we weren't expecting it. Ignore it.
|
||||
ObjectID object_id = p_obj.id;
|
||||
if (!object_pending_set.erase(object_id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Populate DAP::Variable's with the object's properties. These properties will be divided by categories.
|
||||
Array properties;
|
||||
Array script_members;
|
||||
Array script_constants;
|
||||
Array script_node;
|
||||
DAP::Variable node_type;
|
||||
Array node_properties;
|
||||
|
||||
for (SceneDebuggerObject::SceneDebuggerProperty &property : p_obj.properties) {
|
||||
PropertyInfo &info = property.first;
|
||||
|
||||
// Script members ("Members/" prefix)
|
||||
if (info.name.begins_with("Members/")) {
|
||||
info.name = info.name.trim_prefix("Members/");
|
||||
script_members.push_back(parse_object_variable(property));
|
||||
}
|
||||
|
||||
// Script constants ("Constants/" prefix)
|
||||
else if (info.name.begins_with("Constants/")) {
|
||||
info.name = info.name.trim_prefix("Constants/");
|
||||
script_constants.push_back(parse_object_variable(property));
|
||||
}
|
||||
|
||||
// Script node ("Node/" prefix)
|
||||
else if (info.name.begins_with("Node/")) {
|
||||
info.name = info.name.trim_prefix("Node/");
|
||||
script_node.push_back(parse_object_variable(property));
|
||||
}
|
||||
|
||||
// Regular categories (with type Variant::NIL)
|
||||
else if (info.type == Variant::NIL) {
|
||||
if (!node_properties.is_empty()) {
|
||||
node_type.value = itos(node_properties.size());
|
||||
variable_list.insert(node_type.variablesReference, node_properties.duplicate());
|
||||
properties.push_back(node_type.to_json());
|
||||
}
|
||||
|
||||
node_type.name = info.name;
|
||||
node_type.type = "Category";
|
||||
node_type.variablesReference = variable_id++;
|
||||
node_properties.clear();
|
||||
}
|
||||
|
||||
// Regular properties.
|
||||
else {
|
||||
node_properties.push_back(parse_object_variable(property));
|
||||
}
|
||||
}
|
||||
|
||||
// Add the last category.
|
||||
if (!node_properties.is_empty()) {
|
||||
node_type.value = itos(node_properties.size());
|
||||
variable_list.insert(node_type.variablesReference, node_properties.duplicate());
|
||||
properties.push_back(node_type.to_json());
|
||||
}
|
||||
|
||||
// Add the script categories, in reverse order to be at the front of the array:
|
||||
// ( [members; constants; node; category1; category2; ...] )
|
||||
if (!script_node.is_empty()) {
|
||||
DAP::Variable node;
|
||||
node.name = "Node";
|
||||
node.type = "Category";
|
||||
node.value = itos(script_node.size());
|
||||
node.variablesReference = variable_id++;
|
||||
variable_list.insert(node.variablesReference, script_node);
|
||||
properties.push_front(node.to_json());
|
||||
}
|
||||
|
||||
if (!script_constants.is_empty()) {
|
||||
DAP::Variable constants;
|
||||
constants.name = "Constants";
|
||||
constants.type = "Category";
|
||||
constants.value = itos(script_constants.size());
|
||||
constants.variablesReference = variable_id++;
|
||||
variable_list.insert(constants.variablesReference, script_constants);
|
||||
properties.push_front(constants.to_json());
|
||||
}
|
||||
|
||||
if (!script_members.is_empty()) {
|
||||
DAP::Variable members;
|
||||
members.name = "Members";
|
||||
members.type = "Category";
|
||||
members.value = itos(script_members.size());
|
||||
members.variablesReference = variable_id++;
|
||||
variable_list.insert(members.variablesReference, script_members);
|
||||
properties.push_front(members.to_json());
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(!object_list.has(object_id));
|
||||
variable_list.insert(object_list[object_id], properties);
|
||||
}
|
||||
|
||||
void DebugAdapterProtocol::parse_evaluation(DebuggerMarshalls::ScriptStackVariable &p_var) {
|
||||
// If the eval is not on the pending list, we weren't expecting it. Ignore it.
|
||||
String eval = p_var.name;
|
||||
if (!eval_pending_list.erase(eval)) {
|
||||
return;
|
||||
}
|
||||
|
||||
DAP::Variable variable;
|
||||
variable.name = p_var.name;
|
||||
variable.value = p_var.value;
|
||||
variable.type = Variant::get_type_name(p_var.value.get_type());
|
||||
variable.variablesReference = parse_variant(p_var.value);
|
||||
|
||||
eval_list.insert(variable.name, variable);
|
||||
}
|
||||
|
||||
const Variant DebugAdapterProtocol::parse_object_variable(const SceneDebuggerObject::SceneDebuggerProperty &p_property) {
|
||||
const PropertyInfo &info = p_property.first;
|
||||
const Variant &value = p_property.second;
|
||||
|
||||
DAP::Variable var;
|
||||
var.name = info.name;
|
||||
var.type = Variant::get_type_name(info.type);
|
||||
var.value = value;
|
||||
var.variablesReference = parse_variant(value);
|
||||
|
||||
return var.to_json();
|
||||
}
|
||||
|
||||
ObjectID DebugAdapterProtocol::search_object_id(DAPVarID p_var_id) {
|
||||
for (const KeyValue<ObjectID, DAPVarID> &E : object_list) {
|
||||
if (E.value == p_var_id) {
|
||||
return E.key;
|
||||
}
|
||||
}
|
||||
return ObjectID();
|
||||
}
|
||||
|
||||
bool DebugAdapterProtocol::request_remote_object(const ObjectID &p_object_id) {
|
||||
// If the object is already on the pending list, we don't need to request it again.
|
||||
if (object_pending_set.has(p_object_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorDebuggerNode::get_singleton()->get_default_debugger()->request_remote_object(p_object_id);
|
||||
object_pending_set.insert(p_object_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DebugAdapterProtocol::request_remote_evaluate(const String &p_eval, int p_stack_frame) {
|
||||
// If the eval is already on the pending list, we don't need to request it again
|
||||
if (eval_pending_list.has(p_eval)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
EditorDebuggerNode::get_singleton()->get_default_debugger()->request_remote_evaluate(p_eval, p_stack_frame);
|
||||
eval_pending_list.insert(p_eval);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DebugAdapterProtocol::process_message(const String &p_text) {
|
||||
JSON json;
|
||||
ERR_FAIL_COND_V_MSG(json.parse(p_text) != OK, true, "Malformed message!");
|
||||
|
|
@ -966,7 +1150,7 @@ void DebugAdapterProtocol::on_debug_stack_frame_var(const Array &p_data) {
|
|||
|
||||
List<int> scope_ids = stackframe_list.find(frame)->value;
|
||||
ERR_FAIL_COND(scope_ids.size() != 3);
|
||||
ERR_FAIL_INDEX(stack_var.type, 3);
|
||||
ERR_FAIL_INDEX(stack_var.type, 4);
|
||||
int var_id = scope_ids.get(stack_var.type);
|
||||
|
||||
DAP::Variable variable;
|
||||
|
|
@ -986,6 +1170,20 @@ void DebugAdapterProtocol::on_debug_data(const String &p_msg, const Array &p_dat
|
|||
return;
|
||||
}
|
||||
|
||||
if (p_msg == "scene:inspect_object") {
|
||||
// An object was requested from the debuggee; parse it.
|
||||
SceneDebuggerObject remote_obj;
|
||||
remote_obj.deserialize(p_data);
|
||||
|
||||
parse_object(remote_obj);
|
||||
} else if (p_msg == "evaluation_return") {
|
||||
// An evaluation was requested from the debuggee; parse it.
|
||||
DebuggerMarshalls::ScriptStackVariable remote_evaluation;
|
||||
remote_evaluation.deserialize(p_data);
|
||||
|
||||
parse_evaluation(remote_evaluation);
|
||||
}
|
||||
|
||||
notify_custom_data(p_msg, p_data);
|
||||
}
|
||||
|
||||
|
|
@ -1049,7 +1247,7 @@ DebugAdapterProtocol::DebugAdapterProtocol() {
|
|||
debugger_node->connect("breakpoint_toggled", callable_mp(this, &DebugAdapterProtocol::on_debug_breakpoint_toggled));
|
||||
|
||||
debugger_node->get_default_debugger()->connect("stopped", callable_mp(this, &DebugAdapterProtocol::on_debug_stopped));
|
||||
debugger_node->get_default_debugger()->connect("output", callable_mp(this, &DebugAdapterProtocol::on_debug_output));
|
||||
debugger_node->get_default_debugger()->connect(SceneStringName(output), callable_mp(this, &DebugAdapterProtocol::on_debug_output));
|
||||
debugger_node->get_default_debugger()->connect("breaked", callable_mp(this, &DebugAdapterProtocol::on_debug_breaked));
|
||||
debugger_node->get_default_debugger()->connect("stack_dump", callable_mp(this, &DebugAdapterProtocol::on_debug_stack_dump));
|
||||
debugger_node->get_default_debugger()->connect("stack_frame_vars", callable_mp(this, &DebugAdapterProtocol::on_debug_stack_frame_vars));
|
||||
|
|
|
|||
|
|
@ -31,12 +31,13 @@
|
|||
#ifndef DEBUG_ADAPTER_PROTOCOL_H
|
||||
#define DEBUG_ADAPTER_PROTOCOL_H
|
||||
|
||||
#include "core/io/stream_peer.h"
|
||||
#include "core/debugger/debugger_marshalls.h"
|
||||
#include "core/io/stream_peer_tcp.h"
|
||||
#include "core/io/tcp_server.h"
|
||||
|
||||
#include "debug_adapter_parser.h"
|
||||
#include "debug_adapter_types.h"
|
||||
#include "scene/debugger/scene_debugger.h"
|
||||
|
||||
#define DAP_MAX_BUFFER_SIZE 4194304 // 4MB
|
||||
#define DAP_MAX_CLIENTS 8
|
||||
|
|
@ -75,6 +76,8 @@ class DebugAdapterProtocol : public Object {
|
|||
|
||||
friend class DebugAdapterParser;
|
||||
|
||||
using DAPVarID = int;
|
||||
|
||||
private:
|
||||
static DebugAdapterProtocol *singleton;
|
||||
DebugAdapterParser *parser = nullptr;
|
||||
|
|
@ -99,6 +102,13 @@ private:
|
|||
void reset_stack_info();
|
||||
|
||||
int parse_variant(const Variant &p_var);
|
||||
void parse_object(SceneDebuggerObject &p_obj);
|
||||
const Variant parse_object_variable(const SceneDebuggerObject::SceneDebuggerProperty &p_property);
|
||||
void parse_evaluation(DebuggerMarshalls::ScriptStackVariable &p_var);
|
||||
|
||||
ObjectID search_object_id(DAPVarID p_var_id);
|
||||
bool request_remote_object(const ObjectID &p_object_id);
|
||||
bool request_remote_evaluate(const String &p_eval, int p_stack_frame);
|
||||
|
||||
bool _initialized = false;
|
||||
bool _processing_breakpoint = false;
|
||||
|
|
@ -106,7 +116,7 @@ private:
|
|||
bool _processing_stackdump = false;
|
||||
int _remaining_vars = 0;
|
||||
int _current_frame = 0;
|
||||
uint64_t _request_timeout = 1000;
|
||||
uint64_t _request_timeout = 5000;
|
||||
bool _sync_breakpoints = false;
|
||||
|
||||
String _current_request;
|
||||
|
|
@ -114,10 +124,16 @@ private:
|
|||
|
||||
int breakpoint_id = 0;
|
||||
int stackframe_id = 0;
|
||||
int variable_id = 0;
|
||||
DAPVarID variable_id = 0;
|
||||
List<DAP::Breakpoint> breakpoint_list;
|
||||
HashMap<DAP::StackFrame, List<int>, DAP::StackFrame> stackframe_list;
|
||||
HashMap<int, Array> variable_list;
|
||||
HashMap<DAPVarID, Array> variable_list;
|
||||
|
||||
HashMap<ObjectID, DAPVarID> object_list;
|
||||
HashSet<ObjectID> object_pending_set;
|
||||
|
||||
HashMap<String, DAP::Variable> eval_list;
|
||||
HashSet<String> eval_pending_list;
|
||||
|
||||
public:
|
||||
friend class DebugAdapterServer;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
|
||||
#include "debug_adapter_server.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "editor/editor_log.h"
|
||||
#include "editor/editor_node.h"
|
||||
#include "editor/editor_settings.h"
|
||||
|
|
@ -38,6 +37,7 @@
|
|||
int DebugAdapterServer::port_override = -1;
|
||||
|
||||
DebugAdapterServer::DebugAdapterServer() {
|
||||
// TODO: Move to editor_settings.cpp
|
||||
_EDITOR_DEF("network/debug_adapter/remote_port", remote_port);
|
||||
_EDITOR_DEF("network/debug_adapter/request_timeout", protocol._request_timeout);
|
||||
_EDITOR_DEF("network/debug_adapter/sync_breakpoints", protocol._sync_breakpoints);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue