Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Natvis improvements #10338

Merged
merged 2 commits into from Jan 6, 2022
Merged

Conversation

Pokechu22
Copy link
Contributor

I've improved the natvis files for BitField, and added one for EnumMap. See this page for more info about natvis, and here's Microsoft's STL natvis. Basically, it's an XML pseudo-language with a lot of quirks which is used for defining how things should show up in the visual studio debugger.

Here's some screenshots of the new EnumMap display in the debugger:

image
image

And here's a diff in formatting for all of the stuff in BitFieldTest:
 TEST(BitField, Storage)
 ?object
 {hex=0 full_u64=0 full_s64=0 ...}
     hex: 0
     full_u64: 0
     full_s64: 0
     regular_field_unsigned: 0
     regular_field_unsigned2: 0
     regular_field_signed: 0
     at_dword_boundary: 0
-    signed_1bit: false
+    signed_1bit: 0
     flag: false
-    enum_1: 0
-    enum_2: 0
+    enum_1: A (0)
+    enum_2: A (0)
 ?object
 {hex=18446744073709551615 full_u64=18446744073709551615 full_s64=-1 ...}
     hex: 18446744073709551615
     full_u64: 18446744073709551615
     full_s64: -1
     regular_field_unsigned: 7
     regular_field_unsigned2: 7
     regular_field_signed: 7
     at_dword_boundary: 15
-    signed_1bit: true
-    flag: false
-    enum_1: 3
-    enum_2: 3
+    signed_1bit: 1
+    flag: true
+    enum_1: D (3)
+    enum_2: D (3)
 ?object
 {hex=9223372036854775807 full_u64=9223372036854775807 full_s64=9223372036854775807 ...}
     hex: 9223372036854775807
     full_u64: 9223372036854775807
     full_s64: 9223372036854775807
     regular_field_unsigned: 7
     regular_field_unsigned2: 7
     regular_field_signed: 7
     at_dword_boundary: 15
-    signed_1bit: true
+    signed_1bit: 1
     flag: false
-    enum_1: 3
-    enum_2: 3
+    enum_1: D (3)
+    enum_2: D (3)
 ?object
 {hex=9223372036854775808 full_u64=9223372036854775808 full_s64=-9223372036854775808 ...}
     hex: 9223372036854775808
     full_u64: 9223372036854775808
     full_s64: -9223372036854775808
     regular_field_unsigned: 0
     regular_field_unsigned2: 0
     regular_field_signed: 0
     at_dword_boundary: 0
-    signed_1bit: false
-    flag: false
-    enum_1: 0
-    enum_2: 0
+    signed_1bit: 0
+    flag: true
+    enum_1: A (0)
+    enum_2: A (0)
 ?object
 {hex=9223372036854775880 full_u64=9223372036854775880 full_s64=-9223372036854775736 ...}
     hex: 9223372036854775880
     full_u64: 9223372036854775880
     full_s64: -9223372036854775736
     regular_field_unsigned: 0
     regular_field_unsigned2: 0
     regular_field_signed: 0
     at_dword_boundary: 0
-    signed_1bit: false
-    flag: false
-    enum_1: 0
-    enum_2: 0
+    signed_1bit: 0
+    flag: true
+    enum_1: A (0)
+    enum_2: A (0)
 ?object
 {hex=1115638279670828351 full_u64=1115638279670828351 full_s64=1115638279670828351 ...}
     hex: 1115638279670828351
     full_u64: 1115638279670828351
     full_s64: 1115638279670828351
     regular_field_unsigned: 6
     regular_field_unsigned2: 6
     regular_field_signed: 6
     at_dword_boundary: 10
-    signed_1bit: true
+    signed_1bit: 1
     flag: false
-    enum_1: 3
-    enum_2: 3
+    enum_1: D (3)
+    enum_2: D (3)
 ?object
 {hex=12157589738054409517 full_u64=12157589738054409517 full_s64=-6289154335655142099 ...}
     hex: 12157589738054409517
     full_u64: 12157589738054409517
     full_s64: -6289154335655142099
     regular_field_unsigned: 6
     regular_field_unsigned2: 6
     regular_field_signed: 6
     at_dword_boundary: 15
