]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Proc/mmapfiles.d
MFC r368207,368607:
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Proc / mmapfiles.d
1 #!/usr/sbin/dtrace -s
2 /*
3  * mmapfiles.d - mmap'd files by process.
4  *               Written using DTrace (Solaris 10 3/05).
5  *
6  * $Id: mmapfiles.d 14 2007-09-11 08:03:35Z brendan $
7  *
8  * USAGE:       mmapfiles.d    # hit Ctrl-C to end sample
9  *
10  * FIELDS:
11  *              MMAPS           number of mmaps
12  *              CMD             process name
13  *              PATHNAME        pathname of mmap'd file
14  *
15  * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
16  *
17  * CDDL HEADER START
18  *
19  *  The contents of this file are subject to the terms of the
20  *  Common Development and Distribution License, Version 1.0 only
21  *  (the "License").  You may not use this file except in compliance
22  *  with the License.
23  *
24  *  You can obtain a copy of the license at Docs/cddl1.txt
25  *  or http://www.opensolaris.org/os/licensing.
26  *  See the License for the specific language governing permissions
27  *  and limitations under the License.
28  *
29  * CDDL HEADER END
30  *
31  * 18-Oct-2005  Brendan Gregg   Created this.
32  * 20-Apr-2006     "      "     Last update.
33  */
34
35 #pragma D option quiet
36
37 dtrace:::BEGIN
38 {
39         printf("Tracing... Hit Ctrl-C to end.\n");
40 }
41
42 syscall::mmap:entry
43 /(int)arg4 > 0/
44 {
45         /*
46          * Fetch filename
47          */
48         this->filep = curthread->t_procp->p_user.u_finfo.fi_list[arg4].uf_file;
49         this->vnodep = this->filep != 0 ? this->filep->f_vnode : 0;
50         self->vpath = this->vnodep ? (this->vnodep->v_path != 0 ?
51             cleanpath(this->vnodep->v_path) : "<unknown>") : "<unknown>";
52
53         /* Store Details */
54         @hits[execname, self->vpath] = count();
55 }
56
57 dtrace:::END
58 {
59         /* Print Details */
60         printf("%5s %-16s %s\n", "MMAPS", "CMD", "PATHNAME");
61         printa("%@5d %-16s %s\n", @hits);
62 }