-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Debuginfo] Add MSVC Synthetic and Summary providers to LLDB #135354
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
Hmm, I was originally going to separate it out, but I think I can squeeze the |
(cc @wesleywiser: maybe you could take a look if you have the bandwidth and are willing?) |
src/etc/lldb_providers.py
Outdated
@@ -127,6 +131,25 @@ def has_children(self) -> bool: | |||
return False | |||
|
|||
|
|||
def get_template_args(type_name: str) -> List[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add a comment on this function (or maybe we have unit tests for this code?) that could check that this is doing what it wants to?
Checking locally, it looks like this is specifically getting the top-level generic (nit: maybe rename the function? Templates aren't really what Rust calls this) arguments.
print(get_template_args("Foo<Bar>")) # = ['Bar']
print(get_template_args("Foo<Bar<A, B>>")) # = ['Bar<A, B>']
print(get_template_args("Foo<Bar<A<A1, A2>, B>>")) # = ['Bar<A<A1, A2>, B>']
print(get_template_args("Foo<Bar<A<A1, A2>, B>, Baz1, Baz2>")) # ['Bar<A<A1, A2>, B>', 'Baz1', 'Baz2']
I think that's probably reasonable for what we need this function for -- it looks like we actually only ever look at the 0th argument -- but it's also at least IMO not intuitive from glancing at the code that this is the result, so seems like a comment would be worthwhile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sure. The rationale for the name mostly comes down to "that's what LLDB calls it", as it's ~a replacement for SBType.template_args (which always fails on MSVC for whatever reason. IIRC the information does exist in the PDB, LLDB just doesn't care. I'm sure it's fixable on their end, but afaik that's gonna be a lot of effort).
Returning a list will be useful for fixing up the type name output (once i get around to that), since it'll need to recursively format the generic args. Grabbing only the first level should mean I can look up the full type via target.FindFirstType()
and call .GetDisplayTypeName()
to leverage any existing SyntheticProvider.get_type_name()
.
src/etc/lldb_providers.py
Outdated
|
||
# acquire the first generic parameter via its type name | ||
_, _, end = self.valobj.GetTypeName().partition("<") | ||
element_name, _, _ = end.partition(",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this can't use the get_template_args above. Is that because we're not getting a proper type here (e.g., other noise is mixed in)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, that's a remnant from when it was the only place that needed a template args replacement
Adds handling for
tuple$<>
,ref$<slice$2<>
,ref$<str$>
andenum2$<>
.Also fixes a bug in MSVC vec/string handling where the script was unable to determine the element's type due to LLDB ignoring template arg debug information
Sample code
Before:
After: