jdk/src/sample/solaris/dtrace/hotspot_jni/hotspot_jni_calls_stat.d
author hseigel
Wed, 01 Mar 2017 08:00:02 -0500
changeset 46194 5596e6f63072
parent 25859 3317bb8137f4
permissions -rw-r--r--
8172307: Remove ununsed JVM API JVM_GetModuleByPackageName() Summary: Remove get_module_by_package_name() etc., and unneeded test. Reviewed-by: sspitsyn, gtriantafill
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
#!/usr/sbin/dtrace -Zs
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     4
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    17
 *   - Neither the name of Oracle nor the names of its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Usage:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *    1. hotspot_jni_calls_stat.d -c "java ..."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *    2. hotspot_jni_calls_stat.d -p JAVA_PID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * This script collects statistics about how many times particular JNI
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * method has been called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#pragma D option quiet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#pragma D option destructive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#pragma D option defaultargs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#pragma D option bufsize=16m
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#pragma D option aggrate=100ms
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
:::BEGIN
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    printf("BEGIN hotspot_jni tracing\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
hotspot_jni$target:::*-entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    JNI_CALLS ++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    @jni_calls[probename] = count();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
:::END
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    printa("%10@d %s\n", @jni_calls);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    printf("\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    printf("Total number of JNI calls: %d\n", JNI_CALLS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    printf("\nEND hotspot_jni tracing.\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
syscall::rexit:entry,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
syscall::exit:entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
/pid == $target/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
   exit(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
}