-
Notifications
You must be signed in to change notification settings - Fork 352
[lldb][FrameRecognizer] Make VerboseTrapFrameRecognizer aware of Swift-C++ interop frames #9306
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][FrameRecognizer] Make VerboseTrapFrameRecognizer aware of Swift-C++ interop frames #9306
Conversation
…t-C++ interop frames
| static bool ShouldHideSwiftFrame(llvm::StringRef frame_name) { | ||
| static llvm::SmallVector<RegularExpression, 2> s_patterns{ | ||
| RegularExpression{R"(^(__C\.)?std\.)"}, | ||
| RegularExpression{R"(protocol witness for Cxx\.)"}}; |
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.
Would it be theoretically possible to have the Swift hidden frame recognizer take over in this case? It seems wrong to maintain this list in two places.
| if (auto module_node = ChildAtPath(witness_node, {Node::Kind::Module}); | ||
| module_node && module_node->getText() == "__C_Synthesized") | ||
| return true; | ||
| ; |
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.
stray ;
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.
FYI, maybe it'd be okay to remove all protocol witnesses.
| // prefix for functions from libc++. We don't want to | ||
| // stop in those frames either. | ||
| && !frame_name.GetStringRef().starts_with("__C.std.") && | ||
| !frame_name.GetStringRef().starts_with("std.") |
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 check live inside SwiftHiddenFrameRecognizer(), assuming that we never want to stop there?
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.
Depends, do we want to hide all frames from the std module? With C++ interop that could make sense. But wasn't sure.
|
|
||
| @swiftTest | ||
| def test(self): | ||
| self.build() |
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.
Why not just do:
lldbutil.run_to_source_breakpoint(self, "Break here", lldb.SBFileSpec("main.swift")
?
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.
Is it because we don't expect tp hit the breakpoint?
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.
Yup, lldbutil.run_to_source_breakpoint asserts that we stopped at some breakpoint. Which won't happen for this test.
Might be worth creating a wrapper for the "just launch the executable" case. That way we could make use of __buitin_debugtrap in more tests too.
| // check the namespace prefix too. | ||
| if (!frame_name.GetStringRef().starts_with("std::") && | ||
| !most_relevant_frame_sp->IsHidden() | ||
| #ifdef LLDB_ENABLE_SWIFT |
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 this live in the language plugin? The goal is to reduce the amount of changes in generic (non-Swift specific) code and we definitely don't want to add more.
|
Argh forgot to squash the commits... |
This patch ensures that if
libc++is called from Swift (via Swift interop for example), and triggers a__builtin_verbose_trap, we don't stop in the Swift-C++ compiler-generated shims.E.g., in the example test-case, the stacktrace looks like:
We want to stop in frame 5, which is where the call into
stdstarted.rdar://136357737