@@ -566,21 +566,39 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
566
566
None ,
567
567
) ) ;
568
568
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 == "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 )
583
582
} ;
583
+ const DW_TAG_CONST_TYPE : c_uint = 0x0026 ;
584
+
585
+ // must wrap type in a `const` modifier for LLDB to be able to inspect the value of the member
586
+ let field_type =
587
+ llvm:: LLVMRustDIBuilderCreateQualifiedType ( DIB ( cx) , DW_TAG_CONST_TYPE , t_di) ;
588
+
589
+ llvm:: LLVMRustDIBuilderCreateStaticMemberType (
590
+ DIB ( cx) ,
591
+ wrapper_struct_type_di_node,
592
+ name. as_c_char_ptr ( ) ,
593
+ name. len ( ) ,
594
+ unknown_file_metadata ( cx) ,
595
+ UNKNOWN_LINE_NUMBER ,
596
+ field_type,
597
+ DIFlags :: FlagZero ,
598
+ Some ( cx. const_u64 ( value) ) ,
599
+ align,
600
+ )
601
+ } ;
584
602
585
603
// We also always have an associated constant for the discriminant value
586
604
// of the variant.
0 commit comments