> On Jan 8, 2015, at 8:26 AM, Mario Zechner <badlogicga...@gmail.com> wrote: > > Hi, > > we are currently trying work around some issues with rapid suspend/resume. We > essentially setup a thread in the inferior with which we communicate via TCP > to get informed of events such as thread start/stop without having to set > breakpoints and stopping the inferior. > > Eventually we need to associate the native threads with the SBThread we get > from LLDB's API. SBThread has an id and an index, but those don't seem to map > to anything on the inferior side (e.g. the pthread id of the thread). > > Is there a way to perform this association?
As Greg said, on Mac OS X each thread created by the system since the last reboot is assigned an incrementing number, the globally unique thread id. That's what lldb and sample use as the thread identifiers -- pthread_t values may be reused by the system during a process lifetime as threads are created and destroyed. You can get the globally unique thread id for the current thread via the nonportable pthread_threadid_np() call. e.g. (lldb) thread info thread #1: tid = 0x088f, 0x00007fff856b352e libsystem_kernel.dylib`mach_msg_trap + 10, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP (lldb) p/x (void*)malloc(8) (void *) $2 = 0x0000620000007a00 (lldb) p/d (uint64_t) pthread_threadid_np(0, $2) (uint64_t) $3 = 0 (lldb) x/gx $2 0x620000007a00: 0x000000000000088f J _______________________________________________ lldb-dev mailing list lldb-dev@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev