agent/test/jdi/serialvm.java

Mon, 28 Jul 2014 15:06:38 -0700

author
fzhinkin
date
Mon, 28 Jul 2014 15:06:38 -0700
changeset 6997
dbb05f6d93c4
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

8051344: JVM crashed in Compile::start() during method parsing w/ UseRTMDeopt turned on
Summary: call rtm_deopt() only if there were no compilation bailouts before.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 import com.sun.jdi.*;
    26 import com.sun.jdi.connect.*;
    28 import java.util.Map;
    29 import java.util.List;
    30 import java.util.Iterator;
    31 import java.io.IOException;
    34 /* This class is used to test multi VM connectivity feature of
    35  * SA/JDI. Accepts two PIDs as arguments. Connects to first VM
    36  *, disposes it, connects to second VM, disposes second VM.
    37  */
    40 public class serialvm {
    41     static AttachingConnector myPIDConn;
    42     static VirtualMachine vm1;
    43     static VirtualMachine vm2;
    44     static VirtualMachineManager vmmgr;
    46     public static void println(String msg) {
    47         System.out.println(msg);
    48     }
    50     private static void usage() {
    51         System.err.println("Usage: java serialvm <pid1> <pid2>");
    52         System.exit(1);
    53     }
    55     public static void main(String args[]) {
    56         vmmgr = Bootstrap.virtualMachineManager();
    57         List attachingConnectors = vmmgr.attachingConnectors();
    58         if (attachingConnectors.isEmpty()) {
    59             System.err.println( "ERROR: No attaching connectors");
    60             return;
    61         }
    62         Iterator myIt = attachingConnectors.iterator();
    63         while (myIt.hasNext()) {
    64             AttachingConnector tmpCon = (AttachingConnector)myIt.next();
    65             if (tmpCon.name().equals(
    66                 "sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
    67                 myPIDConn = tmpCon;
    68                 break;
    69             }
    70         }
    72         int pid1 = 0, pid2 = 0;
    73         String pidText = null;
    74         switch (args.length) {
    75         case (2):
    76             try {
    77                 pidText = args[0];
    78                 pid1 = Integer.parseInt(pidText);
    79                 System.out.println( "pid1: " + pid1);
    80                 pidText = args[1];
    81                 pid2 = Integer.parseInt(pidText);
    82                 System.out.println( "pid2: " + pid2);
    83             } catch (NumberFormatException e) {
    84                 println(e.getMessage());
    85                 usage();
    86             }
    87             break;
    88         default:
    89             usage();
    90         }
    92         // attach, dispose, attach2, dispose2 pattern
    93         // as opposed to attach1, attach2, dispose1, dispose2
    94         vm1 = attachPID(pid1);
    95         if (vm1 != null) {
    96             System.out.println("vm1: attached ok!");
    97             System.out.println(vm1.version());
    98             sagdoit mine = new sagdoit(vm1);
    99             mine.doAll();
   100         }
   101         if (vm1 != null) {
   102             vm1.dispose();
   103         }
   105         vm2 = attachPID(pid2);
   106         if (vm2 != null) {
   107             System.out.println("vm2: attached ok!");
   108             System.out.println(vm2.version());
   109             sagdoit mine = new sagdoit(vm2);
   110             mine.doAll();
   111         }
   114         if (vm2 != null) {
   115             vm2.dispose();
   116         }
   117     }
   119    private static VirtualMachine attachPID(int pid) {
   120         Map connArgs = myPIDConn.defaultArguments();
   121         System.out.println("connArgs = " + connArgs);
   122         VirtualMachine vm;
   123         Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
   124         connArg.setValue(Integer.toString(pid));
   126         try {
   127             vm = myPIDConn.attach(connArgs);
   128         } catch (IOException ee) {
   129             System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
   130             vm = null;
   131         } catch (IllegalConnectorArgumentsException ee) {
   132             System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
   133             vm = null;
   134         }
   135         return vm;
   136    }
   137 }

mercurial