diff --git a/include/restorer.h b/include/restorer.h index f4f197f48..745741f08 100644 --- a/include/restorer.h +++ b/include/restorer.h @@ -311,4 +311,20 @@ static void always_inline rst_mutex_unlock(rst_mutex_t *mutex) sys_futex(mutex, FUTEX_WAKE, 1, NULL, NULL, 0); } +/* We need own handler */ + +#ifdef BUG_ON_HANDLER +# undef BUG_ON_HANDLER +#endif + +#define BUG_ON_HANDLER(condition) \ + do { \ + if ((condition)) { \ + long tgid = sys_gettid(); \ + write_hex_n(0x5a5a5a5a); \ + write_num_n(__LINE__); \ + sys_tgkill(tgid, tgid, SIGABRT); \ + } \ + } while (0) + #endif /* CR_RESTORER_H__ */ diff --git a/include/syscall-codes.h b/include/syscall-codes.h index 249b16776..68e6d20b8 100644 --- a/include/syscall-codes.h +++ b/include/syscall-codes.h @@ -24,6 +24,7 @@ #define __NR_exit 60 #define __NR_flock 73 #define __NR_unlink 87 +#define __NR_tgkill 131 #define __NR__sysctl 156 #define __NR_prctl 157 #define __NR_arch_prctl 158 diff --git a/include/syscall.h b/include/syscall.h index 254cff03b..3ccdf6a02 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -279,6 +279,11 @@ static void always_inline local_sleep(long seconds) sys_nanosleep(&req, &rem); } +static long always_inline sys_tgkill(long tgid, long pid, int sig) +{ + return syscall3(__NR_tgkill, tgid, pid, (long)sig); +} + #else /* CONFIG_X86_64 */ # error x86-32 bit mode not yet implemented #endif /* CONFIG_X86_64 */