Browse Source

added more data structures to Natvis for msdev

can now debug signal_map and connections in Objects
can now view more Variant types, such as packed arrays
derammo 3 years ago
parent
commit
0c46b5f8e9
1 changed files with 67 additions and 17 deletions
  1. 67 17
      platform/windows/godot.natvis

+ 67 - 17
platform/windows/godot.natvis

@@ -32,6 +32,38 @@
 		</Expand>
 	</Type>
 
+	<Type Name="HashMap&lt;*,*&gt;">
+		<Expand>
+			<Item Name="[size]">num_elements</Item>
+			<LinkedListItems>
+				<Size>num_elements</Size>
+				<HeadPointer>head_element</HeadPointer>
+				<NextPointer>next</NextPointer>
+				<ValueNode>data</ValueNode>
+			</LinkedListItems>
+		</Expand>
+	</Type>
+
+	<Type Name="VMap&lt;*,*&gt;">
+		<Expand>
+			<Item Condition="_cowdata._ptr" Name="[size]">*(reinterpret_cast&lt;int*&gt;(_cowdata._ptr) - 1)</Item>
+			<ArrayItems Condition="_cowdata._ptr">
+				<Size>*(reinterpret_cast&lt;int*&gt;(_cowdata._ptr) - 1)</Size>
+				<ValuePointer>reinterpret_cast&lt;VMap&lt;$T1,$T2&gt;::Pair*&gt;(_cowdata._ptr)</ValuePointer>
+			</ArrayItems>
+		</Expand>
+	</Type>
+
+	<Type Name="VMap&lt;Callable,*&gt;::Pair">
+		<DisplayString Condition="dynamic_cast&lt;CallableCustomMethodPointerBase*&gt;(key.custom)">{dynamic_cast&lt;CallableCustomMethodPointerBase*&gt;(key.custom)->text}</DisplayString>
+	</Type>
+
+	<!-- requires PR 64364
+	<Type Name="GDScriptThreadContext">
+		<DisplayString Condition="_is_main == true">main thread {_debug_thread_id}</DisplayString>
+	</Type>
+	-->
+
 	<Type Name="Variant">
 		<DisplayString Condition="type == Variant::NIL">nil</DisplayString>
 		<DisplayString Condition="type == Variant::BOOL">{_data._bool}</DisplayString>
