Rollup merge of #155737 - Walnut356:getsyntheticvalue, r=jieyouxu

Account for `GetSyntheticValue` failures

`GetSyntheticValue` returns an invalid `SBValue` if no synthetic is present. That wasn't a problem before when we  were attaching synthetics to every type, but it won't be the case once github.com/rust-lang/rust/pull/155336 or similar lands. Additionally, codelldb subverts `lldb_commands` to apply similar behavior that doesn't attach synthetics to every type, so this fixes a regression there too.

Additionally, I removed 1 useless instance of `GetSyntheticValue`, since pointers should always be `IndirectionSyntheticProvider`, not `DefaultSyntheticProvider`.
This commit is contained in:
Jacob Pratt
2026-04-25 01:21:54 -04:00
committed by GitHub
+30 -23
View File
@@ -108,8 +108,6 @@ class DefaultSyntheticProvider:
return self.valobj.GetNumChildren() return self.valobj.GetNumChildren()
def get_child_index(self, name: str) -> int: def get_child_index(self, name: str) -> int:
if self.is_ptr and name == "$$dereference$$":
return self.valobj.Dereference().GetSyntheticValue()
return self.valobj.GetIndexOfChildWithName(name) return self.valobj.GetIndexOfChildWithName(name)
def get_child_at_index(self, index: int) -> Optional[SBValue]: def get_child_at_index(self, index: int) -> Optional[SBValue]:
@@ -133,13 +131,17 @@ class IndirectionSyntheticProvider:
return 1 return 1
def get_child_index(self, name: str) -> int: def get_child_index(self, name: str) -> int:
if self.is_ptr and name == "$$dereference$$": if name == "$$dereference$$":
return 0 return 0
return -1 return -1
def get_child_at_index(self, index: int) -> Optional[SBValue]: def get_child_at_index(self, index: int) -> Optional[SBValue]:
if index == 0: if index == 0:
return self.valobj.Dereference().GetSyntheticValue() value = self.valobj.Dereference()
if (synth := value.GetSyntheticValue()).IsValid():
return synth
else:
return value
return None return None
def update(self): def update(self):
@@ -569,7 +571,9 @@ class ClangEncodedEnumProvider:
self.variant = all_variants.GetChildAtIndex(index) self.variant = all_variants.GetChildAtIndex(index)
self.value = self.variant.GetChildMemberWithName( self.value = self.variant.GetChildMemberWithName(
ClangEncodedEnumProvider.VALUE_MEMBER_NAME ClangEncodedEnumProvider.VALUE_MEMBER_NAME
).GetSyntheticValue() )
if (synth := self.value.GetSyntheticValue()).IsValid():
self.value = synth
def _getCurrentVariantIndex(self, all_variants: SBValue) -> int: def _getCurrentVariantIndex(self, all_variants: SBValue) -> int:
default_index = 0 default_index = 0
@@ -651,9 +655,10 @@ class MSVCEnumSyntheticProvider:
).GetValueAsUnsigned() ).GetValueAsUnsigned()
if tag == discr: if tag == discr:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
else: # if invalid, DISCR must be a range else: # if invalid, DISCR must be a range
begin: int = ( begin: int = (
@@ -671,16 +676,18 @@ class MSVCEnumSyntheticProvider:
if begin < end: if begin < end:
if begin <= tag <= end: if begin <= tag <= end:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
else: else:
if tag >= begin or tag <= end: if tag >= begin or tag <= end:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
else: # if invalid, tag is a 128 bit value else: # if invalid, tag is a 128 bit value
tag_lo: int = self.valobj.GetChildMemberWithName( tag_lo: int = self.valobj.GetChildMemberWithName(
@@ -714,9 +721,9 @@ class MSVCEnumSyntheticProvider:
discr: int = (exact_hi << 64) | exact_lo discr: int = (exact_hi << 64) | exact_lo
if tag == discr: if tag == discr:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
else: # if invalid, DISCR must be a range else: # if invalid, DISCR must be a range
begin_lo: int = ( begin_lo: int = (
@@ -748,16 +755,16 @@ class MSVCEnumSyntheticProvider:
if begin < end: if begin < end:
if begin <= tag <= end: if begin <= tag <= end:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
else: else:
if tag >= begin or tag <= end: if tag >= begin or tag <= end:
self.variant = child self.variant = child
self.value = child.GetChildMemberWithName( self.value = child.GetChildMemberWithName("value")
"value" if (synth := self.value.GetSyntheticValue()).IsValid():
).GetSyntheticValue() self.value = synth
return return
def num_children(self) -> int: def num_children(self) -> int: