A MachO userspace corefile may contain LC_THREAD commands which specify thread exception state. For arm64* only (for now), report a human-readable version of this state as the thread stop reason, instead of 'SIGSTOP'. As a follow-up, similar functionality can be implemented for x86 cores by translating the trapno/err exception registers. rdar://82898146 Differential Revision: https://reviews.llvm.org/D109795
25 lines
498 B
C++
25 lines
498 B
C++
#include <stdlib.h>
|
|
#include <thread>
|
|
#include <unistd.h>
|
|
#include <vector>
|
|
|
|
void *sleep_worker(void *in) {
|
|
sleep(30);
|
|
sleep(30);
|
|
return nullptr;
|
|
}
|
|
|
|
void *crash_worker(void *in) {
|
|
sleep(1);
|
|
volatile int *p = nullptr; // break here
|
|
return (void *)*p;
|
|
}
|
|
|
|
int main() {
|
|
std::vector<std::thread> threads;
|
|
threads.push_back(std::move(std::thread(crash_worker, nullptr)));
|
|
for (int i = 0; i < 15; i++)
|
|
threads.push_back(std::move(std::thread(sleep_worker, nullptr)));
|
|
sleep(10);
|
|
}
|