What does thread id in sampling result mean?

Hi,


Below is the output of "sample" cmd and I have a question that what does the id "119013" mean here?


I have verified that this is not pthread id neither is mach port. What I'm trying to do is now I have a mach port id of a thread and I want to know which thread it is in sampling result. Any tips?


Call graph:

2915 Thread_119013 DispatchQueue_1: com.apple.main-thread (serial)

+ 2915 start (in libdyld.dylib) + 1 [0x7fffd39bd255]

+ 2915 NSApplicationMain (in AppKit) + 1237 [0x7fffbc541a8a]

+ 2915 -[NSApplication run] (in AppKit) + 926 [0x7fffbc576fbd]

+ 2915 -[BrowserApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in Safari) + 252 [0x7fffcf09d771]

+ 2915 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit) + 1637 [0x7fffbcc928eb]

+ 2915 _DPSNextEvent (in AppKit) + 1093 [0x7fffbc5825f5]

+ 2915 _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox) + 71 [0x7fffbde8bbd6]

+ 2915 ReceiveNextEventCommon (in HIToolbox) + 432 [0x7fffbde8bda1]

+ 2915 RunCurrentEventLoopInMode (in HIToolbox) + 240 [0x7fffbde8bf6c]

+ 2915 CFRunLoopRunSpecific (in CoreFoundation) + 420 [0x7fffbe8eb874]

+ 2915 __CFRunLoopRun (in CoreFoundation) + 1361 [0x7fffbe8ec021]

+ 2915 __CFRunLoopServiceMachPort (in CoreFoundation) + 212 [0x7fffbe8ecba4]

+ 2915 mach_msg (in libsystem_kernel.dylib) + 55 [0x7fffd3ae3867]

+ 2915 mach_msg_trap (in libsystem_kernel.dylib) + 10 [0x7fffd3ae441a]


Thanks in advance.

Replies

It’s a globally unique (since the system booted) ID number associated with the thread. It’s super useful when you’re looking at thread issues that span multiple processes, keeping in mind that both

pthread_t
and Mach ports are meaningful only within the scope of one process.

You’ll often see it abbreviated as tid.

You can get the tid for a pthread using

pthread_threadid_np
. The easiest way to get the tid for a Mach thread is by bouncing through
pthread_from_mach_thread_np
, but you can also get it via
THREAD_IDENTIFIER_INFO
.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thank you for the quick response. This is really helpful.