14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER START
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * The contents of this file are subject to the terms of the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Common Development and Distribution License, Version 1.0 only
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * (the "License"). You may not use this file except in compliance
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * with the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * or http://www.opensolaris.org/os/licensing.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * See the License for the specific language governing permissions
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * and limitations under the License.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * When distributing Covered Code, include this CDDL HEADER in each
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * If applicable, add the following below this CDDL HEADER, with the
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * fields enclosed by brackets "[]" replaced with your own identifying
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * information: Portions Copyright [yyyy] [name of copyright owner]
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync *
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * CDDL HEADER END
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync * Use is subject to license terms.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct callinfo {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint64_t ts; /* timestamp of last syscall entry */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint64_t elapsed; /* total elapsed time in nanoseconds */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint64_t calls; /* number of calls made */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync size_t maxbytes; /* maximum byte count argument */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct callinfo i[string]; /* declare i as an associative array */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsyscall::read:entry, syscall::write:entry
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/pid == $1/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i[probefunc].ts = timestamp;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i[probefunc].calls++;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i[probefunc].maxbytes = arg2 > i[probefunc].maxbytes ?
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync arg2 : i[probefunc].maxbytes;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncsyscall::read:return, syscall::write:return
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/i[probefunc].ts != 0 && pid == $1/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i[probefunc].elapsed += timestamp - i[probefunc].ts;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncEND
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync{
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf(" calls max bytes elapsed nsecs\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf("------ ----- --------- -------------\n");
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf(" read %5d %9d %d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i["read"].calls, i["read"].maxbytes, i["read"].elapsed);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync printf(" write %5d %9d %d\n",
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync i["write"].calls, i["write"].maxbytes, i["write"].elapsed);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}