2

I need to trace some debugging information on the threads in my application, at least the name or maybe even only the count of them. Xcode does it wonderfully (showing the name of the dispatch queue) :

enter image description here

How can I replicate this using any technology? I looked a little bit to NSTread ([NSThread callStackSymbols] is beautiful, but only for the current thread) and pthread, pthread_from_mach_thread_np looks promising. Even an external call to ps is acceptable if nothing else.

Liviu
  • 1,859
  • 2
  • 22
  • 48
  • If Xcode does it, why not use Xcode? Have you tried *”Instruments”*? – Mark Setchell Nov 24 '17 at 21:26
  • I needed in the application, as precised, as the app might do some useful log for later debugging, on another system. – Liviu Nov 25 '17 at 01:05
  • Do you want (1) the count of threads, (2) the names of threads, or (3) the current function names executing in each thread? – John Zwinck Nov 25 '17 at 01:15
  • @John Zwinck Preferable all of them ... If only I could enumerate them somehow (like `CreateToolhelp32Snapshot` on Windows, not asking much) ... – Liviu Nov 25 '17 at 01:21
  • Start here: https://stackoverflow.com/questions/3475750/posix-api-call-to-list-all-the-pthreads-running-in-a-process - but `/proc` doesn't exist on Mac OS. – John Zwinck Nov 25 '17 at 01:52

0 Answers0