brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · decd3ea Raw
35 lines · c
1#ifndef LLDB_TEST_ATTACH_H2#define LLDB_TEST_ATTACH_H3 4// On some systems (e.g., some versions of linux) it is not possible to attach5// to a process without it giving us special permissions. This defines the6// lldb_enable_attach macro, which should perform any such actions, if needed by7// the platform.8#if defined(__linux__)9#include <sys/prctl.h>10 11// Android API <= 16 does not have these defined.12#ifndef PR_SET_PTRACER13#define PR_SET_PTRACER 0x59616d6114#endif15#ifndef PR_SET_PTRACER_ANY16#define PR_SET_PTRACER_ANY ((unsigned long)-1)17#endif18 19// For now we execute on best effort basis.  If this fails for some reason, so20// be it.21#define lldb_enable_attach()                                                   \22  do {                                                                         \23    const int prctl_result =                                                   \24        prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);                    \25    (void)prctl_result;                                                        \26  } while (0)27 28#else // not linux29 30#define lldb_enable_attach()31 32#endif // defined(__linux__)33 34#endif // LLDB_TEST_ATTACH_H35