@@ -149,8 +149,12 @@ def initialize_category(debugger, internal_dict):
149149 lldb .SBDebugger .SetInternalVariable ('target.process.thread.step-avoid-regexp' ,
150150 '^<?(std|core|alloc)::' , debugger .GetInstanceName ())
151151
152- max_string_summary_langth = debugger .GetSetting (
153- 'target.max-string-summary-length' ).GetIntegerValue ()
152+ # The GetSetting method is not available on older LLDB versions
153+ try :
154+ max_string_summary_langth = debugger .GetSetting (
155+ 'target.max-string-summary-length' ).GetIntegerValue ()
156+ except :
157+ pass
154158
155159
156160def attach_synthetic_to_type (synth_class , type_name , is_regex = False ):
@@ -963,19 +967,34 @@ class MsvcEnum2SynthProvider(EnumSynthProvider):
963967
964968 def update (self ):
965969 tparams = get_template_params (self .valobj .GetTypeName ())
966- self .type_name = tparams [0 ]
967-
968- def has_children (self ):
969- return True
970+
971+ if len (tparams ) == 1 : # Regular enum
972+ discr = gcm (self .valobj , 'tag' )
973+ self .variant = gcm (self .valobj , 'variant' +
974+ str (discr .GetValueAsUnsigned ())).GetChildAtIndex (0 )
975+ else : # Niche enum
976+ dataful_min = int (tparams [1 ])
977+ dataful_max = int (tparams [2 ])
978+ discr = gcm (self .valobj , 'tag' )
979+ if dataful_min <= discr .GetValueAsUnsigned () <= dataful_max :
980+ self .variant = gcm (self .valobj , 'dataful_variant' )
970981
971- def get_child_at_index (self , index ):
972- return self .valobj .GetChildAtIndex (index )
982+ names = re .split ("::" , self .variant .GetTypeName ())
983+ variant_name = names [- 1 ]
984+ self .type_name = tparams [0 ]
973985
974- def get_index_of_child (self , name ):
975- return self .valobj .GetChildIndex (name )
986+ if self .variant .IsValid () and self .variant .GetNumChildren () > self .skip_first :
987+ if self .variant .GetChildAtIndex (self .skip_first ).GetName () == '__0' :
988+ self .is_tuple_variant = True
989+ self .summary = variant_name + \
990+ tuple_summary (self .variant , skip_first = self .skip_first )
991+ else :
992+ self .summary = variant_name + " " + obj_summary (self .variant )
993+ else :
994+ self .summary = variant_name
976995
977- def get_type_name (self ):
978- return self .type_name
996+ def get_summary (self ):
997+ return self .summary
979998
980999
9811000class StdHashMapSynthProvider (RustSynthProvider ):
0 commit comments