1c432c8f8SZachary Turner // This header is included in all the test programs (C and C++) and provides a 2c432c8f8SZachary Turner // hook for dealing with platform-specifics. 3*e0dbd025SPavel Labath 4c432c8f8SZachary Turner #if defined(_WIN32) || defined(_WIN64) 5*e0dbd025SPavel Labath #define LLDB_DYLIB_EXPORT __declspec(dllexport) 6*e0dbd025SPavel Labath #define LLDB_DYLIB_IMPORT __declspec(dllimport) 7c432c8f8SZachary Turner #else 8*e0dbd025SPavel Labath #define LLDB_DYLIB_EXPORT 9*e0dbd025SPavel Labath #define LLDB_DYLIB_IMPORT 10c432c8f8SZachary Turner #endif 11*e0dbd025SPavel Labath 12*e0dbd025SPavel Labath #ifdef COMPILING_LLDB_TEST_DLL 13*e0dbd025SPavel Labath #define LLDB_TEST_API LLDB_DYLIB_EXPORT 14c432c8f8SZachary Turner #else 15*e0dbd025SPavel Labath #define LLDB_TEST_API LLDB_DYLIB_IMPORT 16c432c8f8SZachary Turner #endif 17c432c8f8SZachary Turner 18f343968fSZachary Turner #if defined(_WIN32) 19f343968fSZachary Turner #define LLVM_PRETTY_FUNCTION __FUNCSIG__ 20f343968fSZachary Turner #else 21f343968fSZachary Turner #define LLVM_PRETTY_FUNCTION LLVM_PRETTY_FUNCTION 22f343968fSZachary Turner #endif 23f343968fSZachary Turner 24d0f89cd7SPavel Labath 25d0f89cd7SPavel Labath // On some systems (e.g., some versions of linux) it is not possible to attach to a process 26d0f89cd7SPavel Labath // without it giving us special permissions. This defines the lldb_enable_attach macro, which 27d0f89cd7SPavel Labath // should perform any such actions, if needed by the platform. This is a macro instead of a 28d0f89cd7SPavel Labath // function to avoid the need for complex linking of the test programs. 29d0f89cd7SPavel Labath #if defined(__linux__) 30d0f89cd7SPavel Labath #include <sys/prctl.h> 31d0f89cd7SPavel Labath 32fa3d652dSPavel Labath // Android API <= 16 does not have these defined. 33fa3d652dSPavel Labath #ifndef PR_SET_PTRACER 34fa3d652dSPavel Labath #define PR_SET_PTRACER 0x59616d61 35fa3d652dSPavel Labath #endif 36fa3d652dSPavel Labath #ifndef PR_SET_PTRACER_ANY 37fa3d652dSPavel Labath #define PR_SET_PTRACER_ANY ((unsigned long)-1) 38fa3d652dSPavel Labath #endif 39fa3d652dSPavel Labath 40d0f89cd7SPavel Labath // For now we execute on best effort basis. If this fails for some reason, so be it. 41d0f89cd7SPavel Labath #define lldb_enable_attach() \ 42d0f89cd7SPavel Labath do \ 43d0f89cd7SPavel Labath { \ 44d0f89cd7SPavel Labath const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); \ 45d0f89cd7SPavel Labath (void)prctl_result; \ 46d0f89cd7SPavel Labath } while (0) 47d0f89cd7SPavel Labath 48d0f89cd7SPavel Labath #else // not linux 49d0f89cd7SPavel Labath 50d0f89cd7SPavel Labath #define lldb_enable_attach() 51d0f89cd7SPavel Labath 52d0f89cd7SPavel Labath #endif 53