-    signed_1bit: true
-    flag: false
-    enum_1: 2
-    enum_2: 0
+    signed_1bit: 1
+    flag: true
+    enum_1: C (2)
+    enum_2: A (0)
 ?object
 {hex=1952210759788999965 full_u64=1952210759788999965 full_s64=1952210759788999965 ...}
     hex: 1952210759788999965
     full_u64: 1952210759788999965
     full_s64: 1952210759788999965
     regular_field_unsigned: 2
     regular_field_unsigned2: 2
     regular_field_signed: 2
     at_dword_boundary: 14
-    signed_1bit: false
+    signed_1bit: 0
     flag: false
-    enum_1: 3
-    enum_2: 3
+    enum_1: D (3)
+    enum_2: D (3)
 ?object
 {hex=16372065037784856923 full_u64=16372065037784856923 full_s64=-2074679035924694693 ...}
     hex: 16372065037784856923
     full_u64: 16372065037784856923
     full_s64: -2074679035924694693
     regular_field_unsigned: 4
     regular_field_unsigned2: 4
     regular_field_signed: 4
     at_dword_boundary: 2
-    signed_1bit: false
-    flag: false
-    enum_1: 2
-    enum_2: 1
+    signed_1bit: 0
+    flag: true
+    enum_1: C (2)
+    enum_2: B (1)
 
 TEST(BitFieldArray, Unsigned)
 ?object
 {hex=0 a=0 b=0 ...}
     hex: 0
     a: 0
     b: 0
     c: 0
-    arr: {storage=0 }
+    arr: {[0]=0 [1]=0 [2]=0 ...}
 ?object
 {hex=2 a=2 b=0 ...}
     hex: 2
     a: 2
     b: 0
     c: 0
-    arr: {storage=2 }
+    arr: {[0]=2 [1]=0 [2]=0 ...}
 ?object
 {hex=14 a=2 b=3 ...}
     hex: 14
     a: 2
     b: 3
     c: 0
-    arr: {storage=14 }
+    arr: {[0]=2 [1]=3 [2]=0 ...}
 ?object
 {hex=62 a=2 b=3 ...}
     hex: 62
     a: 2
     b: 3
     c: 3
-    arr: {storage=62 }
+    arr: {[0]=2 [1]=3 [2]=3 ...}
 ?object
 {hex=58 a=2 b=2 ...}
     hex: 58
     a: 2
     b: 2
     c: 3
-    arr: {storage=58 }
+    arr: {[0]=2 [1]=2 [2]=3 ...}
 ?object
 {hex=21 a=1 b=1 ...}
     hex: 21
     a: 1
     b: 1
     c: 1
-    arr: {storage=21 }
+    arr: {[0]=1 [1]=1 [2]=1 ...}
 ?object
 {hex=63 a=3 b=3 ...}
     hex: 63
     a: 3
     b: 3
     c: 3
-    arr: {storage=63 }
+    arr: {[0]=3 [1]=3 [2]=3 ...}
 ?object
 {hex=36 a=0 b=1 ...}
     hex: 36
     a: 0
     b: 1
     c: 2
-    arr: {storage=36 }
+    arr: {[0]=0 [1]=1 [2]=2 ...}
 
 TEST(BitFieldArray, Signed)
 ?object
 {hex=0 a=0 b=0 ...}
     hex: 0
     a: 0
     b: 0
     c: 0
-    arr: {storage=0 }
+    arr: {[0]=0 [1]=0 [2]=0 ...}
 ?object
-{hex=64 a=2 b=0 ...}
+{hex=64 a=-2 b=0 ...}
     hex: 64
-    a: 2
+    a: -2
     b: 0
     c: 0
-    arr: {storage=64 }
+    arr: {[0]=-2 [1]=0 [2]=0 ...}
 ?object
-{hex=448 a=2 b=3 ...}
+{hex=448 a=-2 b=-1 ...}
     hex: 448
-    a: 2
-    b: 3
+    a: -2
+    b: -1
     c: 0
-    arr: {storage=448 }
+    arr: {[0]=-2 [1]=-1 [2]=0 ...}
 ?object
-{hex=1984 a=2 b=3 ...}
+{hex=1984 a=-2 b=-1 ...}
     hex: 1984
-    a: 2
-    b: 3
-    c: 3
-    arr: {storage=1984 }
+    a: -2
+    b: -1
+    c: -1
+    arr: {[0]=-2 [1]=-1 [2]=-1 ...}
 ?object
-{hex=1856 a=2 b=2 ...}
+{hex=1856 a=-2 b=-2 ...}
     hex: 1856
