1 // This header is included in all the test programs (C and C++) and provides a 2 // hook for dealing with platform-specifics. 3 #if defined(_WIN32) || defined(_WIN64) 4 #ifdef COMPILING_LLDB_TEST_DLL 5 #define LLDB_TEST_API __declspec(dllexport) 6 #else 7 #define LLDB_TEST_API __declspec(dllimport) 8 #endif 9 #else 10 #define LLDB_TEST_API 11 #endif 12 13 #if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0) 14 // Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all 15 // calls to __uncaught_exception. Unfortunately, it does seem to eliminate 16 // the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is 17 // declared. This may not be necessary after MSVC 12. 18 #include <eh.h> 19 #endif 20 21 22 // On some systems (e.g., some versions of linux) it is not possible to attach to a process 23 // without it giving us special permissions. This defines the lldb_enable_attach macro, which 24 // should perform any such actions, if needed by the platform. This is a macro instead of a 25 // function to avoid the need for complex linking of the test programs. 26 #if defined(__linux__) 27 #include <sys/prctl.h> 28 29 #if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY) 30 // For now we execute on best effort basis. If this fails for some reason, so be it. 31 #define lldb_enable_attach() \ 32 do \ 33 { \ 34 const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); \ 35 (void)prctl_result; \ 36 } while (0) 37 38 #endif 39 40 #else // not linux 41 42 #define lldb_enable_attach() 43 44 #endif 45