Rollup merge of #147178 - Walnut356:msvc_enum_summary, r=Mark-Simulacrum

[DebugInfo] Improve formatting of MSVC enum struct variants

More robust handling mirroring the `TupleSummaryProvider` function

before:
<img width="1168" height="28" alt="image" src="https://github.com/user-attachments/assets/994f0884-55c2-4d3d-b1b2-97df17f0c9f0" />

after:
<img width="813" height="31" alt="image" src="https://github.com/user-attachments/assets/8ad3dfa0-3aa7-42a9-bf50-6f5eaf0365aa" />

This shouldn't affect any tests as we don't run debuginfo tests for MSVC afaik
This commit is contained in:
Matthias Krüger
2025-10-12 19:07:46 +02:00
committed by GitHub

View File

@@ -652,6 +652,21 @@ class MSVCEnumSyntheticProvider:
return name return name
def StructSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
output = []
for i in range(valobj.GetNumChildren()):
child: SBValue = valobj.GetChildAtIndex(i)
summary = child.summary
if summary is None:
summary = child.value
if summary is None:
summary = StructSummaryProvider(child, _dict)
summary = child.GetName() + ":" + summary
output.append(summary)
return "{" + ", ".join(output) + "}"
def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
enum_synth = MSVCEnumSyntheticProvider(valobj.GetNonSyntheticValue(), _dict) enum_synth = MSVCEnumSyntheticProvider(valobj.GetNonSyntheticValue(), _dict)
variant_names: SBType = valobj.target.FindFirstType( variant_names: SBType = valobj.target.FindFirstType(
@@ -695,16 +710,7 @@ def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
return name + TupleSummaryProvider(enum_synth.value, _dict) return name + TupleSummaryProvider(enum_synth.value, _dict)
else: else:
# enum variant is a regular struct # enum variant is a regular struct
var_list = ( return name + StructSummaryProvider(enum_synth.value, _dict)
str(enum_synth.value.GetNonSyntheticValue()).split("= ", 1)[1].splitlines()
)
vars = [x.strip() for x in var_list if x not in ("{", "}")]
if vars[0][0] == "(":
vars[0] = vars[0][1:]
if vars[-1][-1] == ")":
vars[-1] = vars[-1][:-1]
return f"{name}{{{', '.join(vars)}}}"
class TupleSyntheticProvider: class TupleSyntheticProvider: