CMake: Add sigaction, sigaltstack, self dbg
This commit is contained in:
@@ -58,6 +58,9 @@ endif (MSVC)
|
||||
if (UNIX)
|
||||
find_package(DL)
|
||||
find_package(Demangle)
|
||||
find_package(Sigaction)
|
||||
find_package(Sigaltstack)
|
||||
find_package(SelfDbg)
|
||||
endif (UNIX)
|
||||
|
||||
find_package(SSE)
|
||||
|
37
cmake/FindSelfDbg.cmake
Normal file
37
cmake/FindSelfDbg.cmake
Normal file
@@ -0,0 +1,37 @@
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
int main() {
|
||||
pid_t tid = syscall(SYS_gettid);
|
||||
int status;
|
||||
waitpid((pid_t) 0, &status, 0);
|
||||
return WIFEXITED(status) && WEXITSTATUS(status);
|
||||
}"
|
||||
DBG_GDB_FOUND
|
||||
)
|
||||
|
||||
if (DBG_GDB_FOUND)
|
||||
add_compile_options(
|
||||
-DWITH_DBG_GDB
|
||||
)
|
||||
endif (DBG_GDB_FOUND)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <sys/prctl.h>
|
||||
int main() {
|
||||
return prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
|
||||
}"
|
||||
PRCTL_PT_FOUND
|
||||
)
|
||||
|
||||
if (PRCTL_PT_FOUND)
|
||||
add_compile_options(
|
||||
-DWITH_PRCTL_PT
|
||||
)
|
||||
endif (PRCTL_PT_FOUND)
|
26
cmake/FindSigaction.cmake
Normal file
26
cmake/FindSigaction.cmake
Normal file
@@ -0,0 +1,26 @@
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <signal.h>
|
||||
void *addr;
|
||||
int code;
|
||||
void handler(int sig, siginfo_t *si, void *context) {
|
||||
addr = si->si_addr;
|
||||
code = si->si_code;
|
||||
}
|
||||
int main() {
|
||||
struct sigaction sa;
|
||||
sa.sa_flags = SA_SIGINFO;
|
||||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_sigaction = handler;
|
||||
sigaction(SIGSEGV, &sa, 0);
|
||||
return 0;
|
||||
}"
|
||||
SIGACTION_FOUND
|
||||
)
|
||||
|
||||
if (SIGACTION_FOUND)
|
||||
add_compile_options(
|
||||
-DWITH_SIGACTION
|
||||
)
|
||||
endif (SIGACTION_FOUND)
|
21
cmake/FindSigaltstack.cmake
Normal file
21
cmake/FindSigaltstack.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
include(CheckCXXSourceCompiles)
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
int main() {
|
||||
stack_t ss;
|
||||
ss.ss_sp = calloc(SIGSTKSZ, 1);
|
||||
ss.ss_size = SIGSTKSZ;
|
||||
ss.ss_flags = 0;
|
||||
sigaltstack(&ss, nullptr);
|
||||
return 0;
|
||||
}"
|
||||
SIGALTSTACK
|
||||
)
|
||||
|
||||
if (SIGALTSTACK_FOUND)
|
||||
add_compile_options(
|
||||
-DWITH_SIGALTSTACK
|
||||
)
|
||||
endif (SIGALTSTACK_FOUND)
|
Reference in New Issue
Block a user