Skip to content

Commit

Permalink
OSX 10.12.0, Tar File: dtrace-209
Browse files Browse the repository at this point in the history
  • Loading branch information
gvnn3 committed Nov 26, 2016
1 parent 774d7a7 commit 16d447a
Show file tree
Hide file tree
Showing 379 changed files with 5,681 additions and 1,654 deletions.
3 changes: 1 addition & 2 deletions DTTk/Disk/iopattern
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/ksh
##!/usr/bin/ksh
#!/bin/bash
#
# iopattern - print disk I/O pattern.
# Written using DTrace (Solaris 10 3/05).
Expand Down
2 changes: 1 addition & 1 deletion DTTk/Proc/lastwords
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ print "Tracing... Waiting for $command to exit..."
}
/* SOLARIS: proc::proc_exit:exit */
proc::exit1:exit
proc:::exit
/execname == strstr(execname, $$1) || $$1 == strstr($$1, execname)/
{
/* print, erm, footer */
Expand Down
12 changes: 10 additions & 2 deletions DTTk/Proc/rwbypid.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,20 @@ dtrace:::BEGIN
printf("Tracing... Hit Ctrl-C to end.\n");
}

syscall::*read*:entry
syscall::read:entry,
syscall::read_nocancel:entry,
syscall::readv_nocancel:entry,
syscall::pread_nocancel:entry
{
@calls[pid, execname, "R"] = sum(arg0);
}

syscall::*write*:entry
syscall::write:entry,
syscall::writev:entry,
syscall::pwrite:entry,
syscall::write_nocancel:entry,
syscall::writev_nocancel:entry,
syscall::pwrite_nocancel:entry
{
@calls[pid, execname, "W"] = sum(arg0);
}
Expand Down
6 changes: 3 additions & 3 deletions DTTk/Proc/rwbytype.d
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ fbt::VNOP_READ:entry,
fbt::VNOP_WRITE:entry
{
self->type = xlate <struct vtype2str *>(((struct vnode *)arg0)->v_type)->code;
self->size = ((struct uio *)arg1)->uio_resid;
self->size = ((struct uio *)arg1)->uio_resid_64;
self->uiop = (struct uio *)arg1;
}

