-
Notifications
You must be signed in to change notification settings - Fork 341
Display generic function type parameters in backtraces. #8703
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
Display generic function type parameters in backtraces. #8703
Conversation
There was a global cache for Swift display names, however, it didn't take the symbol context into account, which means the demangling result is non-deterministic depending on whether the symbol context had the necessary debug info to resolve the names of archetypes or not. In addition to that Display names are not supposed to be on a hot path (unlike names, which are used to resolve breakpoints).
This patch changes the behavior of SwiftLanguage::GetFunctionDisplayName() so it now: - (if exe_ctx && sc available) does generic parameter binding - (if only sc availble) shows the archetype name - the letter τ will now only appear if neither no context whatsover is available - (drive by) omits self rdar://126883922
@swift-ci test |
@swift-ci test linux |
@@ -1730,6 +1735,8 @@ bool SwiftLanguage::GetFunctionDisplayName( | |||
VariableSP var_sp(args.GetVariableAtIndex(arg_idx)); | |||
ValueObjectSP var_value_sp( | |||
ValueObjectVariable::Create(exe_scope, var_sp)); | |||
if (!var_sp || !var_value_sp || var_sp->IsArtificial()) |
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 assume this is the self
bit you mentioned in the commit message?
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.
Yes.
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.
can you explain a little more, where is self being omitted? Is there a test for it that I've overlooked?
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.
LGTM! Very excited to see this
@@ -498,10 +498,10 @@ bool Function::IsTopLevelFunction() { | |||
return result; | |||
} | |||
|
|||
ConstString Function::GetDisplayName(const SymbolContext *sc) const { |
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.
What's the reason the SymbolContext
is no longer plumbed through?
stream = lldb.SBStream() | ||
bkpt.GetLocationAtIndex(0).GetDescription(stream, 1) | ||
desc = stream.GetData() | ||
self.assertIn("C.f<T>(T, U) -> ()", desc) |
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.
shouldn't this be C.f<U>(T, U)
? The function's generic parameter is named U
in the source, and its containing class has the generic type named T
. If this test is passing, do we have a bug?
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.
Uh, thanks!
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'll track that separately and fix it in a follow-up, since it isn't a regression.
This patch changes the behavior of SwiftLanguage::GetFunctionDisplayName()
so it now:
rdar://126883922