From: Apple Date: Thu, 4 Oct 2018 22:01:37 +0000 (+0000) Subject: system_cmds-805.200.21.tar.gz X-Git-Tag: macos-1014^0 X-Git-Url: https://git.saurik.com/apple/system_cmds.git/commitdiff_plain/530d02b6d6489eaa76ff9853c2897b2dc48d2d8e system_cmds-805.200.21.tar.gz --- diff --git a/arch.tproj/arch.c b/arch.tproj/arch.c index 426fea0..86df70a 100644 --- a/arch.tproj/arch.c +++ b/arch.tproj/arch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2016 Apple Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -76,6 +76,8 @@ static const CPUTypes knownArchs[] = { #if defined(__i386__) || defined(__x86_64__) {"i386", CPU_TYPE_I386}, {"x86_64", CPU_TYPE_X86_64}, +#elif defined(__arm64__) + {"arm64", CPU_TYPE_ARM64}, #elif defined(__arm__) {"arm", CPU_TYPE_ARM}, #else @@ -97,14 +99,18 @@ extern char **environ; * the arch command is running. NULL means unsupported. */ #if defined(__i386__) || defined(__x86_64__) -#define NATIVE_32 "i386" -#define NATIVE_64 "x86_64" + #define NATIVE_32 "i386" + #define NATIVE_64 "x86_64" +#elif defined(__arm64__) + #define NATIVE_64 "arm64" + #define NATIVE_32 NULL #elif defined(__arm__) -#define NATIVE_32 "arm" -#define NATIVE_64 NULL + #define NATIVE_32 "arm" + #define NATIVE_64 NULL #else -#error "Unsupported architecture" + #error "Unsupported architecture" #endif + bool unrecognizednative32seen = false; bool unrecognizednative64seen = false; diff --git a/fs_usage.tproj/fs_usage.c b/fs_usage.tproj/fs_usage.c index 7ef5728..8d1e67e 100644 --- a/fs_usage.tproj/fs_usage.c +++ b/fs_usage.tproj/fs_usage.c @@ -68,7 +68,7 @@ typedef struct th_info { struct th_info *next; - uintptr_t thread; + uint64_t thread; /* this is needed for execve()/posix_spawn(), because the command name at the end probe is the new name, which we don't want */ char command[MAXCOMLEN + 1]; @@ -78,21 +78,21 @@ typedef struct th_info { * (e.g., one absolute, one relative). traditional fs_usage behavior was to display the * *first* lookup, so we need to save it off once we see it. */ - unsigned long vnodeid; /* the vp of the VFS_LOOKUP we're currently in, 0 if we are not in one */ + uint64_t vnodeid; /* the vp of the VFS_LOOKUP we're currently in, 0 if we are not in one */ char pathname[MAXPATHLEN]; char pathname2[MAXPATHLEN]; char *newest_pathname; /* points to pathname2 if it's filled, otherwise pathname if it's filled, otherwise NULL */ int pid; int type; - unsigned long arg1; - unsigned long arg2; - unsigned long arg3; - unsigned long arg4; - unsigned long arg5; - unsigned long arg6; - unsigned long arg7; - unsigned long arg8; + uint64_t arg1; + uint64_t arg2; + uint64_t arg3; + uint64_t arg4; + uint64_t arg5; + uint64_t arg6; + uint64_t arg7; + uint64_t arg8; int waited; uint64_t stime; } *th_info_t; @@ -100,17 +100,17 @@ typedef struct th_info { struct diskio { struct diskio *next; struct diskio *prev; - unsigned long type; - unsigned long bp; - unsigned long dev; - unsigned long blkno; - unsigned long iosize; - unsigned long io_errno; - unsigned long is_meta; + uint64_t type; + uint64_t bp; + uint64_t dev; + uint64_t blkno; + uint64_t iosize; + uint64_t io_errno; + uint64_t is_meta; uint64_t vnodeid; - uintptr_t issuing_thread; + uint64_t issuing_thread; pid_t issuing_pid; - uintptr_t completion_thread; + uint64_t completion_thread; char issuing_command[MAXCOMLEN + 1]; uint64_t issued_time; uint64_t completed_time; @@ -122,12 +122,12 @@ struct diskio { #define HASH_MASK (HASH_SIZE - 1) void setup_ktrace_callbacks(void); -void extend_syscall(uintptr_t thread, int type, ktrace_event_t event); +void extend_syscall(uint64_t thread, int type, ktrace_event_t event); /* printing routines */ -bool check_filter_mode(pid_t pid, th_info_t ti, unsigned long type, int error, int retval, char *sc_name); -void format_print(th_info_t ti, char *sc_name, ktrace_event_t event, unsigned long type, int format, uint64_t now, uint64_t stime, int waited, const char *pathname, struct diskio *dio); -int print_open(ktrace_event_t event, uintptr_t flags); +bool check_filter_mode(pid_t pid, th_info_t ti, uint64_t type, int error, int retval, char *sc_name); +void format_print(th_info_t ti, char *sc_name, ktrace_event_t event, uint64_t type, int format, uint64_t now, uint64_t stime, int waited, const char *pathname, struct diskio *dio); +int print_open(ktrace_event_t event, uint64_t flags); /* metadata info hash routines */ void meta_add_name(uint64_t blockno, const char *pathname); @@ -137,14 +137,14 @@ void meta_delete_all(void); /* event ("thread info") routines */ void event_enter(int type, ktrace_event_t event); void event_exit(char *sc_name, int type, ktrace_event_t event, int format); -th_info_t event_find(uintptr_t thread, int type); +th_info_t event_find(uint64_t thread, int type); void event_delete(th_info_t ti_to_delete); void event_delete_all(void); -void event_mark_thread_waited(uintptr_t); +void event_mark_thread_waited(uint64_t); /* network fd set routines */ -void fd_set_is_network(pid_t pid, unsigned long fd, bool set); -bool fd_is_network(pid_t pid, unsigned long fd); +void fd_set_is_network(pid_t pid, uint64_t fd, bool set); +bool fd_is_network(pid_t pid, uint64_t fd); void fd_clear_pid(pid_t pid); void fd_clear_all(void); @@ -153,17 +153,17 @@ void init_shared_cache_mapping(void); void lookup_name(uint64_t user_addr, char **type, char **name); /* disk I/O tracking routines */ -struct diskio *diskio_start(unsigned long type, unsigned long bp, unsigned long dev, unsigned long blkno, unsigned long iosize, ktrace_event_t event); -struct diskio *diskio_find(unsigned long bp); -struct diskio *diskio_complete(unsigned long bp, unsigned long io_errno, unsigned long resid, uintptr_t thread, uint64_t curtime, struct timeval curtime_wall); +struct diskio *diskio_start(uint64_t type, uint64_t bp, uint64_t dev, uint64_t blkno, uint64_t iosize, ktrace_event_t event); +struct diskio *diskio_find(uint64_t bp); +struct diskio *diskio_complete(uint64_t bp, uint64_t io_errno, uint64_t resid, uint64_t thread, uint64_t curtime, struct timeval curtime_wall); void diskio_print(struct diskio *dio); void diskio_free(struct diskio *dio); /* disk name routines */ #define NFS_DEV -1 #define CS_DEV -2 -char *generate_cs_disk_name(unsigned long dev, char *s); -char *find_disk_name(unsigned long dev); +char *generate_cs_disk_name(uint64_t dev, char *s); +char *find_disk_name(uint64_t dev); void cache_disk_names(void); #define CLASS_MASK 0xff000000 @@ -386,7 +386,11 @@ void cache_disk_names(void); #define BSC_pwrite_nocancel 0x040c067c #define BSC_aio_suspend_nocancel 0x40c0694 #define BSC_guarded_open_np 0x040c06e4 +#define BSC_guarded_open_dprotected_np 0x040c0790 #define BSC_guarded_close_np 0x040c06e8 +#define BSC_guarded_write_np 0x040c0794 +#define BSC_guarded_pwrite_np 0x040c0798 +#define BSC_guarded_writev_np 0x040c079c #define BSC_fsgetpath 0x040c06ac @@ -461,6 +465,7 @@ void cache_disk_names(void); #define FMT_OPENAT 45 #define FMT_RENAMEAT 46 #define FMT_IOCTL_SYNCCACHE 47 +#define FMT_GUARDED_OPEN 48 #define DBG_FUNC_ALL (DBG_FUNC_START | DBG_FUNC_END) @@ -543,14 +548,18 @@ const struct bsd_syscall bsd_syscalls[MAX_BSD_SYSCALL] = { NORMAL_SYSCALL(posix_spawn), SYSCALL_WITH_NOCANCEL(open, FMT_OPEN), SYSCALL(open_extended, FMT_OPEN), - SYSCALL(guarded_open_np, FMT_OPEN), + SYSCALL(guarded_open_np, FMT_GUARDED_OPEN), SYSCALL_NAMED(open_dprotected_np, open_dprotected, FMT_OPEN), + SYSCALL(guarded_open_dprotected_np, FMT_GUARDED_OPEN), SYSCALL(dup, FMT_FD_2), SYSCALL(dup2, FMT_FD_2), SYSCALL_WITH_NOCANCEL(close, FMT_FD), SYSCALL(guarded_close_np, FMT_FD), SYSCALL_WITH_NOCANCEL(read, FMT_FD_IO), SYSCALL_WITH_NOCANCEL(write, FMT_FD_IO), + SYSCALL(guarded_write_np, FMT_FD_IO), + SYSCALL(guarded_pwrite_np, FMT_FD_IO), + SYSCALL(guarded_writev_np, FMT_FD_IO), SYSCALL(fgetxattr, FMT_FD), SYSCALL(fsetxattr, FMT_FD), SYSCALL(fremovexattr, FMT_FD), @@ -724,7 +733,13 @@ main(int argc, char *argv[]) get_screenwidth(); s = ktrace_session_create(); - assert(s); + assert(s != NULL); + (void)ktrace_ignore_process_filter_for_event(s, P_WrData); + (void)ktrace_ignore_process_filter_for_event(s, P_RdData); + (void)ktrace_ignore_process_filter_for_event(s, P_WrMeta); + (void)ktrace_ignore_process_filter_for_event(s, P_RdMeta); + (void)ktrace_ignore_process_filter_for_event(s, P_PgOut); + (void)ktrace_ignore_process_filter_for_event(s, P_PgIn); while ((ch = getopt(argc, argv, "bewf:R:S:E:t:W")) != -1) { switch (ch) { @@ -1274,7 +1289,7 @@ setup_ktrace_callbacks(void) * is all we really need. */ void -extend_syscall(uintptr_t thread, int type, ktrace_event_t event) +extend_syscall(uint64_t thread, int type, ktrace_event_t event) { th_info_t ti; @@ -1338,7 +1353,7 @@ extend_syscall(uintptr_t thread, int type, ktrace_event_t event) #pragma mark printing routines static void -get_mode_nibble(char *buf, unsigned long smode, unsigned long special, char x_on, char x_off) +get_mode_nibble(char *buf, uint64_t smode, uint64_t special, char x_on, char x_off) { if (smode & 04) buf[0] = 'r'; @@ -1358,7 +1373,7 @@ get_mode_nibble(char *buf, unsigned long smode, unsigned long special, char x_on } static void -get_mode_string(unsigned long mode, char *buf) +get_mode_string(uint64_t mode, char *buf) { memset(buf, '-', 9); buf[9] = '\0'; @@ -1405,11 +1420,11 @@ clip_64bit(char *s, uint64_t value) * filters may be combined; default is all filters on (except cachehit) */ bool -check_filter_mode(pid_t pid, th_info_t ti, unsigned long type, int error, int retval, char *sc_name) +check_filter_mode(pid_t pid, th_info_t ti, uint64_t type, int error, int retval, char *sc_name) { bool ret = false; int network_fd_isset = 0; - unsigned long fd; + uint64_t fd; /* cachehit is special -- it's not on by default */ if (sc_name[0] == 'C' && !strcmp(sc_name, "CACHE_HIT")) { @@ -1560,7 +1575,7 @@ check_filter_mode(pid_t pid, th_info_t ti, unsigned long type, int error, int re } int -print_open(ktrace_event_t event, uintptr_t flags) +print_open(ktrace_event_t event, uint64_t flags) { char mode[] = "______"; @@ -1602,7 +1617,7 @@ print_open(ktrace_event_t event, uintptr_t flags) */ void format_print(th_info_t ti, char *sc_name, ktrace_event_t event, - unsigned long type, int format, uint64_t now, uint64_t stime, + uint64_t type, int format, uint64_t now, uint64_t stime, int waited, const char *pathname, struct diskio *dio) { uint64_t secs, usecs; @@ -1613,16 +1628,16 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, int len = 0; int clen = 0; size_t tlen = 0; - unsigned long class; + uint64_t class; uint64_t user_addr; uint64_t user_size; char *framework_name; char *framework_type; char *p1; char *p2; - char buf[MAXWIDTH]; + char buf[2 * PATH_MAX + 64]; char cs_diskname[32]; - unsigned long threadid; + uint64_t threadid; struct timeval now_walltime; static char timestamp[32]; @@ -1756,7 +1771,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, if (event->arg1) clen += printf(" F=%-3d[%3d]", (int)ti->arg1, (int)event->arg1); else - clen += printf(" F=%-3d B=0x%-6lx", (int)ti->arg1, event->arg2); + clen += printf(" F=%-3d B=0x%-6" PRIx64, (int)ti->arg1, (uint64_t)event->arg2); break; @@ -1784,7 +1799,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, /* * pageout */ - clen += printf(" B=0x%-8lx", event->arg1); + clen += printf(" B=0x%-8" PRIx64, (uint64_t)event->arg1); break; case FMT_HFS_update: @@ -1839,12 +1854,12 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, * physical disk I/O */ if (dio->io_errno) { - clen += printf(" D=0x%8.8lx [%3d]", dio->blkno, (int)dio->io_errno); + clen += printf(" D=0x%8.8" PRIx64 " [%3d]", dio->blkno, (int)dio->io_errno); } else { if (BC_flag) - clen += printf(" D=0x%8.8lx B=0x%-6lx BC:%s /dev/%s ", dio->blkno, dio->iosize, BC_STR(dio->bc_info), find_disk_name(dio->dev)); + clen += printf(" D=0x%8.8" PRIx64 " B=0x%-6" PRIx64 " BC:%s /dev/%s ", dio->blkno, dio->iosize, BC_STR(dio->bc_info), find_disk_name(dio->dev)); else - clen += printf(" D=0x%8.8lx B=0x%-6lx /dev/%s ", dio->blkno, dio->iosize, find_disk_name(dio->dev)); + clen += printf(" D=0x%8.8" PRIx64 " B=0x%-6" PRIx64 " /dev/%s ", dio->blkno, dio->iosize, find_disk_name(dio->dev)); if (dio->is_meta) { if (!(type & P_DISKIO_READ)) { @@ -1867,9 +1882,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, * physical disk I/O */ if (dio->io_errno) - clen += printf(" D=0x%8.8lx [%3lu]", dio->blkno, dio->io_errno); + clen += printf(" D=0x%8.8" PRIx64 " [%3" PRIu64 "]", dio->blkno, dio->io_errno); else - clen += printf(" D=0x%8.8lx B=0x%-6lx /dev/%s", dio->blkno, dio->iosize, generate_cs_disk_name(dio->dev, cs_diskname)); + clen += printf(" D=0x%8.8" PRIx64 " B=0x%-6" PRIx64 " /dev/%s", dio->blkno, dio->iosize, generate_cs_disk_name(dio->dev, cs_diskname)); break; @@ -2094,7 +2109,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, /* * ioctl */ - clen += printf(" B=%lu /dev/%s", event->arg3, find_disk_name(event->arg1)); + clen += printf(" B=%" PRIu64 " /dev/%s", (uint64_t)event->arg3, find_disk_name(event->arg1)); break; } @@ -2121,7 +2136,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, case FMT_UNMAP_INFO: { - clen += printf(" D=0x%8.8lx B=0x%-6lx /dev/%s", event->arg2, event->arg3, find_disk_name(event->arg1)); + clen += printf(" D=0x%8.8" PRIx64 " B=0x%-6" PRIx64 " /dev/%s", (uint64_t)event->arg2, (uint64_t)event->arg3, find_disk_name(event->arg1)); break; } @@ -2148,7 +2163,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, clen += printf("[%3d] ", (int)event->arg1); } else { if (format == FMT_PREAD) - clen += printf(" B=0x%-8lx ", event->arg2); + clen += printf(" B=0x%-8" PRIx64 " ", (uint64_t)event->arg2); else clen += printf(" "); } @@ -2310,7 +2325,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, /* * fchmod, fchmod_extended, chmod, chmod_extended */ - unsigned long mode; + uint64_t mode; if (format == FMT_FCHMOD || format == FMT_FCHMOD_EXT) { if (event->arg1) @@ -2371,9 +2386,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, case FMT_MOUNT: { if (event->arg1) - clen += printf(" [%3d] ", (int)event->arg1, ti->arg3); + clen += printf(" [%3d] ", (int)event->arg1, ti->arg3); else - clen += printf(" ", ti->arg3); + clen += printf(" ", ti->arg3); nopadding = 1; break; @@ -2407,6 +2422,11 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, nopadding = 1; break; + case FMT_GUARDED_OPEN: + clen += print_open(event, ti->arg4); + nopadding = 1; + break; + case FMT_SOCKET: { /* @@ -2458,9 +2478,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, } if (event->arg1) - clen += printf(" [%3d] <%s, %s, 0x%lx>", (int)event->arg1, domain, type, ti->arg3); + clen += printf(" [%3d] <%s, %s, 0x%" PRIx64 ">", (int)event->arg1, domain, type, ti->arg3); else - clen += printf(" F=%-3d <%s, %s, 0x%lx>", (int)event->arg2, domain, type, ti->arg3); + clen += printf(" F=%-3d <%s, %s, 0x%" PRIx64 ">", (int)event->arg2, domain, type, ti->arg3); break; } @@ -2482,9 +2502,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, op = "UNKNOWN"; if (event->arg1) - clen += printf(" [%3d] P=0x%8.8lx <%s>", (int)event->arg1, ti->arg2, op); + clen += printf(" [%3d] P=0x%8.8" PRIx64 " <%s>", (int)event->arg1, ti->arg2, op); else - clen += printf(" P=0x%8.8lx <%s>", ti->arg2, op); + clen += printf(" P=0x%8.8" PRIx64 " <%s>", ti->arg2, op); break; } @@ -2494,9 +2514,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, * aio_return [errno] AIOCBP IOSIZE */ if (event->arg1) - clen += printf(" [%3d] P=0x%8.8lx", (int)event->arg1, ti->arg1); + clen += printf(" [%3d] P=0x%8.8" PRIx64, (int)event->arg1, ti->arg1); else - clen += printf(" P=0x%8.8lx B=0x%-8lx", ti->arg1, event->arg2); + clen += printf(" P=0x%8.8" PRIx64 " B=0x%-8" PRIx64, ti->arg1, (uint64_t)event->arg2); break; @@ -2517,9 +2537,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, */ if (ti->arg2) { if (event->arg1) - clen += printf(" [%3d] P=0x%8.8lx", (int)event->arg1, ti->arg2); + clen += printf(" [%3d] P=0x%8." PRIx64, (int)event->arg1, ti->arg2); else - clen += printf(" P=0x%8.8lx", ti->arg2); + clen += printf(" P=0x%8.8" PRIx64, ti->arg2); } else { if (event->arg1) clen += printf(" F=%-3d[%3d]", (int)ti->arg1, (int)event->arg1); @@ -2534,9 +2554,9 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, * aio_error, aio_read, aio_write [errno] AIOCBP */ if (event->arg1) - clen += printf(" [%3d] P=0x%8.8lx", (int)event->arg1, ti->arg1); + clen += printf(" [%3d] P=0x%8.8" PRIx64, (int)event->arg1, ti->arg1); else - clen += printf(" P=0x%8.8lx", ti->arg1); + clen += printf(" P=0x%8.8" PRIx64, ti->arg1); break; @@ -2645,7 +2665,7 @@ format_print(th_info_t ti, char *sc_name, ktrace_event_t event, p2 = " "; if (columns > MAXCOLS || wideflag) - printf("%s%s %3llu.%06llu%s %s.%lu\n", p1, pathname, secs, usecs, p2, command_name, threadid); + printf("%s%s %3llu.%06llu%s %s.%" PRIu64 "\n", p1, pathname, secs, usecs, p2, command_name, threadid); else printf("%s%s %3llu.%06llu%s %-12.12s\n", p1, pathname, secs, usecs, p2, command_name); @@ -2733,7 +2753,7 @@ add_event(ktrace_event_t event, int type) { th_info_t ti; int hashid; - unsigned long eventid; + uint64_t eventid; if ((ti = th_info_freelist)) th_info_freelist = ti->next; @@ -2768,7 +2788,7 @@ add_event(ktrace_event_t event, int type) } th_info_t -event_find(uintptr_t thread, int type) +event_find(uint64_t thread, int type) { th_info_t ti; int hashid; @@ -2906,7 +2926,7 @@ event_exit(char *sc_name, int type, ktrace_event_t event, int format) } void -event_mark_thread_waited(uintptr_t thread) +event_mark_thread_waited(uint64_t thread) { th_info_t ti; int hashid; @@ -3009,7 +3029,7 @@ fd_clear_all(void) } void -fd_set_is_network(pid_t pid, unsigned long fd, bool set) +fd_set_is_network(pid_t pid, uint64_t fd, bool set) { struct pid_fd_set *pfs; @@ -3025,7 +3045,7 @@ fd_set_is_network(pid_t pid, unsigned long fd, bool set) if (!set) return; - newsize = MAX((fd + CHAR_BIT) / CHAR_BIT, 2 * pfs->setsize); + newsize = MAX(((size_t)fd + CHAR_BIT) / CHAR_BIT, 2 * pfs->setsize); pfs->set = reallocf(pfs->set, newsize); assert(pfs->set != NULL); @@ -3040,7 +3060,7 @@ fd_set_is_network(pid_t pid, unsigned long fd, bool set) } bool -fd_is_network(pid_t pid, unsigned long fd) +fd_is_network(pid_t pid, uint64_t fd) { struct pid_fd_set *pfs; @@ -3335,8 +3355,8 @@ struct diskio *free_diskios = NULL; struct diskio *busy_diskios = NULL; struct diskio * -diskio_start(unsigned long type, unsigned long bp, unsigned long dev, - unsigned long blkno, unsigned long iosize, ktrace_event_t event) +diskio_start(uint64_t type, uint64_t bp, uint64_t dev, + uint64_t blkno, uint64_t iosize, ktrace_event_t event) { const char *command; struct diskio *dio; @@ -3379,7 +3399,7 @@ diskio_start(unsigned long type, unsigned long bp, unsigned long dev, } struct diskio * -diskio_find(unsigned long bp) +diskio_find(uint64_t bp) { struct diskio *dio; @@ -3392,8 +3412,8 @@ diskio_find(unsigned long bp) } struct diskio * -diskio_complete(unsigned long bp, unsigned long io_errno, unsigned long resid, - uintptr_t thread, uint64_t curtime, struct timeval curtime_wall) +diskio_complete(uint64_t bp, uint64_t io_errno, uint64_t resid, + uint64_t thread, uint64_t curtime, struct timeval curtime_wall) { struct diskio *dio; @@ -3429,7 +3449,7 @@ diskio_print(struct diskio *dio) { char *p = NULL; int len = 0; - unsigned long type; + uint64_t type; int format = FMT_DISKIO; char buf[64]; @@ -3547,8 +3567,11 @@ diskio_print(struct diskio *dio) buf[len] = 0; - if (check_filter_mode(-1, NULL, type, 0, 0, buf)) - format_print(NULL, buf, NULL, type, format, dio->completed_time, dio->issued_time, 1, "", dio); + if (check_filter_mode(-1, NULL, type, 0, 0, buf)) { + const char *pathname = ktrace_get_path_for_vp(s, dio->vnodeid); + format_print(NULL, buf, NULL, type, format, dio->completed_time, + dio->issued_time, 1, pathname ? pathname : "", dio); + } } #pragma mark disk name routines @@ -3618,7 +3641,7 @@ recache_disk_names(void) } char * -find_disk_name(unsigned long dev) +find_disk_name(uint64_t dev) { struct diskrec *dnp; int i; @@ -3641,12 +3664,12 @@ find_disk_name(unsigned long dev) } char * -generate_cs_disk_name(unsigned long dev, char *s) +generate_cs_disk_name(uint64_t dev, char *s) { if (dev == -1) return "UNKNOWN"; - sprintf(s, "disk%lus%lu", (dev >> 16) & 0xffff, dev & 0xffff); + sprintf(s, "disk%" PRIu64 "s%" PRIu64, (dev >> 16) & 0xffff, dev & 0xffff); return (s); } diff --git a/gcore.tproj/corefile.c b/gcore.tproj/corefile.c index 8242b6e..b1e4421 100644 --- a/gcore.tproj/corefile.c +++ b/gcore.tproj/corefile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Apple Inc. All rights reserved. + * Copyright (c) 2016-2018 Apple Inc. All rights reserved. */ #include "options.h" diff --git a/gcore.tproj/dyld_shared_cache.c b/gcore.tproj/dyld_shared_cache.c index 92d0042..c65ffca 100644 --- a/gcore.tproj/dyld_shared_cache.c +++ b/gcore.tproj/dyld_shared_cache.c @@ -24,6 +24,7 @@ static const size_t dyld_cache_header_size = sizeof (struct copied_dyld_cache_he /* * The shared cache must both contain the magic ID and * match the uuid we discovered via dyld's information. + * Assumes that the dyld_cache_header grows in a binary compatible fashion. */ bool get_uuid_from_shared_cache_mapping(const void *addr, size_t size, uuid_t out) @@ -31,7 +32,7 @@ get_uuid_from_shared_cache_mapping(const void *addr, size_t size, uuid_t out) const struct copied_dyld_cache_header *ch = addr; if (size < sizeof (*ch)) return false; - static const char prefix[] = "dyld_v1 "; + static const char prefix[] = "dyld_v"; if (strncmp(ch->magic, prefix, strlen(prefix)) != 0) return false; uuid_copy(out, ch->uuid); diff --git a/gcore.tproj/gcore-entitlements.plist b/gcore.tproj/gcore-entitlements.plist new file mode 100644 index 0000000..39c14ef --- /dev/null +++ b/gcore.tproj/gcore-entitlements.plist @@ -0,0 +1,8 @@ + + + + + com.apple.security.cs.debugger.root + + + diff --git a/gcore.tproj/sparse.c b/gcore.tproj/sparse.c index ad5d917..c62b9f3 100644 --- a/gcore.tproj/sparse.c +++ b/gcore.tproj/sparse.c @@ -160,13 +160,14 @@ add_subregions_for_libent( if (OPTIONS_DEBUG(opt, 2)) { hsize_str_t hstr; - printr(r, "subregion %llx-%llx %7s %12s\t%s [%s off %zd for %zd nsects %u flags %x]\n", + printr(r, "subregion %llx-%llx %7s %12s\t%s [%s off %lu for %lu nsects %u flags %x]\n", S_ADDR(s), S_ENDADDR(s), str_hsize(hstr, S_SIZE(s)), sc->segname, S_FILENAME(s), str_prot(sc->initprot), - sc->fileoff, sc->filesize, + (unsigned long)sc->fileoff, + (unsigned long)sc->filesize, sc->nsects, sc->flags); } break; diff --git a/latency.tproj/latency.c b/latency.tproj/latency.c index b48bc55..d8b67e4 100644 --- a/latency.tproj/latency.c +++ b/latency.tproj/latency.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -176,7 +177,7 @@ typedef struct event *event_t; struct event { event_t ev_next; - uintptr_t ev_thread; + uint64_t ev_thread; uint32_t ev_type; uint64_t ev_timestamp; }; @@ -187,10 +188,10 @@ typedef struct lookup *lookup_t; struct lookup { lookup_t lk_next; - uintptr_t lk_thread; - uintptr_t lk_dvp; - long *lk_pathptr; - long lk_pathname[NUMPARMS + 1]; + uint64_t lk_thread; + uint64_t lk_dvp; + int64_t *lk_pathptr; + int64_t lk_pathname[NUMPARMS + 1]; }; @@ -199,8 +200,8 @@ typedef struct threadmap *threadmap_t; struct threadmap { threadmap_t tm_next; - uintptr_t tm_thread; - uintptr_t tm_pthread; + uint64_t tm_thread; + uint64_t tm_pthread; char tm_command[MAXCOMLEN + 1]; char tm_orig_command[MAXCOMLEN + 1]; }; @@ -211,7 +212,7 @@ typedef struct threadrun *threadrun_t; struct threadrun { threadrun_t tr_next; - uintptr_t tr_thread; + uint64_t tr_thread; kd_buf *tr_entry; uint64_t tr_timestamp; int tr_priority; @@ -223,7 +224,7 @@ typedef struct thread_entry *thread_entry_t; struct thread_entry { thread_entry_t te_next; - uintptr_t te_thread; + uint64_t te_thread; }; #define HASH_SIZE 1024 @@ -326,23 +327,23 @@ const char *sched_reasons[] = { static double handle_decrementer(kd_buf *, int); static kd_buf *log_decrementer(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, double i_latency); static void read_command_map(void); -static void enter_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info); -static void exit_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info); -static void print_entry(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd_note); +static void enter_syscall(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info); +static void exit_syscall(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info); +static void print_entry(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd_note); static void log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf *kd_note); static char *find_code(int); -static void pc_to_string(char *pcstring, uintptr_t pc, int max_len, int mode); +static void pc_to_string(char *pcstring, uint64_t pc, int max_len, int mode); static void getdivisor(void); static int sample_sc(void); static void init_code_file(void); static void do_kernel_nm(void); static void open_logfile(const char*); -static int binary_search(kern_sym_t *list, int low, int high, uintptr_t addr); +static int binary_search(kern_sym_t *list, int low, int high, uint64_t addr); -static void create_map_entry(uintptr_t, char *); -static void check_for_thread_update(uintptr_t thread, int debugid_base, kd_buf *kbufp, char **command); -static void log_scheduler(kd_buf *kd_start, kd_buf *kd_stop, kd_buf *end_of_sample, int s_priority, double s_latency, uintptr_t thread); -static int check_for_scheduler_latency(int type, uintptr_t *thread, uint64_t now, kd_buf *kd, kd_buf **kd_start, int *priority, double *latency); +static void create_map_entry(uint64_t, char *); +static void check_for_thread_update(uint64_t thread, int debugid_base, kd_buf *kbufp, char **command); +static void log_scheduler(kd_buf *kd_start, kd_buf *kd_stop, kd_buf *end_of_sample, int s_priority, double s_latency, uint64_t thread); +static int check_for_scheduler_latency(int type, uint64_t *thread, uint64_t now, kd_buf *kd, kd_buf **kd_start, int *priority, double *latency); static void open_rawfile(const char *path); static void screen_update(FILE *); @@ -1221,7 +1222,7 @@ read_command_map(void) } void -create_map_entry(uintptr_t thread, char *command) +create_map_entry(uint64_t thread, char *command) { threadmap_t tme; @@ -1244,7 +1245,7 @@ create_map_entry(uintptr_t thread, char *command) } static void -delete_thread_entry(uintptr_t thread) +delete_thread_entry(uint64_t thread) { threadmap_t tme; @@ -1272,7 +1273,7 @@ delete_thread_entry(uintptr_t thread) } static void -find_and_insert_tmp_map_entry(uintptr_t pthread, char *command) +find_and_insert_tmp_map_entry(uint64_t pthread, char *command) { threadmap_t tme; @@ -1303,7 +1304,7 @@ find_and_insert_tmp_map_entry(uintptr_t pthread, char *command) } static void -create_tmp_map_entry(uintptr_t thread, uintptr_t pthread) +create_tmp_map_entry(uint64_t thread, uint64_t pthread) { threadmap_t tme; @@ -1323,7 +1324,7 @@ create_tmp_map_entry(uintptr_t thread, uintptr_t pthread) } static threadmap_t -find_thread_entry(uintptr_t thread) +find_thread_entry(uint64_t thread) { threadmap_t tme; @@ -1338,7 +1339,7 @@ find_thread_entry(uintptr_t thread) } static void -find_thread_name(uintptr_t thread, char **command) +find_thread_name(uint64_t thread, char **command) { threadmap_t tme; @@ -1350,7 +1351,7 @@ find_thread_name(uintptr_t thread, char **command) } static void -add_thread_entry_to_list(thread_entry_t *list, uintptr_t thread) +add_thread_entry_to_list(thread_entry_t *list, uint64_t thread) { thread_entry_t te; @@ -1366,7 +1367,7 @@ add_thread_entry_to_list(thread_entry_t *list, uintptr_t thread) } static void -exec_thread_entry(uintptr_t thread, char *command) +exec_thread_entry(uint64_t thread, char *command) { threadmap_t tme; @@ -1385,7 +1386,7 @@ exec_thread_entry(uintptr_t thread, char *command) } static void -record_thread_entry_for_gc(uintptr_t thread) +record_thread_entry_for_gc(uint64_t thread) { add_thread_entry_to_list(&thread_delete_list, thread); } @@ -1470,7 +1471,7 @@ delete_all_thread_entries(void) } static void -insert_run_event(uintptr_t thread, int priority, kd_buf *kd, uint64_t now) +insert_run_event(uint64_t thread, int priority, kd_buf *kd, uint64_t now) { threadrun_t trp; @@ -1501,7 +1502,7 @@ insert_run_event(uintptr_t thread, int priority, kd_buf *kd, uint64_t now) } static threadrun_t -find_run_event(uintptr_t thread) +find_run_event(uint64_t thread) { threadrun_t trp; int hashid = thread & HASH_MASK; @@ -1515,7 +1516,7 @@ find_run_event(uintptr_t thread) } static void -delete_run_event(uintptr_t thread) +delete_run_event(uint64_t thread) { threadrun_t trp = 0; threadrun_t trp_prev; @@ -1573,7 +1574,7 @@ gc_run_events(void) static void -insert_start_event(uintptr_t thread, int type, uint64_t now) +insert_start_event(uint64_t thread, int type, uint64_t now) { event_t evp; @@ -1604,7 +1605,7 @@ insert_start_event(uintptr_t thread, int type, uint64_t now) static uint64_t -consume_start_event(uintptr_t thread, int type, uint64_t now) +consume_start_event(uint64_t thread, int type, uint64_t now) { event_t evp; event_t evp_prev; @@ -1670,7 +1671,7 @@ gc_start_events(void) } static int -thread_in_user_mode(uintptr_t thread, char *command) +thread_in_user_mode(uint64_t thread, char *command) { event_t evp; @@ -1689,7 +1690,7 @@ thread_in_user_mode(uintptr_t thread, char *command) } static lookup_t -handle_lookup_event(uintptr_t thread, int debugid, kd_buf *kdp) +handle_lookup_event(uint64_t thread, int debugid, kd_buf *kdp) { lookup_t lkp; boolean_t first_record = FALSE; @@ -1746,7 +1747,7 @@ handle_lookup_event(uintptr_t thread, int debugid, kd_buf *kdp) } static void -delete_lookup_event(uintptr_t thread, lookup_t lkp_to_delete) +delete_lookup_event(uint64_t thread, lookup_t lkp_to_delete) { lookup_t lkp; lookup_t lkp_prev; @@ -1876,7 +1877,7 @@ sample_sc(void) for (kd = (kd_buf *)my_buffer; kd < end_of_sample; kd++) { kd_buf *kd_start; - uintptr_t thread = kd->arg5; + uint64_t thread = kd->arg5; int type = kd->debugid & DBG_FUNC_MASK; (void)check_for_thread_update(thread, type, kd, NULL); @@ -1916,7 +1917,7 @@ sample_sc(void) } void -enter_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info) +enter_syscall(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info) { char *p; double timestamp; @@ -1941,19 +1942,19 @@ enter_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, u pc_to_string(&pcstring[0], kd->arg2, 58, mode); - fprintf(fp, "%9.1f %8.1f\t\tINTERRUPT[%2lx] @ %-58.58s %8lx %2d %s\n", - timestamp, delta, kd->arg1, &pcstring[0], thread, cpunum, command); + fprintf(fp, "%9.1f %8.1f\t\tINTERRUPT[%2" PRIx64 "] @ %-58.58s %8" PRIx64 " %2d %s\n", + timestamp, delta, (uint64_t)kd->arg1, &pcstring[0], thread, cpunum, command); } else if (type == MACH_vmfault) { - fprintf(fp, "%9.1f %8.1f\t\t%-28.28s %8lx %2d %s\n", + fprintf(fp, "%9.1f %8.1f\t\t%-28.28s %8" PRIx64 " %2d %s\n", timestamp, delta, p, thread, cpunum, command); } else { - fprintf(fp, "%9.1f %8.1f\t\t%-28.28s %-16lx %-16lx %-16lx %-16lx %8lx %2d %s\n", - timestamp, delta, p, kd->arg1, kd->arg2, kd->arg3, kd->arg4, + fprintf(fp, "%9.1f %8.1f\t\t%-28.28s %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + timestamp, delta, p, (uint64_t)kd->arg1, (uint64_t)kd->arg2, (uint64_t)kd->arg3, (uint64_t)kd->arg4, thread, cpunum, command); } } else { - fprintf(fp, "%9.1f %8.1f\t\t%-8x %-16lx %-16lx %-16lx %-16lx %8lx %2d %s\n", - timestamp, delta, type, kd->arg1, kd->arg2, kd->arg3, kd->arg4, + fprintf(fp, "%9.1f %8.1f\t\t%-8x %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + timestamp, delta, type, (uint64_t)kd->arg1, (uint64_t)kd->arg2, (uint64_t)kd->arg3, (uint64_t)kd->arg4, thread, cpunum, command); } } @@ -1963,7 +1964,7 @@ enter_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, u } void -exit_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info) +exit_syscall(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, int print_info) { char *p; uint64_t user_addr; @@ -1983,28 +1984,28 @@ exit_syscall(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, ui if ((p = find_code(type))) { if (type == INTERRUPT) { - fprintf(fp, "INTERRUPT %8lx %2d %s\n", thread, cpunum, command); + fprintf(fp, "INTERRUPT %8" PRIx64 " %2d %s\n", thread, cpunum, command); } else if (type == MACH_vmfault && kd->arg4 <= DBG_PAGEIND_FAULT) { user_addr = ((uint64_t)kd->arg1 << 32) | (uint32_t)kd->arg2; - fprintf(fp, "%-28.28s %-10.10s %-16qx %8lx %2d %s\n", + fprintf(fp, "%-28.28s %-10.10s %-16qx %8" PRIx64 " %2d %s\n", p, fault_name[kd->arg4], user_addr, thread, cpunum, command); } else { - fprintf(fp, "%-28.28s %-16lx %-16lx %8lx %2d %s\n", - p, kd->arg1, kd->arg2, + fprintf(fp, "%-28.28s %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + p, (uint64_t)kd->arg1, (uint64_t)kd->arg2, thread, cpunum, command); } } else { - fprintf(fp, "%-8x %-16lx %-16lx %8lx %2d %s\n", - type, kd->arg1, kd->arg2, + fprintf(fp, "%-8x %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + type, (uint64_t)kd->arg1, (uint64_t)kd->arg2, thread, cpunum, command); } } } void -print_entry(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd_note) +print_entry(FILE *fp, kd_buf *kd, uint64_t thread, int type, char *command, uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd_note) { char *p; @@ -2023,17 +2024,17 @@ print_entry(FILE *fp, kd_buf *kd, uintptr_t thread, int type, char *command, uin } else { fprintf(fp, "%9.1f %8.1f\t\t", timestamp, delta); } - fprintf(fp, "%-28.28s %-16lx %-16lx %-16lx %-16lx %8lx %2d %s\n", - p, kd->arg1, kd->arg2, kd->arg3, kd->arg4, thread, cpunum, command); + fprintf(fp, "%-28.28s %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + p, (uint64_t)kd->arg1, (uint64_t)kd->arg2, (uint64_t)kd->arg3, (uint64_t)kd->arg4, thread, cpunum, command); } else { - fprintf(fp, "%9.1f %8.1f\t\t%-8x %-16lx %-16lx %-16lx %-16lx %8lx %2d %s\n", - timestamp, delta, type, kd->arg1, kd->arg2, kd->arg3, kd->arg4, + fprintf(fp, "%9.1f %8.1f\t\t%-8x %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %8" PRIx64 " %2d %s\n", + timestamp, delta, type, (uint64_t)kd->arg1, (uint64_t)kd->arg2, (uint64_t)kd->arg3, (uint64_t)kd->arg4, thread, cpunum, command); } } void -check_for_thread_update(uintptr_t thread, int debugid_base, kd_buf *kbufp, char **command) +check_for_thread_update(uint64_t thread, int debugid_base, kd_buf *kbufp, char **command) { if (debugid_base == TRACE_DATA_NEWTHREAD) { /* @@ -2062,7 +2063,7 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf { lookup_t lkp; int mode; - uintptr_t reason; + uint64_t reason; char *p; char *command; char *command1; @@ -2075,7 +2076,7 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf double delta; char joe[32]; - uintptr_t thread = kd->arg5; + uint64_t thread = kd->arg5; int cpunum = CPU_NUMBER(kd); int debugid = kd->debugid; int type = kd->debugid & DBG_FUNC_MASK; @@ -2095,28 +2096,28 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf case CQ_action: pc_to_string(&pcstring[0], kd->arg1, 84, KERNEL_MODE); - fprintf(log_fp, "%9.1f %8.1f\t\tCQ_action @ %-84.84s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f\t\tCQ_action @ %-84.84s %8" PRIx64 " %2d %s\n", timestamp, delta, &pcstring[0], thread, cpunum, command); break; case TES_action: pc_to_string(&pcstring[0], kd->arg1, 83, KERNEL_MODE); - fprintf(log_fp, "%9.1f %8.1f\t\tTES_action @ %-83.83s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f\t\tTES_action @ %-83.83s %8" PRIx64 " %2d %s\n", timestamp, delta, &pcstring[0], thread, cpunum, command); break; case IES_action: pc_to_string(&pcstring[0], kd->arg1, 83, KERNEL_MODE); - fprintf(log_fp, "%9.1f %8.1f\t\tIES_action @ %-83.83s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f\t\tIES_action @ %-83.83s %8" PRIx64 " %2d %s\n", timestamp, delta, &pcstring[0], thread, cpunum, command); break; case IES_filter: pc_to_string(&pcstring[0], kd->arg1, 83, KERNEL_MODE); - fprintf(log_fp, "%9.1f %8.1f\t\tIES_filter @ %-83.83s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f\t\tIES_filter @ %-83.83s %8" PRIx64 " %2d %s\n", timestamp, delta, &pcstring[0], thread, cpunum, command); break; @@ -2141,12 +2142,12 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf pc_to_string(&pcstring[0], kd->arg2, 84, mode); - fprintf(log_fp, "%9.1f %8.1f[%.1f]%s\tDECR_TRAP @ %-84.84s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f[%.1f]%s\tDECR_TRAP @ %-84.84s %8" PRIx64 " %2d %s\n", timestamp, delta, i_latency, p, &pcstring[0], thread, cpunum, command); break; case DECR_SET: - fprintf(log_fp, "%9.1f %8.1f[%.1f] \t%-28.28s %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f[%.1f] \t%-28.28s %8" PRIx64 " %2d %s\n", timestamp, delta, (double)kd->arg1/divisor, "DECR_SET", thread, cpunum, command); break; @@ -2157,7 +2158,7 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf if (command1 == EMPTYSTRING) { command1 = command_buf; - sprintf(command1, "%-8lx", kd->arg2); + sprintf(command1, "%-8" PRIx64, (uint64_t)kd->arg2); } if (thread_in_user_mode(kd->arg2, command1)) { p = "U"; @@ -2174,12 +2175,12 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf } if (sched_reason[0] == '?') { - sprintf(joe, "%lx", reason); + sprintf(joe, "%" PRIx64, reason); sched_reason = joe; } - sprintf(sched_info, "%16.16s @ pri %3lu --> %16.16s @ pri %3lu%s", command, kd->arg3, command1, kd->arg4, p); + sprintf(sched_info, "%16.16s @ pri %3" PRIu64 " --> %16.16s @ pri %3" PRIu64 "%s", command, (uint64_t)kd->arg3, command1, (uint64_t)kd->arg4, p); - fprintf(log_fp, "%9.1f %8.1f\t\t%-10.10s[%s] %s %8lx %2d\n", + fprintf(log_fp, "%9.1f %8.1f\t\t%-10.10s[%s] %s %8" PRIx64 " %2d\n", timestamp, delta, "MACH_SCHED", sched_reason, sched_info, thread, cpunum); break; @@ -2197,7 +2198,7 @@ log_info(uint64_t now, uint64_t idelta, uint64_t start_bias, kd_buf *kd, kd_buf clen = 0; } - fprintf(log_fp, "%9.1f %8.1f\t\t%-14.14s %-59s %-16lx %8lx %2d %s\n", + fprintf(log_fp, "%9.1f %8.1f\t\t%-14.14s %-59s %-16" PRIx64 " %8" PRIx64 " %2d %s\n", timestamp, delta, "VFS_LOOKUP", &p[clen], lkp->lk_dvp, thread, cpunum, command); @@ -2252,7 +2253,7 @@ log_range(kd_buf *kd_buffer, kd_buf *kd_start, kd_buf *kd_stop, kd_buf *kd_note, last_timestamp = now; } else { int debugid = kd->debugid; - uintptr_t thread = kd->arg5; + uint64_t thread = kd->arg5; int type = kd->debugid & DBG_FUNC_MASK; if ((type >> 24) == DBG_TRACE) { @@ -2284,7 +2285,7 @@ log_decrementer(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, double i_ double sample_timestamp; char buf1[128]; - uintptr_t thread = kd_beg->arg5; + uint64_t thread = kd_beg->arg5; int cpunum = CPU_NUMBER(kd_end); for (kd_count = 0, kd_start = kd_beg - 1; (kd_start >= (kd_buf *)my_buffer); kd_start--, kd_count++) { @@ -2349,7 +2350,7 @@ log_decrementer(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, double i_ void -log_scheduler(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, int s_priority, double s_latency, uintptr_t thread) +log_scheduler(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, int s_priority, double s_latency, uint64_t thread) { kd_buf *kd_start, *kd_stop; uint64_t now; @@ -2401,7 +2402,7 @@ log_scheduler(kd_buf *kd_beg, kd_buf *kd_end, kd_buf *end_of_sample, int s_prior } int -check_for_scheduler_latency(int type, uintptr_t *thread, uint64_t now, kd_buf *kd, kd_buf **kd_start, int *priority, double *latency) +check_for_scheduler_latency(int type, uint64_t *thread, uint64_t now, kd_buf *kd, kd_buf **kd_start, int *priority, double *latency) { int found_latency = 0; @@ -2681,19 +2682,19 @@ do_kernel_nm(void) } void -pc_to_string(char *pcstring, uintptr_t pc, int max_len, int mode) +pc_to_string(char *pcstring, uint64_t pc, int max_len, int mode) { int ret; size_t len; if (mode == USER_MODE) { - sprintf(pcstring, "%-16lx [usermode addr]", pc); + sprintf(pcstring, "%-16" PRIx64 " [usermode addr]", pc); return; } ret = binary_search(kern_sym_tbl, 0, kern_sym_count-1, pc); if (ret == -1 || kern_sym_tbl[ret].k_sym_name == NULL) { - sprintf(pcstring, "%-16lx", pc); + sprintf(pcstring, "%-16" PRIx64, pc); return; } if ((len = kern_sym_tbl[ret].k_sym_len) > (max_len - 8)) { @@ -2702,7 +2703,7 @@ pc_to_string(char *pcstring, uintptr_t pc, int max_len, int mode) memcpy(pcstring, kern_sym_tbl[ret].k_sym_name, len); - sprintf(&pcstring[len], "+0x%-5lx", pc - (uintptr_t)kern_sym_tbl[ret].k_sym_addr); + sprintf(&pcstring[len], "+0x%-5" PRIx64, pc - (uint64_t)kern_sym_tbl[ret].k_sym_addr); } @@ -2710,7 +2711,7 @@ pc_to_string(char *pcstring, uintptr_t pc, int max_len, int mode) * Return -1 if not found, else return index */ int -binary_search(kern_sym_t *list, int low, int high, uintptr_t addr) +binary_search(kern_sym_t *list, int low, int high, uint64_t addr) { int mid; @@ -2723,13 +2724,13 @@ binary_search(kern_sym_t *list, int low, int high, uintptr_t addr) } if (low + 1 == high) { - if ((uintptr_t)list[low].k_sym_addr <= addr && addr < (uintptr_t)list[high].k_sym_addr) { + if ((uint64_t)list[low].k_sym_addr <= addr && addr < (uint64_t)list[high].k_sym_addr) { /* * We have a range match */ return low; } - if ((uintptr_t)list[high].k_sym_addr <= addr) { + if ((uint64_t)list[high].k_sym_addr <= addr) { return high; } /* @@ -2739,7 +2740,7 @@ binary_search(kern_sym_t *list, int low, int high, uintptr_t addr) } mid = (low + high) / 2; - if (addr < (uintptr_t)list[mid].k_sym_addr) { + if (addr < (uint64_t)list[mid].k_sym_addr) { return binary_search(list, low, mid, addr); } diff --git a/lskq.tproj/lskq.c b/lskq.tproj/lskq.c index 5292093..a25b1ef 100644 --- a/lskq.tproj/lskq.c +++ b/lskq.tproj/lskq.c @@ -340,6 +340,10 @@ enum kqtype { KQTYPE_DYNAMIC }; +#define POLICY_TIMESHARE 1 +#define POLICY_RR 2 +#define POLICY_FIFO 4 + static int process_kqueue(int pid, const char *procname, enum kqtype type, uint64_t kqid, struct proc_fdinfo *fdlist, int nfds) @@ -397,14 +401,32 @@ process_kqueue(int pid, const char *procname, enum kqtype type, uint64_t kqid, printf("%-10s ", " "); // evst } else { printf("%-8s ", " "); // fdtype - printf("%-7s ", " "); // fflags + char policy_type; + switch (kqinfo.kqdi_pol) { + case POLICY_RR: + policy_type = 'R'; + break; + case POLICY_FIFO: + policy_type = 'F'; + case POLICY_TIMESHARE: + case 0: + default: + policy_type = '-'; + break; + } + snprintf(tmpstr, 4, "%c%c%c", (kqinfo.kqdi_pri == 0)?'-':'P', policy_type, (kqinfo.kqdi_cpupercent == 0)?'-':'%'); + printf("%-7s ", tmpstr); // fflags printf("%-15s ", " "); // flags printf("%-17s ", " "); // evst } - int qos = MAX(MAX(kqinfo.kqdi_events_qos, kqinfo.kqdi_async_qos), + if (!raw && kqinfo.kqdi_pri != 0) { + printf("%3d ", kqinfo.kqdi_pri); //qos + } else { + int qos = MAX(MAX(kqinfo.kqdi_events_qos, kqinfo.kqdi_async_qos), kqinfo.kqdi_sync_waiter_qos); - printf("%3s ", thread_qos_name(qos)); + printf("%3s ", thread_qos_name(qos)); //qos + } printf("%-18s ", " "); // data printf("%-18s ", " "); // udata printf("%#18llx ", kqinfo.kqdi_servicer); // ext0 diff --git a/lsmp.tproj/common.h b/lsmp.tproj/common.h index d9552ca..35014c1 100644 --- a/lsmp.tproj/common.h +++ b/lsmp.tproj/common.h @@ -187,6 +187,6 @@ kern_return_t get_taskinfo_of_receiver_by_send_right(ipc_info_name_t *sendright, kern_return_t get_ipc_info_from_lsmp_spaceinfo(mach_port_t port_name, ipc_info_name_t *out_sendright); /* basic util functions */ -uint32_t print_hex_data(char *outstr, size_t maxlen, char *prefix, char *desc, void *addr, int len); +uint32_t print_hex_data(char *outstr, uint32_t maxlen, char *prefix, char *desc, void *addr, int len); #endif diff --git a/lsmp.tproj/lsmp.c b/lsmp.tproj/lsmp.c index 2e46f70..92691d7 100644 --- a/lsmp.tproj/lsmp.c +++ b/lsmp.tproj/lsmp.c @@ -202,8 +202,6 @@ int main(int argc, char *argv[]) { if (psettaskinfo[i].pid == lsmp_config.pid) taskinfo = &psettaskinfo[i]; - - ret = KERN_SUCCESS; } JSON_OBJECT_BEGIN(lsmp_config.json_output); diff --git a/lsmp.tproj/port_details.c b/lsmp.tproj/port_details.c index caed133..619bf02 100644 --- a/lsmp.tproj/port_details.c +++ b/lsmp.tproj/port_details.c @@ -139,10 +139,10 @@ uint32_t show_recipe_detail(mach_voucher_attr_recipe_t recipe, char *voucher_out JSON_OBJECT_BEGIN(json); uint32_t len = 0; - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, VOUCHER_DETAIL_PREFIX "Key: %u, ", recipe->key)); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, "Command: %u, ", recipe->command)); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, "Previous voucher: 0x%x, ", recipe->previous_voucher)); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, "Content size: %u\n", recipe->content_size)); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), VOUCHER_DETAIL_PREFIX "Key: %u, ", recipe->key); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), "Command: %u, ", recipe->command); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), "Previous voucher: 0x%x, ", recipe->previous_voucher); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), "Content size: %u\n", recipe->content_size); JSON_OBJECT_SET(json, key, %u, recipe->key); JSON_OBJECT_SET(json, command, %u, recipe->command); @@ -152,20 +152,20 @@ uint32_t show_recipe_detail(mach_voucher_attr_recipe_t recipe, char *voucher_out switch (recipe->key) { case MACH_VOUCHER_ATTR_KEY_ATM: JSON_OBJECT_SET(json, ATM_ID, %llu, *(uint64_t *)(uintptr_t)recipe->content); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, VOUCHER_DETAIL_PREFIX "ATM ID: %llu", *(uint64_t *)(uintptr_t)recipe->content)); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), VOUCHER_DETAIL_PREFIX "ATM ID: %llu", *(uint64_t *)(uintptr_t)recipe->content); break; case MACH_VOUCHER_ATTR_KEY_IMPORTANCE: // content may not be valid JSON, exclude // JSON_OBJECT_SET(json, importance_info, "%s", (char *)recipe->content); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, VOUCHER_DETAIL_PREFIX "IMPORTANCE INFO: %s", (char *)recipe->content)); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), VOUCHER_DETAIL_PREFIX "IMPORTANCE INFO: %s", (char *)recipe->content); break; case MACH_VOUCHER_ATTR_KEY_BANK: // content may not be valid JSON, exclude // JSON_OBJECT_SET(json, resource_accounting_info, "%s", (char *)recipe->content); - len += safesize(snprintf(&voucher_outstr[len], maxlen - len, VOUCHER_DETAIL_PREFIX "RESOURCE ACCOUNTING INFO: %s", (char *)recipe->content)); + len += snprintf(&voucher_outstr[len], safesize(maxlen - len), VOUCHER_DETAIL_PREFIX "RESOURCE ACCOUNTING INFO: %s", (char *)recipe->content); break; default: - len += print_hex_data(&voucher_outstr[len], maxlen - len, VOUCHER_DETAIL_PREFIX, "Recipe Contents", (void *)recipe->content, MIN(recipe->content_size, lsmp_config.voucher_detail_length)); + len += print_hex_data(&voucher_outstr[len], safesize(maxlen - len), VOUCHER_DETAIL_PREFIX, "Recipe Contents", (void *)recipe->content, MIN(recipe->content_size, lsmp_config.voucher_detail_length)); break; } @@ -198,27 +198,27 @@ char * copy_voucher_detail(mach_port_t task, mach_port_name_t voucher, JSON_t js (mach_voucher_attr_raw_recipe_array_t)&voucher_contents[0], &recipe_size); if (kr != KERN_SUCCESS && kr != KERN_NOT_SUPPORTED) { - plen += safesize(snprintf(&voucher_outstr[plen], detail_maxlen - plen, VOUCHER_DETAIL_PREFIX "Voucher: 0x%x Failed to get contents %s\n", v_kobject, mach_error_string(kr))); + plen += snprintf(&voucher_outstr[plen], safesize(detail_maxlen - plen), VOUCHER_DETAIL_PREFIX "Voucher: 0x%x Failed to get contents %s\n", v_kobject, mach_error_string(kr)); return voucher_outstr; } if (recipe_size == 0) { - plen += safesize(snprintf(&voucher_outstr[plen], detail_maxlen - plen, VOUCHER_DETAIL_PREFIX "Voucher: 0x%x has no contents\n", v_kobject)); + plen += snprintf(&voucher_outstr[plen], safesize(detail_maxlen - plen), VOUCHER_DETAIL_PREFIX "Voucher: 0x%x has no contents\n", v_kobject); return voucher_outstr; } - plen += safesize(snprintf(&voucher_outstr[plen], detail_maxlen - plen, VOUCHER_DETAIL_PREFIX "Voucher: 0x%x\n", v_kobject)); + plen += snprintf(&voucher_outstr[plen], safesize(detail_maxlen - plen), VOUCHER_DETAIL_PREFIX "Voucher: 0x%x\n", v_kobject); unsigned int used_size = 0; mach_voucher_attr_recipe_t recipe = NULL; while (recipe_size > used_size) { recipe = (mach_voucher_attr_recipe_t)&voucher_contents[used_size]; if (recipe->key) { - plen += show_recipe_detail(recipe, &voucher_outstr[plen], detail_maxlen - plen, json); + plen += show_recipe_detail(recipe, &voucher_outstr[plen], safesize(detail_maxlen - plen), json); } used_size += sizeof(mach_voucher_attr_recipe_data_t) + recipe->content_size; } } else { - plen += safesize(snprintf(&voucher_outstr[plen], detail_maxlen - plen, VOUCHER_DETAIL_PREFIX "Invalid voucher: 0x%x\n", voucher)); + plen += snprintf(&voucher_outstr[plen], safesize(detail_maxlen - plen), VOUCHER_DETAIL_PREFIX "Invalid voucher: 0x%x\n", voucher); } return voucher_outstr; @@ -303,7 +303,6 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta int j, k, port_status_flag_idx; kern_return_t ret; boolean_t send = FALSE; - boolean_t sendonce = FALSE; boolean_t dnreq = FALSE; int sendrights = 0; unsigned int kotype = 0; @@ -547,7 +546,7 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta allTaskInfos[j].processName); } - k2nnode = k2n_table_lookup_next(k2nnode, k2nnode->info_name->iin_name); + k2nnode = k2n_table_lookup_next(k2nnode, entry->iin_object); } } return; @@ -570,7 +569,6 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta } if (entry->iin_type & MACH_PORT_TYPE_SEND_ONCE) { - sendonce = TRUE; counts->sendoncecount++; } @@ -684,25 +682,25 @@ static void show_task_table_entry(ipc_info_name_t *entry, my_per_task_info_t *ta JSON_OBJECT_END(json); // non-kobject } -uint32_t print_hex_data(char *outstr, size_t maxlen, char *prefix, char *desc, void *addr, int len) { +uint32_t print_hex_data(char *outstr, uint32_t maxlen, char *prefix, char *desc, void *addr, int len) { int i; unsigned char buff[17]; unsigned char *pc = addr; uint32_t plen = 0; if (desc != NULL) - plen += safesize(snprintf(&outstr[len], maxlen - plen, "%s%s:\n", prefix, desc)); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), "%s%s:\n", prefix, desc); for (i = 0; i < len; i++) { if ((i % 16) == 0) { if (i != 0) - plen += safesize(snprintf(&outstr[len], maxlen - plen, " %s\n", buff)); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), " %s\n", buff); - plen += safesize(snprintf(&outstr[len], maxlen - plen, "%s %04x ", prefix, i)); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), "%s %04x ", prefix, i); } - plen += safesize(snprintf(&outstr[len], maxlen - plen, " %02x", pc[i])); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), " %02x", pc[i]); if ((pc[i] < 0x20) || (pc[i] > 0x7e)) buff[i % 16] = '.'; @@ -712,11 +710,11 @@ uint32_t print_hex_data(char *outstr, size_t maxlen, char *prefix, char *desc, v } while ((i % 16) != 0) { - plen += safesize(snprintf(&outstr[len], maxlen - plen, " ")); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), " "); i++; } - plen += safesize(snprintf(&outstr[len], maxlen - plen, " %s\n", buff)); + plen += snprintf(&outstr[plen], safesize(maxlen - plen), " %s\n", buff); return plen; } diff --git a/lsmp.tproj/task_details.c b/lsmp.tproj/task_details.c index e8b1ffe..f642e0d 100644 --- a/lsmp.tproj/task_details.c +++ b/lsmp.tproj/task_details.c @@ -43,7 +43,7 @@ static uint32_t k2n_hash(natural_t kobject) { return (uint64_t)kobject * 2654435761 >> 32; } -struct k2n_table_node *k2n_table_lookup_next(struct k2n_table_node *node, natural_t kobject) { +static struct k2n_table_node *k2n_table_lookup_next_internal(struct k2n_table_node *node, natural_t kobject) { while (node) { if (kobject == node->kobject) return node; @@ -54,6 +54,13 @@ struct k2n_table_node *k2n_table_lookup_next(struct k2n_table_node *node, natura return NULL; } +struct k2n_table_node *k2n_table_lookup_next(struct k2n_table_node *node, natural_t kobject) { + if (!node) { + return NULL; + } + return k2n_table_lookup_next_internal(node->next, kobject); +} + struct k2n_table_node *k2n_table_lookup(struct k2n_table_node **table, natural_t kobject) { uint32_t hv; struct k2n_table_node *node; @@ -62,7 +69,7 @@ struct k2n_table_node *k2n_table_lookup(struct k2n_table_node **table, natural_t node = table[hv & K2N_TABLE_MASK]; - return k2n_table_lookup_next(node, kobject); + return k2n_table_lookup_next_internal(node, kobject); } static void k2n_table_enter(struct k2n_table_node **table, natural_t kobject, ipc_info_name_t *info_name) { @@ -76,6 +83,7 @@ static void k2n_table_enter(struct k2n_table_node **table, natural_t kobject, ip node->kobject = kobject; node->info_name = info_name; + assert(kobject == info_name->iin_object); node->next = table[hv & K2N_TABLE_MASK]; table[hv & K2N_TABLE_MASK] = node; @@ -242,19 +250,19 @@ void get_exc_behavior_string(exception_behavior_t b, char *out_string, size_t le out_string[0]='\0'; if (b & MACH_EXCEPTION_CODES) - strncat(out_string, "MACH +", len); + strlcat(out_string, "MACH +", len); switch (b & ~MACH_EXCEPTION_CODES) { case EXCEPTION_DEFAULT: - strncat(out_string, " DEFAULT", len); + strlcat(out_string, " DEFAULT", len); break; case EXCEPTION_STATE: - strncat(out_string, " STATE", len); + strlcat(out_string, " STATE", len); break; case EXCEPTION_STATE_IDENTITY: - strncat(out_string, " IDENTITY", len); + strlcat(out_string, " IDENTITY", len); break; default: - strncat(out_string, " UNKNOWN", len); + strlcat(out_string, " UNKNOWN", len); } } @@ -263,29 +271,29 @@ void get_exc_mask_string(exception_mask_t m, char *out_string, size_t len) out_string[0]='\0'; if (m & (1<exceptionInfo.behaviors[i], behavior_string, sizeof(behavior_string)); - get_exc_mask_string(taskinfo->exceptionInfo.masks[i], mask_string, 200); + get_exc_mask_string(taskinfo->exceptionInfo.masks[i], mask_string, sizeof(mask_string)); JSON_OBJECT_BEGIN(json); JSON_OBJECT_SET(json, port, "0x%08x", taskinfo->exceptionInfo.ports[i]); diff --git a/memory_pressure.tproj/memory_pressure.c b/memory_pressure.tproj/memory_pressure.c index eb72738..2b2784e 100644 --- a/memory_pressure.tproj/memory_pressure.c +++ b/memory_pressure.tproj/memory_pressure.c @@ -41,6 +41,7 @@ unsigned long phys_mem = 0; /* amount of physical memory in bytes */ unsigned int phys_pages = 0; /* number of physical memory pages */ int sleep_seconds = 1; +int requested_hysteresis_seconds = 0; boolean_t quiet_mode_on = FALSE; boolean_t simulate_mode_on = FALSE; @@ -83,6 +84,7 @@ usage(void) " -p - allocate memory until percent free is this (or less)\n" " -s - how long to sleep between checking for a set percent level\n" " -w - don't allocate, just wait until percent free is this then exit\n" + " -y - Hysteresis Interval: how long to wait after requested percntage free is reached, before exiting program. Requires the usage of the -p option\n" " -v - print VM statistics every sampling interval\n" " -Q - reduces the tool's output\n" " -S - simulate the system's memory pressure level without applying any real pressure\n" @@ -457,6 +459,7 @@ munch_for_percentage(unsigned int sleep_seconds, unsigned int wait_percent_free, { int total_pages_allocated = 0; + int current_stable_timer = 0; /* in seconds */ unsigned int current_percent = 0; boolean_t page_op = PAGE_OP_FREE; unsigned int pages_to_process = 0; @@ -539,6 +542,18 @@ munch_for_percentage(unsigned int sleep_seconds, unsigned int wait_percent_free, printf("."); fflush(stdout); } + + /* Stability has been reached; Increment current_stable_timer by sleep_seconds */ + + if (current_stable_timer <= requested_hysteresis_seconds){ + current_stable_timer += sleep_seconds; + /* Debug only */ + /* printf("\n Percentage Free stable for %d seconds", current_stable_timer); */ + } else { + printf ("\n Maintained memory pressure to %d percent free for more than %d seconds. Stopping pressure now.", current_percent, requested_hysteresis_seconds); + return; + } + print_vm_stats_on_page_processing = FALSE; } @@ -566,7 +581,7 @@ main(int argc, char * const argv[]) unsigned int print_vm_stats = 0; char level[10]; - while ((opt = getopt(argc, argv, "hl:p:s:w:vQS")) != -1) { + while ((opt = getopt(argc, argv, "hl:p:s:w:y:vQS")) != -1) { switch (opt) { case 'h': usage(); @@ -599,6 +614,9 @@ main(int argc, char * const argv[]) case 'w': wait_percent_free = atoi(optarg); break; + case 'y': + requested_hysteresis_seconds = atoi(optarg); + break; case 'v': print_vm_stats = 1; break; @@ -618,6 +636,13 @@ main(int argc, char * const argv[]) return 0; } + if (requested_hysteresis_seconds > 0) { + if (desired_percent == 0) { + printf("Hysteresis time may only be specified in conjunction with a non-zero value for the -p option. \n"); + usage(); + } + } + phys_mem = read_sysctl_int("hw.physmem"); phys_pages = (unsigned int) (phys_mem / PAGE_SIZE); diff --git a/mslutil/mslutil.c b/mslutil/mslutil.c index 7d20637..5738d4a 100644 --- a/mslutil/mslutil.c +++ b/mslutil/mslutil.c @@ -16,7 +16,7 @@ static void print_usage() { - printf("usage: mslutil pid [--disable] | [--enable malloc | vm | full | lite]\n"); + printf("usage: mslutil pid [--disable] | [--enable malloc | vm | full | lite | vmlite]\n"); } static int send_msl_command(uint64_t pid, uint64_t flavor) @@ -68,7 +68,9 @@ int main(int argc, const char * argv[]) } else if (strcmp(argv[3], "vm") == 0) { flavor = MEMORYSTATUS_ENABLE_MSL_VM; } else if (strcmp(argv[3], "lite") == 0) { - flavor = MEMORYSTATUS_ENABLE_MSL_LITE; + flavor = MEMORYSTATUS_ENABLE_MSL_LITE_FULL; + } else if (strcmp(argv[3], "vmlite") == 0) { + flavor = MEMORYSTATUS_ENABLE_MSL_LITE_VM; } if (flavor == 0) { diff --git a/passwd.tproj/od_passwd.c b/passwd.tproj/od_passwd.c index 02df631..f24883a 100644 --- a/passwd.tproj/od_passwd.c +++ b/passwd.tproj/od_passwd.c @@ -102,7 +102,7 @@ od_passwd(char* uname, char* locn, char* aname) aname = strdup(uname); } - master_mode = (getuid() == 0); + master_mode = (geteuid() == 0); change_pass_on_self = (strcmp(aname, uname) == 0); if (locn) { @@ -150,10 +150,20 @@ od_passwd(char* uname, char* locn, char* aname) printf("Changing password for %s.\n", uname); + bool isSecureToken = false; + if (master_mode) { + CFArrayRef authorityValues = NULL; + authorityValues = ODRecordCopyValues(rec, kODAttributeTypeAuthenticationAuthority, &error); + if (authorityValues != NULL) { + isSecureToken = CFArrayContainsValue(authorityValues, CFRangeMake(0, CFArrayGetCount(authorityValues)), (const void *)CFSTR(";SecureToken;")); + CFRelease(authorityValues); + } + } + /* - * Prompt for password if not super-user, or if changing a remote node. + * Prompt for password if not super-user, or if changing a remote node, or if changing a record that uses SecureToken. */ - int needs_auth = (!master_mode || CFStringCompareWithOptions(location, CFSTR("/Local/"), CFRangeMake(0, 7), 0) != kCFCompareEqualTo); + int needs_auth = (!master_mode || CFStringCompareWithOptions(location, CFSTR("/Local/"), CFRangeMake(0, 7), 0) != kCFCompareEqualTo || isSecureToken); if (needs_auth) { char prompt[BUFSIZ]; @@ -166,6 +176,15 @@ od_passwd(char* uname, char* locn, char* aname) if (p) { oldpass = CFStringCreateWithCString(NULL, p, kCFStringEncodingUTF8); memset(p, 0, strlen(p)); + + if (!change_pass_on_self) { + if (!ODRecordSetNodeCredentials(rec, authname, oldpass, &error)) { + show_error(error); + exit(1); + } + CFRelease(oldpass); + oldpass = NULL; + } } } diff --git a/passwd.tproj/passwd.entitlements b/passwd.tproj/passwd.entitlements new file mode 100644 index 0000000..71bd7ea --- /dev/null +++ b/passwd.tproj/passwd.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.private.opendirectoryd.identity + + + diff --git a/proc_uuid_policy.tproj/proc_uuid_policy.1 b/proc_uuid_policy.tproj/proc_uuid_policy.1 index 53d8a87..f7398dd 100644 --- a/proc_uuid_policy.tproj/proc_uuid_policy.1 +++ b/proc_uuid_policy.tproj/proc_uuid_policy.1 @@ -10,7 +10,7 @@ .Nm .Ar verb .Ar policy -.Ar uuid +.Ar uuid | path .Sh DESCRIPTION .Nm sets policy for a specific UUID or mach-o file with the kernel diff --git a/proc_uuid_policy.tproj/proc_uuid_policy.c b/proc_uuid_policy.tproj/proc_uuid_policy.c index dfa8a8c..0078cb9 100644 --- a/proc_uuid_policy.tproj/proc_uuid_policy.c +++ b/proc_uuid_policy.tproj/proc_uuid_policy.c @@ -206,7 +206,7 @@ static void usage(void) { - fprintf(stderr, "usage: %s \n", getprogname()); + fprintf(stderr, "usage: %s \n", getprogname()); fprintf(stderr, "Verbs:\n"); fprintf(stderr, "\tclear\tClear all policies for a given UUID\n"); fprintf(stderr, "\tadd\tAdd a specific policy\n"); diff --git a/sc_usage.tproj/sc_usage.c b/sc_usage.tproj/sc_usage.c index d39e8ef..3dcdf9f 100644 --- a/sc_usage.tproj/sc_usage.c +++ b/sc_usage.tproj/sc_usage.c @@ -119,12 +119,12 @@ struct entry { }; struct th_info { - uintptr_t thread; + uint64_t thread; int depth; int vfslookup; int curpri; - long *pathptr; - long pathname[NUMPARMS + 1]; + int64_t *pathptr; + int64_t pathname[NUMPARMS + 1]; struct entry th_entry[MAX_NESTED]; }; @@ -305,10 +305,12 @@ main(int argc, char *argv[]) exit(1); } - if (0 != reexec_to_match_kernel()) { +#if !defined(__arm64__) + if (0 != reexec_to_match_kernel()) { fprintf(stderr, "Could not re-execute: %d\n", errno); exit(1); } +#endif /* get our name */ if (argc > 0) { @@ -1054,7 +1056,7 @@ find_proc_names(void) } static struct th_info * -find_thread(uintptr_t thread) +find_thread(uint64_t thread) { struct th_info *ti; @@ -1120,7 +1122,7 @@ sort_scalls(void) if ((unsigned long)(((double)now - te->otime) / divisor) > 5000000) { ti->thread = 0; ti->vfslookup = 0; - ti->pathptr = (long *)NULL; + ti->pathptr = (int64_t *)NULL; ti->pathname[0] = 0; num_of_threads--; } @@ -1325,7 +1327,7 @@ sample_sc(void) th_state[i].depth = 0; th_state[i].thread = 0; th_state[i].vfslookup = 0; - th_state[i].pathptr = (long *)NULL; + th_state[i].pathptr = (int64_t *)NULL; th_state[i].pathname[0] = 0; } num_of_threads = 0; @@ -1341,7 +1343,7 @@ sample_sc(void) for (i = 0; i < count; i++) { int debugid, baseid; - uintptr_t thread; + uint64_t thread; int type, code; uint64_t now; struct th_info *ti, *switched_out, *switched_in; @@ -1361,7 +1363,7 @@ sample_sc(void) baseid = debugid & 0xffff0000; if (type == vfs_lookup) { - long *sargptr; + int64_t *sargptr; if ((ti = find_thread(thread)) == (struct th_info *)0) continue; diff --git a/stackshot.tproj/stackshot.c b/stackshot.tproj/stackshot.c index 7b0ddc8..0a67d50 100644 --- a/stackshot.tproj/stackshot.c +++ b/stackshot.tproj/stackshot.c @@ -35,7 +35,6 @@ static void usage(char **argv) fprintf (stderr, " -b : get bootprofile\n"); fprintf (stderr, " -c : get coalition data\n"); fprintf (stderr, " -i : get instructions and cycles\n"); - fprintf (stderr, " -t : enable tailspin mode\n"); fprintf (stderr, " -g : get thread group data\n"); fprintf (stderr, " -s : fork a sleep process\n"); fprintf (stderr, " -L : disable loadinfo\n"); @@ -66,7 +65,6 @@ int main(int argc, char **argv) { uint32_t iostats = 0; uint32_t active_kernel_threads_only = 0; - uint32_t tailspin = 0; uint32_t bootprofile = 0; uint32_t thread_group = 0; uint32_t coalition = 0; @@ -103,9 +101,6 @@ int main(int argc, char **argv) { case 'g': thread_group |= STACKSHOT_THREAD_GROUP; break; - case 't': - tailspin |= STACKSHOT_TAILSPIN; - break; case 'd': delta = TRUE; break; @@ -146,8 +141,8 @@ top: perror("stackshot_config_create"); return 1; } - flags = flags | loadinfo | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_GET_DQ | STACKSHOT_KCDATA_FORMAT | - tailspin | bootprofile | active_kernel_threads_only | iostats | thread_group | coalition | instrs_cycles; + flags = flags | loadinfo | STACKSHOT_SAVE_IMP_DONATION_PIDS | STACKSHOT_GET_DQ | STACKSHOT_KCDATA_FORMAT | STACKSHOT_THREAD_WAITINFO | + bootprofile | active_kernel_threads_only | iostats | thread_group | coalition | instrs_cycles; int err = stackshot_config_set_flags(config, flags); if (err != 0) { diff --git a/system_cmds.xcodeproj/project.pbxproj b/system_cmds.xcodeproj/project.pbxproj index 06d5b8d..b1e3d4e 100644 --- a/system_cmds.xcodeproj/project.pbxproj +++ b/system_cmds.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 1812F1A31C8F923900F3DC9E /* PBXTargetDependency */, 1812F1A51C8F923900F3DC9E /* PBXTargetDependency */, 1812F1A71C8F923900F3DC9E /* PBXTargetDependency */, + F2291F681FFEBC4F00161936 /* PBXTargetDependency */, 1812F1A91C8F923900F3DC9E /* PBXTargetDependency */, 1812F1AB1C8F923900F3DC9E /* PBXTargetDependency */, 1812F1AD1C8F923900F3DC9E /* PBXTargetDependency */, @@ -86,6 +87,7 @@ 1523FE6F1595069900661E82 /* PBXTargetDependency */, BA0A861A1396B41F00D2272C /* PBXTargetDependency */, BA0A861613968ECA00D2272C /* PBXTargetDependency */, + F2291F641FFEBC4000161936 /* PBXTargetDependency */, BA959E8813968D8A00CA9C60 /* PBXTargetDependency */, BA959E8A13968D8A00CA9C60 /* PBXTargetDependency */, BA959E8C13968D8A00CA9C60 /* PBXTargetDependency */, @@ -241,6 +243,7 @@ 1523FE711595069F00661E82 /* PBXTargetDependency */, BA0A861C1396B42600D2272C /* PBXTargetDependency */, BA0A861813968ED500D2272C /* PBXTargetDependency */, + F2291F661FFEBC4700161936 /* PBXTargetDependency */, BA959E9213968DA900CA9C60 /* PBXTargetDependency */, BA959E9413968DA900CA9C60 /* PBXTargetDependency */, BA959E9613968DA900CA9C60 /* PBXTargetDependency */, @@ -324,9 +327,7 @@ 78DE9DFE1B504D7F00FE6DF5 /* wait4path.c in Sources */ = {isa = PBXBuildFile; fileRef = 78DE9DFC1B504D7F00FE6DF5 /* wait4path.c */; }; 78DE9E001B504DE500FE6DF5 /* wait4path.version in Sources */ = {isa = PBXBuildFile; fileRef = 78DE9DFD1B504D7F00FE6DF5 /* wait4path.version */; }; 78DE9EE61B505F1800FE6DF5 /* wait4path.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 78DE9EE51B505EBF00FE6DF5 /* wait4path.1 */; }; - 8EC391681C973400001E28E6 /* proc_uuid_policy.c in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EC391671C973400001E28E6 /* proc_uuid_policy.c */; }; 8EC391691C973405001E28E6 /* proc_uuid_policy.c in Sources */ = {isa = PBXBuildFile; fileRef = 8EC391671C973400001E28E6 /* proc_uuid_policy.c */; }; - 8EC3916B1C97341E001E28E6 /* proc_uuid_policy.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EC3916A1C97341E001E28E6 /* proc_uuid_policy.1 */; }; 8EC3916C1C973429001E28E6 /* proc_uuid_policy.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8EC3916A1C97341E001E28E6 /* proc_uuid_policy.1 */; }; 97999D321AE84CE400E8B10F /* lskq.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 97999D301AE84C7600E8B10F /* lskq.1 */; }; 97999D331AE84D0A00E8B10F /* lskq.c in Sources */ = {isa = PBXBuildFile; fileRef = 97999D311AE84C7600E8B10F /* lskq.c */; }; @@ -509,11 +510,19 @@ C96F50BD15BDFEFB008682F7 /* lsmp.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C96F50AC15BDCBF0008682F7 /* lsmp.1 */; }; C96F50BE15BDFF03008682F7 /* lsmp.c in Sources */ = {isa = PBXBuildFile; fileRef = C96F50AD15BDCE8E008682F7 /* lsmp.c */; }; C9779F6E159A2A0C009436FD /* libutil.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BA4B7A091373BA4600003422 /* libutil.dylib */; }; + C99490E42090F55E00246D9D /* zprint.lua in CopyFiles */ = {isa = PBXBuildFile; fileRef = C99490E32090F55D00246D9D /* zprint.lua */; }; + C99490E52090F56F00246D9D /* zprint.lua in CopyFiles */ = {isa = PBXBuildFile; fileRef = C99490E32090F55D00246D9D /* zprint.lua */; }; C9D64CD11B91065D00CFA43B /* system_cmds.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = C9D64CCF1B91063200CFA43B /* system_cmds.plist */; }; C9D64CD31B91067500CFA43B /* system_cmds.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = C9D64CCF1B91063200CFA43B /* system_cmds.plist */; }; C9E0691A1C58BD7E00C956EB /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA9B766D13739D27001BB39F /* CoreFoundation.framework */; }; C9E0691C1C58BDA000C956EB /* CoreSymbolication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E0691B1C58BDA000C956EB /* CoreSymbolication.framework */; }; C9E0691E1C58BDB800C956EB /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E0691D1C58BDB800C956EB /* IOKit.framework */; }; + F2291F551FFEBB6A00161936 /* CoreSymbolication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E0691B1C58BDA000C956EB /* CoreSymbolication.framework */; }; + F2291F601FFEBB9E00161936 /* zlog.c in Sources */ = {isa = PBXBuildFile; fileRef = F2291F5F1FFEBB9E00161936 /* zlog.c */; }; + F27B70282044CB40003C04FC /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F27B70272044CB40003C04FC /* CoreFoundation.framework */; }; + F27B702B2045038B003C04FC /* SymbolicationHelper.c in Sources */ = {isa = PBXBuildFile; fileRef = F27B70292045038B003C04FC /* SymbolicationHelper.c */; }; + F29F5A5B203E12BC005B0099 /* entitlements.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = F29F5A5A203E12BB005B0099 /* entitlements.plist */; }; + F29F5A5F203E5347005B0099 /* zlog.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = F29F5A5C203E4403005B0099 /* zlog.1 */; }; /* End PBXBuildFile section */ /* Begin PBXBuildRule section */ @@ -1651,6 +1660,27 @@ remoteGlobalIDString = C96F50AE15BDCEC3008682F7; remoteInfo = lsmp; }; + F2291F631FFEBC4000161936 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BA2DE9181372FA9100D1913C /* Project object */; + proxyType = 1; + remoteGlobalIDString = F2291F501FFEBB6A00161936; + remoteInfo = zlog; + }; + F2291F651FFEBC4700161936 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BA2DE9181372FA9100D1913C /* Project object */; + proxyType = 1; + remoteGlobalIDString = F2291F501FFEBB6A00161936; + remoteInfo = zlog; + }; + F2291F671FFEBC4F00161936 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = BA2DE9181372FA9100D1913C /* Project object */; + proxyType = 1; + remoteGlobalIDString = F2291F501FFEBB6A00161936; + remoteInfo = zlog; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -2244,6 +2274,16 @@ ); runOnlyForDeploymentPostprocessing = 1; }; + C99490E22090F53B00246D9D /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/local/share/recon; + dstSubfolderSpec = 0; + files = ( + C99490E52090F56F00246D9D /* zprint.lua in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; C9D64CD01B91064700CFA43B /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 8; @@ -2260,9 +2300,19 @@ dstPath = /AppleInternal/CoreOS/BATS/unit_tests; dstSubfolderSpec = 0; files = ( - 8EC391681C973400001E28E6 /* proc_uuid_policy.c in CopyFiles */, + F29F5A5B203E12BC005B0099 /* entitlements.plist in CopyFiles */, + C99490E42090F55E00246D9D /* zprint.lua in CopyFiles */, C9D64CD31B91067500CFA43B /* system_cmds.plist in CopyFiles */, - 8EC3916B1C97341E001E28E6 /* proc_uuid_policy.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; + F29F5A5E203E532B005B0099 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 8; + dstPath = /usr/local/share/man/man1; + dstSubfolderSpec = 0; + files = ( + F29F5A5F203E5347005B0099 /* zlog.1 in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 1; }; @@ -2271,7 +2321,6 @@ /* Begin PBXFileReference section */ 08ADC98B1E70715D0001CB70 /* ktrace.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ktrace.framework; path = System/Library/PrivateFrameworks/ktrace.framework; sourceTree = SDKROOT; }; 08CE3D291E6E22A200DF1B78 /* stackshot */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = stackshot; sourceTree = BUILT_PRODUCTS_DIR; }; - 08CE3D301E6E22B000DF1B78 /* stackshot */ = {isa = PBXFileReference; lastKnownFileType = folder; path = stackshot; sourceTree = ""; }; 08CE3D321E6E22DE00DF1B78 /* stackshot.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = stackshot.c; path = stackshot.tproj/stackshot.c; sourceTree = ""; }; 08DC48851A12C21B008AAF38 /* kpgo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = kpgo; sourceTree = BUILT_PRODUCTS_DIR; }; 08DC488D1A12C2C6008AAF38 /* kpgo.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = kpgo.c; sourceTree = ""; }; @@ -2281,154 +2330,8 @@ 1523FE631595048900661E82 /* ltop */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ltop; sourceTree = BUILT_PRODUCTS_DIR; }; 1523FE6A1595056C00661E82 /* ltop.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = ltop.1; sourceTree = ""; }; 1523FE6B1595056C00661E82 /* ltop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltop.c; sourceTree = ""; }; - 1821B00B1C88BEE2000BAA0C /* usage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = usage.cpp; sourceTree = ""; }; - 1821B00C1C88BEE2000BAA0C /* usage.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = usage.hpp; sourceTree = ""; }; - 18380CDC1C596E8900DC6B89 /* eostrace.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = eostrace.c; sourceTree = ""; }; - 18410FED1CC881FD00385C96 /* entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = entitlements.plist; sourceTree = ""; }; - 1845E41418EB95810010F451 /* TraceFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TraceFile.cpp; sourceTree = ""; }; - 1845E41518EB95810010F451 /* TraceFile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TraceFile.hpp; sourceTree = ""; }; - 18597EC818CBC2A300531A50 /* kdprof.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = kdprof.1; sourceTree = ""; }; - 18597ECC18CBC35700531A50 /* Action.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Action.hpp; sourceTree = ""; }; - 18597ECD18CBC35700531A50 /* CollectAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CollectAction.hpp; sourceTree = ""; }; - 18597ECE18CBC35700531A50 /* CollectAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CollectAction.cpp; sourceTree = ""; }; - 18597ECF18CBC35700531A50 /* DisableAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DisableAction.hpp; sourceTree = ""; }; - 18597ED018CBC35700531A50 /* DisableAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DisableAction.cpp; sourceTree = ""; }; - 18597ED118CBC35700531A50 /* EnableAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EnableAction.hpp; sourceTree = ""; }; - 18597ED218CBC35700531A50 /* EnableAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EnableAction.cpp; sourceTree = ""; }; - 18597ED318CBC35700531A50 /* EventPrinting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EventPrinting.hpp; sourceTree = ""; }; - 18597ED418CBC35700531A50 /* EventPrinting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventPrinting.cpp; sourceTree = ""; }; - 18597ED518CBC35700531A50 /* global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = global.h; sourceTree = ""; }; - 18597ED618CBC35700531A50 /* Globals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Globals.hpp; sourceTree = ""; }; - 18597ED718CBC35700531A50 /* Globals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Globals.cpp; sourceTree = ""; }; - 18597ED818CBC35700531A50 /* InitializeAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = InitializeAction.hpp; sourceTree = ""; }; - 18597ED918CBC35700531A50 /* InitializeAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InitializeAction.cpp; sourceTree = ""; }; - 18597EDA18CBC35700531A50 /* kdprof.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kdprof.cpp; sourceTree = ""; }; - 18597EDB18CBC35700531A50 /* NoWrapAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NoWrapAction.hpp; sourceTree = ""; }; - 18597EDC18CBC35700531A50 /* NoWrapAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NoWrapAction.cpp; sourceTree = ""; }; - 18597EDD18CBC35700531A50 /* PrintStateAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PrintStateAction.hpp; sourceTree = ""; }; - 18597EDE18CBC35700531A50 /* PrintStateAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PrintStateAction.cpp; sourceTree = ""; }; - 18597EDF18CBC35700531A50 /* RemoveAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoveAction.hpp; sourceTree = ""; }; - 18597EE018CBC35700531A50 /* RemoveAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveAction.cpp; sourceTree = ""; }; - 18597EE118CBC35700531A50 /* SaveTraceAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SaveTraceAction.hpp; sourceTree = ""; }; - 18597EE218CBC35700531A50 /* SaveTraceAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SaveTraceAction.cpp; sourceTree = ""; }; - 18597EE318CBC35700531A50 /* SleepAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SleepAction.hpp; sourceTree = ""; }; - 18597EE418CBC35700531A50 /* SleepAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SleepAction.cpp; sourceTree = ""; }; - 18597EE518CBC35700531A50 /* SummaryPrinting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = SummaryPrinting.hpp; sourceTree = ""; }; - 18597EE618CBC35700531A50 /* SummaryPrinting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SummaryPrinting.cpp; sourceTree = ""; }; - 18597EE718CBC35700531A50 /* TraceFileAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TraceFileAction.hpp; sourceTree = ""; }; - 18597EE818CBC35700531A50 /* TraceFileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TraceFileAction.cpp; sourceTree = ""; }; - 185B9771191022B200FCB84C /* VoucherContentSysctl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VoucherContentSysctl.cpp; sourceTree = ""; }; - 185B97731910475500FCB84C /* WriteTraceFileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WriteTraceFileAction.cpp; sourceTree = ""; }; - 185B97741910475500FCB84C /* WriteTraceFileAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WriteTraceFileAction.hpp; sourceTree = ""; }; - 185F75141CC2EFC600B0EA9E /* TypeFilterAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TypeFilterAction.cpp; sourceTree = ""; }; - 185F75151CC2EFC600B0EA9E /* TypeFilterAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TypeFilterAction.hpp; sourceTree = ""; }; - 185F75171CC337D400B0EA9E /* Machine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Machine.cpp; sourceTree = ""; }; - 185F75191CC34EBE00B0EA9E /* WriteTraceFileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WriteTraceFileAction.cpp; sourceTree = ""; }; - 185F751A1CC34EBE00B0EA9E /* WriteTraceFileAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = WriteTraceFileAction.hpp; sourceTree = ""; }; - 18624C851BF6400200FA0575 /* TypeSummary.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TypeSummary.hpp; sourceTree = ""; }; - 18624C861BF64ED700FA0575 /* CPUTypeSummary.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CPUTypeSummary.hpp; sourceTree = ""; }; - 18624C871BF6503600FA0575 /* ProcessTypeSummary.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ProcessTypeSummary.hpp; sourceTree = ""; }; - 18624C881BF651EC00FA0575 /* ThreadTypeSummary.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = ThreadTypeSummary.hpp; sourceTree = ""; }; - 186288CF1CC5DA71002950E0 /* UUIDMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UUIDMap.cpp; sourceTree = ""; }; - 186288D01CC5DA71002950E0 /* UUIDMap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UUIDMap.hpp; sourceTree = ""; }; - 1865513A18CA70B5003B92A7 /* CPPUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPPUtil.h; sourceTree = ""; }; - 1865513B18CA70B5003B92A7 /* UtilAbsInterval.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilAbsInterval.cpp; sourceTree = ""; }; - 1865513C18CA70B5003B92A7 /* UtilAbsInterval.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilAbsInterval.hpp; sourceTree = ""; }; - 1865513D18CA70B5003B92A7 /* UtilAbsTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilAbsTime.cpp; sourceTree = ""; }; - 1865513E18CA70B5003B92A7 /* UtilAbsTime.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilAbsTime.hpp; sourceTree = ""; }; - 1865513F18CA70B5003B92A7 /* UtilAssert.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilAssert.hpp; sourceTree = ""; }; - 1865514018CA70B5003B92A7 /* UtilBase.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilBase.hpp; sourceTree = ""; }; - 1865514118CA70B5003B92A7 /* UtilException.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilException.hpp; sourceTree = ""; }; - 1865514218CA70B5003B92A7 /* UtilFileDescriptor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilFileDescriptor.hpp; sourceTree = ""; }; - 1865514318CA70B5003B92A7 /* UtilLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilLog.cpp; sourceTree = ""; }; - 1865514418CA70B5003B92A7 /* UtilLog.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilLog.hpp; sourceTree = ""; }; - 1865514518CA70B5003B92A7 /* UtilMakeUnique.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilMakeUnique.hpp; sourceTree = ""; }; - 1865514618CA70B5003B92A7 /* UtilMappedFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilMappedFile.cpp; sourceTree = ""; }; - 1865514718CA70B5003B92A7 /* UtilMappedFile.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilMappedFile.hpp; sourceTree = ""; }; - 1865514818CA70B5003B92A7 /* UtilMemoryBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilMemoryBuffer.hpp; sourceTree = ""; }; - 1865514918CA70B5003B92A7 /* UtilNanoInterval.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilNanoInterval.hpp; sourceTree = ""; }; - 1865514A18CA70B5003B92A7 /* UtilNanoTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilNanoTime.cpp; sourceTree = ""; }; - 1865514B18CA70B5003B92A7 /* UtilNanoTime.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilNanoTime.hpp; sourceTree = ""; }; - 1865514C18CA70B5003B92A7 /* UtilPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilPath.cpp; sourceTree = ""; }; - 1865514D18CA70B5003B92A7 /* UtilPath.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilPath.hpp; sourceTree = ""; }; - 1865514E18CA70B5003B92A7 /* UtilPrettyPrinting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilPrettyPrinting.cpp; sourceTree = ""; }; - 1865514F18CA70B5003B92A7 /* UtilPrettyPrinting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilPrettyPrinting.hpp; sourceTree = ""; }; - 1865515018CA70B5003B92A7 /* UtilString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilString.cpp; sourceTree = ""; }; - 1865515118CA70B5003B92A7 /* UtilString.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilString.hpp; sourceTree = ""; }; - 1865515218CA70B5003B92A7 /* UtilTerminalColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilTerminalColor.cpp; sourceTree = ""; }; - 1865515318CA70B5003B92A7 /* UtilTerminalColor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilTerminalColor.hpp; sourceTree = ""; }; - 1865515418CA70B5003B92A7 /* UtilTime.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilTime.hpp; sourceTree = ""; }; - 1865515518CA70B5003B92A7 /* UtilTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UtilTimer.cpp; sourceTree = ""; }; - 1865515618CA70B5003B92A7 /* UtilTimer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilTimer.hpp; sourceTree = ""; }; - 1865515718CA70B5003B92A7 /* UtilTRange.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilTRange.hpp; sourceTree = ""; }; - 1865515818CA70B5003B92A7 /* UtilTRangeValue.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UtilTRangeValue.hpp; sourceTree = ""; }; - 1865518018CA7104003B92A7 /* msa.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = msa.1; sourceTree = ""; }; - 1865518C18CA72F7003B92A7 /* Action.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Action.hpp; sourceTree = ""; }; - 1865518E18CA72F7003B92A7 /* EventProcessing.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EventProcessing.hpp; sourceTree = ""; }; - 1865518F18CA72F7003B92A7 /* EventRingBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = EventRingBuffer.hpp; sourceTree = ""; }; - 1865519018CA72F7003B92A7 /* global.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = global.h; sourceTree = ""; }; - 1865519118CA72F7003B92A7 /* Globals.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Globals.cpp; sourceTree = ""; }; - 1865519218CA72F7003B92A7 /* Globals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Globals.hpp; sourceTree = ""; }; - 1865519418CA72F7003B92A7 /* LiveTraceAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LiveTraceAction.cpp; sourceTree = ""; }; - 1865519518CA72F7003B92A7 /* LiveTraceAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = LiveTraceAction.hpp; sourceTree = ""; }; - 1865519618CA72F7003B92A7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; - 1865519718CA72F7003B92A7 /* Printing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Printing.cpp; sourceTree = ""; }; - 1865519818CA72F7003B92A7 /* Printing.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Printing.hpp; sourceTree = ""; }; - 1865519918CA72F7003B92A7 /* ReadTraceFileAction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReadTraceFileAction.cpp; sourceTree = ""; }; - 1865519A18CA72F7003B92A7 /* ReadTraceFileAction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ReadTraceFileAction.hpp; sourceTree = ""; }; - 1873F11E1CC52204008950A8 /* BinaryDataTraceEncoder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BinaryDataTraceEncoder.hpp; sourceTree = ""; }; - 1873F1211CC551DD008950A8 /* DeviceMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceMap.cpp; sourceTree = ""; }; - 1873F1221CC551DD008950A8 /* DeviceMap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DeviceMap.hpp; sourceTree = ""; }; - 1873F1261CC587E2008950A8 /* BinaryDataTraceDecoder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BinaryDataTraceDecoder.hpp; sourceTree = ""; }; - 1875DF421C443513004AC849 /* KDState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KDState.cpp; sourceTree = ""; }; - 1888DB65191A8A4400A0541E /* PrintBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = PrintBuffer.hpp; sourceTree = ""; }; - 188959FC1958D287004576E8 /* TaskRequestedPolicy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TaskRequestedPolicy.hpp; sourceTree = ""; }; 189337C21CC7CB4800B2A6A4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; }; - 189337C41CC7DA8700B2A6A4 /* UtilCoreSymbolication.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = UtilCoreSymbolication.hpp; sourceTree = ""; }; - 189632961C5FD38E00FA9646 /* eostrace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eostrace.h; sourceTree = ""; }; - 18C65BAD1CC1868D005194F4 /* TypeFilter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TypeFilter.cpp; sourceTree = ""; }; - 18C65BAE1CC1868D005194F4 /* TypeFilter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TypeFilter.hpp; sourceTree = ""; }; - 18C8728718EA128B00F86DD9 /* CPUActivity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPUActivity.hpp; sourceTree = ""; }; - 18C8728818EA128B00F86DD9 /* CPUSummary.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CPUSummary.hpp; sourceTree = ""; }; - 18C8728918EA128B00F86DD9 /* IOActivity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IOActivity.hpp; sourceTree = ""; }; - 18C8728A18EA128B00F86DD9 /* KDBG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KDBG.cpp; sourceTree = ""; }; - 18C8728B18EA128B00F86DD9 /* KDBG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KDBG.hpp; sourceTree = ""; }; - 18C8728C18EA128B00F86DD9 /* KDCPUMapEntry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KDCPUMapEntry.hpp; sourceTree = ""; }; - 18C8728D18EA128B00F86DD9 /* KDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KDebug.h; sourceTree = ""; }; - 18C8728E18EA128B00F86DD9 /* KDEvent.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KDEvent.hpp; sourceTree = ""; }; - 18C8728F18EA128B00F86DD9 /* KDState.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KDState.hpp; sourceTree = ""; }; - 18C8729018EA128B00F86DD9 /* KDThreadMapEntry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KDThreadMapEntry.hpp; sourceTree = ""; }; - 18C8729118EA128B00F86DD9 /* Kernel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Kernel.cpp; sourceTree = ""; }; - 18C8729218EA128B00F86DD9 /* Kernel.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Kernel.hpp; sourceTree = ""; }; - 18C8729318EA128B00F86DD9 /* Machine.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Machine.hpp; sourceTree = ""; }; - 18C8729418EA128B00F86DD9 /* Machine.impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Machine.impl.hpp; sourceTree = ""; }; - 18C8729518EA128B00F86DD9 /* Machine.mutable-impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "Machine.mutable-impl.hpp"; sourceTree = ""; }; - 18C8729618EA128B00F86DD9 /* MachineCPU.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineCPU.hpp; sourceTree = ""; }; - 18C8729718EA128B00F86DD9 /* MachineCPU.impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineCPU.impl.hpp; sourceTree = ""; }; - 18C8729818EA128B00F86DD9 /* MachineCPU.mutable-impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "MachineCPU.mutable-impl.hpp"; sourceTree = ""; }; - 18C8729918EA128B00F86DD9 /* MachineMachMsg.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineMachMsg.hpp; sourceTree = ""; }; - 18C8729A18EA128B00F86DD9 /* MachineProcess.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineProcess.hpp; sourceTree = ""; }; - 18C8729B18EA128B00F86DD9 /* MachineProcess.impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineProcess.impl.hpp; sourceTree = ""; }; - 18C8729C18EA128B00F86DD9 /* MachineProcess.mutable-impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "MachineProcess.mutable-impl.hpp"; sourceTree = ""; }; - 18C8729D18EA128B00F86DD9 /* MachineThread.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineThread.hpp; sourceTree = ""; }; - 18C8729E18EA128B00F86DD9 /* MachineThread.impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineThread.impl.hpp; sourceTree = ""; }; - 18C8729F18EA128B00F86DD9 /* MachineThread.mutable-impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = "MachineThread.mutable-impl.hpp"; sourceTree = ""; }; - 18C872A018EA128B00F86DD9 /* MachineVoucher.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MachineVoucher.hpp; sourceTree = ""; }; - 18C872A118EA128B00F86DD9 /* MetaTypes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MetaTypes.hpp; sourceTree = ""; }; - 18C872A218EA128B00F86DD9 /* NurseryMachMsg.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = NurseryMachMsg.hpp; sourceTree = ""; }; - 18C872A318EA128B00F86DD9 /* ProcessSummary.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ProcessSummary.hpp; sourceTree = ""; }; - 18C872A418EA128B00F86DD9 /* ThreadSummary.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadSummary.hpp; sourceTree = ""; }; - 18C872A518EA128B00F86DD9 /* TraceCodes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TraceCodes.cpp; sourceTree = ""; }; - 18C872A618EA128B00F86DD9 /* TraceCodes.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TraceCodes.hpp; sourceTree = ""; }; - 18C872A718EA128B00F86DD9 /* TraceDataHeader.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = TraceDataHeader.hpp; sourceTree = ""; }; - 18C872A818EA128B00F86DD9 /* VoucherInterval.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoucherInterval.hpp; sourceTree = ""; }; - 18D0E13119101CD200F93974 /* VoucherContentSysctl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = VoucherContentSysctl.hpp; sourceTree = ""; }; - 18D6F9AF1C5A8EF000F472A7 /* eostraced.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eostraced.c; sourceTree = ""; }; - 18D6F9B11C5A8EFB00F472A7 /* com.apple.eostraced.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.apple.eostraced.plist; sourceTree = ""; }; - 18D8B66519535B92008847DF /* TaskEffectivePolicy.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TaskEffectivePolicy.hpp; sourceTree = ""; }; 18EA07101C99C76C006D3005 /* EmbeddedOSSupportHost.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EmbeddedOSSupportHost.framework; path = System/Library/PrivateFrameworks/EmbeddedOSSupportHost.framework; sourceTree = SDKROOT; }; - 18EA07121C99E4E3006D3005 /* copy_of_AppleEmbeddedOSSupport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = copy_of_AppleEmbeddedOSSupport.c; path = eostrace/copy_of_AppleEmbeddedOSSupport.c; sourceTree = SOURCE_ROOT; }; - 18EA07131C99E4E3006D3005 /* copy_of_AppleEmbeddedOSSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = copy_of_AppleEmbeddedOSSupport.h; path = eostrace/copy_of_AppleEmbeddedOSSupport.h; sourceTree = SOURCE_ROOT; }; 550C19E01804C55E001DA380 /* iosim.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = iosim.1; sourceTree = ""; }; 550C19E11804C55E001DA380 /* iosim.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iosim.c; sourceTree = ""; }; 550C19EB1804D226001DA380 /* iosim */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = iosim; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2449,8 +2352,7 @@ 97999D2F1AE84C7600E8B10F /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = common.h; path = lskq.tproj/common.h; sourceTree = ""; }; 97999D301AE84C7600E8B10F /* lskq.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; name = lskq.1; path = lskq.tproj/lskq.1; sourceTree = ""; }; 97999D311AE84C7600E8B10F /* lskq.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = lskq.c; path = lskq.tproj/lskq.c; sourceTree = ""; }; - 9FAAF8741C158C0B00E6856D /* ThreadRequestedPolicy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadRequestedPolicy.hpp; sourceTree = ""; }; - 9FAAF8761C158C2300E6856D /* ThreadEffectivePolicy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ThreadEffectivePolicy.hpp; sourceTree = ""; }; + A7C0927020EC491E0068148E /* passwd.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = passwd.entitlements; sourceTree = ""; }; ADA9007717679A8C00161ADF /* purge */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = purge; sourceTree = BUILT_PRODUCTS_DIR; }; ADA900791767A02700161ADF /* purge.8 */ = {isa = PBXFileReference; lastKnownFileType = text; path = purge.8; sourceTree = ""; }; ADA9007A1767A02700161ADF /* purge.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = purge.c; sourceTree = ""; }; @@ -2706,10 +2608,17 @@ C96F50AC15BDCBF0008682F7 /* lsmp.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; name = lsmp.1; path = lsmp.tproj/lsmp.1; sourceTree = SOURCE_ROOT; }; C96F50AD15BDCE8E008682F7 /* lsmp.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = lsmp.c; path = lsmp.tproj/lsmp.c; sourceTree = SOURCE_ROOT; }; C96F50B715BDCEC3008682F7 /* lsmp */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = lsmp; sourceTree = BUILT_PRODUCTS_DIR; }; - C97199F11C5206DE006D9758 /* libktrace.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libktrace.dylib; path = usr/lib/libktrace.dylib; sourceTree = SDKROOT; }; + C99490E32090F55D00246D9D /* zprint.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = zprint.lua; sourceTree = ""; }; C9D64CCF1B91063200CFA43B /* system_cmds.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = system_cmds.plist; path = tests/system_cmds.plist; sourceTree = ""; }; C9E0691B1C58BDA000C956EB /* CoreSymbolication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreSymbolication.framework; path = System/Library/PrivateFrameworks/CoreSymbolication.framework; sourceTree = SDKROOT; }; C9E0691D1C58BDB800C956EB /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; + F2291F5D1FFEBB6A00161936 /* zlog */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = zlog; sourceTree = BUILT_PRODUCTS_DIR; }; + F2291F5F1FFEBB9E00161936 /* zlog.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = zlog.c; sourceTree = ""; }; + F27B70272044CB40003C04FC /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.0.Internal.sdk/System/Library/Frameworks/CoreFoundation.framework; sourceTree = DEVELOPER_DIR; }; + F27B70292045038B003C04FC /* SymbolicationHelper.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = SymbolicationHelper.c; sourceTree = ""; }; + F27B702A2045038B003C04FC /* SymbolicationHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SymbolicationHelper.h; sourceTree = ""; }; + F29F5A5A203E12BB005B0099 /* entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = entitlements.plist; sourceTree = ""; }; + F29F5A5C203E4403005B0099 /* zlog.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = zlog.1; sourceTree = ""; }; FEBEE5CF1B0EACEB00166A8B /* entitlements.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = entitlements.plist; sourceTree = ""; }; /* End PBXFileReference section */ @@ -3103,6 +3012,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F2291F531FFEBB6A00161936 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + F27B70282044CB40003C04FC /* CoreFoundation.framework in Frameworks */, + F2291F551FFEBB6A00161936 /* CoreSymbolication.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -3132,205 +3050,16 @@ path = ltop.tproj; sourceTree = ""; }; - 18380CDB1C596E8900DC6B89 /* eostrace */ = { - isa = PBXGroup; - children = ( - 189632961C5FD38E00FA9646 /* eostrace.h */, - 18380CDC1C596E8900DC6B89 /* eostrace.c */, - 18EA07131C99E4E3006D3005 /* copy_of_AppleEmbeddedOSSupport.h */, - 18EA07121C99E4E3006D3005 /* copy_of_AppleEmbeddedOSSupport.c */, - ); - path = eostrace; - sourceTree = ""; - }; - 18597EC518CBC2A300531A50 /* kdprof */ = { - isa = PBXGroup; - children = ( - 18597ECC18CBC35700531A50 /* Action.hpp */, - 18597ECD18CBC35700531A50 /* CollectAction.hpp */, - 18597ECE18CBC35700531A50 /* CollectAction.cpp */, - 18597ECF18CBC35700531A50 /* DisableAction.hpp */, - 18597ED018CBC35700531A50 /* DisableAction.cpp */, - 18597ED118CBC35700531A50 /* EnableAction.hpp */, - 18597ED218CBC35700531A50 /* EnableAction.cpp */, - 18597ED318CBC35700531A50 /* EventPrinting.hpp */, - 18597ED418CBC35700531A50 /* EventPrinting.cpp */, - 18597ED518CBC35700531A50 /* global.h */, - 18597ED618CBC35700531A50 /* Globals.hpp */, - 18597ED718CBC35700531A50 /* Globals.cpp */, - 18597ED818CBC35700531A50 /* InitializeAction.hpp */, - 18597ED918CBC35700531A50 /* InitializeAction.cpp */, - 18597EDA18CBC35700531A50 /* kdprof.cpp */, - 18597EDB18CBC35700531A50 /* NoWrapAction.hpp */, - 18597EDC18CBC35700531A50 /* NoWrapAction.cpp */, - 18597EDD18CBC35700531A50 /* PrintStateAction.hpp */, - 18597EDE18CBC35700531A50 /* PrintStateAction.cpp */, - 18597EDF18CBC35700531A50 /* RemoveAction.hpp */, - 18597EE018CBC35700531A50 /* RemoveAction.cpp */, - 18597EE118CBC35700531A50 /* SaveTraceAction.hpp */, - 18597EE218CBC35700531A50 /* SaveTraceAction.cpp */, - 18597EE318CBC35700531A50 /* SleepAction.hpp */, - 18597EE418CBC35700531A50 /* SleepAction.cpp */, - 18597EE518CBC35700531A50 /* SummaryPrinting.hpp */, - 18597EE618CBC35700531A50 /* SummaryPrinting.cpp */, - 18597EE718CBC35700531A50 /* TraceFileAction.hpp */, - 18597EE818CBC35700531A50 /* TraceFileAction.cpp */, - 185F75151CC2EFC600B0EA9E /* TypeFilterAction.hpp */, - 185F75141CC2EFC600B0EA9E /* TypeFilterAction.cpp */, - 1821B00C1C88BEE2000BAA0C /* usage.hpp */, - 1821B00B1C88BEE2000BAA0C /* usage.cpp */, - 185F751A1CC34EBE00B0EA9E /* WriteTraceFileAction.hpp */, - 185F75191CC34EBE00B0EA9E /* WriteTraceFileAction.cpp */, - 18410FED1CC881FD00385C96 /* entitlements.plist */, - 18597EC818CBC2A300531A50 /* kdprof.1 */, - ); - path = kdprof; - sourceTree = ""; - }; - 1865513918CA6F8C003B92A7 /* CPPUtil */ = { - isa = PBXGroup; - children = ( - 1865513A18CA70B5003B92A7 /* CPPUtil.h */, - 1865513B18CA70B5003B92A7 /* UtilAbsInterval.cpp */, - 1865513C18CA70B5003B92A7 /* UtilAbsInterval.hpp */, - 1865513D18CA70B5003B92A7 /* UtilAbsTime.cpp */, - 1865513E18CA70B5003B92A7 /* UtilAbsTime.hpp */, - 1865513F18CA70B5003B92A7 /* UtilAssert.hpp */, - 1865514018CA70B5003B92A7 /* UtilBase.hpp */, - 189337C41CC7DA8700B2A6A4 /* UtilCoreSymbolication.hpp */, - 1865514118CA70B5003B92A7 /* UtilException.hpp */, - 1865514218CA70B5003B92A7 /* UtilFileDescriptor.hpp */, - 1865514318CA70B5003B92A7 /* UtilLog.cpp */, - 1865514418CA70B5003B92A7 /* UtilLog.hpp */, - 1865514518CA70B5003B92A7 /* UtilMakeUnique.hpp */, - 1865514618CA70B5003B92A7 /* UtilMappedFile.cpp */, - 1865514718CA70B5003B92A7 /* UtilMappedFile.hpp */, - 1865514818CA70B5003B92A7 /* UtilMemoryBuffer.hpp */, - 1865514918CA70B5003B92A7 /* UtilNanoInterval.hpp */, - 1865514A18CA70B5003B92A7 /* UtilNanoTime.cpp */, - 1865514B18CA70B5003B92A7 /* UtilNanoTime.hpp */, - 1865514C18CA70B5003B92A7 /* UtilPath.cpp */, - 1865514D18CA70B5003B92A7 /* UtilPath.hpp */, - 1865514E18CA70B5003B92A7 /* UtilPrettyPrinting.cpp */, - 1865514F18CA70B5003B92A7 /* UtilPrettyPrinting.hpp */, - 1865515018CA70B5003B92A7 /* UtilString.cpp */, - 1865515118CA70B5003B92A7 /* UtilString.hpp */, - 1865515218CA70B5003B92A7 /* UtilTerminalColor.cpp */, - 1865515318CA70B5003B92A7 /* UtilTerminalColor.hpp */, - 1865515418CA70B5003B92A7 /* UtilTime.hpp */, - 1865515518CA70B5003B92A7 /* UtilTimer.cpp */, - 1865515618CA70B5003B92A7 /* UtilTimer.hpp */, - 1865515718CA70B5003B92A7 /* UtilTRange.hpp */, - 1865515818CA70B5003B92A7 /* UtilTRangeValue.hpp */, - ); - path = CPPUtil; - sourceTree = ""; - }; - 1865517D18CA7104003B92A7 /* msa */ = { - isa = PBXGroup; - children = ( - 1865518C18CA72F7003B92A7 /* Action.hpp */, - 1865518E18CA72F7003B92A7 /* EventProcessing.hpp */, - 1865518F18CA72F7003B92A7 /* EventRingBuffer.hpp */, - 1865519018CA72F7003B92A7 /* global.h */, - 1865519218CA72F7003B92A7 /* Globals.hpp */, - 1865519118CA72F7003B92A7 /* Globals.cpp */, - 1865519518CA72F7003B92A7 /* LiveTraceAction.hpp */, - 1865519418CA72F7003B92A7 /* LiveTraceAction.cpp */, - 1865519618CA72F7003B92A7 /* main.cpp */, - 1888DB65191A8A4400A0541E /* PrintBuffer.hpp */, - 1865519818CA72F7003B92A7 /* Printing.hpp */, - 1865519718CA72F7003B92A7 /* Printing.cpp */, - 1865519A18CA72F7003B92A7 /* ReadTraceFileAction.hpp */, - 1865519918CA72F7003B92A7 /* ReadTraceFileAction.cpp */, - 18D0E13119101CD200F93974 /* VoucherContentSysctl.hpp */, - 185B9771191022B200FCB84C /* VoucherContentSysctl.cpp */, - 185B97741910475500FCB84C /* WriteTraceFileAction.hpp */, - 185B97731910475500FCB84C /* WriteTraceFileAction.cpp */, - 1865518018CA7104003B92A7 /* msa.1 */, - ); - path = msa; - sourceTree = ""; - }; 189337C11CC7CB4800B2A6A4 /* Frameworks */ = { isa = PBXGroup; children = ( + F27B70272044CB40003C04FC /* CoreFoundation.framework */, 08ADC98B1E70715D0001CB70 /* ktrace.framework */, 189337C21CC7CB4800B2A6A4 /* CoreFoundation.framework */, ); name = Frameworks; sourceTree = ""; }; - 18C8728518EA11B900F86DD9 /* KDBG */ = { - isa = PBXGroup; - children = ( - 18C8728D18EA128B00F86DD9 /* KDebug.h */, - 1873F1261CC587E2008950A8 /* BinaryDataTraceDecoder.hpp */, - 1873F11E1CC52204008950A8 /* BinaryDataTraceEncoder.hpp */, - 18C8728718EA128B00F86DD9 /* CPUActivity.hpp */, - 18C8728818EA128B00F86DD9 /* CPUSummary.hpp */, - 18624C861BF64ED700FA0575 /* CPUTypeSummary.hpp */, - 1873F1221CC551DD008950A8 /* DeviceMap.hpp */, - 1873F1211CC551DD008950A8 /* DeviceMap.cpp */, - 18C8728918EA128B00F86DD9 /* IOActivity.hpp */, - 18C8728B18EA128B00F86DD9 /* KDBG.hpp */, - 18C8728A18EA128B00F86DD9 /* KDBG.cpp */, - 18C8728C18EA128B00F86DD9 /* KDCPUMapEntry.hpp */, - 18C8728E18EA128B00F86DD9 /* KDEvent.hpp */, - 18C8728F18EA128B00F86DD9 /* KDState.hpp */, - 1875DF421C443513004AC849 /* KDState.cpp */, - 18C8729018EA128B00F86DD9 /* KDThreadMapEntry.hpp */, - 18C8729218EA128B00F86DD9 /* Kernel.hpp */, - 18C8729118EA128B00F86DD9 /* Kernel.cpp */, - 18C8729318EA128B00F86DD9 /* Machine.hpp */, - 185F75171CC337D400B0EA9E /* Machine.cpp */, - 18C8729418EA128B00F86DD9 /* Machine.impl.hpp */, - 18C8729518EA128B00F86DD9 /* Machine.mutable-impl.hpp */, - 18C8729618EA128B00F86DD9 /* MachineCPU.hpp */, - 18C8729718EA128B00F86DD9 /* MachineCPU.impl.hpp */, - 18C8729818EA128B00F86DD9 /* MachineCPU.mutable-impl.hpp */, - 18C8729918EA128B00F86DD9 /* MachineMachMsg.hpp */, - 18C8729A18EA128B00F86DD9 /* MachineProcess.hpp */, - 18C8729B18EA128B00F86DD9 /* MachineProcess.impl.hpp */, - 18C8729C18EA128B00F86DD9 /* MachineProcess.mutable-impl.hpp */, - 18C8729D18EA128B00F86DD9 /* MachineThread.hpp */, - 18C8729E18EA128B00F86DD9 /* MachineThread.impl.hpp */, - 18C8729F18EA128B00F86DD9 /* MachineThread.mutable-impl.hpp */, - 18C872A018EA128B00F86DD9 /* MachineVoucher.hpp */, - 18C872A118EA128B00F86DD9 /* MetaTypes.hpp */, - 18C872A218EA128B00F86DD9 /* NurseryMachMsg.hpp */, - 18C872A318EA128B00F86DD9 /* ProcessSummary.hpp */, - 18624C871BF6503600FA0575 /* ProcessTypeSummary.hpp */, - 18D8B66519535B92008847DF /* TaskEffectivePolicy.hpp */, - 9FAAF8761C158C2300E6856D /* ThreadEffectivePolicy.hpp */, - 188959FC1958D287004576E8 /* TaskRequestedPolicy.hpp */, - 9FAAF8741C158C0B00E6856D /* ThreadRequestedPolicy.hpp */, - 18C872A418EA128B00F86DD9 /* ThreadSummary.hpp */, - 18624C881BF651EC00FA0575 /* ThreadTypeSummary.hpp */, - 18C872A618EA128B00F86DD9 /* TraceCodes.hpp */, - 18C872A518EA128B00F86DD9 /* TraceCodes.cpp */, - 18C872A718EA128B00F86DD9 /* TraceDataHeader.hpp */, - 1845E41518EB95810010F451 /* TraceFile.hpp */, - 1845E41418EB95810010F451 /* TraceFile.cpp */, - 18624C851BF6400200FA0575 /* TypeSummary.hpp */, - 18C65BAE1CC1868D005194F4 /* TypeFilter.hpp */, - 18C65BAD1CC1868D005194F4 /* TypeFilter.cpp */, - 186288D01CC5DA71002950E0 /* UUIDMap.hpp */, - 186288CF1CC5DA71002950E0 /* UUIDMap.cpp */, - 18C872A818EA128B00F86DD9 /* VoucherInterval.hpp */, - ); - path = KDBG; - sourceTree = ""; - }; - 18D6F9A91C5A8EDB00F472A7 /* eostraced */ = { - isa = PBXGroup; - children = ( - 18D6F9AF1C5A8EF000F472A7 /* eostraced.c */, - 18D6F9B11C5A8EFB00F472A7 /* com.apple.eostraced.plist */, - ); - path = eostraced; - sourceTree = ""; - }; 3F56BF751F56057800266763 /* Recovered References */ = { isa = PBXGroup; children = ( @@ -3426,7 +3155,6 @@ isa = PBXGroup; children = ( 08CE3D321E6E22DE00DF1B78 /* stackshot.c */, - 08CE3D301E6E22B000DF1B78 /* stackshot */, 18EA07101C99C76C006D3005 /* EmbeddedOSSupportHost.framework */, BA4FD1E11372FAFA0025925C /* APPLE_LICENSE */, BA4FD2FB1372FB710025925C /* BSD.xcconfig */, @@ -3438,7 +3166,6 @@ BA4FD1F61372FAFA0025925C /* atrun.tproj */, BA4FD1FF1372FAFA0025925C /* chkpasswd.tproj */, BA4FD20A1372FAFA0025925C /* chpass.tproj */, - 1865513918CA6F8C003B92A7 /* CPPUtil */, BA4FD21E1372FAFA0025925C /* dmesg.tproj */, BA4FD2261372FAFA0025925C /* dynamic_pager.tproj */, BA4FD22E1372FAFA0025925C /* fs_usage.tproj */, @@ -3448,8 +3175,6 @@ BA4FD24B1372FAFA0025925C /* hostinfo.tproj */, 550C19DF1804C55E001DA380 /* iosim.tproj */, BA4FD24F1372FAFA0025925C /* iostat.tproj */, - 18C8728518EA11B900F86DD9 /* KDBG */, - 18597EC518CBC2A300531A50 /* kdprof */, 08DC488C1A12C2C5008AAF38 /* kpgo.tproj */, BA4FD2551372FAFA0025925C /* latency.tproj */, BA4FD2591372FAFA0025925C /* login.tproj */, @@ -3459,7 +3184,6 @@ BA4FD2691372FAFA0025925C /* mean.tproj */, B3F0E6DA16E9706E008FAD09 /* memory_pressure.tproj */, BA4FD26C1372FAFA0025925C /* mkfile.tproj */, - 1865517D18CA7104003B92A7 /* msa */, 0D06BC5F1E8F08CB00C6EC2D /* mslutil */, BA4FD2701372FAFA0025925C /* newgrp.tproj */, BA4FD2741372FAFA0025925C /* nologin.tproj */, @@ -3477,8 +3201,6 @@ BA4FD2BA1372FAFA0025925C /* sysctl.tproj */, C625B28916D6F27E00168EF7 /* taskpolicy.tproj */, BA4FD2BF1372FAFA0025925C /* trace.tproj */, - 18380CDB1C596E8900DC6B89 /* eostrace */, - 18D6F9A91C5A8EDB00F472A7 /* eostraced */, BA4FD2C31372FAFA0025925C /* vifs.tproj */, BA4FD2C71372FAFA0025925C /* vipw.tproj */, 55CCB16716B84ED100B56979 /* vm_purgeable_stat.tproj */, @@ -3487,6 +3209,7 @@ B158E3A1185A836700474677 /* wordexp-helper.tproj */, BA4FD2D11372FAFA0025925C /* zdump.tproj */, BA4FD2D51372FAFA0025925C /* zic.tproj */, + F2291F5E1FFEBB8500161936 /* zlog.tproj */, BA4FD2E31372FAFA0025925C /* zprint.tproj */, BA4B7A0D1373BBB600003422 /* Libraries */, BA4FD2F01372FB3D0025925C /* Products */, @@ -3506,7 +3229,6 @@ BA4B7A0D1373BBB600003422 /* Libraries */ = { isa = PBXGroup; children = ( - C97199F11C5206DE006D9758 /* libktrace.dylib */, BA4B79BF1373A53700003422 /* libbsm.dylib */, BA4B7A9313765F8B00003422 /* libncurses.dylib */, BA4B7A091373BA4600003422 /* libutil.dylib */, @@ -3809,6 +3531,7 @@ BA4FD2811372FAFA0025925C /* passwd.tproj */ = { isa = PBXGroup; children = ( + A7C0927020EC491E0068148E /* passwd.entitlements */, BA4FD2831372FAFA0025925C /* file_passwd.c */, BA4FD2841372FAFA0025925C /* nis_passwd.c */, BA4FD2851372FAFA0025925C /* od_passwd.c */, @@ -3966,6 +3689,7 @@ BA4FD2E31372FAFA0025925C /* zprint.tproj */ = { isa = PBXGroup; children = ( + C99490E32090F55D00246D9D /* zprint.lua */, FEBEE5CF1B0EACEB00166A8B /* entitlements.plist */, BA4FD2E51372FAFA0025925C /* zprint.1 */, BA4FD2E61372FAFA0025925C /* zprint.c */, @@ -4027,6 +3751,7 @@ 8EC391651C9733C2001E28E6 /* proc_uuid_policy */, 08CE3D291E6E22A200DF1B78 /* stackshot */, 0D06BC5E1E8F08CB00C6EC2D /* mslutil */, + F2291F5D1FFEBB6A00161936 /* zlog */, ); name = Products; sourceTree = ""; @@ -4084,6 +3809,18 @@ path = ac.tproj; sourceTree = ""; }; + F2291F5E1FFEBB8500161936 /* zlog.tproj */ = { + isa = PBXGroup; + children = ( + F29F5A5C203E4403005B0099 /* zlog.1 */, + F29F5A5A203E12BB005B0099 /* entitlements.plist */, + F2291F5F1FFEBB9E00161936 /* zlog.c */, + F27B70292045038B003C04FC /* SymbolicationHelper.c */, + F27B702A2045038B003C04FC /* SymbolicationHelper.h */, + ); + path = zlog.tproj; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -4343,6 +4080,7 @@ BA0A860813968E8500D2272C /* Sources */, BA0A860A13968E8500D2272C /* Frameworks */, BA0A860C13968E8500D2272C /* CopyFiles */, + C99490E22090F53B00246D9D /* CopyFiles */, ); buildRules = ( ); @@ -5015,6 +4753,23 @@ productReference = C96F50B715BDCEC3008682F7 /* lsmp */; productType = "com.apple.product-type.tool"; }; + F2291F501FFEBB6A00161936 /* zlog */ = { + isa = PBXNativeTarget; + buildConfigurationList = F2291F5A1FFEBB6A00161936 /* Build configuration list for PBXNativeTarget "zlog" */; + buildPhases = ( + F2291F511FFEBB6A00161936 /* Sources */, + F2291F531FFEBB6A00161936 /* Frameworks */, + F29F5A5E203E532B005B0099 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = zlog; + productName = ac; + productReference = F2291F5D1FFEBB6A00161936 /* zlog */; + productType = "com.apple.product-type.tool"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -5294,6 +5049,7 @@ BA0A860713968E8500D2272C /* zprint */, 08CE3D281E6E22A200DF1B78 /* stackshot */, 0D06BC5D1E8F08CB00C6EC2D /* mslutil */, + F2291F501FFEBB6A00161936 /* zlog */, ); }; /* End PBXProject section */ @@ -6035,6 +5791,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F2291F511FFEBB6A00161936 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + F2291F601FFEBB9E00161936 /* zlog.c in Sources */, + F27B702B2045038B003C04FC /* SymbolicationHelper.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -6838,6 +6603,21 @@ target = C96F50AE15BDCEC3008682F7 /* lsmp */; targetProxy = C96F50BB15BDFDB1008682F7 /* PBXContainerItemProxy */; }; + F2291F641FFEBC4000161936 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = F2291F501FFEBB6A00161936 /* zlog */; + targetProxy = F2291F631FFEBC4000161936 /* PBXContainerItemProxy */; + }; + F2291F661FFEBC4700161936 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = F2291F501FFEBB6A00161936 /* zlog */; + targetProxy = F2291F651FFEBC4700161936 /* PBXContainerItemProxy */; + }; + F2291F681FFEBC4F00161936 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = F2291F501FFEBB6A00161936 /* zlog */; + targetProxy = F2291F671FFEBC4F00161936 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin XCBuildConfiguration section */ @@ -7450,6 +7230,7 @@ 1873300418CBD4A700275344 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = passwd.tproj/passwd.entitlements; INSTALL_PATH = /usr/bin; "OTHER_LDFLAGS[sdk=macosx*][arch=*]" = ( "-framework", @@ -7653,6 +7434,7 @@ 1873301A18CBD4A700275344 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = "taskpolicy.tproj/taskpolicy-entitlements.plist"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/sbin; @@ -7760,7 +7542,6 @@ MTL_ENABLE_DEBUG_INFO = NO; New_Setting14GCC_ENABLE_OBJC_GC = unsupported; PRODUCT_NAME = wait4path; - SDKROOT = macosx; STRIP_INSTALLED_PRODUCT_debug = NO; USE_HEADERMAP = NO; WANTS_GET_TASK_ALLOW = NO; @@ -7834,7 +7615,6 @@ New_Setting14GCC_ENABLE_OBJC_GC = unsupported; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = wait4path; - SDKROOT = macosx; STRIP_INSTALLED_PRODUCT_debug = NO; USE_HEADERMAP = NO; WANTS_GET_TASK_ALLOW = NO; @@ -8351,6 +8131,7 @@ BAE589CD1378FCAA0049DD3B /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = passwd.tproj/passwd.entitlements; INSTALL_PATH = /usr/bin; "OTHER_LDFLAGS[sdk=macosx*][arch=*]" = ( "-framework", @@ -8429,6 +8210,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "gcore.tproj/gcore-entitlements.plist"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)/$(SYSTEM_LIBRARY_DIR)/Frameworks/Kernel.framework/PrivateHeaders"; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; @@ -8461,6 +8243,7 @@ CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; + CODE_SIGN_ENTITLEMENTS = "gcore.tproj/gcore-entitlements.plist"; FRAMEWORK_SEARCH_PATHS = "$(SDKROOT)/$(SYSTEM_LIBRARY_DIR)/Frameworks/Kernel.framework/PrivateHeaders"; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -8487,6 +8270,7 @@ C625B28E16D6F27E00168EF7 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CODE_SIGN_ENTITLEMENTS = "taskpolicy.tproj/taskpolicy-entitlements.plist"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; HEADER_SEARCH_PATHS = "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders"; INSTALL_PATH = /usr/sbin; @@ -8505,6 +8289,44 @@ }; name = Release; }; + F2291F5B1FFEBB6A00161936 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = zlog.tproj/entitlements.plist; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + ); + HEADER_SEARCH_PATHS = ( + "$(SDKROOT)/$(SYSTEM_LIBRARY_DIR)/Frameworks/Kernel.framework/PrivateHeaders/mach", + "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders", + "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd", + ); + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; + F2291F5C1FFEBB6A00161936 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_ENTITLEMENTS = zlog.tproj/entitlements.plist; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + "$(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks", + ); + HEADER_SEARCH_PATHS = ( + "$(SDKROOT)/$(SYSTEM_LIBRARY_DIR)/Frameworks/Kernel.framework/PrivateHeaders/mach", + "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders", + "$(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders/bsd", + ); + INSTALL_PATH = /usr/local/bin; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -9084,6 +8906,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + F2291F5A1FFEBB6A00161936 /* Build configuration list for PBXNativeTarget "zlog" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + F2291F5B1FFEBB6A00161936 /* Release */, + F2291F5C1FFEBB6A00161936 /* Debug */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = BA2DE9181372FA9100D1913C /* Project object */; diff --git a/taskpolicy.tproj/taskpolicy-entitlements.plist b/taskpolicy.tproj/taskpolicy-entitlements.plist new file mode 100644 index 0000000..39c14ef --- /dev/null +++ b/taskpolicy.tproj/taskpolicy-entitlements.plist @@ -0,0 +1,8 @@ + + + + + com.apple.security.cs.debugger.root + + + diff --git a/tests/system_cmds.plist b/tests/system_cmds.plist index 5f5b961..d2fd882 100644 --- a/tests/system_cmds.plist +++ b/tests/system_cmds.plist @@ -180,6 +180,31 @@ WorkingDirectory /tmp/ + + Arch + platform-native + AsRoot + + Command + + /usr/local/bin/proc_uuid_policy + add + alt-dyld + /usr/bin/yes + + EligibleResource + deviceClass == 'iPhone' + IgnoreCrashes + + + TestName + test_proc_uuid_policy + TestSpecificLogs + + + WorkingDirectory + /tmp/ + diff --git a/trace.tproj/trace.1 b/trace.tproj/trace.1 index ac9d270..afbd280 100644 --- a/trace.tproj/trace.1 +++ b/trace.tproj/trace.1 @@ -64,6 +64,11 @@ optionally converted to a human-readable, plain-text format. .Pp .Nm operates according to the command flag specified. +.Pp +NOTE: +.Nm +is obsolete. The command you probably want is +.Xr ktrace 1 .Sh COMMANDS .Bl -tag -width Ds .It Fl h diff --git a/trace.tproj/trace.c b/trace.tproj/trace.c index 98aadc8..b68c53e 100644 --- a/trace.tproj/trace.c +++ b/trace.tproj/trace.c @@ -158,7 +158,7 @@ typedef struct event *event_t; struct event { event_t ev_next; - uintptr_t ev_thread; + uint64_t ev_thread; uint32_t ev_debugid; uint64_t ev_timestamp; }; @@ -168,10 +168,10 @@ typedef struct lookup *lookup_t; struct lookup { lookup_t lk_next; - uintptr_t lk_thread; - uintptr_t lk_dvp; - long *lk_pathptr; - long lk_pathname[NUMPARMS + 1]; + uint64_t lk_thread; + uint64_t lk_dvp; + int64_t *lk_pathptr; + int64_t lk_pathname[NUMPARMS + 1]; }; typedef struct threadmap *threadmap_t; @@ -179,8 +179,8 @@ typedef struct threadmap *threadmap_t; struct threadmap { threadmap_t tm_next; - uintptr_t tm_thread; - uintptr_t tm_pthread; + uint64_t tm_thread; + uint64_t tm_pthread; boolean_t tm_deleteme; char tm_command[MAXCOMLEN + 1]; }; @@ -219,7 +219,7 @@ static void codesc_find_dupes(void); static int read_command_map(int, uint32_t); static void read_cpu_map(int); static void find_thread_command(kd_buf *, char **); -static void create_map_entry(uintptr_t, char *); +static void create_map_entry(uint64_t, char *); static void getdivisor(); static unsigned long argtoul(); @@ -240,17 +240,17 @@ static void Log_trace(); static void read_trace(); static void signal_handler(int); static void signal_handler_RAW(int); -static void delete_thread_entry(uintptr_t); -static void find_and_insert_tmp_map_entry(uintptr_t, char *); -static void create_tmp_map_entry(uintptr_t, uintptr_t); -static void find_thread_name(uintptr_t, char **, boolean_t); +static void delete_thread_entry(uint64_t); +static void find_and_insert_tmp_map_entry(uint64_t, char *); +static void create_tmp_map_entry(uint64_t, uint64_t); +static void find_thread_name(uint64_t, char **, boolean_t); static void execute_process(char * const argv[]); static int writetrace(int); static int write_command_map(int); static int debugid_compar(const void *, const void *); -static threadmap_t find_thread_entry(uintptr_t); +static threadmap_t find_thread_entry(uint64_t); static void saw_filter_class(uint8_t class); static void saw_filter_end_range(uint8_t end_class); @@ -591,7 +591,7 @@ int write_command_map(int fd) static -lookup_t handle_lookup_event(uintptr_t thread, int debugid, kd_buf *kdp) +lookup_t handle_lookup_event(uint64_t thread, int debugid, kd_buf *kdp) { lookup_t lkp; int hashid; @@ -640,7 +640,7 @@ lookup_t handle_lookup_event(uintptr_t thread, int debugid, kd_buf *kdp) static -void delete_lookup_event(uintptr_t thread, lookup_t lkp_to_delete) +void delete_lookup_event(uint64_t thread, lookup_t lkp_to_delete) { lookup_t lkp; lookup_t lkp_prev; @@ -671,7 +671,7 @@ void delete_lookup_event(uintptr_t thread, lookup_t lkp_to_delete) static -void insert_start_event(uintptr_t thread, int debugid, uint64_t now) +void insert_start_event(uint64_t thread, int debugid, uint64_t now) { event_t evp; int hashid; @@ -699,7 +699,7 @@ void insert_start_event(uintptr_t thread, int debugid, uint64_t now) static -uint64_t consume_start_event(uintptr_t thread, int debugid, uint64_t now) +uint64_t consume_start_event(uint64_t thread, int debugid, uint64_t now) { event_t evp; event_t evp_prev; @@ -1006,7 +1006,7 @@ void read_trace(void) uint64_t prev; uint64_t prevdelta = 0; uint32_t cpunum = 0; - uintptr_t thread; + uint64_t thread; double x = 0.0; double y = 0.0; double event_elapsed_time = 0; @@ -1142,7 +1142,7 @@ void read_trace(void) if ( !lkp) { int t_debugid; - uintptr_t t_thread; + uint64_t t_thread; if ((debugid & DBG_FUNC_START) || debugid == MACH_MAKERUNNABLE) { @@ -1227,24 +1227,26 @@ void read_trace(void) len -= 51; else len = 0; -#ifdef __LP64__ +#if defined(__LP64__) || defined(__arm64__) - fprintf(output_file, "%-16lx %-51s %-16lx %-2d %s\n", lkp->lk_dvp, &strptr[len], thread, cpunum, command); + fprintf(output_file, "%-16llx %-51s %-16" PRIx64 " %-2d %s\n", (uint64_t)lkp->lk_dvp, &strptr[len], thread, cpunum, command); #else - fprintf(output_file, "%-8x %-51s %-8lx %-2d %s\n", (unsigned int)lkp->lk_dvp, &strptr[len], thread, cpunum, command); + fprintf(output_file, "%-8x %-51s %-8" PRIx64 " %-2d %s\n", (unsigned int)lkp->lk_dvp, &strptr[len], thread, cpunum, command); #endif delete_lookup_event(thread, lkp); } else if (debugid == TRACE_INFO_STRING) { -#ifdef __LP64__ - fprintf(output_file, "%-32s%-36s %-16lx %-2d %s\n", (char *) &kdp->arg1, "", thread, cpunum, command); +#if defined(__LP64__) || defined(__arm64__) + fprintf(output_file, "%-32s%-36s %-16" PRIx64 " %-2d %s\n", (char *) &kdp->arg1, "", thread, cpunum, command); #else - fprintf(output_file, "%-16s%-46s %-8lx %-2d %s\n", (char *) &kdp->arg1, "", thread, cpunum, command); + fprintf(output_file, "%-16s%-46s %-8" PRIx64 " %-2d %s\n", (char *) &kdp->arg1, "", thread, cpunum, command); #endif } else { -#ifdef __LP64__ - fprintf(output_file, "%-16lx %-16lx %-16lx %-16lx %-16lx %-2d %s\n", kdp->arg1, kdp->arg2, kdp->arg3, kdp->arg4, thread, cpunum, command); +#if defined(__LP64__) || defined(__arm64__) + fprintf(output_file, "%-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-16" PRIx64 " %-2d %s\n", + (uint64_t)kdp->arg1, (uint64_t)kdp->arg2, (uint64_t)kdp->arg3, (uint64_t)kdp->arg4, thread, cpunum, command); #else - fprintf(output_file, "%-8lx %-8lx %-8lx %-8lx %-8lx %-2d %s\n", kdp->arg1, kdp->arg2, kdp->arg3, kdp->arg4, thread, cpunum, command); + fprintf(output_file, "%-8" PRIx64 " %-8" PRIx64 " %-8" PRIx64 " %-8" PRIx64 " %-8" PRIx64 " %-2d %s\n", + (uint64_t)kdp->arg1, (uint64_t)kdp->arg2, (uint64_t)kdp->arg3, (uint64_t)kdp->arg4, thread, cpunum, command); #endif } lines++; @@ -1293,12 +1295,15 @@ int main (int argc, char* argv[], char *envp[]) fprintf(stderr, "Could not re-execute: %d\n", errno); exit(1); } - } else { + } +#if !defined(__arm64__) + else { if (0 != reexec_to_match_kernel()) { fprintf(stderr, "Could not re-execute: %d\n", errno); exit(1); } } +#endif if (setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_PASSIVE) < 0) { printf("setiopolicy failed\n"); exit(1); @@ -2703,8 +2708,8 @@ read_command_map(int fd, uint32_t count) printf("Thread Command\n"); for (i = 0; i < total_threads; i++) { - printf ("0x%lx %s\n", - mapptr[i].thread, + printf ("0x%" PRIx64 " %s\n", + (uint64_t)mapptr[i].thread, mapptr[i].command); } } @@ -2713,7 +2718,7 @@ read_command_map(int fd, uint32_t count) } void -create_map_entry(uintptr_t thread, char *command) +create_map_entry(uint64_t thread, char *command) { threadmap_t tme; int hashid; @@ -2736,7 +2741,7 @@ create_map_entry(uintptr_t thread, char *command) } void -delete_thread_entry(uintptr_t thread) +delete_thread_entry(uint64_t thread) { threadmap_t tme = 0; threadmap_t tme_prev; @@ -2766,7 +2771,7 @@ delete_thread_entry(uintptr_t thread) } void -find_and_insert_tmp_map_entry(uintptr_t pthread, char *command) +find_and_insert_tmp_map_entry(uint64_t pthread, char *command) { threadmap_t tme = 0; threadmap_t tme_prev; @@ -2801,7 +2806,7 @@ find_and_insert_tmp_map_entry(uintptr_t pthread, char *command) } void -create_tmp_map_entry(uintptr_t thread, uintptr_t pthread) +create_tmp_map_entry(uint64_t thread, uint64_t pthread) { threadmap_t tme; @@ -2821,7 +2826,7 @@ create_tmp_map_entry(uintptr_t thread, uintptr_t pthread) threadmap_t -find_thread_entry(uintptr_t thread) +find_thread_entry(uint64_t thread) { threadmap_t tme; int hashid; @@ -2836,7 +2841,7 @@ find_thread_entry(uintptr_t thread) } void -find_thread_name(uintptr_t thread, char **command, boolean_t deleteme) +find_thread_name(uint64_t thread, char **command, boolean_t deleteme) { threadmap_t tme; @@ -2852,7 +2857,7 @@ find_thread_name(uintptr_t thread, char **command, boolean_t deleteme) void find_thread_command(kd_buf *kbufp, char **command) { - uintptr_t thread; + uint64_t thread; threadmap_t tme; int debugid_base; diff --git a/zlog.tproj/SymbolicationHelper.c b/zlog.tproj/SymbolicationHelper.c new file mode 100644 index 0000000..68a1285 --- /dev/null +++ b/zlog.tproj/SymbolicationHelper.c @@ -0,0 +1,181 @@ +// +// SymbolicationHelper.c +// zlog +// +// Created by Rasha Eqbal on 2/26/18. +// + +#include "SymbolicationHelper.h" + +/* + * Most of the CoreSymbolication code here has been copied from ioclasscount in the IOKitTools project. + */ + +#define kAddressKey CFSTR("Address") +#define kNameKey CFSTR("Name") +#define kPathKey CFSTR("Path") +#define kSegmentsKey CFSTR("Segments") +#define kSizeKey CFSTR("Size") +#define kUuidKey CFSTR("UUID") + +static void AddSymbolOwnerSummary(CSSymbolOwnerRef owner, CFMutableDictionaryRef binaryImages); +static void ShowBinaryImage(const void *key, const void *value, void *context); + +/* + * Symbolicates 'addr' using the 'symbolicator' passed in. + * Adds owner info to 'binaryImages' for offline symbolication. + * + * Top-level function that needs to be called on each frame address in the backtrace. + */ +void PrintSymbolicatedAddress(CSSymbolicatorRef symbolicator, mach_vm_address_t addr, CFMutableDictionaryRef binaryImages) +{ + printf("0x%llx", addr); + + CSSymbolOwnerRef ownerInfo = CSSymbolicatorGetSymbolOwnerWithAddressAtTime(symbolicator, addr, kCSNow); + if (!CSIsNull(ownerInfo)) { + const char *moduleName = CSSymbolOwnerGetName(ownerInfo); + if (moduleName) { + printf(" <%s>", moduleName); + } + } + + CSSymbolRef symbolInfo = CSSymbolicatorGetSymbolWithAddressAtTime(symbolicator, addr, kCSNow); + if (!CSIsNull(symbolInfo)) { + printf(" %s", CSSymbolGetName(symbolInfo)); + } + + CSSourceInfoRef sourceInfo = CSSymbolicatorGetSourceInfoWithAddressAtTime(symbolicator, addr, kCSNow); + if (!CSIsNull(sourceInfo)) { + const char *fileName = CSSourceInfoGetPath(sourceInfo); + if (fileName) { + printf(" at %s:%d", fileName, CSSourceInfoGetLineNumber(sourceInfo)); + } + } + printf("\n"); + + AddSymbolOwnerSummary(ownerInfo, binaryImages); +} + +/* + * Adds symbolication information for 'owner' to 'binaryImages' to help with offline symbolication. + * + * This is called from PrintSymbolicatedAddress() on the symbol owner for each address it symbolicates. + */ +static void AddSymbolOwnerSummary(CSSymbolOwnerRef owner, CFMutableDictionaryRef binaryImages) +{ + const CFUUIDBytes *uuidBytes = NULL; + CFUUIDRef uuid = NULL; + CFStringRef uuidString = NULL, path = NULL, name = NULL; + CFMutableDictionaryRef summaryDict = NULL; + __block CSSegmentRef textSegment = kCSNull, textExecSegment = kCSNull; + CSSegmentRef segment = kCSNull; + CSRange range; + CFNumberRef address = NULL, size = NULL; + +#define RETURN_IF_NULL(ptr) \ +if (!(ptr)) { \ +goto cleanup; \ +} + + uuidBytes = CSSymbolOwnerGetCFUUIDBytes(owner); + if (uuidBytes) { + uuid = CFUUIDCreateFromUUIDBytes(NULL, *uuidBytes); + if (uuid) { + uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuid); + } + } + RETURN_IF_NULL(uuidString); + + if (!CFDictionaryContainsKey(binaryImages, uuidString)) { + summaryDict = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + RETURN_IF_NULL(summaryDict); + + CFDictionarySetValue(summaryDict, kUuidKey, uuidString); + + path = CFStringCreateWithCString(kCFAllocatorDefault, CSSymbolOwnerGetPath(owner), kCFStringEncodingUTF8); + RETURN_IF_NULL(path); + CFDictionarySetValue(summaryDict, kPathKey, path); + + name = CFStringCreateWithCString(kCFAllocatorDefault, CSSymbolOwnerGetName(owner), kCFStringEncodingUTF8); + RETURN_IF_NULL(name); + CFDictionarySetValue(summaryDict, kNameKey, name); + + CSSymbolOwnerForeachSegment(owner, ^(CSSegmentRef segment) { + if (strcmp(CSRegionGetName(segment), "__TEXT SEGMENT") == 0) { + textSegment = segment; + CSRetain(textSegment); + } else if (strcmp(CSRegionGetName(segment), "__TEXT_EXEC SEGMENT") == 0) { + textExecSegment = segment; + CSRetain(textExecSegment); + } + }); + + segment = !CSIsNull(textExecSegment) ? textExecSegment : textSegment; + if (CSIsNull(segment)) { + goto cleanup; + } + range = CSRegionGetRange(segment); + + address = CFNumberCreate(NULL, kCFNumberLongLongType, &range.location); + RETURN_IF_NULL(address); + CFDictionarySetValue(summaryDict, kAddressKey, address); + + size = CFNumberCreate(NULL, kCFNumberLongLongType, &range.length); + RETURN_IF_NULL(size); + CFDictionarySetValue(summaryDict, kSizeKey, size); + + CFDictionarySetValue(binaryImages, uuidString, summaryDict); + } + +cleanup: + if (size) CFRelease(size); + if (address) CFRelease(address); + if (!CSIsNull(textExecSegment)) CSRelease(textExecSegment); + if (!CSIsNull(textSegment)) CSRelease(textSegment); + if (name) CFRelease(name); + if (path) CFRelease(path); + if (summaryDict) CFRelease(summaryDict); + if (uuidString) CFRelease(uuidString); + if (uuid) CFRelease(uuid); +} + +/* + * Prints offline symbolication information for the images passed in 'binaryImages'. + * + * Top-level function that needs to be called if the tool wants to include support + * for offline symbolication. + */ +void PrintBinaryImagesInfo(CFMutableDictionaryRef binaryImages) +{ + if (CFDictionaryGetCount(binaryImages) > 0) { + printf("\nBinary Images:\n"); + CFDictionaryApplyFunction(binaryImages, ShowBinaryImage, NULL); + } else { + printf("No binary images\n"); + } +} + +/* + * Prints information about a binary image necessary for offline symbolication. + * + * This is called from PrintBinaryImagesInfo() on each element in 'binaryImages'. + */ +static void ShowBinaryImage(const void *key, const void *value, void *context) +{ + char nameString[256] = {0}, uuidString[256] = {0}, pathString[256] = {0}; + CFStringRef uuid = (CFStringRef)key; + CFStringGetCString(uuid, uuidString, sizeof(uuidString), kCFStringEncodingASCII); + CFDictionaryRef summary = (CFDictionaryRef)value; + + CFStringRef name = CFDictionaryGetValue(summary, kNameKey); + CFStringGetCString(name, nameString, sizeof(nameString), kCFStringEncodingASCII); + CFStringRef path = CFDictionaryGetValue(summary, kPathKey); + CFStringGetCString(path, pathString, sizeof(pathString), kCFStringEncodingASCII); + CFNumberRef addressNumber = CFDictionaryGetValue(summary, kAddressKey); + CFNumberRef sizeNumber = CFDictionaryGetValue(summary, kSizeKey); + int64_t address, size; + CFNumberGetValue(addressNumber, kCFNumberSInt64Type, &address); + CFNumberGetValue(sizeNumber, kCFNumberSInt64Type, &size); + + printf("%p - %p %s <%s> %s\n", (void*)address, (void*)address + size, nameString, uuidString, pathString); +} diff --git a/zlog.tproj/SymbolicationHelper.h b/zlog.tproj/SymbolicationHelper.h new file mode 100644 index 0000000..f9d90c5 --- /dev/null +++ b/zlog.tproj/SymbolicationHelper.h @@ -0,0 +1,35 @@ +// +// SymbolicationHelper.h +// zlog +// +// Created by Rasha Eqbal on 2/26/18. +// + +#ifndef SymbolicationHelper_h +#define SymbolicationHelper_h + +#include +#include + +/* + * Call this function on each address that needs to be symbolicated. + * + * sym: The CSSymbolicatorRef which will be used for symbolication. For example, to symbolicate + * kernel addresses create a CSSymbolicatorRef by calling CSSymbolicatorCreateWithMachKernel(). + * addr: The address that needs to be symbolicated. + * binaryImages: The dictionary that aggregates binary image info for offline symbolication. + */ +void PrintSymbolicatedAddress(CSSymbolicatorRef sym, mach_vm_address_t addr, CFMutableDictionaryRef binaryImages); + +/* + * Call this function to dump binary image info required for offline symbolication. + * + * binaryImages: The dictionary that stores this info. + * + * The preferred way to use this is to create a CFMutableDictionaryRef with a call to CFDictionaryCreateMutable() + * and pass it in to PrintSymbolicatedAddress() when symbolicating addresses. This will auto-populate the dictionary, + * which just needs to be passed in here to print the relevant information. + */ +void PrintBinaryImagesInfo(CFMutableDictionaryRef binaryImages); + +#endif /* SymbolicationHelper_h */ diff --git a/zlog.tproj/entitlements.plist b/zlog.tproj/entitlements.plist new file mode 100644 index 0000000..600122d --- /dev/null +++ b/zlog.tproj/entitlements.plist @@ -0,0 +1,8 @@ + + + + + com.apple.private.kernel.get-kext-info + + + diff --git a/zlog.tproj/zlog.1 b/zlog.tproj/zlog.1 new file mode 100644 index 0000000..141caa9 --- /dev/null +++ b/zlog.tproj/zlog.1 @@ -0,0 +1,56 @@ +.\" Copyright (c) 2018, Apple Inc. All rights reserved. +.\" +.Dd February 21, 2018 +.Dt ZLOG 1 +.Os "Mac OS X" +.Sh NAME +.Nm zlog +.Nd show allocation backtraces for kernel zones +.Sh SYNOPSIS +.Nm +.Op Fl t +.Op Fl z Ar name Op Fl n Ar num | Fl l +.Op Fl h +.Sh DESCRIPTION +.Nm +displays allocation (and free, if used in corruption tracking mode with +the boot-arg "-zc") backtraces for zones that have zone logging enabled. +Zone logging can be turned on by using the boot-arg "zlog=", +where 'N' can range from 1 to 10, and 'name' is the name of the zone to +be tracked. +.Pp +.Nm +interprets the following options: +.Pp +.Bl -tag -width "disable -" +.\" -t +.It Fl t +(Default) list all the zones that have logging enabled +.\" -z +.It Fl z Ar name +show all allocation backtraces for zone +.Ar name +.\" -n +.It Fl n Ar num +Can be used in combination with the +.Fl z +option to show the top +.Ar num +backtraces with the most active references in the zone +.Ar name +.\" -l +.It Fl l +Can be used in combination with the +.Fl z +option to show the backtrace most likely contributing to a leak in the zone +.Ar name +(prints the backtrace with the most active references) +.\" -h +.It Fl h +show the help text +.El +.Sh DIAGNOSTICS +.Ex -std +.Sh SEE ALSO +.Xr zprint 1 , +.Xr ioclasscount 1 diff --git a/zlog.tproj/zlog.c b/zlog.tproj/zlog.c new file mode 100644 index 0000000..c08b8bc --- /dev/null +++ b/zlog.tproj/zlog.c @@ -0,0 +1,241 @@ +// +// zlog.c +// zlog +// +// Created by Rasha Eqbal on 1/4/18. +// + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "SymbolicationHelper.h" + +extern kern_return_t +mach_zone_get_btlog_records(host_priv_t host, + mach_zone_name_t name, + zone_btrecord_array_t *recsp, + mach_msg_type_number_t *recsCntp); +extern kern_return_t +mach_zone_get_zlog_zones(host_priv_t host, + mach_zone_name_array_t *namesp, + mach_msg_type_number_t *namesCntp); + +static int compare_zone_btrecords(const void *left, const void *right); +static void usage(FILE *stream, char **argv); +static void print_zone_info(const char *name); +static void get_zone_btrecords(const char *name, int topN); +static void list_zones_with_zlog_enabled(void); + +static void usage(FILE *stream, char **argv) +{ + fprintf (stream, "usage: %s [-t] [-z name [-n num | -l]] [-h]\n", argv[0]); + fprintf (stream, " -t : list all the zones that have logging enabled\n"); + fprintf (stream, " -z : show all allocation backtraces for zone \n"); + fprintf (stream, " -n : show top backtraces with the most active references in zone \n"); + fprintf (stream, " -l : show the backtrace most likely contributing to a leak in zone \n"); + fprintf (stream, " (prints the backtrace with the most active references)\n"); + fprintf (stream, " -h : print this help text\n"); + exit(stream != stdout); +} + +static int compare_zone_btrecords(const void *left, const void *right) +{ + zone_btrecord_t *btl = (zone_btrecord_t *)left; + zone_btrecord_t *btr = (zone_btrecord_t *)right; + + return (btr->ref_count - btl->ref_count); +} + +static void print_zone_info(const char *name) +{ + mach_zone_name_t zname; + mach_zone_info_t zone_info; + kern_return_t kr; + + strcpy(zname.mzn_name, name); + kr = mach_zone_info_for_zone(mach_host_self(), zname, &zone_info); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "error: call to mach_zone_info_for_zone() failed: %s\n", mach_error_string(kr)); + exit(1); + } + printf("zone name : %s\n", name); + printf("element size (bytes) : %lld\n", zone_info.mzi_elem_size); + printf("in-use size (bytes) : %lld\n", zone_info.mzi_count * zone_info.mzi_elem_size); + printf("total size (bytes) : %lld\n", zone_info.mzi_cur_size); + printf("\n"); +} + +static void get_zone_btrecords(const char *name, int topN) +{ + kern_return_t kr; + int i, j, index; + mach_zone_name_t zname; + unsigned int recs_count = 0; + zone_btrecord_t *recs, *recs_addr = NULL; + CSSymbolicatorRef kernelSym; + CFMutableDictionaryRef binaryImages; + + /* Create kernel symbolicator */ + kernelSym = CSSymbolicatorCreateWithMachKernel(); + if (CSIsNull(kernelSym)) { + fprintf(stderr, "error: CSSymbolicatorCreateWithMachKernel() returned NULL\n"); + exit(1); + } + /* Create dictionary to collect binary image info for offline symbolication */ + binaryImages = CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); + + /* Query the kernel for backtrace records */ + strcpy(zname.mzn_name, name); + kr = mach_zone_get_btlog_records(mach_host_self(), zname, &recs_addr, &recs_count); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "error: call to mach_zone_get_btlog_records() failed: %s\n", mach_error_string(kr)); + exit(1); + } + + if (recs_count == 0) { + goto finish; + } + + recs = recs_addr; + if (topN == 1) { + /* Print the backtrace with the highest no. of refs */ + index = 0; + for (i = 0; i < recs_count; i++) { + if (recs[i].ref_count > recs[index].ref_count) { + index = i; + } + } + recs = recs_addr + index; + } else if (topN == 0) { + /* Print all backtraces */ + topN = recs_count; + } else { + /* Sort the records by no. of refs, and print the top */ + qsort(recs, recs_count, sizeof *recs, compare_zone_btrecords); + } + + printf("printing top %d (out of %d) allocation backtrace(s) for zone %s\n", topN, recs_count, zname.mzn_name); + + for (i = 0; i < topN; i++) { + printf("\nactive refs: %d operation type: %s\n", recs[i].ref_count, + (recs[i].operation_type == ZOP_ALLOC)? "ALLOC": (recs[i].operation_type == ZOP_FREE)? "FREE": "UNKNOWN"); + + for (j = 0; j < MAX_ZTRACE_DEPTH; j++) { + mach_vm_address_t addr = (mach_vm_address_t)recs[i].bt[j]; + if (!addr) { + break; + } + PrintSymbolicatedAddress(kernelSym, addr, binaryImages); + } + } + + /* Print relevant info for offline symbolication */ + PrintBinaryImagesInfo(binaryImages); + CFRelease(binaryImages); + +finish: + if ((recs_addr != NULL) && (recs_count != 0)) { + kr = vm_deallocate(mach_task_self(), (vm_address_t) recs_addr, (vm_size_t) (recs_count * sizeof *recs)); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "call to vm_deallocate() failed: %s\n", mach_error_string(kr)); + exit(1); + } + } + CSRelease(kernelSym); +} + +static void list_zones_with_zlog_enabled(void) +{ + kern_return_t kr; + mach_zone_name_t *name = NULL; + unsigned int name_count = 0, i; + + /* Get names for zones that have zone logging enabled */ + kr = mach_zone_get_zlog_zones(mach_host_self(), &name, &name_count); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "error: call to mach_zone_get_zlog_zones() failed: %s\n", mach_error_string(kr)); + exit(1); + } + + if (name_count == 0) { + printf("zlog not enabled for any zones.\n"); + } else { + printf("zlog enabled for zones...\n"); + } + + for (i = 0; i < name_count; i++) { + print_zone_info(name[i].mzn_name); + } + + if ((name != NULL) && (name_count != 0)) { + kr = vm_deallocate(mach_task_self(), (vm_address_t) name, (vm_size_t) (name_count * sizeof *name)); + if (kr != KERN_SUCCESS) { + fprintf(stderr, "call to vm_deallocate() failed: %s\n", mach_error_string(kr)); + exit(1); + } + } +} + +#define VERSION_STRING "zlog output version: 1" + +int main(int argc, char *argv[]) +{ + int c, topN = 0; + const char *zone_name = NULL; + + /* Identifier string for SpeedTracer parsing */ + printf("%s\n\n", VERSION_STRING); + + if (argc == 1) { + /* default when no arguments are specified */ + list_zones_with_zlog_enabled(); + printf("Run 'zlog -h' for usage info.\n"); + return 0; + } + + while ((c = getopt(argc, argv, "tz:n:lh")) != -1) { + switch(c) { + case 't': + list_zones_with_zlog_enabled(); + break; + case 'z': + zone_name = optarg; + break; + case 'n': + topN = atoi(optarg); + break; + case 'l': + topN = 1; + break; + case 'h': + usage(stdout, argv); + break; + case '?': + default: + usage(stderr, argv); + break; + } + } + + if (optind < argc) { + usage(stderr, argv); + } + + if (zone_name) { + print_zone_info(zone_name); + get_zone_btrecords(zone_name, topN); + } else { + /* -n or -l was specified without -z */ + if (topN != 0) { + usage(stderr, argv); + } + } + + return 0; +} diff --git a/zprint.tproj/zprint.c b/zprint.tproj/zprint.c index 8d095d2..a968dc3 100644 --- a/zprint.tproj/zprint.c +++ b/zprint.tproj/zprint.c @@ -294,7 +294,7 @@ main(int argc, char **argv) &name, &nameCnt, &info, &infoCnt, &wiredInfo, &wiredInfoCnt); if (kr != KERN_SUCCESS) { - fprintf(stderr, "%s: mach_zone_info: %s\n", + fprintf(stderr, "%s: mach_memory_info: %s (try running as root)\n", program, mach_error_string(kr)); exit(1); } diff --git a/zprint.tproj/zprint.lua b/zprint.tproj/zprint.lua new file mode 100644 index 0000000..3c7d5fc --- /dev/null +++ b/zprint.tproj/zprint.lua @@ -0,0 +1,127 @@ +require 'strict' + +-- # zprint +-- +-- Parse the output of zprint into tables. + +local zprint = {} + +-- Return the lines inside "dashed" lines -- that is, lines that are entirely +-- made up of dashes (-) in the string `str`. The `skip_dashed` argument +-- controls how many dashed lines to skip before returning the lines between it +-- and the next dashed line. +local function lines_inside_dashes(str, skip_dashed) + local start_pos = 1 + for _ = 1, skip_dashed do + _, start_pos = str:find('\n[-]+\n', start_pos) + end + assert(start_pos, 'found dashed line in output') + local end_pos, _ = str:find('\n[-]+\n', start_pos + 1) + assert(end_pos, 'found ending dashed line in output') + + return str:sub(start_pos + 1, end_pos - 1) +end + +-- Iterate through the zones listed in the given zprint(1) output `zpout`. +-- +-- for zone in zprint_zones(io.stdin:read('*a')) do +-- print(zone.name, zone.size, zone.used_size) +-- end +function zprint.zones(zpout) + -- Get to the first section delimited by dashes. This is where the zones are + -- recorded. + local zones = lines_inside_dashes(zpout, 1) + + -- Create an iterator for each line, for use in our own iteration function. + local lines = zones:gmatch('([^\n]+)\n') + + return function () + -- Grab the next line. + local line = lines() + if not line then + return nil + end + + -- Match each column from zprint's output. + local name, eltsz, cursz_kb, maxsz_kb, nelts, nelts_max, nused, + allocsz_kb = line:match( + '([%S]+)%s+(%d+)%s+(%d+)K%s+(%d+)K%s+(%d+)%s+(%d+)%s+(%d+)%s+(%d+)') + -- Convert numeric fields to numbers, and into bytes if specified in KiB. + eltsz = tonumber(eltsz) + local cursz = tonumber(cursz_kb) * 1024 + local maxsz = tonumber(maxsz_kb) * 1024 + local usedsz = tonumber(nused) * eltsz + local allocsz = tonumber(allocsz_kb) * 1024 + + -- Return a table representing the zone. + return { + name = name, -- the name of the zone + size = cursz, -- the size of the zone + max_size = maxsz, -- the maximum size of the zone + used_size = usedsz, -- the size of all used elements in the zone + element_size = eltsz, -- the size of each element in the zone + allocation_size = allocsz, -- the size of allocations made for the zone + } + end +end + +-- Iterate through the tags listed in the given zprint(1) output `zpout`. +function zprint.tags(zpout) + -- Get to the third zone delimited by dashes, where the tags are recorded. + local tags = lines_inside_dashes(zpout, 3) + + local lines = tags:gmatch('([^\n]+)\n') + + return function () + local line = lines() + if not line then + return nil + end + + -- Skip any unloaded kmod lines. + while line:match('(unloaded kmod)') do + line = lines() + end + -- End on the zone tags line, since it's not useful. + if line:match('zone tags') then + return nil + end + + -- The line representing a region can take 4 different forms, depending on + -- the type of region. Check for each of them. + + -- Check for 4 columns. + local name, maxsz_kb, cursz_kb = line:match( + '(%S+)%s+%d+%s+%d+%s+(%d+)K%s+(%d+)K$') + if not name then + -- Check for 3 columns. + name, maxsz_kb, cursz_kb = line:match('(%S+)%s+%d+%s+(%d+)K%s+(%d+)K$') + if not name then + -- Check for a two columns. + name, cursz_kb = line:match('(%S+)%s+%d+%s+(%d+)K') + if not name then + -- Check for a single column. + name, cursz_kb = line:match('(%S+)%s+(%d+)K') + end + end + end + -- Convert numeric fields to numbers and then into bytes. + local cursz = tonumber(cursz_kb) * 1024 + local maxsz = maxsz_kb and (tonumber(maxsz_kb) * 1024) + + -- Return a table representing the region. + return { + name = name, + size = cursz, + max_size = maxsz, + } + end +end + +function zprint.total(zpout) + local total = zpout:match('total[^%d]+(%d+.%d+)M of') + local bytes = tonumber(total) * 1024 * 1024 + return bytes +end + +return zprint