-    a: 2
-    b: 2
-    c: 3
-    arr: {storage=1856 }
+    a: -2
+    b: -2
+    c: -1
+    arr: {[0]=-2 [1]=-2 [2]=-1 ...}
 ?object
 {hex=672 a=1 b=1 ...}
     hex: 672
     a: 1
     b: 1
     c: 1
-    arr: {storage=672 }
+    arr: {[0]=1 [1]=1 [2]=1 ...}
 ?object
-{hex=2016 a=3 b=3 ...}
+{hex=2016 a=-1 b=-1 ...}
     hex: 2016
-    a: 3
-    b: 3
-    c: 3
-    arr: {storage=2016 }
+    a: -1
+    b: -1
+    c: -1
+    arr: {[0]=-1 [1]=-1 [2]=-1 ...}
 ?object
 {hex=1152 a=0 b=1 ...}
     hex: 1152
     a: 0
     b: 1
-    c: 2
-    arr: {storage=1152 }
+    c: -2
+    arr: {[0]=0 [1]=1 [2]=-2 ...}
 
 TEST(BitFieldArray, Enum)
 ?object
-{hex=0 a=0 b=0 ...}
+{hex=0 a=A (0) b=A (0) ...}
     hex: 0
-    a: 0
-    b: 0
-    c: 0
-    d: 0
-    arr: {storage=0 }
+    a: A (0)
+    b: A (0)
+    c: A (0)
+    d: A (0)
+    arr: {[0]=A (0) [1]=A (0) [2]=A (0) ...}
 ?object
-{hex=1073741824 a=1 b=0 ...}
+{hex=1073741824 a=B (1) b=A (0) ...}
     hex: 1073741824
-    a: 1
-    b: 0
-    c: 0
-    d: 0
-    arr: {storage=1073741824 }
+    a: B (1)
+    b: A (0)
+    c: A (0)
+    d: A (0)
+    arr: {[0]=B (1) [1]=A (0) [2]=A (0) ...}
 ?object
-{hex=9663676416 a=1 b=2 ...}
+{hex=9663676416 a=B (1) b=C (2) ...}
     hex: 9663676416
-    a: 1
-    b: 2
-    c: 0
-    d: 0
-    arr: {storage=9663676416 }
+    a: B (1)
+    b: C (2)
+    c: A (0)
+    d: A (0)
+    arr: {[0]=B (1) [1]=C (2) [2]=A (0) ...}
 ?object
-{hex=44023414784 a=1 b=2 ...}
+{hex=44023414784 a=B (1) b=C (2) ...}
     hex: 44023414784
-    a: 1
-    b: 2
-    c: 2
-    d: 0
-    arr: {storage=44023414784 }
+    a: B (1)
+    b: C (2)
+    c: C (2)
+    d: A (0)
+    arr: {[0]=B (1) [1]=C (2) [2]=C (2) ...}
 ?object
-{hex=112742891520 a=1 b=2 ...}
+{hex=112742891520 a=B (1) b=C (2) ...}
     hex: 112742891520
-    a: 1
-    b: 2
-    c: 2
-    d: 1
-    arr: {storage=112742891520 }
+    a: B (1)
+    b: C (2)
+    c: C (2)
+    d: B (1)
+    arr: {[0]=B (1) [1]=C (2) [2]=C (2) ...}
 ?object
-{hex=273804165120 a=3 b=3 ...}
+{hex=273804165120 a=D (3) b=D (3) ...}
     hex: 273804165120
-    a: 3
-    b: 3
-    c: 3
-    d: 3
-    arr: {storage=273804165120 }
+    a: D (3)
+    b: D (3)
+    c: D (3)
+    d: D (3)
+    arr: {[0]=D (3) [1]=D (3) [2]=D (3) ...}
 ?object
-{hex=182536110080 a=2 b=2 ...}
+{hex=182536110080 a=C (2) b=C (2) ...}
     hex: 182536110080
-    a: 2
-    b: 2
-    c: 2
-    d: 2
-    arr: {storage=182536110080 }
+    a: C (2)
+    b: C (2)
+    c: C (2)
+    d: C (2)
+    arr: {[0]=C (2) [1]=C (2) [2]=C (2) ...}
 ?object
-{hex=244813135872 a=0 b=1 ...}
+{hex=244813135872 a=A (0) b=B (1) ...}
     hex: 244813135872
