hotspot/agent/test/jdi/runsa.sh
author minqi
Mon, 24 Sep 2012 12:44:00 -0700
changeset 13873 7b72e3873785
parent 5547 f4b087cbb361
permissions -rw-r--r--
6879063: SA should use hsdis for disassembly Summary: We should in SA to use hsdis for it like the JVM does to replace the current java based disassembler. Reviewed-by: twisti, jrose, sla Contributed-by: yumin.qi@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
#!/bin/ksh
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
#
13873
7b72e3873785 6879063: SA should use hsdis for disassembly
minqi
parents: 5547
diff changeset
     3
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
#
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
# This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
# under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
# published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
#
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
# This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
# version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
# accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
#
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
# You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
# 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
#
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
# or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    22
# questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
#  
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
#
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
# This jdk must be hopper or better; it must have the 
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
# SA connectors in VirtualMachineManagerImpl.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
jdk=/java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
#jdk=/net/mmm/export/mmm/jdk1.4fcs.sa
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
doUsage()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
    cat <<EOF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
    Run sagclient.class using Serviceability Agent to talk to a corefile/pid/debugserver.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
    Usage:  runsa.sh [-jdk <jdk-pathname>] [-jdb] [ -jdbx ] [ -d64 ] [ -remote ] [ pid | corefile | debugserver ]
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    -jdk means to use that jdk.  Default is 1.4.1/latest.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    -jdbx means to run it under jdbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    -jdb means to connect using jdb instead of the sagclient program.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    -remote debugserver means you want to connect to a remote debug server
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    The corefile must have been produced by the same java as is running SA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
EOF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
if [ $# = 0 ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    doUsage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
# License file for development version of dbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
#LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
#export LM_LICENSE_FILE
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
do=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
args=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
theClass=sagclient
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
javaArgs=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
while [ $# != 0 ] ; do
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
    case $1 in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
      -vv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
        set -x
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
     -jdk)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
        jdk=$2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
     -jdbx)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
        do=jdbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
     -jdb)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
        do=jdb
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
     -help | help)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
        doUsage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
        exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
     -d64) 
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        d64=-d64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
     -remote)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
        shift 
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
        args="$1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
        do=remote
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
     -*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
        javaArgs="$javaArgs $1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
     *)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        echo "$1" | grep -s '^[0-9]*$' > /dev/null
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
        if [ $? = 0 ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
            # it is a pid
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
            args="$args $1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
        else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
            # It is a core.        
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
            # We have to pass the name of the program that produced the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
            # core, and the core file itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
            args="$jdk/bin/java $1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
   esac
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
   shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
done
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
if [ -z "$jdk" ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    error "--Error: runsa.sh:  Must specify -jdk <jdk-pathname>."
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    error "         Do runsa.sh -help for more info"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
set -x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
# If jjh makes this, then the classes are in .../build/agent.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
# if someone else does, they are in  .
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
classesDir=../../../../../../build/agent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
if [ ! -r $classesDir ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    classesDir=.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    if [ ! -r $classesDir ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
        echo "-- Error: runsa.sh can't find the SA classes"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
        exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
#javacp="/net/mmm/export/mmm/ws/sabaseline/build/solaris/solaris_sparc_compiler1/generated/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
extraArgs="-showversion $javaArgs"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
#extraArgs="-DdbxSvcAgentDSOPathName=/net/mmm/export/mmm/ws/m/b2/sa/src/os/solaris/agent/64bit/libsvc_agent_dbx.so $extraArgs"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
#extraArgs="-DdbxSvcAgentDSOPathName=/net/jano.eng/export/disk05/hotspot/sa/solaris/sparcv9/lib/libsvc_agent_dbx.so $extraArgs"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
mkdir -p workdir
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
if [ sagclient.java -nt ./workdir/sagclient.class ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
    $jdk/bin/javac -d ./workdir -classpath $javacp sagclient.java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    if [ $? != 0 ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
        exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
    $jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    if [ $? != 0 ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
        exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
if [ "$do" = jdbx ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    set -x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    dbx=/net/sparcworks.eng/export/set/sparcworks2/dbx_70_nightly/dev/buildbin/Derived-sparc-S2-opt/bin/dbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    # Have to do this export for jdbx to work.  -cp and -classpath don't work.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    CLASSPATH=$javacp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
    export CLASSPATH
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    #extraArgs="-Djava.class.path=$mhs/../sa/build/agent sun.jvm.hotspot.HSDB $*"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    jvm_invocation="$jdk/bin/java -Xdebug \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
               -Dsun.boot.class.path=$jdk/classes \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
               $extraArgs"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    #export jvm_invocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    JAVASRCPATH=$mhs/../sa/src/share/vm/agent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    export JAVASRCPATH
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    #operand is pathname of .class file, eg ./jj.class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    echo run $args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    clss=`echo $theClass | sed -e 's@\.@/@'`
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    if [ -r ./workdir/$clss.class ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
        # kludge for running sagclient
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
        $dbx  ./workdir/$clss.class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
        # kludge for running HSDB
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
        $dbx  $mhs/../sa/build/agent/$clss.class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
elif [ "$do" = jdb ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    # This hasn't been tested.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    $jdk/bin/jdb -J-Xbootclasspath/a:$classesDir -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
elif [ "$do" = remote ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
    $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    $jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
fi