agent/test/jdi/SASanityChecker.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, 2005, 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 sun.jvm.hotspot.tools.*;
duke@435 26 import sun.jvm.hotspot.runtime.*;
duke@435 27 import java.io.*;
duke@435 28 import java.util.*;
duke@435 29 import java.util.jar.*;
duke@435 30
duke@435 31 /**
duke@435 32 This is a sanity checking tool for Serviceability Agent. To use this class,
duke@435 33 refer to sasanity.sh script in the current directory.
duke@435 34 */
duke@435 35
duke@435 36 public class SASanityChecker extends Tool {
duke@435 37 private static final String saJarName;
duke@435 38 private static final Map c2types;
duke@435 39
duke@435 40 static {
duke@435 41 saJarName = System.getProperty("SASanityChecker.SAJarName", "sa-jdi.jar");
duke@435 42 c2types = new HashMap();
duke@435 43 Object value = new Object();
duke@435 44 c2types.put("sun.jvm.hotspot.code.ExceptionBlob", value);
duke@435 45 c2types.put("sun.jvm.hotspot.code.DeoptimizationBlob", value);
duke@435 46 c2types.put("sun.jvm.hotspot.code.UncommonTrapBlob", value);
duke@435 47
duke@435 48 }
duke@435 49
duke@435 50 public void run() {
duke@435 51 String classPath = System.getProperty("java.class.path");
duke@435 52 StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
duke@435 53 String saJarPath = null;
duke@435 54 while (st.hasMoreTokens()) {
duke@435 55 saJarPath = st.nextToken();
duke@435 56 if (saJarPath.endsWith(saJarName)) {
duke@435 57 break;
duke@435 58 }
duke@435 59 }
duke@435 60
duke@435 61 if (saJarPath == null) {
duke@435 62 throw new RuntimeException(saJarName + " is not the CLASSPATH");
duke@435 63 }
duke@435 64
duke@435 65 String cpuDot = "." + VM.getVM().getCPU() + ".";
duke@435 66 String platformDot = "." + VM.getVM().getOS() + "_" + VM.getVM().getCPU() + ".";
duke@435 67 boolean isClient = VM.getVM().isClientCompiler();
duke@435 68
duke@435 69 try {
duke@435 70 FileInputStream fis = new FileInputStream(saJarPath);
duke@435 71 JarInputStream jis = new JarInputStream(fis);
duke@435 72 JarEntry je = null;
duke@435 73 while ( (je = jis.getNextJarEntry()) != null) {
duke@435 74 String entryName = je.getName();
duke@435 75 int dotClassIndex = entryName.indexOf(".class");
duke@435 76 if (dotClassIndex == -1) {
duke@435 77 // skip non-.class stuff
duke@435 78 continue;
duke@435 79 }
duke@435 80
duke@435 81 entryName = entryName.substring(0, dotClassIndex).replace('/', '.');
duke@435 82
duke@435 83 // skip debugger, asm classes, type classes and jdi binding classes
duke@435 84 if (entryName.startsWith("sun.jvm.hotspot.debugger.") ||
duke@435 85 entryName.startsWith("sun.jvm.hotspot.asm.") ||
duke@435 86 entryName.startsWith("sun.jvm.hotspot.type.") ||
duke@435 87 entryName.startsWith("sun.jvm.hotspot.jdi.") ) {
duke@435 88 continue;
duke@435 89 }
duke@435 90
duke@435 91 String runtimePkgPrefix = "sun.jvm.hotspot.runtime.";
duke@435 92 int runtimeIndex = entryName.indexOf(runtimePkgPrefix);
duke@435 93 if (runtimeIndex != -1) {
duke@435 94 // look for further dot. if there, it has to be sub-package.
duke@435 95 // in runtime sub-packages include only current platform classes.
duke@435 96 if (entryName.substring(runtimePkgPrefix.length() + 1, entryName.length()).indexOf('.') != -1) {
duke@435 97 if (entryName.indexOf(cpuDot) == -1 &&
duke@435 98 entryName.indexOf(platformDot) == -1) {
duke@435 99 continue;
duke@435 100 }
duke@435 101 }
duke@435 102 }
duke@435 103
duke@435 104 if (isClient) {
duke@435 105 if (c2types.get(entryName) != null) {
duke@435 106 continue;
duke@435 107 }
duke@435 108 } else {
duke@435 109 if (entryName.equals("sun.jvm.hotspot.c1.Runtime1")) {
duke@435 110 continue;
duke@435 111 }
duke@435 112 }
duke@435 113
duke@435 114 System.out.println("checking " + entryName + " ..");
duke@435 115 // force init of the class to uncover any vmStructs mismatch
duke@435 116 Class.forName(entryName);
duke@435 117 }
duke@435 118 } catch (Exception exp) {
duke@435 119 System.out.println();
duke@435 120 System.out.println("FAILED");
duke@435 121 System.out.println();
duke@435 122 throw new RuntimeException(exp.getMessage());
duke@435 123 }
duke@435 124 System.out.println();
duke@435 125 System.out.println("PASSED");
duke@435 126 System.out.println();
duke@435 127 }
duke@435 128
duke@435 129 public static void main(String[] args) {
duke@435 130 SASanityChecker checker = new SASanityChecker();
duke@435 131 checker.start(args);
duke@435 132 checker.stop();
duke@435 133 }
duke@435 134 }

mercurial