-    a: 0
-    b: 1
-    c: 2
-    d: 3
-    arr: {storage=244813135872 }
+    a: A (0)
+    b: B (1)
+    c: C (2)
+    d: D (3)
+    arr: {[0]=A (0) [1]=B (1) [2]=C (2) ...}
 
 TEST(BitFieldArray, StorageType)
 ?object
-{hex=10737418240 arr1={storage=10737418240 } arr2={storage=10737418240 } }
+{hex=10737418240 arr1={[0]=0 '\0' [1]=0 '\0' [2]=0 '\0' ...} arr2={[0]=false [1]=true [2]=false ...} }
     hex: 10737418240
-    arr1: {storage=10737418240 }
-    arr2: {storage=10737418240 }
+    arr1: {[0]=0 '\0' [1]=0 '\0' [2]=0 '\0' ...}
+    arr2: {[0]=false [1]=true [2]=false ...}
 ?object
-{hex=11282810912 arr1={storage=11282810912 } arr2={storage=11282810912 } }
+{hex=11282810912 arr1={[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...} arr2={[0]=false [1]=true [2]=false ...} }
     hex: 11282810912
-    arr1: {storage=11282810912 }
-    arr2: {storage=11282810912 }
+    arr1: {[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...}
+    arr2: {[0]=false [1]=true [2]=false ...}
 ?object
-{hex=5914101792 arr1={storage=5914101792 } arr2={storage=5914101792 } }
+{hex=5914101792 arr1={[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...} arr2={[0]=true [1]=false [2]=true ...} }
     hex: 5914101792
-    arr1: {storage=5914101792 }
-    arr2: {storage=5914101792 }
+    arr1: {[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...}
+    arr2: {[0]=true [1]=false [2]=true ...}
 ?object
-{hex=10209069088 arr1={storage=10209069088 } arr2={storage=10209069088 } }
+{hex=10209069088 arr1={[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...} arr2={[0]=true [1]=false [2]=false ...} }
     hex: 10209069088
-    arr1: {storage=10209069088 }
-    arr2: {storage=10209069088 }
+    arr1: {[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...}
+    arr2: {[0]=true [1]=false [2]=false ...}
 ?object
-{hex=10209069088 arr1={storage=10209069088 } arr2={storage=10209069088 } }
+{hex=10209069088 arr1={[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...} arr2={[0]=true [1]=false [2]=false ...} }
     hex: 10209069088
-    arr1: {storage=10209069088 }
-    arr2: {storage=10209069088 }
+    arr1: {[0]=0 '\0' [1]=1 '\x1' [2]=2 '\x2' ...}
+    arr2: {[0]=true [1]=false [2]=false ...}
 
 EnumMap example (located in PixelShaderGen)
 ?tev_alpha_funcs_table
-{m_array={ size=8 } }
-    m_array: { size=8 }
+{0x00007ff7449c81e0 "(false)", 0x00007ff7449c81e8 "(prev.a <  {})", 0x00007ff7449c81f8 "(prev.a == {})", ...}
+    [Never (0)]: 0x00007ff7449c81e0 "(false)"
+    [Less (1)]: 0x00007ff7449c81e8 "(prev.a <  {})"
+    [Equal (2)]: 0x00007ff7449c81f8 "(prev.a == {})"
+    [LEqual (3)]: 0x00007ff7449c8208 "(prev.a <= {})"
+    [Greater (4)]: 0x00007ff7449c8218 "(prev.a >  {})"
+    [NEqual (5)]: 0x00007ff7449c8228 "(prev.a != {})"
+    [GEqual (6)]: 0x00007ff7449c8238 "(prev.a >= {})"
+    [Always (7)]: 0x00007ff7449c80ac "(true)"
+    [Raw View]: {m_array={ size=8 } }

The main benefit here is looking at graphics registers (particularly BP and CP ones) in the visual studio debugger. This is completely separate from the logic used by the fifo player (and EnumFormatter and the names used there).

Note that signed_1bit isn't handled right, but the signed field logic is already painful enough, and I don't think we actually use that in Dolphin (only in the unit test), so I'm not going to worry about it.

Now, enums are properly displayed, and BitFieldArray is also displayed nicely.  Signed values also work correctly, and 1-bit fields are not treated as bools unless the bitfield is explicitly marked as a bool.
@lioncash lioncash merged commit 7bd14c5 into dolphin-emu:master Jan 6, 2022
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants