summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authorgnn <gnn@FreeBSD.org>2012-07-11 16:27:02 +0000
committergnn <gnn@FreeBSD.org>2012-07-11 16:27:02 +0000
commit786ac825530572ff02b9440ed00f28096197f9b9 (patch)
treeeabb05d032e7a979640db2928991f11bb1d8758f /cddl
parentec38b41c3eecfc3b4fb8ebfac57ad414dd1aa654 (diff)
downloadFreeBSD-src-786ac825530572ff02b9440ed00f28096197f9b9.zip
FreeBSD-src-786ac825530572ff02b9440ed00f28096197f9b9.tar.gz
Initial commit of an I/O provider for DTrace on FreeBSD.
These probes are most useful when looking into the structures they provide, which are listed in io.d. For example: dtrace -n 'io:genunix::start { printf("%d\n", args[0]->bio_bcount); }' Note that the I/O systems in FreeBSD and Solaris/Illumos are sufficiently different that there is not a 1:1 mapping from scripts that work with one to the other. MFC after: 1 month
Diffstat (limited to 'cddl')
-rw-r--r--cddl/lib/libdtrace/Makefile1
-rw-r--r--cddl/lib/libdtrace/io.d178
2 files changed, 35 insertions, 144 deletions
diff --git a/cddl/lib/libdtrace/Makefile b/cddl/lib/libdtrace/Makefile
index 81396ff..bdd8acc 100644
--- a/cddl/lib/libdtrace/Makefile
+++ b/cddl/lib/libdtrace/Makefile
@@ -45,6 +45,7 @@ SRCS= dt_aggregate.c \
gmatch.c
DSRCS= errno.d \
+ io.d \
psinfo.d \
signal.d \
unistd.d
diff --git a/cddl/lib/libdtrace/io.d b/cddl/lib/libdtrace/io.d
index 0bd5a06..18a54af 100644
--- a/cddl/lib/libdtrace/io.d
+++ b/cddl/lib/libdtrace/io.d
@@ -27,114 +27,50 @@
#pragma ident "%Z%%M% %I% %E% SMI"
-#pragma D depends_on module unix
#pragma D depends_on provider io
-inline int B_BUSY = B_BUSY;
-#pragma D binding "1.0" B_BUSY
-inline int B_DONE = 0x00000200;
-#pragma D binding "1.0" B_DONE
-inline int B_ERROR = B_ERROR;
-#pragma D binding "1.0" B_ERROR
-inline int B_PAGEIO = B_PAGEIO;
-#pragma D binding "1.0" B_PAGEIO
-inline int B_PHYS = B_PHYS;
-#pragma D binding "1.0" B_PHYS
-inline int B_READ = B_READ;
-#pragma D binding "1.0" B_READ
-inline int B_WRITE = B_WRITE;
-#pragma D binding "1.0" B_WRITE
-inline int B_ASYNC = 0x00000004;
-#pragma D binding "1.0" B_ASYNC
-
-typedef struct bufinfo {
- int b_flags; /* buffer status */
- size_t b_bcount; /* number of bytes */
- caddr_t b_addr; /* buffer address */
- uint64_t b_lblkno; /* block # on device */
- uint64_t b_blkno; /* expanded block # on device */
- size_t b_resid; /* # of bytes not transferred */
- size_t b_bufsize; /* size of allocated buffer */
- caddr_t b_iodone; /* I/O completion routine */
- int b_error; /* expanded error field */
- dev_t b_edev; /* extended device */
-} bufinfo_t;
-
-#pragma D binding "1.0" translator
-translator bufinfo_t < struct buf *B > {
- b_flags = B->b_flags;
- b_addr = B->b_un.b_addr;
- b_bcount = B->b_bcount;
- b_lblkno = B->_b_blkno._f;
- b_blkno = sizeof (long) == 8 ? B->_b_blkno._f : B->_b_blkno._p._l;
- b_resid = B->b_resid;
- b_bufsize = B->b_bufsize;
- b_iodone = (caddr_t)B->b_iodone;
- b_error = B->b_error;
- b_edev = B->b_edev;
-};
-
typedef struct devinfo {
- int dev_major; /* major number */
- int dev_minor; /* minor number */
- int dev_instance; /* instance number */
- string dev_name; /* name of device */
- string dev_statname; /* name of device + instance/minor */
- string dev_pathname; /* pathname of device */
+ int dev_major; /* major number */
+ int dev_minor; /* minor number */
+ int dev_instance; /* instance number */
+ string dev_name; /* name of device */
+ string dev_statname; /* name of device + instance/minor */
+ string dev_pathname; /* pathname of device */
} devinfo_t;
#pragma D binding "1.0" translator
-translator devinfo_t < struct buf *B > {
- dev_major = B->b_dip != NULL ? getmajor(B->b_edev) :
- getmajor(B->b_file->v_vfsp->vfs_dev);
- dev_minor = B->b_dip != NULL ? getminor(B->b_edev) :
- getminor(B->b_file->v_vfsp->vfs_dev);
- dev_instance = B->b_dip == NULL ?
- getminor(B->b_file->v_vfsp->vfs_dev) :
- ((struct dev_info *)B->b_dip)->devi_instance;
- dev_name = B->b_dip == NULL ? "nfs" :
- stringof(`devnamesp[getmajor(B->b_edev)].dn_name);
- dev_statname = strjoin(B->b_dip == NULL ? "nfs" :
- stringof(`devnamesp[getmajor(B->b_edev)].dn_name),
- lltostr(B->b_dip == NULL ? getminor(B->b_file->v_vfsp->vfs_dev) :
- ((struct dev_info *)B->b_dip)->devi_instance == 0 &&
- ((struct dev_info *)B->b_dip)->devi_parent != NULL &&
- ((struct dev_info *)B->b_dip)->devi_parent->devi_node_name ==
- "pseudo" ? getminor(B->b_edev) :
- ((struct dev_info *)B->b_dip)->devi_instance));
- dev_pathname = B->b_dip == NULL ? "<nfs>" :
- ddi_pathname(B->b_dip, getminor(B->b_edev));
+translator devinfo_t < struct devstat *D > {
+ dev_major = D->device_number;
+ dev_minor = D->unit_number;
+ dev_instance = 0;
+ dev_name = stringof(D->device_name);
+ dev_statname = stringof(D->device_name);
+ dev_pathname = stringof(D->device_name);
};
-typedef struct fileinfo {
- string fi_name; /* name (basename of fi_pathname) */
- string fi_dirname; /* directory (dirname of fi_pathname) */
- string fi_pathname; /* full pathname */
- offset_t fi_offset; /* offset within file */
- string fi_fs; /* filesystem */
- string fi_mount; /* mount point of file system */
- int fi_oflags; /* open(2) flags for file descriptor */
-} fileinfo_t;
+typedef struct bufinfo {
+ int b_flags; /* flags */
+ long b_bcount; /* number of bytes */
+ caddr_t b_addr; /* buffer address */
+ uint64_t b_blkno; /* expanded block # on device */
+ uint64_t b_lblkno; /* block # on device */
+ size_t b_resid; /* # of bytes not transferred */
+ size_t b_bufsize; /* size of allocated buffer */
+/* caddr_t b_iodone; I/O completion routine */
+ int b_error; /* expanded error field */
+/* dev_t b_edev; extended device */
+} bufinfo_t;
#pragma D binding "1.0" translator
-translator fileinfo_t < struct buf *B > {
- fi_name = B->b_file == NULL ? "<none>" :
- B->b_file->v_path == NULL ? "<unknown>" :
- basename(cleanpath(B->b_file->v_path));
- fi_dirname = B->b_file == NULL ? "<none>" :
- B->b_file->v_path == NULL ? "<unknown>" :
- dirname(cleanpath(B->b_file->v_path));
- fi_pathname = B->b_file == NULL ? "<none>" :
- B->b_file->v_path == NULL ? "<unknown>" :
- cleanpath(B->b_file->v_path);
- fi_offset = B->b_offset;
- fi_fs = B->b_file == NULL ? "<none>" :
- stringof(B->b_file->v_op->vnop_name);
- fi_mount = B->b_file == NULL ? "<none>" :
- B->b_file->v_vfsp->vfs_vnodecovered == NULL ? "/" :
- B->b_file->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
- cleanpath(B->b_file->v_vfsp->vfs_vnodecovered->v_path);
- fi_oflags = 0;
+translator bufinfo_t < struct bio *B > {
+ b_flags = B->bio_flags;
+ b_bcount = B->bio_bcount;
+ b_addr = B->bio_data;
+ b_blkno = 0;
+ b_lblkno = 0;
+ b_resid = B->bio_resid;
+ b_bufsize = 0; /* XXX gnn */
+ b_error = B->bio_error;
};
/*
@@ -158,63 +94,17 @@ inline int O_APPEND = 0x0008;
#pragma D binding "1.1" O_APPEND
inline int O_CREAT = 0x0200;
#pragma D binding "1.1" O_CREAT
-inline int O_DSYNC = O_DSYNC;
-#pragma D binding "1.1" O_DSYNC
inline int O_EXCL = 0x0800;
#pragma D binding "1.1" O_EXCL
-inline int O_LARGEFILE = O_LARGEFILE;
-#pragma D binding "1.1" O_LARGEFILE
inline int O_NOCTTY = 0x8000;
#pragma D binding "1.1" O_NOCTTY
inline int O_NONBLOCK = 0x0004;
#pragma D binding "1.1" O_NONBLOCK
inline int O_NDELAY = 0x0004;
#pragma D binding "1.1" O_NDELAY
-inline int O_RSYNC = O_RSYNC;
-#pragma D binding "1.1" O_RSYNC
inline int O_SYNC = 0x0080;
#pragma D binding "1.1" O_SYNC
inline int O_TRUNC = 0x0400;
#pragma D binding "1.1" O_TRUNC
-inline int O_XATTR = O_XATTR;
-#pragma D binding "1.1" O_XATTR
-
-#pragma D binding "1.1" translator
-translator fileinfo_t < struct file *F > {
- fi_name = F == NULL ? "<none>" :
- F->f_vnode->v_path == NULL ? "<unknown>" :
- basename(cleanpath(F->f_vnode->v_path));
- fi_dirname = F == NULL ? "<none>" :
- F->f_vnode->v_path == NULL ? "<unknown>" :
- dirname(cleanpath(F->f_vnode->v_path));
- fi_pathname = F == NULL ? "<none>" :
- F->f_vnode->v_path == NULL ? "<unknown>" :
- cleanpath(F->f_vnode->v_path);
- fi_offset = F == NULL ? 0 : F->f_offset;
- fi_fs = F == NULL ? "<none>" : stringof(F->f_vnode->v_op->vnop_name);
- fi_mount = F == NULL ? "<none>" :
- F->f_vnode->v_vfsp->vfs_vnodecovered == NULL ? "/" :
- F->f_vnode->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
- cleanpath(F->f_vnode->v_vfsp->vfs_vnodecovered->v_path);
- fi_oflags = F == NULL ? 0 : F->f_flag + (int)FOPEN;
-};
-
-inline fileinfo_t fds[int fd] = xlate <fileinfo_t> (
- fd >= 0 && fd < curthread->t_procp->p_user.u_finfo.fi_nfiles ?
- curthread->t_procp->p_user.u_finfo.fi_list[fd].uf_file : NULL);
-#pragma D attributes Stable/Stable/Common fds
-#pragma D binding "1.1" fds
-#pragma D binding "1.2" translator
-translator fileinfo_t < struct vnode *V > {
- fi_name = V->v_path == NULL ? "<unknown>" :
- basename(cleanpath(V->v_path));
- fi_dirname = V->v_path == NULL ? "<unknown>" :
- dirname(cleanpath(V->v_path));
- fi_pathname = V->v_path == NULL ? "<unknown>" : cleanpath(V->v_path);
- fi_fs = stringof(V->v_op->vnop_name);
- fi_mount = V->v_vfsp->vfs_vnodecovered == NULL ? "/" :
- V->v_vfsp->vfs_vnodecovered->v_path == NULL ? "<unknown>" :
- cleanpath(V->v_vfsp->vfs_vnodecovered->v_path);
-};
OpenPOWER on IntegriCloud