diff options
| author | Walnut <39544927+Walnut356@users.noreply.github.com> | 2025-01-10 01:53:25 -0600 |
|---|---|---|
| committer | Walnut <39544927+Walnut356@users.noreply.github.com> | 2025-01-10 01:53:25 -0600 |
| commit | 8b14227aa96cf1bfdfdf46e879837b0763073a1b (patch) | |
| tree | e916f4e42f105a88f56c9b3c1efdbf1b3695bc2f | |
| parent | 62bf38fa600f4beb878d61c537837729d4ee689e (diff) | |
| download | rust-8b14227aa96cf1bfdfdf46e879837b0763073a1b.tar.gz rust-8b14227aa96cf1bfdfdf46e879837b0763073a1b.zip | |
add MSVC tuple providers
| -rw-r--r-- | src/etc/lldb_commands | 6 | ||||
| -rw-r--r-- | src/etc/lldb_providers.py | 53 |
2 files changed, 58 insertions, 1 deletions
diff --git a/src/etc/lldb_commands b/src/etc/lldb_commands index ef0c3740f03..71968f2dbe6 100644 --- a/src/etc/lldb_commands +++ b/src/etc/lldb_commands @@ -18,7 +18,10 @@ type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)NonZ type synthetic add -l lldb_lookup.synthetic_lookup -x "^core::num::([a-z_]+::)*NonZero.+$" --category Rust type synthetic add -l lldb_lookup.synthetic_lookup -x "^(std::([a-z_]+::)+)PathBuf$" --category Rust type synthetic add -l lldb_lookup.synthetic_lookup -x "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(.*)$" --category Rust +type synthetic add -l lldb_lookup.MSVCStdSliceSyntheticProvider -x "^ref\$<slice2\$<.+> >" --category Rust +type synthetic add -l lldb_lookup.MSVCTupleSyntheticProvider -x "^tuple\$<.+>$" --category Rust +type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^tuple\$<.+>$" --category Rust +type synthetic add -l lldb_lookup.synthetic_lookup -x "^\(.*\)$" --category Rust type summary add -F _ -e -x -h "^.*$" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)String$" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?str$" --category Rust @@ -40,4 +43,5 @@ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)N type summary add -F lldb_lookup.summary_lookup -e -x -h "^core::num::([a-z_]+::)*NonZero.+$" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::([a-z_]+::)+)PathBuf$" --category Rust type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust +type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^tuple\$<.+>$" --category Rust type category enable Rust diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 2f32ed833af..9f2b2c85e65 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -205,6 +205,24 @@ def StdPathSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str: return '"%s"' % data +def sequence_formatter(output: str, valobj: SBValue, _dict: LLDBOpaque): + length: int = valobj.GetNumChildren() + + long: bool = False + for i in range(0, length): + if len(output) > 32: + long = True + break + child: SBValue = valobj.GetChildAtIndex(i) + output += f"{child.value}, " + if long: + output = f"(len: {length}) " + output + "..." + else: + output = output[:-2] + + return output + + class StructSyntheticProvider: """Pretty-printer for structs and struct enum variants""" @@ -348,6 +366,41 @@ class TupleSyntheticProvider: return True +class MSVCTupleSyntheticProvider: + __slots__ = ["valobj"] + + def __init__(self, valobj: SBValue, _dict: LLDBOpaque): + self.valobj = valobj + + def num_children(self) -> int: + return self.valobj.GetNumChildren() + + def get_child_index(self, name: str) -> int: + return self.valobj.GetIndexOfChildWithName(name) + + def get_child_at_index(self, index: int) -> SBValue: + child: SBValue = self.valobj.GetChildAtIndex(index) + return child.CreateChildAtOffset(str(index), 0, child.GetType()) + + def update(self): + pass + + def has_children(self) -> bool: + return self.valobj.MightHaveChildren() + + def get_type_name(self) -> str: + name = self.valobj.GetTypeName() + # remove "tuple$<" and ">", str.removeprefix and str.removesuffix require python 3.9+ + name = name[7:-1] + return "(" + name + ")" + + +def TupleSummaryProvider(valobj: SBValue, _dict: LLDBOpaque): + output: str = sequence_formatter("(", valobj, dict) + output += ")" + return output + + class StdVecSyntheticProvider: """Pretty-printer for alloc::vec::Vec<T> |