fbt::VNOP_READ:return
/self->uiop/
{
this->resid = self->uiop->uio_resid;
this->resid = self->uiop->uio_resid_64;
@bytes[pid, execname, self->type, "R"] = sum(self->size - this->resid);
self->type = 0;
self->size = 0;
Expand All @@ -84,7 +84,7 @@ fbt::VNOP_READ:return
fbt::VNOP_WRITE:return
/self->uiop/
{
this->resid = self->uiop->uio_resid;
this->resid = self->uiop->uio_resid_64;
@bytes[pid, execname, self->type, "W"] = sum(self->size - this->resid);
self->type = 0;
self->size = 0;
Expand Down
3 changes: 1 addition & 2 deletions DTTk/Proc/sampleproc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/ksh
# #!/usr/bin/ksh
#!/bin/bash
#
# sampleproc - sample processes on the CPUs.
# Written using DTrace (Solaris 10 3/05).
Expand Down
3 changes: 1 addition & 2 deletions DTTk/System/topsyscall
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/ksh
# #!/usr/bin/ksh
#!/bin/bash
#
# topsyscall - display top syscalls by syscall name.
# Written using DTrace (Solaris 10 3/05).
Expand Down
98 changes: 96 additions & 2 deletions DTTk/dtruss
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,17 @@ dtrace='
OPT_cpu ? printf("%6s ","CPU") : 1;
printf("SYSCALL(args) \t\t = return\n");
/* Apple: Names of top-level sysctl MIBs */
sysctl_first[0] = "CTL_UNSPEC";
sysctl_first[1] = "CTL_KERN";
sysctl_first[2] = "CTL_VM";
sysctl_first[3] = "CTL_VFS";
sysctl_first[4] = "CTL_NET";
sysctl_first[5] = "CTL_DEBUG";
sysctl_first[6] = "CTL_HW";
sysctl_first[7] = "CTL_MACHDEP";
sysctl_first[9] = "CTL_MAXID";
/* globals */
trackedpid[pid] = 0;
self->child = 0;
Expand Down Expand Up @@ -254,7 +265,10 @@ dtrace='
syscall::linkat:entry,
syscall::fchownat:entry,
syscall::renameat:entry,
syscall::faccessat:entry
syscall::sysctl:entry,
syscall::sysctlbyname:entry,
syscall::faccessat:entry,
syscall::kdebug_trace64:entry
/(OPT_command && pid == $target) ||
(OPT_pid && pid == PID) ||
(OPT_name && NAME == strstr(NAME, execname)) ||
Expand Down Expand Up @@ -704,7 +718,87 @@ dtrace='
self->arg3 = 0;
}
/* print select with 5 arguments */
/* Apple: print the arguments passed to sysctl */
syscall::sysctl:return
/self->start/
{
/* calculate elapsed time */
this->elapsed = timestamp - self->start;
self->start = 0;
this->cpu = vtimestamp - self->vstart;
self->vstart = 0;
self->code = errno == 0 ? "" : "Err#";
/* print optional fields */
/* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */
OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1;
OPT_relative ? printf("%8d ",vtimestamp/1000) : 1;
OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1;
OPT_cpu ? printf("%6d ",this->cpu/1000) : 1;
/* print main data */
mib = copyin(self->arg0, self->arg1 * sizeof(int));
mib1 = *(int *)mib;
mib2 = *((int *)mib + 1);
printf("%s(", probefunc);
printf("[%s, ", (self->arg1 > 0) ? ((*(int *)mib > 0 && *(int *)mib < 9) ? sysctl_first[mib1] : "unknown") : 0);
printf("%d, %d, %d, %d, %d] (%d), ",
(self->arg1 > 1) ? *((int *)mib + 1) : 0,
(self->arg1 > 2) ? *((int *)mib + 2) : 0,
(self->arg1 > 3) ? *((int *)mib + 3) : 0,
(self->arg1 > 4) ? *((int *)mib + 4) : 0,
(self->arg1 > 5) ? *((int *)mib + 5) : 0,
self->arg1);
printf("0x%X, 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",
self->arg2, self->arg3, self->arg4, self->arg5,
(int)arg0, self->code, (int)errno);
OPT_stack ? ustack() : 1;
OPT_stack ? trace("\n") : 1;
self->arg0 = 0;
self->arg1 = 0;
self->arg2 = 0;
self->arg3 = 0;
self->arg4 = 0;
self->arg5 = 0;
}
/* Apple: print the string provided to sysctlbyname */
syscall::sysctlbyname:return
/self->start/
{
/* calculate elapsed time */
this->elapsed = timestamp - self->start;
self->start = 0;
this->cpu = vtimestamp - self->vstart;
self->vstart = 0;
self->code = errno == 0 ? "" : "Err#";
/* print optional fields */
/* OPT_printid ? printf("%5d/%d: ",pid,tid) : 1; */
OPT_printid ? printf("%5d/0x%x: ",pid,tid) : 1;
OPT_relative ? printf("%8d ",vtimestamp/1000) : 1;
OPT_elapsed ? printf("%7d ",this->elapsed/1000) : 1;
OPT_cpu ? printf("%6d ",this->cpu/1000) : 1;
/* print main data */
printf("%s(%s, 0x%X, 0x%X, 0x%X, 0x%X)\t\t = %d %s%d\n",probefunc,
copyinstr(self->arg0),
self->arg1,self->arg2,self->arg3,self->arg4,(int)arg0,self->code,(int)errno);
OPT_stack ? ustack() : 1;
OPT_stack ? trace("\n") : 1;
self->arg0 = 0;
self->arg1 = 0;
self->arg2 = 0;
self->arg3 = 0;
self->arg4 = 0;
}
/* print 5 arguments */
syscall::kdebug_trace64:return,
syscall::select:return
/self->start/
{
Expand Down
57 changes: 57 additions & 0 deletions cmd/dtrace_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
#include <sys/sysctl.h>
#include <pthread.h>

#include <System/sys/csr.h>
#include <TargetConditionals.h>

typedef struct dtrace_cmd {
void (*dc_func)(struct dtrace_cmd *); /* function to compile arg */
dtrace_probespec_t dc_spec; /* probe specifier context */
Expand Down Expand Up @@ -1389,6 +1392,33 @@ go(void)
}
}

#define DTRACE_PRIORITY_FOREGROUND 47

static void
set_sched_policy() {
int policy, err;
struct sched_param param;

err = pthread_getschedparam(pthread_self(), &policy, &param);
if (err) {
notice("could not set thread priority: cannot retrieve thread scheduling parameters");
return;
}

param.sched_priority = DTRACE_PRIORITY_FOREGROUND;

err = pthread_setschedparam(pthread_self(), policy, &param);
if (err) {
notice("could not set thread priority to %d", param.sched_priority);
}

err = pthread_set_fixedpriority_self();
if (err) {
notice("could not set thread scheduling priority to fixed");
}

}

/*ARGSUSED*/
static void
intr(int signo)
Expand Down Expand Up @@ -1549,6 +1579,22 @@ main(int argc, char *argv[])
}
/* NOTREACHED */

case 'x':
if ((p = strchr(optarg, '=')) != NULL)
*p++ = '\0';
/*
* At that stage, only parse disallow_dsym
* that we need to be set before dtrace_open
*/

if (strcmp(optarg, "disallow_dsym") == 0) {
_dtrace_disallow_dsym = 1;
}
// Restore the option string
if (p != NULL)
*(--p) = '=';

break;
default:
if (strchr(DTRACE_OPTSTR, c) == NULL)
return (usage(stderr));
Expand All @@ -1575,6 +1621,12 @@ main(int argc, char *argv[])
if (g_mode == DMODE_VERS)
return (printf("%s: %s\n", g_pname, _dtrace_version) <= 0);

