agent/test/jdi/multivm.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

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

mercurial