Skip to content

Commit 4cd9dd0

Browse files
authored
Rollup merge of rust-lang#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
2 parents ff1e7ed + 608c661 commit 4cd9dd0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/etc/lldb_providers.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,21 @@ def get_type_name(self) -> str:
652652
return name
653653

654654

655+
def StructSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
656+
output = []
657+
for i in range(valobj.GetNumChildren()):
658+
child: SBValue = valobj.GetChildAtIndex(i)
659+
summary = child.summary
660+
if summary is None:
661+
summary = child.value
662+
if summary is None:
663+
summary = StructSummaryProvider(child, _dict)
664+
summary = child.GetName() + ":" + summary
665+
output.append(summary)
666+
667+
return "{" + ", ".join(output) + "}"
668+
669+
655670
def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
656671
enum_synth = MSVCEnumSyntheticProvider(valobj.GetNonSyntheticValue(), _dict)
657672
variant_names: SBType = valobj.target.FindFirstType(
@@ -695,16 +710,7 @@ def MSVCEnumSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
695710
return name + TupleSummaryProvider(enum_synth.value, _dict)
696711
else:
697712
# enum variant is a regular struct
698-
var_list = (
699-
str(enum_synth.value.GetNonSyntheticValue()).split("= ", 1)[1].splitlines()
700-
)
701-
vars = [x.strip() for x in var_list if x not in ("{", "}")]
702-
if vars[0][0] == "(":
703-
vars[0] = vars[0][1:]
704-
if vars[-1][-1] == ")":
705-
vars[-1] = vars[-1][:-1]
706-
707-
return f"{name}{{{', '.join(vars)}}}"
713+
return name + StructSummaryProvider(enum_synth.value, _dict)
708714

709715

710716
class TupleSyntheticProvider:

0 commit comments

Comments
 (0)