#if !TARGET_OS_EMBEDDED
if (g_mode != DMODE_HEADER && csr_check(CSR_ALLOW_UNRESTRICTED_DTRACE) != 0) {
notice("system integrity protection is on, some features will not be available\n");
}
#endif

/*
* D compiler target_arch is current_kernel_arch() by default.
* Can be set explicitly by "-arch".
Expand Down Expand Up @@ -2049,6 +2101,11 @@ main(int argc, char *argv[])
if (g_total == 0 && !g_grabanon && !(g_cflags & DTRACE_C_ZDEFS))
dfatal("no probes %s\n", g_cmdc ? "matched" : "specified");

/**
* Set our scheduling policy
*/
set_sched_policy();

/*
* Start tracing. Once we dtrace_go(), reload any options that affect
* our globals in case consuming anonymous state has changed them.
Expand Down
9 changes: 0 additions & 9 deletions config/common.xcconfig

This file was deleted.

2 changes: 0 additions & 2 deletions config/dtrace.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "common.xcconfig"

// On OSX, binaries are not built fat.
VALID_ARCHS[sdk=macosx*] = $(ARCHS_STANDARD_64_BIT)
ARCHS[sdk=macosx*] = $(ARCHS_STANDARD_64_BIT)
4 changes: 1 addition & 3 deletions config/plockstat.xcconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "common.xcconfig"

// On OSX, binaries are not built fat.
VALID_ARCHS[sdk=macosx*] = $(ARCHS_STANDARD_64_BIT)
ARCHS[sdk=macosx*] = $(ARCHS_STANDARD_64_BIT)
ARCHS[sdk=macosx*] = $(ARCHS_STANDARD_64_BIT)
2 changes: 1 addition & 1 deletion darwin_shim.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ gethrtime(void)
start = mach_absolute_time();
}

elapsed = mach_absolute_time() - start;
elapsed = mach_absolute_time();

// Convert to nanoseconds.
// return (elapsed * (uint64_t)sTimebaseInfo.numer)/(uint64_t)sTimebaseInfo.denom;
Expand Down
7 changes: 5 additions & 2 deletions dtrace.1
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Due to the kernel facility it uses to operate, the \fIdtrace\fP command requires
.br
.P
Users new to DTrace are encouraged to read:
\fIHow to Use Oracle Solaris DTrace from Oracle Solaris and OpenSolaris System\fP. Oracle, 2010. Available on the web at http://www.oracle.com/technetwork/server-storage/solaris10/solaris-dtrace-wp-167895.pdf
\fIHow to Use Oracle Solaris DTrace from Oracle Solaris and OpenSolaris
System\fP. Oracle, 2010. Available on the web at http://www.oracle.com/technetwork/server-storage/solaris/solaris-dtrace-wp-167895.pdf
.SH DESCRIPTION
The \fIdtrace\fP command provides a generic interface to all of the essential services provided by the DTrace facility, including:
." If I wanted numbered lists, I'd use .IP n[step] 3 for the first and .IP n+[step] for each other entry
Expand All @@ -62,7 +63,9 @@ Set dtrace's target data model. See \fIarch\fR(1) for a list of currently suppor
Claim anonymous tracing state and display the traced data. You can combine the \fB\-a\fP option with the \fB\-e\fP option to force \fIdtrace\fP to exit immediately after consuming the anonymous tracing state rather than continuing to wait for new data.
.TP
.B \-A
Generate a plist(5) of directives for anonymous tracing. If the \fB\-A\fP option is specified, \fIdtrace\fP compiles any D programs specified using the \fB\-s\fP option or on the command-line and constructs a plist(5) of dtrace directives to enable the specified probes for anonymous trcaing and then exits. By default, \fIdtrace\fP attempts to store the plist to the file /System/Library/Extensions/dtrace_dof.kext/Contents/Info.plist. This behavior can be modified using the \fB\-o\fP option to specify an alternate output file.
Generate a plist(5) of directives for anonymous tracing. If the \fB\-A\fP
option is specified, \fIdtrace\fP compiles any D programs specified using the
\fB\-s\fP option or on the command-line and constructs a plist(5) of dtrace directives to enable the specified probes for anonymous tracing and then exits. By default, \fIdtrace\fP attempts to store the plist to the file /System/Library/Extensions/dtrace_dof.kext/Contents/Info.plist. This behavior can be modified using the \fB\-o\fP option to specify an alternate output file.
.TP
.B \-b
Set principal trace buffer size. The trace buffer size can include any of the size suffixes \fBk\fP, \fBm\fP, \fBg\fP, or \fBt\fP. If the buffer space cannot be allocated, \fIdtrace\fP attempts to reduce the buffer size or exit depending on the setting of the bufresize property.
Expand Down
Loading

0 comments on commit 16d447a

Please sign in to comment.