@@ -55,15 +87,17 @@
 		<DisplayString Condition="type == Variant::OBJECT">{*(Object *)_data._mem}</DisplayString>
 		<DisplayString Condition="type == Variant::DICTIONARY">{*(Dictionary *)_data._mem}</DisplayString>
 		<DisplayString Condition="type == Variant::ARRAY">{*(Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_BYTE_ARRAY">{*(PackedByteArray *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_INT32_ARRAY">{*(PackedInt32Array *)_data._mem}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_BYTE_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;unsigned char&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_INT32_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;int&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<!-- broken, will show incorrect data
 		<DisplayString Condition="type == Variant::PACKED_INT64_ARRAY">{*(PackedInt64Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_FLOAT32_ARRAY">{*(PackedFloat32Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_FLOAT64_ARRAY">{*(PackedFloat64Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_STRING_ARRAY">{*(PackedStringArray *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_VECTOR2_ARRAY">{*(PackedVector2Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_VECTOR3_ARRAY">{*(PackedVector3Array *)_data._mem}</DisplayString>
-		<DisplayString Condition="type == Variant::PACKED_COLOR_ARRAY">{*(PackedColorArray *)_data._mem}</DisplayString>
+		-->
+		<DisplayString Condition="type == Variant::PACKED_FLOAT32_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;float&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_FLOAT64_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;double&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_STRING_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;String&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_VECTOR2_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Vector2&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_VECTOR3_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Vector3&gt;*&gt;(_data.packed_array)->array}</DisplayString>
+		<DisplayString Condition="type == Variant::PACKED_COLOR_ARRAY">{reinterpret_cast&lt;const Variant::PackedArrayRef&lt;Color&gt;*&gt;(_data.packed_array)->array}</DisplayString>
 
 		<StringView Condition="type == Variant::STRING &amp;&amp; ((String *)(_data._mem))->_cowdata._ptr">((String *)(_data._mem))->_cowdata._ptr,s32</StringView>
 
@@ -87,7 +121,7 @@
 			<Item Name="[value]" Condition="type == Variant::OBJECT">*(Object *)_data._mem</Item>
 			<Item Name="[value]" Condition="type == Variant::DICTIONARY">*(Dictionary *)_data._mem</Item>
 			<Item Name="[value]" Condition="type == Variant::ARRAY">*(Array *)_data._mem</Item>
-			<Item Name="[value]" Condition="type == Variant::PACKED_BYTE_ARRAY">*(PackedByteArray *)_data._mem</Item>
+			<Item Name="[value]" Condition="type == Variant::PACKED_BYTE_ARRAY">reinterpret_cast&lt;const Variant::PackedArrayRef&lt;unsigned char&gt;*&gt;(_data.packed_array)->array</Item>
 			<Item Name="[value]" Condition="type == Variant::PACKED_INT32_ARRAY">*(PackedInt32Array *)_data._mem</Item>
 			<Item Name="[value]" Condition="type == Variant::PACKED_INT64_ARRAY">*(PackedInt64Array *)_data._mem</Item>
 			<Item Name="[value]" Condition="type == Variant::PACKED_FLOAT32_ARRAY">*(PackedFloat32Array *)_data._mem</Item>
@@ -105,6 +139,14 @@
 		<StringView Condition="_cowdata._ptr != 0">_cowdata._ptr,s32</StringView>
 	</Type>
 
+	<Type Name="godot::String">
+		<DisplayString>{*reinterpret_cast&lt;void**&gt;(opaque),s32}</DisplayString>
+		<Expand>
+			<Item Name="opaque_ptr">*reinterpret_cast&lt;void**&gt;(opaque)</Item>
+			<Item Name="string">*reinterpret_cast&lt;void**&gt;(opaque),s32</Item>
+		</Expand>
+	</Type>
+
 	<Type Name="StringName">
 		<DisplayString Condition="_data &amp;&amp; _data->cname">{_data->cname}</DisplayString>
 		<DisplayString Condition="_data &amp;&amp; !_data->cname">{_data->name,s32}</DisplayString>
@@ -113,6 +155,22 @@
 		<StringView Condition="_data &amp;&amp; !_data->cname">_data->name,s32</StringView>
 	</Type>
 
+	<!-- can't cast the opaque to ::StringName because Natvis does not support global namespace specifier? -->
+	<Type Name="godot::StringName">
+		<DisplayString Condition="(*reinterpret_cast&lt;const char***&gt;(opaque))[1]">{(*reinterpret_cast&lt;const char***&gt;(opaque))[1],s8}</DisplayString>
+		<DisplayString Condition="!(*reinterpret_cast&lt;const char***&gt;(opaque))[1]">{(*reinterpret_cast&lt;const char***&gt;(opaque))[2],s32}</DisplayString>
+		<Expand>
+			<Item Name="opaque_ptr">*reinterpret_cast&lt;void**&gt;(opaque)</Item>
+			<Item Name="&amp;cname">(*reinterpret_cast&lt;const char***&gt;(opaque))+1</Item>
+			<Item Name="cname">(*reinterpret_cast&lt;const char***&gt;(opaque))[1],s8</Item>
+		</Expand>
+	</Type>
+
+	<Type Name="Object::SignalData">
+		<DisplayString Condition="user.name._cowdata._ptr">"{user.name}" {slot_map}</DisplayString>
+		<DisplayString Condition="!user.name._cowdata._ptr">"{slot_map}</DisplayString>
+	</Type>
+
 	<Type Name="Vector2">
 		<DisplayString>{{{x},{y}}}</DisplayString>
 		<Expand>
@@ -149,12 +207,4 @@
 			<Item Name="alpha">a</Item>
 		</Expand>
 	</Type>
-
-	<Type Name="Node" Inheritable="false">
-		<Expand>
-			<Item Name="Object">(Object*)this</Item>
-			<Item Name="class_name">(StringName*)(((char*)this) + sizeof(Object))</Item>
-			<Item Name="data">(Node::Data*)(((char*)this) + sizeof(Object) + sizeof(StringName))</Item>
-		</Expand>
-	</Type>
 </AutoVisualizer>