godot
godot copied to clipboard
Godot DAP variablesReference/evaluate requests return EncodedObjectAsID/ObjectID respectively instead of the full hierarchy
Tested versions
Reproducable 4.3.0.mono.stable
System information
All OS
Issue description
When debugging with Rider via Editor DAP,
requesting variables returns a confusing EncodedObjectAsID.
requesting evaluate returns just a plain ObjectID.
I am not yet completely sure, what should be returned. By the spec it seems that variablesReference should be not 0, when children are present.
Trace of communication via DAP:
[Trace - 01:46:15 PM] Sending request 'variables - (11)'
Params: {
"variablesReference": 2
}
[Trace - 01:46:15 PM] Received response 'variables - (11)' in 71ms
Result: {
"variables": [
{
"name": "self",
"value": "\u003cEncodedObjectAsID#-9223368171837132330\u003e",
"type": "Object",
"variablesReference": 0
}
]
}
For comparison, I have also send a evaluate request for the same "self" variable. It returns object id.
[Trace - 01:46:22 PM] Sending request 'evaluate - (12)'
Params: {
"expression": "self",
"frameId": 0
}
[Trace - 01:46:22 PM] Received response 'evaluate - (12)' in 28ms
Result: {
"result": "28487714063",
"variablesReference": 0
}
I have checked vscode, adding dump its commands below. It doesn't use DAP. It gets ObjectID first and then calls scene:inspect_object to get more details including children.
Trace of the vscode communication:
Steps to reproduce
I have created a simple project with a scene and one gd script, attached to it.
Put a brakepoint in the _process.
Debug from Rider via generated debug GDScript run configuration.
Minimal reproduction project (MRP)
I have created a simple project with a scene and one gd script.
CC @rsubtil @Faless
For reference, objects in stack variables are encoded as ID on purpose as part of the Godot debugger protocol.
To inspect the actual object, a separate message is needed (scene:inspect_object as you point out).
Inside the Godot editor, this means you get ObjectIDs in the stack variables, then clicking on it the request is made and the result is shown in the inspector.
So indeed, if I understand the reference correctly it seems that we want to set the variablesReference to the ObjectID, then when receiving a variables request with a variablesReference we should fetch that object ID (i.e. doing an inspect_object internally and translating it to DAP format).
I'll only have time to have a closer look at this tomorrow, but just to add my quick 2 cents to the analysis: object inspection is not yet implemented from DAP; it currently only outputs it's internal ID, IIRC. As @Faless said, a call to scene:inspect_object with that ID should retrieve all info from that object.
You can technically do this already as is, as Godot's internal debugging protocol can be exposed through DAP. This is explained on my GSoC report if you wish to take that route.
With that said though, the rationale for exposing this internal communication was to support advanced, Godot-centric concepts that don't map well to the generic DAP structure (e.g. inspecting the live scene tree, registering and querying profiling monitors, etc...). As it stands, complex object inspection is supported through DAP, so developers shouldn't need to "learn tricks" like this to make this work.
I am afraid, it is not possible to use EncodedObjectAsID. Call to scene:inspect_object needs ObjectID.
@van800 they are called EncodedObjectAsID exactly because you can get the original ObjectID by calling get_object_id