62 Threads receive different pid under LinuxThreads. We used to save the result of 63 ::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id 64 was lost under NPTL. Now, we store the result of ::gettid() call in 65 OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is 66 unique again. We therefore use OSThread::_thread_id as unique identifier. 67 68 3. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id 69 to its underlying lwp_id under both the thread libraries. thread_info.lwp_id stores 70 lwp_id of the thread. The lwp id is nothing but the actual pid of clone'd processes. But 71 unfortunately libthread_db does not work very well for core dumps. So, we get pthread_id 72 only for processes. For core dumps, we don't use libthread_db at all (like gdb). 73 74 4. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for 75 ptrace call, we refer to lwp_id of the thread. 76 77 5. for core file, we parse ELF files and read data from them. For processes we use 78 combination of ptrace and /proc calls. 79 80 *************************************************************************************/ 81 82 #ifdef ia64 83 struct user_regs_struct { 84 /* copied from user.h which doesn't define this in a struct */ 85 86 #define IA64_REG_COUNT (EF_SIZE/8+32) /* integer and fp regs */ 87 unsigned long regs[IA64_REG_COUNT]; /* integer and fp regs */ 88 }; 89 #endif 90 91 #if defined(sparc) || defined(sparcv9) 92 #define user_regs_struct pt_regs 93 #endif 94 95 // This C bool type must be int for compatibility with Linux calls and 96 // it would be a mistake to equivalence it to C++ bool on many platforms 97 98 typedef int bool; 99 #define true 1 100 #define false 0 101 102 struct ps_prochandle; 103 104 // attach to a process 105 struct ps_prochandle* Pgrab(pid_t pid); 106 107 // attach to a core dump 108 struct ps_prochandle* Pgrab_core(const char* execfile, const char* corefile); 109 110 // release a process or core | 62 Threads receive different pid under LinuxThreads. We used to save the result of 63 ::getpid() call in OSThread::_thread_id. This way uniqueness of OSThread::_thread_id 64 was lost under NPTL. Now, we store the result of ::gettid() call in 65 OSThread::_thread_id. Because gettid returns actual pid of thread (lwp id), this is 66 unique again. We therefore use OSThread::_thread_id as unique identifier. 67 68 3. There is a unique LWP id under both thread libraries. libthread_db maps pthread_id 69 to its underlying lwp_id under both the thread libraries. thread_info.lwp_id stores 70 lwp_id of the thread. The lwp id is nothing but the actual pid of clone'd processes. But 71 unfortunately libthread_db does not work very well for core dumps. So, we get pthread_id 72 only for processes. For core dumps, we don't use libthread_db at all (like gdb). 73 74 4. ptrace operates on this LWP id under both the thread libraries. When we say 'pid' for 75 ptrace call, we refer to lwp_id of the thread. 76 77 5. for core file, we parse ELF files and read data from them. For processes we use 78 combination of ptrace and /proc calls. 79 80 *************************************************************************************/ 81 82 83 #if defined(sparc) || defined(sparcv9) 84 #define user_regs_struct pt_regs 85 #endif 86 87 // This C bool type must be int for compatibility with Linux calls and 88 // it would be a mistake to equivalence it to C++ bool on many platforms 89 90 typedef int bool; 91 #define true 1 92 #define false 0 93 94 struct ps_prochandle; 95 96 // attach to a process 97 struct ps_prochandle* Pgrab(pid_t pid); 98 99 // attach to a core dump 100 struct ps_prochandle* Pgrab_core(const char* execfile, const char* corefile); 101 102 // release a process or core |