[Lldb-commits] [PATCH] D130213: [LLDB][ClangExpression] Fix initialization of static enum alias members

Michael Buch via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 21 06:11:30 PDT 2022


Michael137 added a comment.

In D130213#3668450 <https://reviews.llvm.org/D130213#3668450>, @aprantl wrote:

> @werat did you build with assertions enabled?
>
> This change looks fine to me, but it might be interesting to see where the discrepancy between the platforms comes from.

Interestingly, @werat's test case crashes for me (without the patch) but only if I explicitly create an instance of `struct A`. Otherwise, lldb doesn't find `A::e`.

If a class only has constexpr statics, on Darwin we omit the structure type from DWARF:

  0x0000000b: DW_TAG_compile_unit            
                DW_AT_producer    ("Apple clang version 14.0.0 (clang-1400.0.25)")                           
                DW_AT_language    (DW_LANG_C_plus_plus_14)                                                   
                DW_AT_name        ("test.cpp")                                                               
                DW_AT_LLVM_sysroot        ("/Library/Developer/CommandLineTools/SDKs/MacOSX12.5.sdk")        
                DW_AT_APPLE_sdk   ("MacOSX12.5.sdk")                                                         
                DW_AT_stmt_list   (0x00000000)         
                DW_AT_comp_dir    ("/Users/michaelbuch/Git/lldb-build-lambda")                               
                DW_AT_low_pc      (0x0000000100003f9c)                                                                                                                                                                  
                DW_AT_high_pc     (0x0000000100003fb8)                                                       
                                                       
  0x00000032:   DW_TAG_enumeration_type                                                                      
                  DW_AT_type      (0x000000000000004b "int")                                                 
                  DW_AT_enum_class        (true)                                                             
                  DW_AT_name      ("ScopedEnum")                                                             
                  DW_AT_byte_size (0x04)               
                  DW_AT_decl_file ("/Users/michaelbuch/Git/lldb-build-lambda/test.cpp")                      
                  DW_AT_decl_line (1)                                                                        
                                                       
  0x0000003e:     DW_TAG_enumerator                                                                          
                    DW_AT_name    ("scoped_enum_case1")
                    DW_AT_const_value     (1)                                                                
                                                                                                             
  0x00000044:     DW_TAG_enumerator                    
                    DW_AT_name    ("scoped_enum_case2")                                                      
                    DW_AT_const_value     (2)                                                                
                                                                                                             
  0x0000004a:     NULL                                                                                       
                                                                                                             
  0x0000004b:   DW_TAG_base_type                                                                             
                  DW_AT_name      ("int")                                                                    
                  DW_AT_encoding  (DW_ATE_signed)                                                            
                  DW_AT_byte_size (0x04)                                                                     
                                                                                                             
  0x00000052:   DW_TAG_subprogram                                                                            
                  DW_AT_low_pc    (0x0000000100003f9c) 
                  DW_AT_high_pc   (0x0000000100003fb8)                                                       
                  DW_AT_APPLE_omit_frame_ptr      (true)                                                                                                                                                                
                  DW_AT_frame_base        (DW_OP_reg31 WSP)                                                  
                  DW_AT_name      ("main")
                  DW_AT_decl_file ("/Users/michaelbuch/Git/lldb-build-lambda/test.cpp")                      
                  DW_AT_decl_line (13)                                                                       
                  DW_AT_type      (0x000000000000004b "int")                                                 
                  DW_AT_external  (true)
  
  0x0000006b:     DW_TAG_variable
                    DW_AT_location        (DW_OP_fbreg +8)                                                   
                    DW_AT_name    ("enum_alias_val")
                    DW_AT_decl_file       ("/Users/michaelbuch/Git/lldb-build-lambda/test.cpp")              
                    DW_AT_decl_line       (14)
                    DW_AT_type    (0x0000000000000032 "ScopedEnum")                                          
  
  0x00000079:     NULL                                 
  
  0x0000007a:   NULL                                   

This is actually noted in one of the test cases in `TestConstStaticIntegralMember.py`:

  # dsymutil strips the debug info for classes that only have const static
  # data members without a definition namespace scope.                    
  @expectedFailureAll(debug_info=["dsym"])                                
  def test_class_with_only_const_static(self):                            


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130213/new/

https://reviews.llvm.org/D130213



More information about the lldb-commits mailing list