-
Notifications
You must be signed in to change notification settings - Fork 339
[lldb] Find public Objective-C class when reconstructing type #3188
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
[lldb] Find public Objective-C class when reconstructing type #3188
Conversation
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, some nitpicks inside :-)
@@ -4401,6 +4406,33 @@ swift::TypeBase *SwiftASTContext::ReconstructType(ConstString mangled_typename, | |||
*ast_ctx, mangled_typename.GetStringRef()) | |||
.getPointer(); | |||
|
|||
// If we couldn't find the type and it's an obj-c type, | |||
// walk up the type hierarchy until we find something we can | |||
// import, or until we run out of types. |
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.
This comment explains what the code does, but not why. How about:
Objective-C classes sometimes have private subclasses that are invisible to the Swift compiler because they are declared and defined in a .m file. If we can't reconstruct an ObjC type, walk up the type hierarchy until we find something we can import, or until we run out of types.
// walk up the type hierarchy until we find something we can | ||
// import, or until we run out of types. | ||
while (!found_type) { | ||
auto clang_type = GetAsClangType(mangled_typename); |
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.
CompilerType clang_type
GetAsClangType doesn't really have an obvious return type
auto *super_interface_decl = interface_decl->getSuperClass(); | ||
if (!super_interface_decl) | ||
break; | ||
auto super_type = clang_ctx->GetTypeForDecl(super_interface_decl); |
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.
here the type also isn't obvious from the name
When reconstructing a private Objective-C type, walk up the type hierarchy until a type importable from Swift is found or until we run out of types.
d326052
to
33bf8f7
Compare
Hi there. Sorry to bother again. @adrian-prantl @augusto2112 🤦♂️ Recently we found, when user disable the TypeRef mirror impl of Swift symbol resolve, this will cause an infinity loop and finally crash. Reproduce demoThe crash happens for those private Objc type who is not visiable to compiler. Like Apple's private type
var font: UIFont = UIFont.systemFont(ofSize: UIFont.systemFontSize)
print("break here")
Crash Log:lldb-rpc-server_2022-05-11-172619_lizhuolideMacBook-Pro.txt ReasonI found that, during this PR: #3204 However, since the type is private type, it's not visible for compiler and no debug info about that. So, when fallback on SwiftASTContext for symbol discovery. The The infinity call order
Solution ?I'm not really familiar with the changes. Here is our temp patch: Which use the |
@dreampiggy thank you for the detailed report! I'll take a look at the issue. |
@dreampiggy, I'm curious, why do you need to disable the typeref typesystem? |
Actually it's because of debugging performance and experience. :( For our internal company's large iOS project, which use heavily of Swift source code (more than 400+ Swift Module, 100K+ Lines souce), and mixing of Objc/C/C++/Rust code and binary. We found the huge performance regression when using the default When using This is why we disable that option, for now. To be honest, if the typeref mirror implementation can get a better debugging performance or at least equal to the old SwiftASTContext one, we will use the default option as usual. Here is one Demo which I previously provided to adrian for another issue. Which looks a little similiar to our internal project issue: https://github.com/PRESIDENT810/slowDebugTest/tree/simulate_massive_module ( |
@dreampiggy thank you for the feedback! |
Do you think you could share a trace of lldb-rpc-server captured with |
Hi. I'll try to collect and profile and submit for you weekend, with the radar ID or some thirdparty CDN url. |
When reconstructing a private Objective-C type, walk up the
type hierarchy until a type importable from Swift is found or
until we run out of types.