hotspot/agent/test/jdi/runjdb.sh
author sundar
Wed, 09 Jan 2013 22:32:40 +0530
changeset 16163 71f4cff209a9
parent 5547 f4b087cbb361
permissions -rw-r--r--
8005940: provide ant targets to get and update external test scripts Reviewed-by: jlaskey, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
#!/bin/sh
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
#
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
     3
# Copyright (c) 2002, 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
#  jdb is a .c file that seems to discard the setting of CLASSPATH.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
# So, we have to run jdb by calling java directly :-(
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
# License file for development version of dbx
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
export LM_LICENSE_FILE
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
doUsage()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
   cat <<EOF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
Usage:  runjdb.sh corefile -jdk jdk-pathname -sa sa-pathname
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    sa-pathname is the path of a JDI-SA build dir.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
EOF
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
jdk=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
javaArgs=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
args=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
sa=
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
while [ $# != 0 ] ; do
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    case $1 in
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
      -vv)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
        set -x
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
     -jdk)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
        jdk=$2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
        shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
     -sa)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
        sa=$2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
        shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
     -help | help)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
        doUsage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
        exit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
     -*)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
        javaArgs="$javaArgs $1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
     *)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
        if [ ! -z "$args" ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
            echo "Error: Only one core file or pid can be specified"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
            exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
        fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
        echo "$1" | grep -s '^[0-9]*$' > /dev/null
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
        if [ $? = 0 ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
            # it is a pid
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
            args="$args $1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
            echo "Error: A pid is not yet allowed"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
            exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
        else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
            # It is a core.        
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
            # We have to pass the name of the program that produced the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
            # core, and the core file itself.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
            args="$1"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
        fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
        ;;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
   esac
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
   shift
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
done
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
if [ -z "$jdk" ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    echo "Error:  -jdk jdk-pathname is required"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
if [ -z "$sa" ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    echo "Error:  -sa sa-pathname is required"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
if [ -z "$args" ] ; then
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    echo "Error:  a core file or pid must be specified"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
    exit 1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
fi
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
set -x
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
$jdk/bin/jdb -J-Xbootclasspath/a:$sa  -connect \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=$args,javaExecutable=$jdk/bin/java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#$jdk/bin/java -Xbootclasspath/a:$mmm/ws/merlin-sa/build/agent \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
#  com.sun.tools.example.debug.tty.TTY -connect \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
#  sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore,javaExecutable=$jdk/bin/java