about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/etc/debugger_pretty_printers_common.py16
-rw-r--r--src/etc/lldb_rust_formatters.py4
-rw-r--r--src/test/debuginfo/union-smoke.rs5
3 files changed, 15 insertions, 10 deletions
diff --git a/src/etc/debugger_pretty_printers_common.py b/src/etc/debugger_pretty_printers_common.py
index eb562877c85..5e3ff5246a9 100644
--- a/src/etc/debugger_pretty_printers_common.py
+++ b/src/etc/debugger_pretty_printers_common.py
@@ -45,6 +45,7 @@ TYPE_KIND_SINGLETON_ENUM    = 13
 TYPE_KIND_CSTYLE_ENUM       = 14
 TYPE_KIND_PTR               = 15
 TYPE_KIND_FIXED_SIZE_VEC    = 16
+TYPE_KIND_REGULAR_UNION     = 17
 
 ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$"
 ENUM_DISR_FIELD_NAME = "RUST$ENUM$DISR"
@@ -188,15 +189,18 @@ class Type(object):
         union_member_count = len(union_members)
         if union_member_count == 0:
             return TYPE_KIND_EMPTY
-        elif union_member_count == 1:
-            first_variant_name = union_members[0].name
-            if first_variant_name is None:
+
+        first_variant_name = union_members[0].name
+        if first_variant_name is None:
+            if union_member_count == 1:
                 return TYPE_KIND_SINGLETON_ENUM
             else:
-                assert first_variant_name.startswith(ENCODED_ENUM_PREFIX)
-                return TYPE_KIND_COMPRESSED_ENUM
+                return TYPE_KIND_REGULAR_ENUM
+        elif first_variant_name.startswith(ENCODED_ENUM_PREFIX):
+            assert union_member_count == 1
+            return TYPE_KIND_COMPRESSED_ENUM
         else:
-            return TYPE_KIND_REGULAR_ENUM
+            return TYPE_KIND_REGULAR_UNION
 
 
     def __conforms_to_field_layout(self, expected_fields):
diff --git a/src/etc/lldb_rust_formatters.py b/src/etc/lldb_rust_formatters.py
index 335acae5fb6..4427313f9e5 100644
--- a/src/etc/lldb_rust_formatters.py
+++ b/src/etc/lldb_rust_formatters.py
@@ -90,6 +90,7 @@ def print_val(lldb_val, internal_dict):
     type_kind = val.type.get_type_kind()
 
     if (type_kind == rustpp.TYPE_KIND_REGULAR_STRUCT or
+        type_kind == rustpp.TYPE_KIND_REGULAR_UNION or
         type_kind == rustpp.TYPE_KIND_EMPTY):
         return print_struct_val(val,
                                 internal_dict,
@@ -175,7 +176,8 @@ def print_struct_val(val, internal_dict, omit_first_field, omit_type_name, is_tu
     Prints a struct, tuple, or tuple struct value with Rust syntax.
     Ignores any fields before field_start_index.
     """
-    assert val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_STRUCT
+    assert (val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_STRUCT or
+            val.type.get_dwarf_type_kind() == rustpp.DWARF_TYPE_CODE_UNION)
 
     if omit_type_name:
         type_name = ""
diff --git a/src/test/debuginfo/union-smoke.rs b/src/test/debuginfo/union-smoke.rs
index ada9e0b30cc..5d3fbd62023 100644
--- a/src/test/debuginfo/union-smoke.rs
+++ b/src/test/debuginfo/union-smoke.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 // min-lldb-version: 310
-// ignore-macos FIXME(#37479)
 
 // compile-flags:-g
 
@@ -27,9 +26,9 @@
 
 // lldb-command:run
 // lldb-command:print u
-// lldb-check:[...]$0 = { a = ('\x02', '\x02') b = 514 }
+// lldb-check:[...]$0 = U { a: ('\x02', '\x02'), b: 514 }
 // lldb-command:print union_smoke::SU
-// lldb-check:[...]$1 = 257
+// lldb-check:[...]$1 = U { a: ('\x01', '\x01'), b: 257 }
 
 #![allow(unused)]
 #![feature(omit_gdb_pretty_printer_section)]