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
22 lines
400 B
C++
22 lines
400 B
C++
namespace std {
|
|
namespace detail {
|
|
void function_that_aborts() { __builtin_verbose_trap("Bounds error", "out-of-bounds access"); }
|
|
} // namespace detail
|
|
|
|
inline namespace __1 {
|
|
template <typename T> struct vector {
|
|
void operator[](unsigned) { detail::function_that_aborts(); }
|
|
};
|
|
} // namespace __1
|
|
} // namespace std
|
|
|
|
void g() {
|
|
std::vector<int> v;
|
|
v[10];
|
|
}
|
|
|
|
int main() {
|
|
g();
|
|
return 0;
|
|
}
|