@@ -15,9 +15,9 @@ use crate::common::{AsCCharPtr, CodegenCx};
1515use  crate :: debuginfo:: metadata:: enums:: DiscrResult ; 
1616use  crate :: debuginfo:: metadata:: type_map:: { self ,  Stub ,  UniqueTypeId } ; 
1717use  crate :: debuginfo:: metadata:: { 
18-     DINodeCreationResult ,  NO_GENERICS ,  NO_SCOPE_METADATA ,  SmallVec ,   UNKNOWN_LINE_NUMBER , 
19-     build_field_di_node,  file_metadata,  file_metadata_from_def_id,  size_and_align_of ,  type_di_node , 
20-     unknown_file_metadata,  visibility_di_flags, 
18+     DINodeCreationResult ,  DW_TAG_const_type ,   NO_GENERICS ,  NO_SCOPE_METADATA ,  SmallVec , 
19+     UNKNOWN_LINE_NUMBER ,   build_field_di_node,  file_metadata,  file_metadata_from_def_id, 
20+     size_and_align_of ,  type_di_node ,   unknown_file_metadata,  visibility_di_flags, 
2121} ; 
2222use  crate :: debuginfo:: utils:: DIB ; 
2323use  crate :: llvm:: debuginfo:: { DIFile ,  DIFlags ,  DIType } ; 
@@ -566,22 +566,39 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
566566                None , 
567567            ) ) ; 
568568
569-             let  build_assoc_const =
570-                 |name :  & str ,  type_di_node :  & ' ll  DIType ,  value :  u64 ,  align :  Align | unsafe  { 
571-                     llvm:: LLVMRustDIBuilderCreateStaticMemberType ( 
572-                         DIB ( cx) , 
573-                         wrapper_struct_type_di_node, 
574-                         name. as_c_char_ptr ( ) , 
575-                         name. len ( ) , 
576-                         unknown_file_metadata ( cx) , 
577-                         UNKNOWN_LINE_NUMBER , 
578-                         type_di_node, 
579-                         DIFlags :: FlagZero , 
580-                         Some ( cx. const_u64 ( value) ) , 
581-                         align. bits ( )  as  u32 , 
582-                     ) 
569+             let  build_assoc_const = |name :  & str , 
570+                                      type_di_node_ :  & ' ll  DIType , 
571+                                      value :  u64 , 
572+                                      align :  Align | unsafe  { 
573+                 // FIXME: Currently we force all DISCR_* values to be u64's as LLDB seems to have 
574+                 // problems inspecting other value types. Since DISCR_* is typically only going to be 
575+                 // directly inspected via the debugger visualizer - which compares it to the `tag` value 
576+                 // (whose type is not modified at all) it shouldn't cause any real problems. 
577+                 let  ( t_di,  align)  = if  name == ASSOC_CONST_DISCR_NAME  { 
578+                     ( type_di_node_,  align. bits ( )  as  u32 ) 
579+                 }  else  { 
580+                     let  ty_u64 = Ty :: new_uint ( cx. tcx ,  ty:: UintTy :: U64 ) ; 
581+                     ( type_di_node ( cx,  ty_u64) ,  Align :: EIGHT . bits ( )  as  u32 ) 
583582                } ; 
584583
584+                 // must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member 
585+                 let  field_type =
586+                     llvm:: LLVMRustDIBuilderCreateQualifiedType ( DIB ( cx) ,  DW_TAG_const_type ,  t_di) ; 
587+ 
588+                 llvm:: LLVMRustDIBuilderCreateStaticMemberType ( 
589+                     DIB ( cx) , 
590+                     wrapper_struct_type_di_node, 
591+                     name. as_c_char_ptr ( ) , 
592+                     name. len ( ) , 
593+                     unknown_file_metadata ( cx) , 
594+                     UNKNOWN_LINE_NUMBER , 
595+                     field_type, 
596+                     DIFlags :: FlagZero , 
597+                     Some ( cx. const_u64 ( value) ) , 
598+                     align, 
599+                 ) 
600+             } ; 
601+ 
585602            // We also always have an associated constant for the discriminant value 
586603            // of the variant. 
587604            fields. push ( build_assoc_const ( 
0 commit comments