Skip to content

Commit 7e592b9

Browse files
committed
add support for evaluating godot::Variant, godot::Array and godot::Dictionary natvis entries
1 parent 5da5d8c commit 7e592b9

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

natvis/godot-cpp.natvis

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,31 @@
1717
</Expand>
1818
</Type>
1919

20-
<!-- Development notes: there is no way to just ask AI to generate natvis entry for each `godot::` type
21-
Each type required evaluation with LLDB console
20+
<!-- Development notes: At the current state no AI can directly generate a natvis entry for each `godot::` type.
2221
The testdata used for evaluation https://github.com/JetBrains/godot-support/wiki/Developing-godot%E2%80%90cpp.natvis
2322
The change of the memory layout would require adjustments of the natvis
23+
24+
Approach:
25+
1. For each type, inspect `opaque` bytes in LLDB using `memory read -size 8 -count N -format address` on
26+
the address stored in opaque (e.g. `*(void**)demo_type.opaque`) to map the actual field layout.
27+
2. Verify specific field values match known test data (e.g. array size=1, int value=42, string content).
28+
3. Write natvis expressions only after the field offsets are confirmed.
29+
30+
Evaluator constraints (JetBrains natvis engine, I haven't checked anything else):
31+
- Supports: reinterpret_cast, pointer arithmetic on built-in types, array indexing ([n]), Intrinsics
32+
- Does NOT support: calling member functions (e.g. size())
33+
- Nested type visualizers work: `{*(godot::String*)(opaque+8)}` delegates to the String natvis entry
34+
35+
Patterns used:
36+
- Opaque wrapper types (String, StringName, Array, Dictionary, ...): cast opaque slice to the
37+
godot-cpp type pointer — `*(godot::TypeName*)(opaque+N)` — and let that type's natvis handle display
38+
- Engine heap-allocated types stored as pointer (Transform2D, AABB, Basis, ...): double-deref —
39+
`**(godot::TypeName**)(opaque+N)`
40+
- Engine internals without a godot-cpp wrapper (ArrayPrivate, CowData, HashMap): use raw
41+
reinterpret_cast + index arithmetic, document offsets with a comment verified by LLDB
42+
43+
Future upcomming improvements:
44+
- JetBrains natvis support is doing to become x-plat https://youtrack.jetbrains.com/issue/CPP-35297
2445
-->
2546

2647
<!-- opaque[0..7] holds ArrayPrivate*. Dereference as unsigned long long* to read ArrayPrivate

0 commit comments

Comments
 (0)