Files
clang-p2996/lldb/test/Shell/Recognizer/Inputs/verbose_trap-in-stl-callback.cpp
Michael Buch bca507387a [lldb][FrameRecognizer] Display the first non-std frame on verbose_trap (#108825)
This attempts to improve user-experience when LLDB stops on a
verbose_trap. Currently if a `__builtin_verbose_trap` triggers, we
display the first frame above the call to the verbose_trap. So in the
newly added test case, we would've previously stopped here:
```
(lldb) run
Process 28095 launched: '/Users/michaelbuch/a.out' (arm64)
Process 28095 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = Bounds error: out-of-bounds access
    frame #1: 0x0000000100003f5c a.out`std::__1::vector<int>::operator[](this=0x000000016fdfebef size=0, (null)=10) at verbose_trap.cpp:6:9
   3    template <typename T>
   4    struct vector {
   5        void operator[](unsigned) {
-> 6            __builtin_verbose_trap("Bounds error", "out-of-bounds access");
   7        }
   8    };
```

After this patch, we would stop in the first non-`std` frame:
```
(lldb) run
Process 27843 launched: '/Users/michaelbuch/a.out' (arm64)
Process 27843 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = Bounds error: out-of-bounds access
    frame #2: 0x0000000100003f44 a.out`g() at verbose_trap.cpp:14:5
   11  
   12   void g() {
   13       std::vector<int> v;
-> 14       v[10];
   15   }
   16  
```

rdar://134490328
2024-09-19 10:06:28 +01:00

23 lines
467 B
C++

namespace std {
void definitely_aborts() { __builtin_verbose_trap("Failed", "Invariant violated"); }
void aborts_soon() { definitely_aborts(); }
} // namespace std
void g() { std::aborts_soon(); }
namespace std {
namespace detail {
void eventually_aborts() { g(); }
} // namespace detail
inline namespace __1 {
void eventually_aborts() { detail::eventually_aborts(); }
} // namespace __1
} // namespace std
int main() {
std::eventually_aborts();
return 0;
}