os_log

random snippet:

#include <os/log.h>

mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
task_dyld_info_data_t dyld_info;
kern_return_t kr = task_info(mach_task_self(),
                             TASK_DYLD_INFO,
                             reinterpret_cast<task_info_t>(&dyld_info),
                             &count);
  dyld_all_image_infos*  image_infos = (dyld_all_image_infos*)dyld_info.all_image_info_addr;

for(int i=0;i<(int)image_infos->infoArrayCount;i++) {
  os_log(OS_LOG_DEFAULT, "LOGME: Image %d: %s\n", i, image_infos->infoArray[i].imageFilePath);
}

mach_msg_type_number_t thread_count = 0;
thread_act_array_t threads;
kr = task_threads(mach_task_self(), &threads, &thread_count);
os_log(OS_LOG_DEFAULT, "LOGME: Thread Count %d\n", (int)thread_count);

Leave a Reply