wyre/compiler/crash_handler.mu
2020-09-26 00:35:42 +02:00

17 lines
404 B
Text

:crashAllocator IAllocator #Mutable
CrashHandler {
enable() {
::crashAllocator = Memory.newArenaAllocator(64 * 1024)
signal(SIGSEGV, pointer_cast(crashHandler, pointer))
}
crashHandler(sig int) {
::currentAllocator = ::crashAllocator
prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0)
system("xfce4-terminal --hold -x gdb -tui -p $PPID")
while true {
usleep(1000_u * 1000_u)
}
}
}