--- /dev/null
+#freebsd = https://github.com/freebsd/freebsd.git
+iostat.tproj/iostat.8 freebsd usr.sbin/iostat/iostat.8 4724d1448f7e7698308a1e05a7bb9b2069d68234
.Pp
The other use of the
.Nm arch
-command it to run a selected architecture of a universal binary.
+command is to run a selected architecture of a universal binary.
A universal binary contains code that can run on different architectures.
By default, the operating system will select the architecture that most closely
matches the processor type.
--- /dev/null
+CODE_SIGN_IDENTITY = -;
+CURRENT_PROJECT_VERSION = $(RC_ProjectSourceVersion);
+DEAD_CODE_STRIPPING = YES;
+DEBUG_INFORMATION_FORMAT = dwarf-with-dsym;
+PREBINDING = NO;
+// Current macOS
+SDKROOT = macosx.internal;
+VERSION_INFO_PREFIX = __attribute__((visibility("hidden"))) __
+VERSIONING_SYSTEM = apple-generic;
#include <stdio.h>
#include <string.h>
-#include <pw_util.h>
+#include "pw_util.h"
#include "pw_copy.h"
extern char *tempname;
--- /dev/null
+.\" Darwin cpuctl man page adapted from NetBSD (credits below):
+.\"
+.\" $NetBSD: cpuctl.8,v 1.18 2018/01/14 00:45:54 mrg Exp $
+.\"
+.\" Copyright (c) 2007, 2008, 2012, 2015 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Andrew Doran.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd March 18, 2019
+.Dt CPUCTL 8
+.Os Darwin
+.Sh NAME
+.Nm cpuctl
+.Nd program to control CPUs
+.Sh SYNOPSIS
+.Nm cpuctl
+.Ar command
+.Op Ar arguments
+.Sh DESCRIPTION
+The
+.Nm
+command can be used to control and inspect the state of CPUs in the system.
+.Pp
+The first argument,
+.Ar command ,
+specifies the action to take.
+Valid commands are:
+.Bl -tag -width offline
+.It list
+For each CPU in the system, display the current state and time of the last
+state change.
+.It offline Ar cpu Op Ar cpu ...
+Set the specified CPUs off line.
+.Pp
+At least one CPU in the system must remain on line.
+.It online Ar cpu Op Ar cpu ...
+Set the specified CPUs on line.
+.El
+.Sh EXAMPLES
+Run
+.Dl cpuctl offline 2
+and then
+.Dl cpuctl list
+The output should reflect the fact that CPU#2 was taken offline.
--- /dev/null
+//
+// cpuctl.c
+// system_cmds
+//
+// Copyright (c) 2019 Apple Inc. All rights reserved.
+//
+
+#include <err.h>
+#include <getopt.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include <mach/mach.h>
+
+static void usage()
+{
+ printf("usage: cpuctl [ list ]\n");
+ printf(" cpuctl { offline | online } <cpu> [ <cpu>... ]\n");
+ exit(EX_USAGE);
+}
+
+static void fetch_cpu_info(host_t *priv_port,
+ processor_port_array_t proc_ports,
+ mach_msg_type_number_t proc_count,
+ processor_basic_info_data_t *cpus)
+{
+ for (int i = 0; i < proc_count; i++) {
+ mach_msg_type_number_t info_count = PROCESSOR_BASIC_INFO_COUNT;
+
+ if (processor_info(proc_ports[i], PROCESSOR_BASIC_INFO, priv_port,
+ (processor_info_t)&cpus[i], &info_count) != KERN_SUCCESS) {
+ errx(EX_OSERR, "processor_info(%d) failed", i);
+ }
+ }
+}
+
+static int do_cmd_list(mach_msg_type_number_t proc_count, processor_basic_info_data_t *cpus)
+{
+ int prev_lowest = -1;
+ for (int i = 0; i < proc_count; i++) {
+ int lowest_slot = INT_MAX;
+ int lowest_idx = -1;
+ for (int j = 0; j < proc_count; j++) {
+ int slot = cpus[j].slot_num;
+ if (slot > prev_lowest && slot < lowest_slot) {
+ lowest_slot = slot;
+ lowest_idx = j;
+ }
+ }
+ if (lowest_idx == -1)
+ errx(EX_OSERR, "slot numbers are out of range");
+
+ processor_basic_info_data_t *cpu = &cpus[lowest_idx];
+ printf("CPU%d: %-7s type=%x,%x master=%d\n",
+ cpu->slot_num,
+ cpu->running ? "online" : "offline",
+ cpu->cpu_type,
+ cpu->cpu_subtype,
+ cpu->is_master);
+
+ prev_lowest = lowest_slot;
+ }
+ return 0;
+}
+
+static int find_cpu_by_slot(mach_msg_type_number_t proc_count,
+ processor_basic_info_data_t *cpus,
+ int slot)
+{
+ for (int i = 0; i < proc_count; i++) {
+ if (cpus[i].slot_num == slot)
+ return i;
+ }
+ return -1;
+}
+
+int main(int argc, char **argv)
+{
+ int opt;
+
+ while ((opt = getopt(argc, argv, "h")) != -1) {
+ switch (opt) {
+ case 'h':
+ usage();
+ }
+ }
+
+ host_t priv_port;
+ if (host_get_host_priv_port(mach_host_self(), &priv_port) != KERN_SUCCESS)
+ errx(EX_OSERR, "host_get_host_priv_port() failed");
+
+ processor_port_array_t proc_ports;
+ mach_msg_type_number_t proc_count;
+ if (host_processors(priv_port, &proc_ports, &proc_count) != KERN_SUCCESS)
+ errx(EX_OSERR, "host_processors() failed");
+
+ processor_basic_info_data_t *cpus = calloc(proc_count, sizeof(*cpus));
+ if (!cpus)
+ errx(EX_OSERR, "calloc() failed");
+ fetch_cpu_info(&priv_port, proc_ports, proc_count, cpus);
+
+ if (optind == argc)
+ return do_cmd_list(proc_count, cpus);
+
+ const char *cmd = argv[optind];
+ optind++;
+
+ if (!strcmp(cmd, "list"))
+ return do_cmd_list(proc_count, cpus);
+
+ bool up = true;
+ if (!strncmp(cmd, "off", 3))
+ up = false;
+ else if (strncmp(cmd, "on", 2))
+ usage();
+
+ if (optind == argc)
+ usage();
+
+ int ret = 0;
+ for (; optind < argc; optind++) {
+ char *endp = NULL;
+ int slot = (int)strtoul(argv[optind], &endp, 0);
+ if (*endp != 0)
+ usage();
+
+ int cpu = find_cpu_by_slot(proc_count, cpus, slot);
+ if (cpu == -1)
+ errx(EX_USAGE, "Invalid CPU ID %d", slot);
+
+ if (up) {
+ if (processor_start(proc_ports[cpu]) != KERN_SUCCESS)
+ errx(EX_OSERR, "processor_start(%u) failed", cpu);
+ } else {
+ if (processor_exit(proc_ports[cpu]) != KERN_SUCCESS)
+ errx(EX_OSERR, "processor_exit(%u) failed", cpu);
+ }
+ }
+
+ return ret;
+}
/*
- * Copyright (c) 1999-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2019 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <ktrace/session.h>
#include <System/sys/kdebug.h>
-#include <assert.h>
+#include <os/assumes.h>
#include <sys/disk.h>
#include <sys/fcntl.h>
#define BSC_msync_extended 0x040e0104
#define BSC_pread_extended 0x040e0264
#define BSC_pwrite_extended 0x040e0268
+#define BSC_guarded_pwrite_extended 0x040e0798
#define BSC_mmap_extended 0x040e0314
#define BSC_mmap_extended2 0x040f0314
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_pwrite_np, FMT_PREAD),
SYSCALL(guarded_writev_np, FMT_FD_IO),
SYSCALL(fgetxattr, FMT_FD),
SYSCALL(fsetxattr, FMT_FD),
mach_to_nano(uint64_t mach)
{
uint64_t nanoseconds = 0;
- assert(ktrace_convert_timestamp_to_nanoseconds(s, mach, &nanoseconds) == 0);
+ os_assert(ktrace_convert_timestamp_to_nanoseconds(s, mach, &nanoseconds) == 0);
return nanoseconds;
}
exit(1);
}
+static void fs_usage_cleanup(const char *message)
+{
+ if (s){
+ ktrace_session_destroy(s);
+ }
+
+ fprintf(stderr, "Cleaning up tracing state because of %s\n", message);
+}
+
int
main(int argc, char *argv[])
{
bool exclude_pids = false;
uint64_t time_limit_ns = 0;
+ os_set_crash_callback(&fs_usage_cleanup);
+
get_screenwidth();
s = ktrace_session_create();
- assert(s != NULL);
+ os_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);
ktrace_exclude_process(s, "csh");
ktrace_exclude_process(s, "sh");
ktrace_exclude_process(s, "zsh");
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
ktrace_exclude_process(s, "dropbear");
-#endif /* TARGET_OS_EMBEDDED */
+#endif /* (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR) */
}
}
fprintf(stderr, "ERROR: cannot both include and exclude simultaneously\n");
exit(1);
} else {
- assert(!rv);
+ os_assert(!rv);
}
argc--;
});
}
+static void
+extend_syscall_rw(th_info_t ti, ktrace_event_t event)
+{
+ ti->arg1 = event->arg1; /* the fd */
+ ti->arg2 = event->arg2; /* nbytes */
+ ti->arg3 = event->arg3; /* top half offset */
+ ti->arg4 = event->arg4; /* bottom half offset */
+}
+
/*
* Handle system call extended trace data.
* pread and pwrite:
switch (type) {
case BSC_mmap_extended:
- if ((ti = event_find(thread, BSC_mmap)) == NULL)
+ if ((ti = event_find(thread, BSC_mmap)) == NULL) {
return;
+ }
ti->arg8 = ti->arg3; /* save protection */
ti->arg1 = event->arg1; /* the fd */
case BSC_msync_extended:
if ((ti = event_find(thread, BSC_msync)) == NULL) {
- if ((ti = event_find(thread, BSC_msync_nocancel)) == NULL)
+ if ((ti = event_find(thread, BSC_msync_nocancel)) == NULL) {
return;
+ }
}
ti->arg4 = event->arg1; /* top half address */
case BSC_pread_extended:
if ((ti = event_find(thread, BSC_pread)) == NULL) {
- if ((ti = event_find(thread, BSC_pread_nocancel)) == NULL)
+ if ((ti = event_find(thread, BSC_pread_nocancel)) == NULL) {
return;
+ }
}
- ti->arg1 = event->arg1; /* the fd */
- ti->arg2 = event->arg2; /* nbytes */
- ti->arg3 = event->arg3; /* top half offset */
- ti->arg4 = event->arg4; /* bottom half offset */
+ extend_syscall_rw(ti, event);
break;
case BSC_pwrite_extended:
if ((ti = event_find(thread, BSC_pwrite)) == NULL) {
- if ((ti = event_find(thread, BSC_pwrite_nocancel)) == NULL)
+ if ((ti = event_find(thread, BSC_pwrite_nocancel)) == NULL) {
return;
+ }
}
- ti->arg1 = event->arg1; /* the fd */
- ti->arg2 = event->arg2; /* nbytes */
- ti->arg3 = event->arg3; /* top half offset */
- ti->arg4 = event->arg4; /* bottom half offset */
+ extend_syscall_rw(ti, event);
+ break;
+
+ case BSC_guarded_pwrite_extended:
+ if ((ti = event_find(thread, BSC_guarded_pwrite_np)) == NULL) {
+ return;
+ }
+
+ extend_syscall_rw(ti, event);
break;
}
}
int
print_open(ktrace_event_t event, uint64_t flags)
{
- char mode[] = "______";
+ char mode[] = {
+ '_',
+ '_',
+ (flags & O_CREAT) ? 'C' : '_',
+ (flags & O_APPEND) ? 'A' : '_',
+ (flags & O_TRUNC) ? 'T' : '_',
+ (flags & O_EXCL) ? 'E' : '_',
+ (flags & O_NONBLOCK) ? 'N' : '_',
+ (flags & O_SHLOCK) ? 'l' : (flags & O_EXLOCK) ? 'L' : '_',
+ (flags & O_NOFOLLOW) ? 'F' : '_',
+ (flags & O_SYMLINK) ? 'S' : '_',
+ (flags & O_EVTONLY) ? 'V' : '_',
+ (flags & O_CLOEXEC) ? 'X' : '_',
+ '\0',
+ };
if (flags & O_RDWR) {
mode[0] = 'R';
mode[0] = 'R';
}
- if (flags & O_CREAT) {
- mode[2] = 'C';
- }
- if (flags & O_APPEND) {
- mode[3] = 'A';
- }
- if (flags & O_TRUNC) {
- mode[4] = 'T';
- }
- if (flags & O_EXCL) {
- mode[5] = 'E';
- }
-
if (event->arg1) {
return printf(" [%3d] (%s) ", (int)event->arg1, mode);
} else {
mach_time_of_first_event = now;
if (format == FMT_DISKIO || format == FMT_DISKIO_CS) {
- assert(dio);
+ os_assert(dio);
} else {
- assert(event);
+ os_assert(event);
if (format != FMT_UNMAP_INFO)
- assert(ti);
+ os_assert(ti);
}
/* <rdar://problem/19852325> Filter out WindowServer/xcpm ioctls in fs_usage */
if (!command_name)
command_name = "";
- assert(now_walltime.tv_sec || now_walltime.tv_usec);
+ os_assert(now_walltime.tv_sec || now_walltime.tv_usec);
/* try and reuse the timestamp string */
if (last_walltime_secs != now_walltime.tv_sec) {
p = "SETLKW";
break;
+ case F_SETLKWTIMEOUT:
+ p = "SETLKWTIMEOUT";
+ break;
+
+ case F_GETLKPID:
+ p = "GETLKPID";
+ break;
+
+ case F_OFD_GETLK:
+ p = "OFD_GETLK";
+ break;
+
+ case F_OFD_SETLK:
+ p = "OFD_SETLK";
+ break;
+
+ case F_OFD_SETLKW:
+ p = "OFD_SETLKW";
+ break;
+
+ case F_OFD_SETLKWTIMEOUT:
+ p = "OFD_SETLKWTIMEOUT";
+ break;
+
+ case F_OFD_GETLKPID:
+ p = "OFD_GETLKPID";
+ break;
+
case F_PREALLOCATE:
p = "PREALLOCATE";
break;
found = true;
}
- assert(found);
+ os_assert(found);
#endif /* DEBUG */
if ((ti = add_event(event, type)) == NULL)
struct pid_fd_set *pfs;
int hashid;
- assert(pid >= 0);
+ os_assert(pid >= 0);
hashid = pid & HASH_MASK;
newsize = MAX(((size_t)fd + CHAR_BIT) / CHAR_BIT, 2 * pfs->setsize);
pfs->set = reallocf(pfs->set, newsize);
- assert(pfs->set != NULL);
+ os_assert(pfs->set != NULL);
bzero(pfs->set + pfs->setsize, newsize - pfs->setsize);
pfs->setsize = newsize;
#include <err.h>
#include <sysexits.h>
#include <time.h>
+#include <glob.h>
+#include <spawn.h>
+#include <signal.h>
+#include <xpc/xpc.h>
+#include <xpc/private.h>
+#include <sys/event.h>
+#include <sys/time.h>
#if defined(CONFIG_GCORE_MAP) || defined(CONFIG_GCORE_CONV) || defined(CONFIG_GCORE_FREF)
return 0;
}
+/*
+ * expanduser tries to expand the leading '~' (if there is any) in the given
+ * path and returns a copy of the expanded path; it returns NULL on failures.
+ * The caller is responsible for freeing the returned string.
+ */
+static char *
+expanduser(const char *path)
+{
+ if (path == NULL) {
+ return NULL;
+ }
+ if (path[0] != '~') {
+ /*
+ * For consistency, still dup the string so that the caller always
+ * needs to free the string.
+ */
+ return strdup(path);
+ }
+
+ char *expanded = NULL;
+ glob_t globbuf = {};
+ if (OPTIONS_DEBUG(opt, 1)) {
+ printf("Expanding %s\n", path);
+ }
+ int rc = glob(path, GLOB_TILDE, NULL, &globbuf);
+ if (rc == 0) {
+ if (OPTIONS_DEBUG(opt, 3)) {
+ printf("expanduser - gl_pathc: %zu\n", globbuf.gl_pathc);
+ for (size_t i = 0; i < globbuf.gl_pathc; i++) {
+ printf("expanduser - gl_pathv[%zu]: %s\n", i, globbuf.gl_pathv[i]);
+ }
+ }
+ if (globbuf.gl_pathc == 1) {
+ expanded = strdup(globbuf.gl_pathv[0]);
+ if (OPTIONS_DEBUG(opt, 1)) {
+ printf("Expanded path: %s\n", expanded);
+ }
+ }
+ globfree(&globbuf);
+ }
+
+ return expanded;
+}
+
+#define RESPONSE_BUFF_SIZE (2048)
+
+/*
+ * read_response dynamically allocates buffer for reading bytes from the given
+ * fd. Upon success, this function sets response to point to the buffer and
+ * returns bytes being read; otherwise, it returns -1. The caller is
+ * responsible for freeing the response buffer.
+ */
+static ssize_t
+read_response(int fd, char **response)
+{
+ if (response == NULL || *response) {
+ warnx("Invalid response buffer pointer");
+ return -1;
+ }
+
+ ssize_t bytes_read = 0;
+ size_t buff_size = RESPONSE_BUFF_SIZE;
+
+ if (OPTIONS_DEBUG(opt, 3)) {
+ printf("Allocating response buffer (%zu)\n", buff_size);
+ }
+ char *buff = malloc(buff_size);
+ if (buff == NULL) {
+ warn("Failed to allocate response buffer (%zu)", buff_size);
+ return -1;
+ }
+
+ size_t total = 0;
+ bool failed = false;
+
+ do {
+ bytes_read = read(fd, buff + total, buff_size - total);
+ if (bytes_read == -1) {
+ if (errno == EINTR) {
+ continue;
+ }
+ failed = true;
+ break;
+ }
+
+ total += (size_t)bytes_read;
+ if (total == buff_size) {
+ size_t new_buff_size = buff_size * 2;
+ if (OPTIONS_DEBUG(opt, 3)) {
+ printf("Reallocating response buffer (%zu)\n", new_buff_size);
+ }
+ char *new_buff = realloc(buff, new_buff_size);
+ if (new_buff == NULL) {
+ warn("Failed to reallocate response buffer (%zu)", new_buff_size);
+ failed = true;
+ break;
+ }
+ buff_size = new_buff_size;
+ buff = new_buff;
+ }
+ } while (bytes_read != 0);
+
+ if (failed) {
+ if (buff != NULL) {
+ free(buff);
+ }
+ return -1;
+ }
+
+ assert(total < buff_size);
+ buff[total] = '\0';
+ *response = buff;
+
+ return (ssize_t)total;
+}
+
+#define WAITPID_WTO_SIGALRM (100) /* alternative for SIGALRM for kevent timeout */
+#define WAITPID_WTO_SIGERR (101) /* sig for error when waiting for pid */
+
+/*
+ * waitpid_with_timeout returns true if the process exits successfully within
+ * timeout; otherwise, it returns false along with setting exitstatus and
+ * signal_no if the pointers are given.
+ */
+static bool
+waitpid_with_timeout(pid_t pid, int *exitstatus, int *signal_no, int timeout)
+{
+ int status;
+ int kq = -1;
+
+ if (timeout > 0) {
+ kq = kqueue();
+ struct kevent64_s event = {
+ .ident = (uint64_t)pid,
+ .filter = EVFILT_PROC,
+ .flags = EV_ADD | EV_ONESHOT,
+ .fflags = NOTE_EXIT
+ };
+ struct timespec tmout = {
+ .tv_sec = timeout
+ };
+ int ret = kevent64(kq, &event, 1, &event, 1, 0, &tmout);
+ int kevent64_errno = errno;
+
+ close(kq);
+ if (ret == 0) { /* timeout */
+ if (exitstatus) {
+ *exitstatus = 0;
+ }
+ if (signal_no) {
+ *signal_no = WAITPID_WTO_SIGALRM;
+ }
+ return false;
+ }
+
+ if (ret == -1) {
+ warnx("kevent64(): errno=%d (%s)\n", kevent64_errno, strerror(kevent64_errno));
+ goto waitpid_error;
+ }
+
+ if (event.flags == EV_ERROR && event.data != ESRCH) {
+ warnx("event.data (%lld) is not ESRCH when event.flags is EV_ERROR\n", event.data);
+ goto waitpid_error;
+ }
+
+ if (event.ident != (uint64_t)pid) {
+ warnx("event.ident is %lld (should be pid %d)\n", event.ident, pid);
+ goto waitpid_error;
+ }
+
+ if (event.filter != EVFILT_PROC) {
+ warnx("event.filter (%d) is not EVFILT_PROC\n", event.filter);
+ goto waitpid_error;
+ }
+ }
+
+ while (waitpid(pid, &status, 0) < 0) {
+ if (errno == EINTR) {
+ continue;
+ }
+ warnx("waitpid(): errno=%d (%s)\n", errno, strerror(errno));
+ goto waitpid_error;
+ }
+ if (WIFEXITED(status)) {
+ if (exitstatus) {
+ *exitstatus = WEXITSTATUS(status);
+ }
+ if (signal_no) {
+ *signal_no = 0;
+ }
+ return WEXITSTATUS(status) == 0;
+ }
+ if (WIFSIGNALED(status)) {
+ if (exitstatus) {
+ *exitstatus = 0;
+ }
+ if (signal_no) {
+ *signal_no = WTERMSIG(status);
+ }
+ return false;
+ }
+
+waitpid_error:
+ if (exitstatus) *exitstatus = 0;
+ if (signal_no) *signal_no = WAITPID_WTO_SIGERR;
+ return false;
+}
+
+#define DSYMFORUUID_PATH "/usr/local/bin/dsymForUUID"
+
+/*
+ * exec_dsymForUUID spawns dsymForUUID to query dsym UUID info and responds the
+ * result plist. Upon success, this function sets response point to the buffer
+ * and returns bytes being read; otherwise, it returns -1. The caller is
+ * responsible for freeing the response buffer.
+ */
+static ssize_t
+exec_dsymForUUID(uuid_string_t id, char **response)
+{
+ int pipe_fds[2] = {-1, -1};
+ bool file_actions_inited = false;
+ ssize_t bytes_read = -1;
+ int rc;
+
+ rc = pipe(pipe_fds);
+ if (rc == -1) {
+ goto cleanup;
+ }
+
+ posix_spawn_file_actions_t file_actions;
+ rc = posix_spawn_file_actions_init(&file_actions);
+ if (rc) {
+ goto cleanup;
+ }
+ file_actions_inited = true;
+
+ rc = posix_spawn_file_actions_addclose(&file_actions, pipe_fds[0]);
+ if (rc) {
+ goto cleanup;
+ }
+
+ rc = posix_spawn_file_actions_adddup2(&file_actions, pipe_fds[1], STDOUT_FILENO);
+ if (rc) {
+ goto cleanup;
+ }
+
+ rc = posix_spawn_file_actions_addclose(&file_actions, pipe_fds[1]);
+ if (rc) {
+ goto cleanup;
+ }
+
+ char *command[] = {DSYMFORUUID_PATH, id, NULL};
+ pid_t child;
+ rc = posix_spawn(&child, command[0], &file_actions, NULL, command, NULL);
+ if (rc) {
+ goto cleanup;
+ }
+
+ close(pipe_fds[1]);
+ pipe_fds[1] = -1;
+
+ bytes_read = read_response(pipe_fds[0], response);
+
+ waitpid_with_timeout(child, NULL, NULL, 3);
+
+cleanup:
+ if (pipe_fds[1] != -1) {
+ close(pipe_fds[1]);
+ }
+ if (pipe_fds[0] != -1) {
+ close(pipe_fds[0]);
+ }
+ if (file_actions_inited) {
+ posix_spawn_file_actions_destroy(&file_actions);
+ }
+
+ return bytes_read;
+}
+
+/*
+ * get_symbol_rich_executable_path_via_dsymForUUID spawns dsymForUUID to query
+ * dsym uuid info for the given uuid and returns the string of
+ * DBGSymbolRichExecutable; otherwise, it returns NULL on failures. The caller
+ * is responsible for freeing the returned string.
+ */
+static char *
+get_symbol_rich_executable_path_via_dsymForUUID(const uuid_t uuid)
+{
+ char *response;
+ ssize_t size;
+ uuid_string_t uuid_str;
+ xpc_object_t plist = NULL;
+ xpc_object_t uuid_info = NULL;
+ xpc_object_t exec_path = NULL;
+ char *expanded_exec_path = NULL;
+
+ uuid_unparse_upper(uuid, uuid_str);
+
+ size = exec_dsymForUUID(uuid_str, &response);
+ if (size <= 0) {
+ goto cleanup;
+ }
+
+ if (OPTIONS_DEBUG(opt, 3)) {
+ printf("dsymForUUID response:\n%s\n", response);
+ }
+
+ plist = xpc_create_from_plist(response, (size_t)size);
+ if (plist == NULL) {
+ goto cleanup;
+ }
+ if (xpc_get_type(plist) != XPC_TYPE_DICTIONARY) {
+ goto cleanup;
+ }
+
+ uuid_info = xpc_dictionary_get_value(plist, uuid_str);
+ if (uuid_info == NULL) {
+ goto cleanup;
+ }
+ if (xpc_get_type(uuid_info) != XPC_TYPE_DICTIONARY) {
+ goto cleanup;
+ }
+
+ exec_path = xpc_dictionary_get_value(uuid_info, "DBGSymbolRichExecutable");
+ if (exec_path == NULL) {
+ goto cleanup;
+ }
+ if (xpc_get_type(exec_path) != XPC_TYPE_STRING) {
+ goto cleanup;
+ }
+
+ expanded_exec_path = expanduser(xpc_string_get_string_ptr(exec_path));
+
+cleanup:
+ if (plist) {
+ xpc_release(plist);
+ }
+ if (response) {
+ free(response);
+ }
+
+ return expanded_exec_path;
+}
+
/*
* bind the file reference into the output core file.
* filename optionally prefixed with names from a ':'-separated PATH variable
printf("\n");
}
+ int ecode = 0;
+ if (opt->dsymforuuid && (FREF_ID_TYPE(infr->flags) == kFREF_ID_UUID)) {
+ /* Try to use dsymForUUID to get the symbol-rich executable */
+ char *symrich_filepath = get_symbol_rich_executable_path_via_dsymForUUID(infr->id);
+ if (symrich_filepath) {
+ if (opt->verbose) {
+ printf("\tTrying %s from dsymForUUID\n", symrich_filepath);
+ }
+ ecode = convert_fileref_with_file(symrich_filepath, inmh, infr, &invr, lc, oi);
+ free(symrich_filepath);
+ if (ecode == 0) {
+ return (ecode);
+ }
+ warnx("Failed to convert fileref with dsymForUUID. Fall back to local paths");
+ }
+ }
+
const size_t pathsize = path ? strlen(path) : 0;
- int ecode = EX_DATAERR;
+ ecode = EX_DATAERR;
if (0 == pathsize)
ecode = convert_fileref_with_file(nm, inmh, infr, &invr, lc, oi);
else {
.Sy conv\r
.Op Fl L Ar searchpath\r
.Op Fl z\r
+.Op Fl s\r
.Op Fl v\r
.Op Fl d\r
.Ar incore outcore\r
and decompressing any compressed data into the output core file.\r
This conversion usually makes the core file substantially larger.\r
.Pp\r
-Files to be dereferenced must be accessible on the\r
+By default, files to be dereferenced must be accessible on the\r
local filesystem by the same relative paths as they were originally recorded\r
when the dump was taken.\r
Files that are Mach-O objects containing UUIDs are required to match\r
During conversion, if any mapped file\r
identified by modification time\r
cannot be located, substitute zeroed memory.\r
+.It Fl s\r
+When processing file references,\r
+try looking for the pathname through\r
+.Xr dsymForUUID 1\r
+before searching locally.\r
.It Fl v\r
Report progress on the conversion as it proceeds.\r
.It Fl d\r
generally be easy to retrieve.\r
However on the desktop, the lifecycle of this cache is managed locally\r
e.g. with\r
-.Xr update_dyld_shared_cache 1.\r
+.Xr update_dyld_shared_cache 1 .\r
When this cache is recreated it is given a new UUID, the directory\r
entry for the old cache is removed, and the same filename\r
is used for the new cache.\r
.Pp\r
.Sh SEE ALSO \r
.Xr dyld 1 ,\r
-.Xr update_dyld_shared_cache 1\r
+.Xr update_dyld_shared_cache 1 ,\r
+.Xr dsymForUUID 1\r
.chunksize = 0,
.calgorithm = COMPRESSION_LZFSE,
.ncthresh = DEFAULT_NC_THRESHOLD,
+ .dsymforuuid = 0,
};
static int
task_t task = TASK_NULL;
const struct proc_bsdinfo *pbi = NULL;
+ const int rc = kill(pid, 0);
- if (-1 != kill(pid, 0)) {
- /* process or corpse that responds to signals */
+ if (rc == 0) {
+ /* process or corpse that may respond to signals */
pbi = get_bsdinfo(pid);
- if (NULL == pbi)
- errx(EX_OSERR, "cannot get process info for %d", pid);
+ }
+
+ if (rc == 0 && pbi != NULL) {
+ /* process or corpse that responds to signals */
/* make our data model match the data model of the target */
if (-1 == reexec_to_match_lp64ness(pbi->pbi_flags & PROC_FLAG_LP64))
change_credentials(pbi->pbi_uid, pbi->pbi_gid);
} else {
if (MACH_PORT_NULL == corpse) {
+ if (rc == 0) {
+ errx(EX_OSERR, "cannot get process info for %d", pid);
+ }
switch (errno) {
case ESRCH:
errc(EX_DATAERR, errno, "no process with pid %d", pid);
err_set_exit_b(^(int eval) {
if (EX_USAGE == eval)
fprintf(stderr,
- "usage:\t%s %s [-v] [-L searchpath] [-z] incore outcore\n", pgm, argv[1]);
+ "usage:\t%s %s [-v] [-L searchpath] [-z] [-s] incore outcore\n", pgm, argv[1]);
});
char *searchpath = NULL;
int c;
optind = 2;
- while ((c = getopt(argc, argv, "dzvL:")) != -1) {
+ while ((c = getopt(argc, argv, "dzvL:s")) != -1) {
switch (c) {
/*
* likely documented options
case 'v':
options.verbose++;
break;
-
+ case 's':
+ options.dsymforuuid++;
+ break;
/*
* dev and debugging help
*/
compression_algorithm calgorithm; // algorithm in use
size_t ncthresh; // F_NOCACHE enabled *above* this value
int allfilerefs; // if set, every mapped file on the root fs is a fileref
+ int dsymforuuid; // Try dsysForUUID to retrieve symbol-rich executable
};
extern const struct options *opt;
*/
dogettytab();
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (strncmp(ttyn, _PATH_CONSOLE, sizeof(ttyn)) == 0)
ttyopenmode |= O_POPUP;
#endif
#include <libkern/OSAtomic.h>
#include <limits.h>
#include <errno.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include "panic.h"
+#include <IOKit/IOKitLib.h>
#define IO_MODE_SEQ 0
#define IO_MODE_RANDOM 1
#define MAX_THREADS 1000
#define MAX_FILENAME 64
#define MAX_ITERATIONS 10000
-#define LATENCY_BIN_SIZE 500
-#define LATENCY_BINS 11
+#define LATENCY_BIN_SIZE 1000
+#define LATENCY_BINS 31
#define LOW_LATENCY_BIN_SIZE 50
-#define LOW_LATENCY_BINS 11
+#define LOW_LATENCY_BINS 21
#define THROUGHPUT_INTERVAL 5000
#define DEFAULT_FILE_SIZE (262144)
#define BLOCKSIZE 1024
#define MAX_CMD_SIZE 256
#define PG_MASK ~(0xFFF)
+#define kIONVMeANS2ControllerString "AppleANS2Controller"
+#define kIONVMeControllerString "AppleNVMeController"
+
+typedef enum {
+ kDefaultDevice = 0,
+ kNVMeDevice = 1,
+ kNVMeDeviceANS2 = 2,
+} qos_device_type_t;
int burst_count = 10; /* Unit: Number ; Desc.: I/O Burst Count */
int inter_burst_duration = 0; /* Unit: msecs ; Desc.: I/O Inter-Burst Duration (-1: Random value [0,100]) */
int io_tier = 0; /* Unit: 0/1/2/3; Desc.: I/O Tier */
int file_size = DEFAULT_FILE_SIZE; /* Unit: pages ; Desc.: File Size in 4096 byte blocks */
int cached_io_flag = 0; /* Unit: 0/1 ; Desc.: I/O Caching behavior (no-cached/cached) */
+int io_qos_timeout_ms = 0; /* Unit: msecs ; Desc.: I/O QOS timeout */
char *user_fname;
int user_specified_file = 0;
+qos_device_type_t qos_device = 0;
-int64_t total_io_count;
-int64_t total_io_size;
-int64_t total_io_time;
-int64_t total_burst_count;
+int64_t total_io_count = 0;
+int64_t total_io_size = 0;
+int64_t total_io_time = 0;
+int64_t max_io_time = 0;
+int64_t total_burst_count = 0;
int64_t latency_histogram[LATENCY_BINS];
int64_t burst_latency_histogram[LATENCY_BINS];
int64_t low_latency_histogram[LOW_LATENCY_BINS];
int64_t throughput_histogram[MAX_ITERATIONS];
int64_t throughput_index;
+CFRunLoopTimerRef runLoopTimer = NULL;
void print_usage(void);
-void print_data_percentage(int percent);
+void print_data_percentage(double percent);
void print_stats(void);
unsigned int find_io_bin(int64_t latency, int latency_bin_size, int latency_bins);
void signalHandler(int sig);
+void assertASP(CFRunLoopTimerRef timer, void *info );
+void start_qos_timer(void);
+void stop_qos_timer(void);
void perform_io(int fd, char *buf, int size, int type);
void *sync_routine(void *arg);
void *calculate_throughput(void *arg);
void validate_option(int value, int min, int max, char *option, char *units);
void print_test_setup(int value, char *option, char *units, char *comment);
void setup_process_io_policy(int io_tier);
-void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size);
+void setup_qos_device(void);
+void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size, double io_count);
void
print_usage(void)
printf("-z: (number) File Size in pages (1 page = 4096 bytes) \n");
printf("-n: (string) File name used for tests (the tool would create files if this option is not specified)\n");
printf("-a: (0/1 : Non-cached/Cached) I/O Caching behavior\n");
+ printf("-q: (msecs) I/O QoS timeout. Time of I/O before drive assert and system panic\n");
}
-void print_data_percentage(int percent)
+void print_data_percentage(double percent)
{
int count = (int)(round(percent / 5.0));
int spaces = 20 - count;
printf("|");
}
-void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size)
+void print_latency_histogram(int64_t *data, int latency_bins, int latency_bin_size, double io_count)
{
double percentage;
char label[MAX_FILENAME];
else
snprintf(label, MAX_FILENAME, "%d - %d usecs", i * latency_bin_size, (i+1) * latency_bin_size);
printf("%25s ", label);
- percentage = ((double)data[i] * 100.0) / (double)total_io_count;
- print_data_percentage((int)percentage);
- printf(" %.2lf%%\n", percentage);
+ percentage = ((double)data[i] * 100.000000) / io_count;
+ print_data_percentage(percentage);
+ printf(" %.6lf%%\n", percentage);
}
printf("\n");
}
printf("Total I/Os : %lld\n", total_io_count);
printf("Avg. Latency : %.2lf usecs\n", ((double)total_io_time) / ((double)total_io_count));
+ printf("Max. Latency : %.2lf usecs\n", ((double)max_io_time));
printf("Low Latency Histogram: \n");
- print_latency_histogram(low_latency_histogram, LOW_LATENCY_BINS, LOW_LATENCY_BIN_SIZE);
+ print_latency_histogram(low_latency_histogram, LOW_LATENCY_BINS, LOW_LATENCY_BIN_SIZE, (double)total_io_count);
printf("Latency Histogram: \n");
- print_latency_histogram(latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
+ print_latency_histogram(latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE, (double)total_io_count);
printf("Burst Avg. Latency Histogram: \n");
- print_latency_histogram(burst_latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE);
+ print_latency_histogram(burst_latency_histogram, LATENCY_BINS, LATENCY_BIN_SIZE, (double)total_burst_count);
printf("Throughput Timeline: \n");
exit(0);
}
+void setup_qos_device(void)
+{
+ kern_return_t status = kIOReturnError;
+ io_iterator_t iterator = IO_OBJECT_NULL;
+
+ if(io_qos_timeout_ms <= 0)
+ return;
+
+ printf ( "*** setup_qos_device *** \n" );
+
+ status = IOServiceGetMatchingServices ( kIOMasterPortDefault, IOServiceMatching ( kIONVMeANS2ControllerString ), &iterator );
+
+ if ( status != kIOReturnSuccess )
+ return;
+
+ if ( iterator != IO_OBJECT_NULL ) {
+ printf ( "Found NVMe ANS2 Device \n" );
+ qos_device = kNVMeDeviceANS2;
+ } else {
+
+ status= IOServiceGetMatchingServices ( kIOMasterPortDefault, IOServiceMatching ( kIONVMeControllerString ), &iterator );
+
+ if ( status != kIOReturnSuccess )
+ return;
+
+ if ( iterator != IO_OBJECT_NULL ) {
+ printf ( "Found NVMe Device \n" );
+ qos_device = kNVMeDevice;
+ }
+ else {
+ printf ( "NVMe Device not found, not setting qos timeout\n" );
+ qos_device = kDefaultDevice;
+ }
+ }
+}
+
+void assertASP(CFRunLoopTimerRef timer, void *info )
+{
+ char command [ 1024 ];
+
+ if(qos_device == kDefaultDevice)
+ return;
+
+ printf("assertASP. Timeout of IO exceeds = %d msec\n", io_qos_timeout_ms);
+
+ // kNVMe_ANS2_Force_Assert_offset = 0x13EC, // GP59
+ // kNVMe_Force_Assert_Offset = 0x550,
+
+ if(qos_device == kNVMeDeviceANS2)
+ snprintf ( command, sizeof ( command ), "/usr/local/bin/nvmectl-tool.py -a WriteRegister32 $((0x13EC)) 0xFFFF" );
+ else if(qos_device == kNVMeDevice)
+ snprintf ( command, sizeof ( command ), "/usr/local/bin/nvmectl-tool.py -a WriteRegister32 $((0x550)) 0xFFFF" );
+ else
+ return;
+
+ // Assert ASP
+ printf("Command : %s\n", command);
+ system(command);
+
+ // Panic the system as well
+ panic("IO time > QoS timeout");
+
+ return;
+}
+
+void start_qos_timer(void)
+{
+ float timeout_sec;
+
+ if(io_qos_timeout_ms <= 0)
+ return;
+
+ timeout_sec = (float)io_qos_timeout_ms/1000;
+
+ // Schedule a "timeout" delayed task that checks IO's which take > timeout sec to complete
+ runLoopTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent()+timeout_sec, 0, 0, 0, assertASP, NULL);
+ CFRunLoopAddTimer(CFRunLoopGetMain(), runLoopTimer, kCFRunLoopDefaultMode);
+}
+
+void stop_qos_timer(void)
+{
+ if(runLoopTimer == NULL)
+ return;
+
+ CFRunLoopTimerInvalidate(runLoopTimer);
+ CFRunLoopRemoveTimer(CFRunLoopGetMain(), runLoopTimer, kCFRunLoopDefaultMode);
+ CFRelease(runLoopTimer);
+}
void perform_io(int fd, char *buf, int size, int type)
{
}
}
+ start_qos_timer();
+
gettimeofday(&start_tv, NULL);
perform_io(fd, data, io_size, workload_type);
gettimeofday(&end_tv, NULL);
+ stop_qos_timer();
+
OSAtomicIncrement64(&total_io_count);
OSAtomicAdd64(io_size, &total_io_size);
elapsed = ((end_tv.tv_sec - start_tv.tv_sec) * 1000000) + (end_tv.tv_usec - start_tv.tv_usec);
+
+ if (elapsed > max_io_time) {
+ max_io_time = elapsed;
+ }
+
OSAtomicAdd64(elapsed, &total_io_time);
OSAtomicIncrement64(&(latency_histogram[find_io_bin(elapsed, LATENCY_BIN_SIZE, LATENCY_BINS)]));
OSAtomicIncrement64(&(low_latency_histogram[find_io_bin(elapsed, LOW_LATENCY_BIN_SIZE, LOW_LATENCY_BINS)]));
pthread_t throughput_thread;
char fname[MAX_FILENAME];
- while((option = getopt(argc, argv,"hc:i:d:t:f:m:j:s:x:l:z:n:a:")) != -1) {
+ while((option = getopt(argc, argv,"hc:i:d:t:f:m:j:s:x:l:z:n:a:q:")) != -1) {
switch(option) {
case 'c':
burst_count = atoi(optarg);
cached_io_flag = atoi(optarg);
validate_option(cached_io_flag, 0, 1, "I/Os cached/no-cached", "");
break;
+ case 'q':
+ io_qos_timeout_ms = atoi(optarg);
+ validate_option(io_qos_timeout_ms, 0, INT_MAX, "I/O QoS timeout", "msecs");
+ break;
default:
printf("Unknown option %c\n", option);
print_usage();
print_test_setup(test_duration, "Test duration", "secs", "0 indicates tool waits for Ctrl+C");
print_test_setup(io_tier, "I/O Tier", "", 0);
print_test_setup(cached_io_flag, "I/O Caching", "", "0 indicates non-cached I/Os");
+ print_test_setup(io_qos_timeout_ms, "I/O QoS Threshold Timeout", "msecs", 0);
print_test_setup(0, "File read-aheads", "", "0 indicates read-aheads disabled");
printf("**********************************************************\n");
system("purge");
setup_process_io_policy(io_tier);
+ setup_qos_device();
+
printf("**********************************************************\n");
printf("Creating threads and generating workload...\n");
exit(1);
}
- /* All threads are now initialized */
- if (test_duration)
- alarm(test_duration);
+ if(io_qos_timeout_ms > 0) {
+ CFRunLoopRunInMode(kCFRunLoopDefaultMode, (CFTimeInterval)test_duration, false);
+ alarm(1);
+ } else {
+ /* All threads are now initialized */
+ if (test_duration)
+ alarm(test_duration);
+ }
for(i=0; i < thread_count; i++)
pthread_join(thread_list[i], NULL);
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/usr.sbin/iostat/iostat.8,v 1.20 2001/08/07 13:59:48 ru Exp $
+.\" $FreeBSD$
.\"
.\" Copyright (c) 1985, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
+.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\"
.\" @(#)iostat.8 8.1 (Berkeley) 6/6/93
.\"
-.Dd September 27, 2001
+.Dd May 22, 2015
.Dt IOSTAT 8
.Os
.Sh NAME
.Tn I/O
statistics
.Sh SYNOPSIS
-.Nm iostat
+.Nm
.Op Fl CUdKIoT?\&
.Op Fl c Ar count
.Op Fl n Ar devs
.Op Fl w Ar wait
.Op Ar drives
.Sh DESCRIPTION
-.Nm Iostat
-displays kernel
+The
+.Nm
+utility displays kernel
.Tn I/O
statistics on terminal, device and cpu operations.
The first statistics that are printed are averaged over the system uptime.
.Pp
The options are as follows:
.Bl -tag -width flag
-.\" ==========
.It Fl ?\&
Display a usage statement and exit.
-.\" ==========
-.It Fl C
-Display CPU statistics.
-This is on by default, unless
-.Fl d
-is specified.
-.\" ==========
.It Fl c
Repeat the display
.Ar count
If no
.Ar wait
interval is specified, the default is 1 second.
-.\" ==========
+.It Fl C
+Display CPU statistics.
+This is on by default, unless
+.Fl d
+is specified.
.It Fl d
Display only device statistics.
If this flag is turned on, only device statistics will be displayed, unless
.Fl U
or
.Fl T
-is also specfied to enable the display of CPU, load average or TTY statistics.
-.\" ==========
+is also specified to enable the display of CPU, load average or TTY statistics.
.It Fl I
-Display total statstics for a given time period, rather than average
+Display total statistics for a given time period, rather than average
statistics for each second during that time period.
-.\" ==========
.It Fl K
In the blocks transferred display (-o), display block count in kilobytes rather
then the device native block size.
-.\" ==========
.It Fl n
Display up to
.Ar devs
number of devices.
-.Nm iostat
-will display fewer devices if there aren't
+The
+.Nm
+utility will display fewer devices if there are not
.Ar devs
devices present.
-.\" ==========
.It Fl o
Display old-style
-.Nm iostat
+.Nm
device statistics.
-Sectors per second, transfers per second, and miliseconds per seek are
+Sectors per second, transfers per second, and milliseconds per seek are
displayed.
If
.Fl I
is specified, total blocks/sectors, total transfers, and
-miliseconds per seek are displayed.
-.\" ==========
+milliseconds per seek are displayed.
.It Fl T
Display TTY statistics.
This is on by default, unless
.Fl d
is specified.
-.\" ==========
.It Fl U
Display system load averages.
This is on by default, unless
.Fl d
is specified.
-.\" ==========
.It Fl w
Pause
.Ar wait
is specified, the default is infinity.
.El
.Pp
-.Nm Iostat
-displays its information in the following format:
+The
+.Nm
+utility displays its information in the following format:
.Bl -tag -width flag
.It tty
.Bl -tag -width indent -compact
.It devices
Device operations.
The header of the field is the device name and unit number.
-.Nm iostat
+The
+.Nm
+utility
will display as many devices as will fit in a standard 80 column screen, or
the maximum number of devices in the system, whichever is smaller.
If
.Fl n
is specified on the command line,
-.Nm iostat
+.Nm
will display the smaller of the
requested number of devices, and the maximum number of devices in the system.
To force
-.Nm iostat
+.Nm
to display specific drives, their names may be supplied on the command
line.
-.Nm iostat
+The
+.Nm
+utility
will not display more devices than will fit in an 80 column screen, unless
the
.Fl n
devices to display, or the list of specified devices exceeds 80 columns.
If fewer devices are specified on the command line than will fit in an 80
column screen,
-.Nm iostat
+.Nm
will show only the specified devices.
.Pp
The standard
-.Nm iostat
+.Nm
device display shows the following statistics:
.Pp
.Bl -tag -width indent -compact
.El
.Pp
The standard
-.Nm iostat
+.Nm
device display, with the
.Fl I
flag specified, shows the following statistics:
.El
.Pp
The old-style
-.Nm iostat
+.Nm
display (using
.Fl o )
shows the following statistics:
.El
.Pp
The old-style
-.Nm iostat
+.Nm
display, with the
.Fl I
flag specified, shows the following statistics:
.Fl C
flags are given, the TTY and CPU displays will be displayed.
.Sh SEE ALSO
-.Xr fstat 1 ,
.Xr netstat 1 ,
.Xr nfsstat 1 ,
.Xr ps 1 ,
-.Xr pstat 8
+.Xr top 1 ,
+.Xr vm_stat 1
.Pp
The sections starting with ``Interpreting system activity'' in
.%T "Installing and Operating 4.3BSD" .
.Sh HISTORY
This version of
-.Nm iostat
+.Nm
first appeared in
-.Nm FreeBSD 3.0 .
+.Fx 3.0 .
/*
- * Copyright (c) 1999-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2019 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
* @APPLE_LICENSE_HEADER_END@
*/
-/*
+/*-
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
* Copyright (c) 1997, 1998, 2000, 2001 Kenneth D. Merry
* All rights reserved.
*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: src/usr.sbin/iostat/iostat.c,v 1.22 2001/09/01 07:40:19 kris Exp $
+ * $FreeBSD$
*/
/*
* Parts of this program are derived from the original FreeBSD iostat
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
/* local function declarations */
static void usage(void);
static void phdr(int signo);
-static void do_phdr();
+static void do_phdr(void);
static void devstats(int perf_select, long double etime, int havelast);
static void cpustats(void);
static void loadstats(void);
exit(1);
}
+static void
+resetscr(void)
+{
+ (void)endwin();
+}
+
int
main(int argc, char *argv[])
{
if (!RAW_flag) {
if (initscr() == NULL) {
- printf("Unrecognized TERM type, try vt100\n");
+ fprintf(stderr, "Unrecognized TERM type, try vt100\n");
exit(1);
}
+ atexit(resetscr);
clear();
refresh();
bail(SLEEP_EXIT, 1);
}
-#if defined(__APPLE__) && TARGET_OS_EMBEDDED
+#if defined(__APPLE__) && (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
/* on embedded, allow a shell to live in /private/var/personalized_debug/bin/sh */
#define _PATH_DEBUGSHELL "/private/var/personalized_debug/bin/sh"
if (stat(pwd->pw_shell, &st) != 0) {
#ifndef _LSKQ_COMMON_H_
#define _LSKQ_COMMON_H_
+#include <stdint.h>
+
/*
* This file must be kept in sync with xnu headers
*/
/*
* bsd/sys/event.h
*/
-#define KN_ACTIVE 0x0001
-#define KN_QUEUED 0x0002
-#define KN_DISABLED 0x0004
-#define KN_DROPPING 0x0008
-#define KN_USEWAIT 0x0010
-#define KN_ATTACHING 0x0020
-#define KN_STAYACTIVE 0x0040
-#define KN_DEFERDELETE 0x0080
-#define KN_ATTACHED 0x0100
-#define KN_DISPATCH 0x0200
-#define KN_UDATA_SPECIFIC 0x0400
-#define KN_SUPPRESSED 0x0800
-#define KN_STOLENDROP 0x1000
-#define KN_REQVANISH 0x2000
-#define KN_VANISHED 0x4000
-
+__options_decl(kn_status_t, uint16_t /* 12 bits really */, {
+ KN_ACTIVE = 0x001, /* event has been triggered */
+ KN_QUEUED = 0x002, /* event is on queue */
+ KN_DISABLED = 0x004, /* event is disabled */
+ KN_DROPPING = 0x008, /* knote is being dropped */
+ KN_LOCKED = 0x010, /* knote is locked (kq_knlocks) */
+ KN_POSTING = 0x020, /* f_event() in flight */
+ KN_STAYACTIVE = 0x040, /* force event to stay active */
+ KN_DEFERDELETE = 0x080, /* defer delete until re-enabled */
+ KN_MERGE_QOS = 0x100, /* f_event() / f_* ran concurrently and overrides must merge */
+ KN_REQVANISH = 0x200, /* requested EV_VANISH */
+ KN_VANISHED = 0x400, /* has vanished */
+ KN_SUPPRESSED = 0x800, /* event is suppressed during delivery */
+});
/*
* bsd/sys/eventvar.h
*/
-#define KQ_SEL 0x01
-#define KQ_SLEEP 0x02
-#define KQ_KEV32 0x08
-#define KQ_KEV64 0x10
-#define KQ_KEV_QOS 0x20
-#define KQ_WORKQ 0x40
-#define KQ_WORKLOOP 0x80
+__options_decl(kq_state_t, uint16_t, {
+ KQ_SEL = 0x0001, /* select was recorded for kq */
+ KQ_SLEEP = 0x0002, /* thread is waiting for events */
+ KQ_PROCWAIT = 0x0004, /* thread waiting for processing */
+ KQ_KEV32 = 0x0008, /* kq is used with 32-bit events */
+ KQ_KEV64 = 0x0010, /* kq is used with 64-bit events */
+ KQ_KEV_QOS = 0x0020, /* kq events carry QoS info */
+ KQ_WORKQ = 0x0040, /* KQ is bound to process workq */
+ KQ_WORKLOOP = 0x0080, /* KQ is part of a workloop */
+ KQ_PROCESSING = 0x0100, /* KQ is being processed */
+ KQ_DRAIN = 0x0200, /* kq is draining */
+ KQ_WAKEUP = 0x0400, /* kq awakened while processing */
+ KQ_DYNAMIC = 0x0800, /* kqueue is dynamically managed */
+ KQ_R2K_ARMED = 0x1000, /* ast notification armed */
+ KQ_HAS_TURNSTILE = 0x2000, /* this kqueue has a turnstile */
+});
+
+/*
+ * bsd/pthread/workqueue_internal.h
+ */
+__enum_decl(workq_tr_state_t, uint8_t, {
+ WORKQ_TR_STATE_IDLE = 0, /* request isn't in flight */
+ WORKQ_TR_STATE_NEW = 1, /* request is being initiated */
+ WORKQ_TR_STATE_QUEUED = 2, /* request is being queued */
+ WORKQ_TR_STATE_CANCELED = 3, /* request is canceled */
+ WORKQ_TR_STATE_BINDING = 4, /* request is preposted for bind */
+ WORKQ_TR_STATE_BOUND = 5, /* request is bound to a thread */
+});
+
/*
* bsd/sys/signal.h
NOTE_REAP
.Pp
.It EVFILT_TIMER:
-.It Sy s u n
-NOTE_SECONDS, NOTE_USECONDS, NOTE_NSECONDS
-.It Sy a
-NOTE_ABSOLUTE
+.It Sy s u n m
+NOTE_SECONDS, NOTE_USECONDS, NOTE_NSECONDS, NOTE_MACHTIME
+.It Sy a A
+NOTE_ABSOLUTE, NOTE_MACH_CONTINUOUS_TIME
.It Sy c
NOTE_CRITICAL
.It Sy b
NOTE_FFOR
.Pp
.It EVFILT_WORKLOOP:
-.It Sy t w
-NOTE_WL_THREAD_REQUEST, NOTE_WL_SYNC_WAIT
-.It Sy !
+.It Sy t w i
+NOTE_WL_THREAD_REQUEST, NOTE_WL_SYNC_WAIT, NOTE_WL_SYNC_IPC
+.It Sy W
NOTE_WL_SYNC_WAKE
.It Sy q
NOTE_WL_UPDATE_QOS
-.It Sy O o
-NOTE_WL_UPDATE_OWNER, NOTE_WL_DISCOVER_OWNER
+.It Sy o
+NOTE_WL_DISCOVER_OWNER
+.It Sy e
+NOTE_WL_IGNORE_ESTALE
.El
.It flags
kevent generic flags bitmask.
.It Sy q
KN_QUEUED (event has been added to the active list)
.It Sy d
-KN_DISABLED
+KN_DISABLED (knote is disabled)
+.It Sy p
+KN_SUPPRESSED (event delivery is in flight)
.It Sy s
-KN_STAYQUEUED (event is marked as always-enqueued on the active list)
+KN_STAYACTIVE (event is marked as always-enqueued on the active list)
.Pp
.It Sy d
-KN_DROPPING
-.It Sy w
-KN_USEWAIT
-.It Sy c
-KN_ATTACHING
-.It Sy a
-KN_ATTACHED
-.Pp
-.It Sy s
-KN_DISPATCH
-.It Sy u
-KN_UDATA_SPECIFIC
-.It Sy p
-KN_SUPPRESSED
-.It Sy t
-KN_STOLENDROP
+KN_DROPPING (knote is about to be dropped)
+.It Sy l
+KN_LOCKED (knote is locked)
+.It Sy P
+KN_POSTING (knote is being posted)
+.It Sy m
+KN_MERGE_QOS (knote is in override saturating mode)
.Pp
+.It Sy D
+KN_DEFERDELETE (knote is waiting for deferred-delete ack)
.It Sy v
KN_REQVANISH
.It Sy n
case EVFILT_TIMER: {
snprintf(str, len, "%c%c%c%c%c ",
- (ff & NOTE_SECONDS) ? 's' :
- (ff & NOTE_USECONDS) ? 'u' :
- (ff & NOTE_NSECONDS) ? 'n' : '?',
- (ff & NOTE_ABSOLUTE) ? 'a' : '-',
- (ff & NOTE_CRITICAL) ? 'c' : '-',
- (ff & NOTE_BACKGROUND) ? 'b' : '-',
- (ff & NOTE_LEEWAY) ? 'l' : '-'
+ (ff & NOTE_SECONDS) ? 's' :
+ (ff & NOTE_USECONDS) ? 'u' :
+ (ff & NOTE_NSECONDS) ? 'n' :
+ (ff & NOTE_MACHTIME) ? 'm' : '?',
+ (ff & NOTE_ABSOLUTE) ? 'a' :
+ (ff & NOTE_MACH_CONTINUOUS_TIME) ? 'A' : '-',
+ (ff & NOTE_CRITICAL) ? 'c' : '-',
+ (ff & NOTE_BACKGROUND) ? 'b' : '-',
+ (ff & NOTE_LEEWAY) ? 'l' : '-'
);
break;
}
break;
case EVFILT_WORKLOOP:
- snprintf(str, len, "%c%c%c%c ",
+ snprintf(str, len, "%c%c%c%c%c ",
(ff & NOTE_WL_THREAD_REQUEST) ? 't' :
- (ff & NOTE_WL_SYNC_WAIT) ? 'w' : '-',
- (ff & NOTE_WL_SYNC_WAKE) ? '!' : '-',
+ (ff & NOTE_WL_SYNC_WAIT) ? 'w' :
+ (ff & NOTE_WL_SYNC_IPC) ? 'i' : '-',
+ (ff & NOTE_WL_SYNC_WAKE) ? 'W' : '-',
(ff & NOTE_WL_UPDATE_QOS) ? 'q' : '-',
- (ff & NOTE_WL_UPDATE_OWNER) ? 'O' :
- (ff & NOTE_WL_DISCOVER_OWNER) ? 'o' : '-'
+ (ff & NOTE_WL_DISCOVER_OWNER) ? 'o' : '-',
+ (ff & NOTE_WL_IGNORE_ESTALE) ? 'e' : '-'
);
break;
if (verbose && ret >= sizeof(struct kqueue_dyninfo)) {
print_kq_info(pid, procname, kqid, kqinfo.kqdi_info.kq_state);
- printf("%18s ", " "); // ident
- printf("%-9s ", " "); // filter
+ if (kqinfo.kqdi_owner) {
+ printf("%#18llx ", kqinfo.kqdi_owner); // ident
+ printf("%-9s ", "WL owned"); // filter
+ } else if (kqinfo.kqdi_servicer) {
+ printf("%#18llx ", kqinfo.kqdi_servicer); // ident
+ printf("%-9s ", "WL"); // filter
+ } else {
+ printf("%18s ", "-"); // ident
+ printf("%-9s ", "WL"); // filter
+ }
dynkq_printed = true;
if (raw) {
printf("%-10s ", " "); // flags
printf("%-10s ", " "); // evst
} else {
- printf("%-8s ", " "); // fdtype
+ const char *reqstate = "???";
+
+ switch (kqinfo.kqdi_request_state) {
+ case WORKQ_TR_STATE_IDLE:
+ reqstate = "";
+ break;
+ case WORKQ_TR_STATE_NEW:
+ reqstate = "new";
+ break;
+ case WORKQ_TR_STATE_QUEUED:
+ reqstate = "queued";
+ break;
+ case WORKQ_TR_STATE_CANCELED:
+ reqstate = "canceled";
+ break;
+ case WORKQ_TR_STATE_BINDING:
+ reqstate = "binding";
+ break;
+ case WORKQ_TR_STATE_BOUND:
+ reqstate = "bound";
+ break;
+ }
+
+ printf("%-8s ", reqstate); // fdtype
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;
+ 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
+ printf("%-15s ", " "); // evst
}
if (!raw && kqinfo.kqdi_pri != 0) {
kqinfo.kqdi_sync_waiter_qos);
printf("%3s ", thread_qos_name(qos)); //qos
}
- printf("%-18s ", " "); // data
- printf("%-18s ", " "); // udata
- printf("%#18llx ", kqinfo.kqdi_servicer); // ext0
- printf("%#18llx ", kqinfo.kqdi_owner); // ext1
printf("\n");
}
}
);
unsigned st = info->kqext_status;
- printf("%c%c%c%c %c%c%c%c %c%c%c%c %c%c ",
- (st & KN_ACTIVE) ? 'a' : '-',
- (st & KN_QUEUED) ? 'q' : '-',
- (st & KN_DISABLED) ? 'd' : '-',
- (st & KN_STAYACTIVE) ? 's' : '-',
-
- (st & KN_DROPPING) ? 'd' : '-',
- (st & KN_USEWAIT) ? 'w' : '-',
- (st & KN_ATTACHING) ? 'c' : '-',
- (st & KN_ATTACHED) ? 'a' : '-',
-
- (st & KN_DISPATCH) ? 's' : '-',
- (st & KN_UDATA_SPECIFIC) ? 'u' : '-',
- (st & KN_SUPPRESSED) ? 'p' : '-',
- (st & KN_STOLENDROP) ? 't' : '-',
-
- (st & KN_REQVANISH) ? 'v' : '-',
- (st & KN_VANISHED) ? 'n' : '-'
+ printf("%c%c%c%c%c %c%c%c%c %c%c%c ",
+ (st & KN_ACTIVE) ? 'a' : '-',
+ (st & KN_QUEUED) ? 'q' : '-',
+ (st & KN_DISABLED) ? 'd' : '-',
+ (st & KN_SUPPRESSED) ? 'p' : '-',
+ (st & KN_STAYACTIVE) ? 's' : '-',
+
+ (st & KN_DROPPING) ? 'd' : '-',
+ (st & KN_LOCKED) ? 'l' : '-',
+ (st & KN_POSTING) ? 'P' : '-',
+ (st & KN_MERGE_QOS) ? 'm' : '-',
+
+ (st & KN_DEFERDELETE) ? 'D' : '-',
+ (st & KN_REQVANISH) ? 'v' : '-',
+ (st & KN_VANISHED) ? 'n' : '-'
);
}
static void
cheatsheet(void)
{
+ const char *bold = "\033[1m";
+ const char *reset = "\033[0m";
+ if (!isatty(STDERR_FILENO)) {
+ bold = reset = "";
+ }
+
fprintf(stderr, "\nFilter-independent flags:\n\n\
-\033[1m\
-command pid kq kqst knid filter fdtype fflags flags evst qos\033[0m\n\033[1m\
--------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- ----------------- ---\033[0m\n\
+%s\
+command pid kq kqst knid filter fdtype fflags flags evst qos%s\n%s\
+-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- ---%s\n\
┌ EV_UDATA_SPECIFIC\n\
EV_DISPATCH ┐ │┌ EV_FLAG0 (EV_POLL)\n\
EV_CLEAR ┐│ ││┌ EV_FLAG1 (EV_OOBAND)\n\
EV_ONESHOT ┐││ │││┌ EV_EOF\n\
EV_RECEIPT ┐│││ ││││┌ EV_ERROR\n\
- ││││ │││││\n\033[1m\
-launchd 1 4 ks- netbiosd 250 PROC ------- andx r1cs upboe aqds dwca supt vn IN\033[0m \n\
- │ │││ ││││ ││││ ││││ ││││ ││\n\
- kqueue file descriptor/dynamic ID ┘ │││ EV_ADD ┘│││ KN_ACTIVE ┘│││ ││││ ││││ ││\n\
- KQ_SLEEP ┘││ EV_ENABLE ┘││ KN_QUEUED ┘││ ││││ ││││ ││\n\
- KQ_SEL ┘│ EV_DISABLE ┘│ KN_DISABLED ┘│ ││││ ││││ │└ KN_VANISHED\n\
- KQ_WORKQ (q) ┤ EV_DELETE ┘ KN_STAYACTIVE ┘ ││││ ││││ └ KN_REQVANISH\n\
- KQ_WORKLOOP (l) ┘ ││││ ││││\n\
- KN_DROPPING ┘│││ │││└ KN_STOLENDROP\n\
- KN_USEWAIT ┘││ ││└ KN_SUPPRESSED\n\
- KN_ATTACHING ┘│ │└ KN_UDATA_SPECIFIC\n\
- KN_ATTACHED ┘ └ KN_DISPATCH\n\
- \n");
+ ││││ │││││\n%s\
+launchd 1 4 ks- netbiosd 250 PROC ------- andx r1cs upboe aqdps dlPm Dvn IN%s\n\
+ │ │││ ││││ │││││ ││││ │││\n\
+ kqueue file descriptor/dynamic ID ┘ │││ EV_ADD ┘│││ KN_ACTIVE ┘││││ ││││ ││└ KN_VANISHED\n\
+ KQ_SLEEP ┘││ EV_ENABLE ┘││ KN_QUEUED ┘│││ ││││ │└ KN_REQVANISH\n\
+ KQ_SEL ┘│ EV_DISABLE ┘│ KN_DISABLED ┘││ ││││ └ KN_DEFERDELETE\n\
+ KQ_WORKQ (q) ┤ EV_DELETE ┘ KN_SUPPRESSED ┘│ ││││\n\
+ KQ_WORKLOOP (l) ┘ KN_STAYACTIVE ┘ ││││\n\
+ ││││\n\
+ KN_DROPPING ┘││└ KN_MERGE_QOS\n\
+ KN_LOCKED ┘└ KN_POSTING\n\
+ \n", bold, reset, bold, reset, bold, reset);
}
static void
print_header(void)
{
if (raw) {
- printf(" pid kq kqst knid filter fflags flags evst qos data");
+ printf(" pid kq kqst knid filter fflags flags evst qos data");
} else {
- printf("command pid kq kqst knid filter fdtype fflags flags evst qos data");
+ printf("command pid kq kqst knid filter fdtype fflags flags evst qos data");
}
if (verbose) {
- printf(" udata servicer / ext0 owner / ext1 ext2 ext3 xflags");
+ printf(" udata ext0 ext1 ext2 ext3 xflags");
}
printf("\n");
if (raw) {
printf("----- ------------------ ---------- ------------------ --------- ---------- ---------- ---------- --- ------------------");
} else {
- printf("-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- ----------------- --- ------------------");
+ printf("-------------------- ----- ------------------ ---- ------------------ --------- -------- ------- --------------- -------------- --- ------------------");
}
if (verbose) {
#include "common.h"
#include "json.h"
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
#define TASK_FOR_PID_USAGE_MESG "\nPlease check your boot-args to ensure you have access to task_for_pid()."
#else
#define TASK_FOR_PID_USAGE_MESG ""
break;
#if TARGET_OS_BRIDGE
case 'm':
- // -m option is unadvertised -- used to set nvram variables on the Intel side
+ // used to set nvram variables on the Intel side
// from the ARM side (Bridge -> Mac)
fprintf(stdout, "Using Mac NVRAM store.\n");
printf("\t-f set firmware variables from a text file\n");
printf("\t-d delete the named variable\n");
printf("\t-c delete all variables\n");
+#if TARGET_OS_BRIDGE
+ printf("\t-m set nvram variables on macOS from bridgeOS\n");
+#endif
printf("\tname=value set named variable\n");
printf("\tname print variable\n");
printf("Note that arguments and options are executed in order.\n");
}
// Get the OF variable's name.
- nameLen = CFStringGetLength(key) + 1;
+ nameLen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(key),
+ kCFStringEncodingUTF8) + 1;
nameBuffer = malloc(nameLen);
if( nameBuffer && CFStringGetCString(key, nameBuffer, nameLen, kCFStringEncodingUTF8) )
nameString = nameBuffer;
else sprintf(numberBuffer, "0x%x", number);
valueString = numberBuffer;
} else if (typeID == CFStringGetTypeID()) {
- valueLen = CFStringGetLength(value) + 1;
+ valueLen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(value),
+ kCFStringEncodingUTF8) + 1;
valueBuffer = malloc(valueLen + 1);
if ( valueBuffer && CFStringGetCString(value, valueBuffer, valueLen, kCFStringEncodingUTF8) )
valueString = valueBuffer;
char *nameString;
// Get the variable's name.
- nameLen = CFStringGetLength(key) + 1;
+ nameLen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(key),
+ kCFStringEncodingUTF8) + 1;
nameBuffer = malloc(nameLen);
if( nameBuffer && CFStringGetCString(key, nameBuffer, nameLen, kCFStringEncodingUTF8) )
nameString = nameBuffer;
/*
- * Copyright (c) 2011-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 2011-2019 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <TargetConditionals.h>
#define INFO_FILE 1
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
#define INFO_NIS 2
#define INFO_OPEN_DIRECTORY 3
#define INFO_PAM 4
#endif
extern int file_passwd(char *, char *);
+#ifdef INFO_NIS
extern int nis_passwd(char *, char *);
+#endif
#ifdef INFO_OPEN_DIRECTORY
extern int od_passwd(char *, char *, char*);
#endif
#include <TargetConditionals.h>
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
subsystem dummy 0;
#else
#include <IOKit/kext/kextmanager_mig.defs>
#ifdef __APPLE__
#include <TargetConditionals.h>
-#if !TARGET_OS_EMBEDDED
+#if !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
#include "kextmanager.h"
#include <IOKit/kext/kextmanager_types.h>
#endif
void usage(void);
u_int get_pageins(void);
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
int reserve_reboot(void);
#endif
err(1, NULL);
}
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
if (!qflag && !lflag) { // shutdown(8) has already checked w/kextd
if ((errno = reserve_reboot()))
err(1, "couldn't lock for reboot");
utx.ut_type = SHUTDOWN_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
-
- int newvalue = 1;
- sysctlbyname("kern.willshutdown", NULL, NULL, &newvalue, sizeof(newvalue));
}
#else
logwtmp("~", "shutdown", "");
return pageins;
}
-#if defined(__APPLE__) && !TARGET_OS_EMBEDDED
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
// XX this routine is also in shutdown.tproj; it would be nice to share
#define WAITFORLOCK 1
/*
- * Copyright (c) 1999-2016 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2019 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
}
}
+static void
+resetscr(void)
+{
+ (void)endwin();
+}
+
int
main(int argc, char *argv[])
{
printf("Unrecognized TERM type, try vt100\n");
exit(1);
}
+ atexit(resetscr);
cbreak();
timeout(100);
noecho();
#include <TargetConditionals.h>
-#if TARGET_OS_EMBEDDED
+#if (TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR)
subsystem dummy 0;
#else
#include <IOKit/kext/kextmanager_mig.defs>
#include <bootstrap_priv.h>
#include <reboot2.h>
#include <utmpx.h>
-#include <sys/sysctl.h>
#include "pathnames.h"
#endif /* __APPLE__ */
utx.ut_type = SHUTDOWN_TIME;
gettimeofday(&utx.ut_tv, NULL);
pututxline(&utx);
-
- int newvalue = 1;
- sysctlbyname("kern.willshutdown", NULL, NULL, &newvalue, sizeof(newvalue));
}
#else
logwtmp("~", "shutdown", "");
1812F1ED1C8F923900F3DC9E /* CopyFiles */,
);
dependencies = (
+ 358407D62245AD55006A0D8E /* PBXTargetDependency */,
926913A61EC706130079D787 /* PBXTargetDependency */,
1812F18D1C8F923900F3DC9E /* PBXTargetDependency */,
1812F18F1C8F923900F3DC9E /* PBXTargetDependency */,
C9D64CD21B91066B00CFA43B /* CopyFiles */,
);
dependencies = (
+ 358407D22245AD40006A0D8E /* PBXTargetDependency */,
926913A21EC706010079D787 /* PBXTargetDependency */,
08CE3D361E6E24CC00DF1B78 /* PBXTargetDependency */,
C21481471C1A1447003BCA63 /* PBXTargetDependency */,
C9D64CD01B91064700CFA43B /* CopyFiles */,
);
dependencies = (
+ 358407D42245AD4B006A0D8E /* PBXTargetDependency */,
926913A41EC706080079D787 /* PBXTargetDependency */,
08CE3D381E6E24DF00DF1B78 /* PBXTargetDependency */,
C21481491C1A14AD003BCA63 /* PBXTargetDependency */,
1523FE6C1595056C00661E82 /* ltop.c in Sources */ = {isa = PBXBuildFile; fileRef = 1523FE6B1595056C00661E82 /* ltop.c */; };
1523FE6D1595058100661E82 /* ltop.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 1523FE6A1595056C00661E82 /* ltop.1 */; };
1812F1EE1C8F923900F3DC9E /* system_cmds.plist in CopyFiles */ = {isa = PBXBuildFile; fileRef = C9D64CCF1B91063200CFA43B /* system_cmds.plist */; };
+ 358407CE2245AC09006A0D8E /* cpuctl.c in Sources */ = {isa = PBXBuildFile; fileRef = 358407CD2245AC09006A0D8E /* cpuctl.c */; };
+ 358407D02245AC32006A0D8E /* cpuctl.8 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 358407CF2245AC32006A0D8E /* cpuctl.8 */; };
+ 5262264121E8295A0053ABA1 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 189337C21CC7CB4800B2A6A4 /* CoreFoundation.framework */; };
+ 5262264221ED5A780053ABA1 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9E0691D1C58BDB800C956EB /* IOKit.framework */; };
550C19E61804D226001DA380 /* libutil.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BA4B7A091373BA4600003422 /* libutil.dylib */; };
550C19EC1804D281001DA380 /* iosim.c in Sources */ = {isa = PBXBuildFile; fileRef = 550C19E11804C55E001DA380 /* iosim.c */; };
550C19ED1804D295001DA380 /* iosim.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 550C19E01804C55E001DA380 /* iosim.1 */; };
remoteGlobalIDString = BACC1D0D1377B481007728F4;
remoteInfo = mean;
};
+ 358407D12245AD40006A0D8E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA2DE9181372FA9100D1913C /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3521C84C2245AA92001B3201;
+ remoteInfo = cpuctl;
+ };
+ 358407D32245AD4B006A0D8E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA2DE9181372FA9100D1913C /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3521C84C2245AA92001B3201;
+ remoteInfo = cpuctl;
+ };
+ 358407D52245AD55006A0D8E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = BA2DE9181372FA9100D1913C /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = 3521C84C2245AA92001B3201;
+ remoteInfo = cpuctl;
+ };
550C19EE1804D2AD001DA380 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = BA2DE9181372FA9100D1913C /* Project object */;
);
runOnlyForDeploymentPostprocessing = 1;
};
+ 3521C84B2245AA92001B3201 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man8;
+ dstSubfolderSpec = 0;
+ files = (
+ 358407D02245AC32006A0D8E /* cpuctl.8 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
550C19E71804D226001DA380 /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
1523FE6B1595056C00661E82 /* ltop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltop.c; sourceTree = "<group>"; };
189337C21CC7CB4800B2A6A4 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
18EA07101C99C76C006D3005 /* EmbeddedOSSupportHost.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = EmbeddedOSSupportHost.framework; path = System/Library/PrivateFrameworks/EmbeddedOSSupportHost.framework; sourceTree = SDKROOT; };
+ 3521C84D2245AA92001B3201 /* cpuctl */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cpuctl; sourceTree = BUILT_PRODUCTS_DIR; };
+ 3521C8562245AB52001B3201 /* cpuctl.tproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = cpuctl.tproj; sourceTree = "<group>"; };
+ 358407CD2245AC09006A0D8E /* cpuctl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = cpuctl.c; path = cpuctl.tproj/cpuctl.c; sourceTree = "<group>"; };
+ 358407CF2245AC32006A0D8E /* cpuctl.8 */ = {isa = PBXFileReference; lastKnownFileType = text; name = cpuctl.8; path = cpuctl.tproj/cpuctl.8; sourceTree = "<group>"; };
550C19E01804C55E001DA380 /* iosim.1 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.man; path = iosim.1; sourceTree = "<group>"; };
550C19E11804C55E001DA380 /* iosim.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iosim.c; sourceTree = "<group>"; };
550C19EB1804D226001DA380 /* iosim */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = iosim; sourceTree = BUILT_PRODUCTS_DIR; };
BA4FD2E51372FAFA0025925C /* zprint.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = zprint.1; sourceTree = "<group>"; };
BA4FD2E61372FAFA0025925C /* zprint.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = zprint.c; sourceTree = "<group>"; };
BA4FD2EF1372FB3D0025925C /* ac */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = ac; sourceTree = BUILT_PRODUCTS_DIR; };
- BA4FD2FB1372FB710025925C /* BSD.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = BSD.xcconfig; path = Makefiles/CoreOS/Xcode/BSD.xcconfig; sourceTree = DEVELOPER_DIR; };
BA4FD30D1372FFD80025925C /* accton */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = accton; sourceTree = BUILT_PRODUCTS_DIR; };
BA4FD323137300EE0025925C /* arch */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = arch; sourceTree = BUILT_PRODUCTS_DIR; };
BA4FD3411373073E0025925C /* at */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = at; sourceTree = BUILT_PRODUCTS_DIR; };
C625B28816D6F27E00168EF7 /* taskpolicy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = taskpolicy; sourceTree = BUILT_PRODUCTS_DIR; };
C625B28A16D6F27E00168EF7 /* taskpolicy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = taskpolicy.c; sourceTree = "<group>"; };
C625B28C16D6F27E00168EF7 /* taskpolicy.8 */ = {isa = PBXFileReference; lastKnownFileType = text; path = taskpolicy.8; sourceTree = "<group>"; };
+ C913CA2E2228B622000051A0 /* base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = base.xcconfig; sourceTree = "<group>"; };
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; };
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 3521C84A2245AA92001B3201 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
550C19E51804D226001DA380 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 5262264221ED5A780053ABA1 /* IOKit.framework in Frameworks */,
+ 5262264121E8295A0053ABA1 /* CoreFoundation.framework in Frameworks */,
550C19E61804D226001DA380 /* libutil.dylib in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
BA2DE9161372FA9100D1913C = {
isa = PBXGroup;
children = (
+ 358407CF2245AC32006A0D8E /* cpuctl.8 */,
+ 358407CD2245AC09006A0D8E /* cpuctl.c */,
+ 3521C8562245AB52001B3201 /* cpuctl.tproj */,
+ C913CA2E2228B622000051A0 /* base.xcconfig */,
08CE3D321E6E22DE00DF1B78 /* stackshot.c */,
18EA07101C99C76C006D3005 /* EmbeddedOSSupportHost.framework */,
BA4FD1E11372FAFA0025925C /* APPLE_LICENSE */,
- BA4FD2FB1372FB710025925C /* BSD.xcconfig */,
C9D64CCF1B91063200CFA43B /* system_cmds.plist */,
BA4FD1D91372FAFA0025925C /* ac.tproj */,
BA4FD1DD1372FAFA0025925C /* accton.tproj */,
08CE3D291E6E22A200DF1B78 /* stackshot */,
0D06BC5E1E8F08CB00C6EC2D /* mslutil */,
F2291F5D1FFEBB6A00161936 /* zlog */,
+ 3521C84D2245AA92001B3201 /* cpuctl */,
);
name = Products;
sourceTree = "<group>";
productReference = 1523FE631595048900661E82 /* ltop */;
productType = "com.apple.product-type.tool";
};
+ 3521C84C2245AA92001B3201 /* cpuctl */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 3521C8512245AA92001B3201 /* Build configuration list for PBXNativeTarget "cpuctl" */;
+ buildPhases = (
+ 3521C8492245AA92001B3201 /* Sources */,
+ 3521C84A2245AA92001B3201 /* Frameworks */,
+ 3521C84B2245AA92001B3201 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = cpuctl;
+ productName = cpuctl;
+ productReference = 3521C84D2245AA92001B3201 /* cpuctl */;
+ productType = "com.apple.product-type.tool";
+ };
550C19E21804D226001DA380 /* iosim */ = {
isa = PBXNativeTarget;
buildConfigurationList = 550C19E91804D226001DA380 /* Build configuration list for PBXNativeTarget "iosim" */;
BA2DE9181372FA9100D1913C /* Project object */ = {
isa = PBXProject;
attributes = {
+ DefaultBuildSystemTypeForWorkspace = Original;
LastUpgradeCheck = 0600;
TargetAttributes = {
08CE3D281E6E22A200DF1B78 = {
1812F18C1C8F923900F3DC9E = {
ProvisioningStyle = Manual;
};
+ 3521C84C2245AA92001B3201 = {
+ CreatedOnToolsVersion = 11.0;
+ ProvisioningStyle = Automatic;
+ };
550C19E21804D226001DA380 = {
ProvisioningStyle = Manual;
};
08CE3D281E6E22A200DF1B78 /* stackshot */,
0D06BC5D1E8F08CB00C6EC2D /* mslutil */,
F2291F501FFEBB6A00161936 /* zlog */,
+ 3521C84C2245AA92001B3201 /* cpuctl */,
);
};
/* End PBXProject section */
);
runOnlyForDeploymentPostprocessing = 0;
};
+ 3521C8492245AA92001B3201 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 358407CE2245AC09006A0D8E /* cpuctl.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
550C19E31804D226001DA380 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
target = BACC1D0D1377B481007728F4 /* mean */;
targetProxy = 1812F1EC1C8F923900F3DC9E /* PBXContainerItemProxy */;
};
+ 358407D22245AD40006A0D8E /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 3521C84C2245AA92001B3201 /* cpuctl */;
+ targetProxy = 358407D12245AD40006A0D8E /* PBXContainerItemProxy */;
+ };
+ 358407D42245AD4B006A0D8E /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 3521C84C2245AA92001B3201 /* cpuctl */;
+ targetProxy = 358407D32245AD4B006A0D8E /* PBXContainerItemProxy */;
+ };
+ 358407D62245AD55006A0D8E /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = 3521C84C2245AA92001B3201 /* cpuctl */;
+ targetProxy = 358407D52245AD55006A0D8E /* PBXContainerItemProxy */;
+ };
550C19EF1804D2AD001DA380 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 550C19E21804D226001DA380 /* iosim */;
};
18732FE218CBD4A700275344 /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = BA4FD2FB1372FB710025925C /* BSD.xcconfig */;
+ baseConfigurationReference = C913CA2E2228B622000051A0 /* base.xcconfig */;
buildSettings = {
+ APPLY_RULES_IN_COPY_FILES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ PLIST_FILE_OUTPUT_FORMAT = binary;
SUPPORTED_PLATFORMS = "macosx watchos iphoneos";
WARNING_CFLAGS = (
"-Wall",
};
name = Debug;
};
+ 3521C8522245AA92001B3201 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ INSTALL_PATH = /usr/bin;
+ PRODUCT_NAME = cpuctl;
+ };
+ name = Release;
+ };
+ 3521C8532245AA92001B3201 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_COMMA = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INFINITE_RECURSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
+ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ INSTALL_PATH = /usr/bin;
+ PRODUCT_NAME = cpuctl;
+ };
+ name = Debug;
+ };
550C19EA1804D226001DA380 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
BA2DE91E1372FA9100D1913C /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = BA4FD2FB1372FB710025925C /* BSD.xcconfig */;
+ baseConfigurationReference = C913CA2E2228B622000051A0 /* base.xcconfig */;
buildSettings = {
+ APPLY_RULES_IN_COPY_FILES = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ PLIST_FILE_OUTPUT_FORMAT = binary;
SUPPORTED_PLATFORMS = "macosx watchos iphoneos";
WARNING_CFLAGS = (
"-Wall",
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ 3521C8512245AA92001B3201 /* Build configuration list for PBXNativeTarget "cpuctl" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 3521C8522245AA92001B3201 /* Release */,
+ 3521C8532245AA92001B3201 /* Debug */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
550C19E91804D226001DA380 /* Build configuration list for PBXNativeTarget "iosim" */ = {
isa = XCConfigurationList;
buildConfigurations = (
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
+ <key>BuildSystemType</key>
+ <string>Original</string>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
<string>alt-dyld</string>
<string>/usr/bin/yes</string>
</array>
- <key>EligibleResource</key>
- <string>deviceClass == 'iPhone'</string>
+ <key>RequiredResources</key>
+ <array>
+ <dict>
+ <key>Properties</key>
+ <string>deviceClass == 'iPhone'</string>
+ </dict>
+ </array>
<key>IgnoreCrashes</key>
<array>
</array>
if (stat_buf.st_size != 0)
{
- if ((file_addr = mmap(0, file_size, PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_FILE, fd, 0)) == (char*) -1)
+ file_addr = mmap(0, file_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FILE, fd, 0);
+ if (file_addr == MAP_FAILED)
{
printf("Error: Can't map file: %s\n", filename);
close(fd);
*/
count++;
- // Grow the size of codesc to store new entries.
+ /* Grow the size of codesc to store new entries. */
size_t total_count = codesc_idx + count;
code_type_t *new_codesc = (code_type_t *)realloc(codesc, (total_count) * sizeof(code_type_t));
codesc = new_codesc;
bzero((char *)(codesc + codesc_idx), count * sizeof(code_type_t));
- for (line = 1, j = 0; j < file_size && codesc_idx < total_count; codesc_idx++)
+ for (line = 1, j = 0; j < file_size && codesc_idx < total_count;
+ codesc_idx++)
{
/* Skip blank lines */
- while (file_addr[j] == '\n')
+ while (j < file_size && file_addr[j] == '\n')
{
j++;
line++;
/* We didn't find a debugid code - skip this line */
if (verbose_flag)
printf("Error: while parsing line %d, skip\n", line);
- while (file_addr[j] != '\n' && j < file_size)
+ while (j < file_size && file_addr[j] != '\n')
j++;
codesc_idx--;
line++;
}
/* Skip whitespace */
- while (file_addr[j] == ' ' || file_addr[j] == '\t')
+ while (j < file_size && (file_addr[j] == ' ' || file_addr[j] == '\t'))
+ {
j++;
+ }
+
+ if (j >= file_size)
+ {
+ break;
+ }
/* Get around old file that had count at the beginning */
if (file_addr[j] == '\n')
{
/* missing debugid string - skip */
if (verbose_flag)
- printf("Error: while parsing line %d, (0x%x) skip\n", line, codesc[codesc_idx].debugid);
+ {
+ printf("Error: while parsing line %d, (0x%x) skip\n", line,
+ codesc[codesc_idx].debugid);
+ }
j++;
codesc_idx--;
continue;
}
+ if (j >= file_size)
+ {
+ break;
+ }
+
/* Next is the debugid string terminated by a newline */
codesc[codesc_idx].debug_string = &file_addr[j];
/* Null out the newline terminator */
- while ((j < file_size) && (file_addr[j] != '\n'))
+ while (j < file_size && file_addr[j] != '\n')
+ {
j++;
+ }
+
+ if (j >= file_size)
+ {
+ break;
+ }
+
file_addr[j] = '\0'; /* File must be read-write */
j++;
line++;
TOOLCHAINS="${TOOLCHAINS}" \
xcrun -sdk "${SDKROOT}" xcodebuild install \
-target zic \
- -sdk "macosx" \
+ -sdk "macosxinternal" \
SRCROOT="${SRCROOT}" \
OBJROOT="${OBJROOT}" \
SYMROOT="${ZICHOST_SYMROOT}" \