llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[lldb][FrameRecognizer] Make VerboseTrapFrameRecognizer aware of Swift-C++ interop frames

Open Michael137 opened this issue 1 year ago • 0 comments

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:

frame #0: 0x0000000102998c00 a.out`std::function_that_aborts() [inlined] __clang_trap_msg$Error$from C++ at aborts.h:0
frame #1: 0x0000000102998c00 a.out`std::function_that_aborts() at aborts.h:4:31
frame #2: 0x0000000102998c1c a.out`std::ConstIterator::operator*(this=0x0000600003954420) const at aborts.h:21:28
frame #3: 0x0000000102998ab0 a.out`std.ConstIterator.pointee.read() at <compiler-generated>:0
frame #4: 0x0000000102998a14 a.out`protocol witness for UnsafeCxxInputIterator.pointee.read in conformance std.ConstIterator at <compiler-generated>:0
frame #5: 0x0000000102998760 a.out`takes<ConstIterator>(t=Aborts.ConstIterator @ 0x000000016d46aeb8) at main.swift:4:7
frame #6: 0x00000001029985e0 a.out`main() at main.swift:9:3
frame #7: 0x0000000102998584 a.out`main at main.swift:13:1
frame #8: 0x000000019053df20 dyld`start + 1988

We want to stop in frame 5, which is where the call into std started.

rdar://136357737

Michael137 avatar Sep 20 '24 12:09 Michael137