8158050: Remove SA-JDI
Remove SA-JDI Reviewed-by: alanb, dsamersoff
This commit is contained in:
parent
0a3a2b861b
commit
3baf6b1f72
@ -1,38 +0,0 @@
|
||||
The HotSpot Serviceability Agent (SA) is a debugger for hotspot core
|
||||
dumps and hung processes. There is a read-only JDI (Java Debugger
|
||||
Interface) implementation on top of SA. This is part of JDK product and
|
||||
the classes are in $JDK/tools/sa-jdi.jar.
|
||||
|
||||
In addition, there are few serviceability tools in $JDK/bin, namely,
|
||||
jstack (java stack trace tool), jmap (heap tool), jinfo (Java config
|
||||
tool) and jsadebugd. The classes for these are also in sa-jdi.jar
|
||||
file. sa-jdi.jar file is built along with hotspot (libjvm.so) on Solaris
|
||||
and Linux platforms. On Windows platform, SA-JDI is not included and
|
||||
serviceability tools do not use SA.
|
||||
|
||||
Apart from these, HotSpot SA consists of a number of tools that are
|
||||
*not* included in JDK product bits.
|
||||
|
||||
The sources and makefile for all-of-SA (including non-productized stuff)
|
||||
are under $HOTSPOT_WS/agent directory. The makefile $HOTSPOT/agent/make
|
||||
directory and shell scripts (and batch files) are used to build and run
|
||||
SA non-product tools. There is also documentation of SA under
|
||||
$HOTSPOT/agent/doc directory.
|
||||
|
||||
To build complete SA, you need to have Rhino Mozilla jar (js.jar)
|
||||
version 1.5R5 under $HOTSPOT/agent/src/share/lib directory. Rhino is
|
||||
JavaScript interpreter written in Java. Rhino is used to implement SA
|
||||
features such as
|
||||
|
||||
* SA command line debugger's JavaScript interface
|
||||
- refer to $HOTSPOT/agent/doc/clhsdb.html
|
||||
- refer to $HOTSPOT/agent/doc/jsdb.html
|
||||
* SA simple object query language (SOQL)
|
||||
- language to query Java heap.
|
||||
|
||||
Rhino's "js.jar" is not included in hotspot source bundles. You need to
|
||||
download it from http://www.mozilla.org/rhino/download.html.
|
||||
|
||||
Without js.jar, $HOTSPOT/agent/make/Makefile will fail to build. But,
|
||||
note that sa-jdi.jar containing the productized portions of SA will
|
||||
still be built when you build hotspot JVM.
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,12 +28,8 @@ module jdk.hotspot.agent {
|
||||
requires java.desktop;
|
||||
requires java.rmi;
|
||||
requires java.scripting;
|
||||
requires jdk.jdi;
|
||||
|
||||
// RMI needs to serialize types in this package
|
||||
exports sun.jvm.hotspot.debugger.remote to java.rmi;
|
||||
provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SACoreAttachingConnector;
|
||||
provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SADebugServerAttachingConnector;
|
||||
provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SAPIDAttachingConnector;
|
||||
|
||||
}
|
||||
|
@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.Array;
|
||||
import sun.jvm.hotspot.runtime.BasicType;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
|
||||
public class ArrayReferenceImpl extends ObjectReferenceImpl
|
||||
implements ArrayReference
|
||||
{
|
||||
private int length;
|
||||
ArrayReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Array aRef) {
|
||||
super(aVm, aRef);
|
||||
length = (int) aRef.getLength();
|
||||
}
|
||||
|
||||
ArrayTypeImpl arrayType() {
|
||||
return (ArrayTypeImpl)type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array length.
|
||||
*/
|
||||
public int length() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public Value getValue(int index) {
|
||||
List list = getValues(index, 1);
|
||||
return (Value)list.get(0);
|
||||
}
|
||||
|
||||
public List getValues() {
|
||||
return getValues(0, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the range to set/get is valid.
|
||||
* length of -1 (meaning rest of array) has been converted
|
||||
* before entry.
|
||||
*/
|
||||
private void validateArrayAccess(int index, int len) {
|
||||
// because length can be computed from index,
|
||||
// index must be tested first for correct error message
|
||||
if ((index < 0) || (index > length())) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Invalid array index: " + index);
|
||||
}
|
||||
if (len < 0) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Invalid array range length: " + len);
|
||||
}
|
||||
if (index + len > length()) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Invalid array range: " +
|
||||
index + " to " + (index + len - 1));
|
||||
}
|
||||
}
|
||||
|
||||
public List getValues(int index, int len) {
|
||||
if (len == -1) { // -1 means the rest of the array
|
||||
len = length() - index;
|
||||
}
|
||||
validateArrayAccess(index, len);
|
||||
List vals = new ArrayList();
|
||||
if (len == 0) {
|
||||
return vals;
|
||||
}
|
||||
|
||||
sun.jvm.hotspot.oops.TypeArray typeArray = null;
|
||||
sun.jvm.hotspot.oops.ObjArray objArray = null;
|
||||
if (ref() instanceof sun.jvm.hotspot.oops.TypeArray) {
|
||||
typeArray = (sun.jvm.hotspot.oops.TypeArray)ref();
|
||||
} else if (ref() instanceof sun.jvm.hotspot.oops.ObjArray) {
|
||||
objArray = (sun.jvm.hotspot.oops.ObjArray)ref();
|
||||
} else {
|
||||
throw new RuntimeException("should not reach here");
|
||||
}
|
||||
|
||||
char c = arrayType().componentSignature().charAt(0);
|
||||
BasicType variableType = BasicType.charToBasicType(c);
|
||||
|
||||
final int limit = index + len;
|
||||
for (int ii = index; ii < limit; ii++) {
|
||||
ValueImpl valueImpl;
|
||||
if (variableType == BasicType.T_BOOLEAN) {
|
||||
valueImpl = (BooleanValueImpl) vm.mirrorOf(typeArray.getBooleanAt(ii));
|
||||
} else if (variableType == BasicType.T_CHAR) {
|
||||
valueImpl = (CharValueImpl) vm.mirrorOf(typeArray.getCharAt(ii));
|
||||
} else if (variableType == BasicType.T_FLOAT) {
|
||||
valueImpl = (FloatValueImpl) vm.mirrorOf(typeArray.getFloatAt(ii));
|
||||
} else if (variableType == BasicType.T_DOUBLE) {
|
||||
valueImpl = (DoubleValueImpl) vm.mirrorOf(typeArray.getDoubleAt(ii));
|
||||
} else if (variableType == BasicType.T_BYTE) {
|
||||
valueImpl = (ByteValueImpl) vm.mirrorOf(typeArray.getByteAt(ii));
|
||||
} else if (variableType == BasicType.T_SHORT) {
|
||||
valueImpl = (ShortValueImpl) vm.mirrorOf(typeArray.getShortAt(ii));
|
||||
} else if (variableType == BasicType.T_INT) {
|
||||
valueImpl = (IntegerValueImpl) vm.mirrorOf(typeArray.getIntAt(ii));
|
||||
} else if (variableType == BasicType.T_LONG) {
|
||||
valueImpl = (LongValueImpl) vm.mirrorOf(typeArray.getLongAt(ii));
|
||||
} else if (variableType == BasicType.T_OBJECT) {
|
||||
// we may have an [Ljava/lang/Object; - i.e., Object[] with the
|
||||
// elements themselves may be arrays because every array is an Object.
|
||||
valueImpl = (ObjectReferenceImpl) vm.objectMirror(objArray.getObjAt(ii));
|
||||
} else if (variableType == BasicType.T_ARRAY) {
|
||||
valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array) objArray.getObjAt(ii));
|
||||
} else {
|
||||
throw new RuntimeException("should not reach here");
|
||||
}
|
||||
vals.add (valueImpl);
|
||||
}
|
||||
return vals;
|
||||
}
|
||||
|
||||
public void setValue(int index, Value value)
|
||||
throws InvalidTypeException,
|
||||
ClassNotLoadedException {
|
||||
vm.throwNotReadOnlyException("ArrayReference.setValue(...)");
|
||||
}
|
||||
|
||||
public void setValues(List values)
|
||||
throws InvalidTypeException,
|
||||
ClassNotLoadedException {
|
||||
setValues(0, values, 0, -1);
|
||||
}
|
||||
|
||||
public void setValues(int index, List values,
|
||||
int srcIndex, int length)
|
||||
throws InvalidTypeException,
|
||||
ClassNotLoadedException {
|
||||
|
||||
vm.throwNotReadOnlyException("ArrayReference.setValue(...)");
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "instance of " + arrayType().componentTypeName() +
|
||||
"[" + length() + "] (id=" + uniqueID() + ")";
|
||||
}
|
||||
}
|
@ -1,222 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.ArrayKlass;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.ObjArrayKlass;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.TypeArrayKlass;
|
||||
|
||||
import com.sun.jdi.ArrayReference;
|
||||
import com.sun.jdi.ArrayType;
|
||||
import com.sun.jdi.ClassLoaderReference;
|
||||
import com.sun.jdi.ClassNotLoadedException;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.PrimitiveType;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.Type;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class ArrayTypeImpl extends ReferenceTypeImpl implements ArrayType {
|
||||
protected ArrayTypeImpl(VirtualMachine aVm, ArrayKlass aRef) {
|
||||
super(aVm, aRef);
|
||||
}
|
||||
|
||||
public ArrayReference newInstance(int length) {
|
||||
vm.throwNotReadOnlyException("ArrayType.newInstance(int)");
|
||||
return null;
|
||||
}
|
||||
|
||||
public String componentSignature() {
|
||||
return signature().substring(1); // Just skip the leading '['
|
||||
}
|
||||
|
||||
public String componentTypeName() {
|
||||
JNITypeParser parser = new JNITypeParser(componentSignature());
|
||||
return parser.typeName();
|
||||
}
|
||||
|
||||
public ClassLoaderReference classLoader() {
|
||||
if (ref() instanceof TypeArrayKlass) {
|
||||
// primitive array klasses are loaded by bootstrap loader
|
||||
return null;
|
||||
} else {
|
||||
Klass bottomKlass = ((ObjArrayKlass)ref()).getBottomKlass();
|
||||
if (bottomKlass instanceof TypeArrayKlass) {
|
||||
// multidimensional primitive array klasses are loaded by bootstrap loader
|
||||
return null;
|
||||
} else {
|
||||
// class loader of any other obj array klass is same as the loader
|
||||
// that loaded the bottom InstanceKlass
|
||||
Instance xx = (Instance)(((InstanceKlass) bottomKlass).getClassLoader());
|
||||
return vm.classLoaderMirror(xx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> handledInterfaces) {
|
||||
// arrays don't have methods
|
||||
}
|
||||
|
||||
List getAllMethods() {
|
||||
// arrays don't have methods
|
||||
// JLS says arrays have methods of java.lang.Object. But
|
||||
// JVMDI-JDI returns zero size list. We do the same here
|
||||
// for consistency.
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the type object, if any, of a component type of this array.
|
||||
* The component type does not have to be immediate; e.g. this method
|
||||
* can be used to find the component Foo of Foo[][].
|
||||
*/
|
||||
public Type componentType() throws ClassNotLoadedException {
|
||||
ArrayKlass k = (ArrayKlass) ref();
|
||||
if (k instanceof ObjArrayKlass) {
|
||||
Klass elementKlass = ((ObjArrayKlass)k).getElementKlass();
|
||||
if (elementKlass == null) {
|
||||
throw new ClassNotLoadedException(componentSignature());
|
||||
} else {
|
||||
return vm.referenceType(elementKlass);
|
||||
}
|
||||
} else {
|
||||
// It's a primitive type
|
||||
return vm.primitiveTypeMirror(signature().charAt(1));
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isComponentAssignable(Type destination, Type source) {
|
||||
if (source instanceof PrimitiveType) {
|
||||
// Assignment of primitive arrays requires identical
|
||||
// component types.
|
||||
return source.equals(destination);
|
||||
} else {
|
||||
if (destination instanceof PrimitiveType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ReferenceTypeImpl refSource = (ReferenceTypeImpl)source;
|
||||
ReferenceTypeImpl refDestination = (ReferenceTypeImpl)destination;
|
||||
// Assignment of object arrays requires availability
|
||||
// of widening conversion of component types
|
||||
return refSource.isAssignableTo(refDestination);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Return true if an instance of the given reference type
|
||||
* can be assigned to a variable of this type
|
||||
*/
|
||||
boolean isAssignableTo(ReferenceType destType) {
|
||||
if (destType instanceof ArrayType) {
|
||||
try {
|
||||
Type destComponentType = ((ArrayType)destType).componentType();
|
||||
return isComponentAssignable(destComponentType, componentType());
|
||||
} catch (ClassNotLoadedException e) {
|
||||
// One or both component types has not yet been
|
||||
// loaded => can't assign
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
Symbol typeName = ((ReferenceTypeImpl)destType).typeNameAsSymbol();
|
||||
if (destType instanceof InterfaceType) {
|
||||
// Every array type implements java.io.Serializable and
|
||||
// java.lang.Cloneable. fixme in JVMDI-JDI, includes only
|
||||
// Cloneable but not Serializable.
|
||||
return typeName.equals(vm.javaLangCloneable()) ||
|
||||
typeName.equals(vm.javaIoSerializable());
|
||||
} else {
|
||||
// Only valid ClassType assignee is Object
|
||||
return typeName.equals(vm.javaLangObject());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List inheritedTypes() {
|
||||
// arrays are derived from java.lang.Object and
|
||||
// B[] is derived from A[] if B is derived from A.
|
||||
// But JVMDI-JDI returns zero sized list and we do the
|
||||
// same for consistency.
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
int getModifiers() {
|
||||
/*
|
||||
* For object arrays, the return values for Interface
|
||||
* Accessible.isPrivate(), Accessible.isProtected(),
|
||||
* etc... are the same as would be returned for the
|
||||
* component type. Fetch the modifier bits from the
|
||||
* component type and use those.
|
||||
*
|
||||
* For primitive arrays, the modifiers are always
|
||||
* VMModifiers.FINAL | VMModifiers.PUBLIC
|
||||
*
|
||||
* Reference com.sun.jdi.Accessible.java.
|
||||
*/
|
||||
try {
|
||||
Type t = componentType();
|
||||
if (t instanceof PrimitiveType) {
|
||||
return VMModifiers.FINAL | VMModifiers.PUBLIC;
|
||||
} else {
|
||||
ReferenceType rt = (ReferenceType)t;
|
||||
return rt.modifiers();
|
||||
}
|
||||
} catch (ClassNotLoadedException cnle) {
|
||||
cnle.printStackTrace();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "array class " + name() + " (" + loaderString() + ")";
|
||||
}
|
||||
|
||||
/*
|
||||
* Save a pointless trip over the wire for these methods
|
||||
* which have undefined results for arrays.
|
||||
*/
|
||||
public boolean isPrepared() { return true; }
|
||||
public boolean isVerified() { return true; }
|
||||
public boolean isInitialized() { return true; }
|
||||
public boolean failedToInitialize() { return false; }
|
||||
public boolean isAbstract() { return false; }
|
||||
|
||||
/*
|
||||
* Defined always to be true for arrays
|
||||
*/
|
||||
public boolean isFinal() { return true; }
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
class BaseLineInfo implements LineInfo {
|
||||
private final int lineNumber;
|
||||
private final ReferenceTypeImpl declaringType;
|
||||
|
||||
BaseLineInfo(int lineNumber,
|
||||
ReferenceTypeImpl declaringType) {
|
||||
this.lineNumber = lineNumber;
|
||||
this.declaringType = declaringType;
|
||||
}
|
||||
|
||||
public String liStratum() {
|
||||
return SDE.BASE_STRATUM_NAME;
|
||||
}
|
||||
|
||||
public int liLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public String liSourceName()
|
||||
throws AbsentInformationException {
|
||||
return declaringType.baseSourceName();
|
||||
}
|
||||
|
||||
public String liSourcePath()
|
||||
throws AbsentInformationException {
|
||||
return declaringType.baseSourcePath();
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class BooleanTypeImpl extends PrimitiveTypeImpl implements BooleanType {
|
||||
BooleanTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
return "Z";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedBooleanValue());
|
||||
}
|
||||
}
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class BooleanValueImpl extends PrimitiveValueImpl
|
||||
implements BooleanValue {
|
||||
private boolean value;
|
||||
|
||||
BooleanValueImpl(VirtualMachine aVm,boolean aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof BooleanValue)) {
|
||||
return (value == ((BooleanValue)obj).value())
|
||||
&& super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theBooleanType();
|
||||
}
|
||||
|
||||
public boolean value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)((value)?1:0);
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)((value)?1:0);
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)((value)?1:0);
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)((value)?1:0);
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)((value)?1:0);
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)((value)?1.0:0.0);
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)((value)?1.0:0.0);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class ByteTypeImpl extends PrimitiveTypeImpl implements ByteType {
|
||||
ByteTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "B";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedByteValue());
|
||||
}
|
||||
}
|
@ -1,110 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class ByteValueImpl extends PrimitiveValueImpl
|
||||
implements ByteValue {
|
||||
private byte value;
|
||||
|
||||
ByteValueImpl(VirtualMachine aVm,byte aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof ByteValue)) {
|
||||
return (value == ((ByteValue)obj).value())
|
||||
&& super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(ByteValue byteVal) {
|
||||
return value() - byteVal.value();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theByteType();
|
||||
}
|
||||
|
||||
public byte value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class CharTypeImpl extends PrimitiveTypeImpl implements CharType {
|
||||
CharTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "C";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedCharValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class CharValueImpl extends PrimitiveValueImpl
|
||||
implements CharValue {
|
||||
private char value;
|
||||
|
||||
CharValueImpl(VirtualMachine aVm,char aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof CharValue)) {
|
||||
return (value == ((CharValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(CharValue charVal) {
|
||||
return value() - charVal.value();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theCharType();
|
||||
}
|
||||
|
||||
public char value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
// Note: since char is unsigned, don't check against MIN_VALUE
|
||||
if (value > Byte.MAX_VALUE) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
// Note: since char is unsigned, don't check against MIN_VALUE
|
||||
if (value > Short.MAX_VALUE) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to short");
|
||||
} else {
|
||||
return super.checkedShortValue();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.memory.SystemDictionary;
|
||||
import sun.jvm.hotspot.memory.Universe;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ClassLoaderReferenceImpl
|
||||
extends ObjectReferenceImpl
|
||||
implements ClassLoaderReference
|
||||
{
|
||||
// because we work on process snapshot or core we can
|
||||
// cache visibleClasses & definedClasses always (i.e., no suspension)
|
||||
private List visibleClassesCache;
|
||||
private List definedClassesCache;
|
||||
|
||||
ClassLoaderReferenceImpl(VirtualMachine aVm, Instance oRef) {
|
||||
super(aVm, oRef);
|
||||
}
|
||||
|
||||
protected String description() {
|
||||
return "ClassLoaderReference " + uniqueID();
|
||||
}
|
||||
|
||||
public List definedClasses() {
|
||||
if (definedClassesCache == null) {
|
||||
definedClassesCache = new ArrayList();
|
||||
Iterator iter = vm.allClasses().iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType type = (ReferenceType)iter.next();
|
||||
if (equals(type.classLoader())) { /* thanks OTI */
|
||||
definedClassesCache.add(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return definedClassesCache;
|
||||
}
|
||||
|
||||
private SystemDictionary getSystemDictionary() {
|
||||
return vm.saSystemDictionary();
|
||||
}
|
||||
|
||||
private Universe getUniverse() {
|
||||
return vm.saUniverse();
|
||||
}
|
||||
|
||||
public List visibleClasses() {
|
||||
if (visibleClassesCache != null)
|
||||
return visibleClassesCache;
|
||||
|
||||
visibleClassesCache = new ArrayList();
|
||||
|
||||
// refer to getClassLoaderClasses in jvmtiGetLoadedClasses.cpp
|
||||
// a. SystemDictionary::classes_do doesn't include arrays of primitive types (any dimensions)
|
||||
SystemDictionary sysDict = getSystemDictionary();
|
||||
sysDict.classesDo(
|
||||
new SystemDictionary.ClassAndLoaderVisitor() {
|
||||
public void visit(Klass k, Oop loader) {
|
||||
if (ref().equals(loader)) {
|
||||
for (Klass l = k; l != null; l = l.arrayKlassOrNull()) {
|
||||
visibleClassesCache.add(vm.referenceType(l));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// b. multi dimensional arrays of primitive types
|
||||
sysDict.primArrayClassesDo(
|
||||
new SystemDictionary.ClassAndLoaderVisitor() {
|
||||
public void visit(Klass k, Oop loader) {
|
||||
if (ref().equals(loader)) {
|
||||
visibleClassesCache.add(vm.referenceType(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// c. single dimensional primitive array klasses from Universe
|
||||
// these are not added to SystemDictionary
|
||||
getUniverse().basicTypeClassesDo(
|
||||
new SystemDictionary.ClassVisitor() {
|
||||
public void visit(Klass k) {
|
||||
visibleClassesCache.add(vm.referenceType(k));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return visibleClassesCache;
|
||||
}
|
||||
|
||||
Type findType(String signature) throws ClassNotLoadedException {
|
||||
List types = visibleClasses();
|
||||
Iterator iter = types.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType type = (ReferenceType)iter.next();
|
||||
if (type.signature().equals(signature)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
JNITypeParser parser = new JNITypeParser(signature);
|
||||
throw new ClassNotLoadedException(parser.typeName(),
|
||||
"Class " + parser.typeName() + " not loaded");
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.java_lang_Class;
|
||||
|
||||
public class ClassObjectReferenceImpl extends ObjectReferenceImpl
|
||||
implements ClassObjectReference {
|
||||
private ReferenceType reflectedType;
|
||||
|
||||
ClassObjectReferenceImpl(VirtualMachine vm, Instance oRef) {
|
||||
super(vm, oRef);
|
||||
}
|
||||
|
||||
public ReferenceType reflectedType() {
|
||||
if (reflectedType == null) {
|
||||
Klass k = java_lang_Class.asKlass(ref());
|
||||
reflectedType = vm.referenceType(k);
|
||||
}
|
||||
return reflectedType;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "instance of " + referenceType().name() +
|
||||
"(reflected class=" + reflectedType().name() + ", " + "id=" +
|
||||
uniqueID() + ")";
|
||||
}
|
||||
}
|
@ -1,263 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
|
||||
import com.sun.jdi.ClassNotLoadedException;
|
||||
import com.sun.jdi.ClassType;
|
||||
import com.sun.jdi.Field;
|
||||
import com.sun.jdi.IncompatibleThreadStateException;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.InvalidTypeException;
|
||||
import com.sun.jdi.InvocationException;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ObjectReference;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.ThreadReference;
|
||||
import com.sun.jdi.Value;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class ClassTypeImpl extends ReferenceTypeImpl
|
||||
implements ClassType
|
||||
{
|
||||
private SoftReference interfacesCache = null;
|
||||
private SoftReference allInterfacesCache = null;
|
||||
private SoftReference subclassesCache = null;
|
||||
|
||||
protected ClassTypeImpl(VirtualMachine aVm, InstanceKlass aRef) {
|
||||
super(aVm, aRef);
|
||||
}
|
||||
|
||||
public ClassType superclass() {
|
||||
InstanceKlass kk = (InstanceKlass)ref().getSuper();
|
||||
if (kk == null) {
|
||||
return null;
|
||||
}
|
||||
return (ClassType) vm.referenceType(kk);
|
||||
}
|
||||
|
||||
public List interfaces() {
|
||||
List interfaces = (interfacesCache != null)? (List) interfacesCache.get() : null;
|
||||
if (interfaces == null) {
|
||||
checkPrepared();
|
||||
interfaces = Collections.unmodifiableList(getInterfaces());
|
||||
interfacesCache = new SoftReference(interfaces);
|
||||
}
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
void addInterfaces(List list) {
|
||||
List immediate = interfaces();
|
||||
|
||||
HashSet hashList = new HashSet(list);
|
||||
hashList.addAll(immediate);
|
||||
list.clear();
|
||||
list.addAll(hashList);
|
||||
|
||||
Iterator iter = immediate.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
interfaze.addSuperinterfaces(list);
|
||||
}
|
||||
|
||||
ClassTypeImpl superclass = (ClassTypeImpl)superclass();
|
||||
if (superclass != null) {
|
||||
superclass.addInterfaces(list);
|
||||
}
|
||||
}
|
||||
|
||||
public List allInterfaces() {
|
||||
List allinterfaces = (allInterfacesCache != null)? (List) allInterfacesCache.get() : null;
|
||||
if (allinterfaces == null) {
|
||||
checkPrepared();
|
||||
allinterfaces = new ArrayList();
|
||||
addInterfaces(allinterfaces);
|
||||
allinterfaces = Collections.unmodifiableList(allinterfaces);
|
||||
allInterfacesCache = new SoftReference(allinterfaces);
|
||||
}
|
||||
return allinterfaces;
|
||||
}
|
||||
|
||||
public List subclasses() {
|
||||
List subclasses = (subclassesCache != null)? (List) subclassesCache.get() : null;
|
||||
if (subclasses == null) {
|
||||
List all = vm.allClasses();
|
||||
subclasses = new ArrayList(0);
|
||||
Iterator iter = all.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType refType = (ReferenceType)iter.next();
|
||||
if (refType instanceof ClassType) {
|
||||
ClassType clazz = (ClassType)refType;
|
||||
ClassType superclass = clazz.superclass();
|
||||
if ((superclass != null) && superclass.equals(this)) {
|
||||
subclasses.add(refType);
|
||||
}
|
||||
}
|
||||
}
|
||||
subclasses = Collections.unmodifiableList(subclasses);
|
||||
subclassesCache = new SoftReference(subclasses);
|
||||
}
|
||||
return subclasses;
|
||||
}
|
||||
|
||||
public Method concreteMethodByName(String name, String signature) {
|
||||
checkPrepared();
|
||||
List methods = visibleMethods();
|
||||
Method method = null;
|
||||
Iterator iter = methods.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Method candidate = (Method)iter.next();
|
||||
if (candidate.name().equals(name) &&
|
||||
candidate.signature().equals(signature) &&
|
||||
!candidate.isAbstract()) {
|
||||
|
||||
method = candidate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
List getAllMethods() {
|
||||
ArrayList list = new ArrayList(methods());
|
||||
ClassType clazz = superclass();
|
||||
while (clazz != null) {
|
||||
list.addAll(clazz.methods());
|
||||
clazz = clazz.superclass();
|
||||
}
|
||||
/*
|
||||
* Avoid duplicate checking on each method by iterating through
|
||||
* duplicate-free allInterfaces() rather than recursing
|
||||
*/
|
||||
Iterator iter = allInterfaces().iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceType interfaze = (InterfaceType)iter.next();
|
||||
list.addAll(interfaze.methods());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
List inheritedTypes() {
|
||||
List inherited = new ArrayList(interfaces());
|
||||
if (superclass() != null) {
|
||||
inherited.add(0, superclass()); /* insert at front */
|
||||
}
|
||||
return inherited;
|
||||
}
|
||||
|
||||
public boolean isEnum() {
|
||||
ClassTypeImpl superclass = (ClassTypeImpl) superclass();
|
||||
if (superclass != null) {
|
||||
return superclass.typeNameAsSymbol().equals(vm.javaLangEnum());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(Field field, Value value)
|
||||
throws InvalidTypeException, ClassNotLoadedException {
|
||||
vm.throwNotReadOnlyException("ClassType.setValue(...)");
|
||||
}
|
||||
|
||||
|
||||
public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
|
||||
List arguments, int options)
|
||||
throws InvalidTypeException,
|
||||
ClassNotLoadedException,
|
||||
IncompatibleThreadStateException,
|
||||
InvocationException {
|
||||
vm.throwNotReadOnlyException("ClassType.invokeMethod(...)");
|
||||
return null;
|
||||
}
|
||||
|
||||
public ObjectReference newInstance(ThreadReference threadIntf,
|
||||
Method methodIntf,
|
||||
List arguments, int options)
|
||||
throws InvalidTypeException,
|
||||
ClassNotLoadedException,
|
||||
IncompatibleThreadStateException,
|
||||
InvocationException {
|
||||
vm.throwNotReadOnlyException("ClassType.newInstance(...)");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
|
||||
/*
|
||||
* Add methods from
|
||||
* parent types first, so that the methods in this class will
|
||||
* overwrite them in the hash table
|
||||
*/
|
||||
|
||||
Iterator<InterfaceType> iter = interfaces().iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
if (!seenInterfaces.contains(interfaze)) {
|
||||
interfaze.addVisibleMethods(methodMap, seenInterfaces);
|
||||
seenInterfaces.add(interfaze);
|
||||
}
|
||||
}
|
||||
|
||||
ClassTypeImpl clazz = (ClassTypeImpl)superclass();
|
||||
if (clazz != null) {
|
||||
clazz.addVisibleMethods(methodMap, seenInterfaces);
|
||||
}
|
||||
|
||||
addToMethodMap(methodMap, methods());
|
||||
}
|
||||
|
||||
boolean isAssignableTo(ReferenceType type) {
|
||||
ClassTypeImpl superclazz = (ClassTypeImpl)superclass();
|
||||
if (this.equals(type)) {
|
||||
return true;
|
||||
} else if ((superclazz != null) && superclazz.isAssignableTo(type)) {
|
||||
return true;
|
||||
} else {
|
||||
List interfaces = interfaces();
|
||||
Iterator iter = interfaces.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
if (interfaze.isAssignableTo(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "class " + name() + "(" + loaderString() + ")";
|
||||
}
|
||||
}
|
@ -1,467 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.LocalVariableTableElement;
|
||||
import sun.jvm.hotspot.oops.LineNumberTableElement;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ConcreteMethodImpl extends MethodImpl {
|
||||
|
||||
/*
|
||||
* A subset of the line number info that is softly cached
|
||||
*/
|
||||
static private class SoftLocationXRefs {
|
||||
final String stratumID; // The stratum of this information
|
||||
final Map lineMapper; // Maps line number to location(s)
|
||||
final List lineLocations; // List of locations ordered by code index
|
||||
|
||||
/*
|
||||
* Note: these do not necessarily correspond to
|
||||
* the line numbers of the first and last elements
|
||||
* in the lineLocations list. Use these only for bounds
|
||||
* checking and with lineMapper.
|
||||
*/
|
||||
final int lowestLine;
|
||||
final int highestLine;
|
||||
|
||||
SoftLocationXRefs(String stratumID, Map lineMapper, List lineLocations,
|
||||
int lowestLine, int highestLine) {
|
||||
this.stratumID = stratumID;
|
||||
this.lineMapper = Collections.unmodifiableMap(lineMapper);
|
||||
this.lineLocations =
|
||||
Collections.unmodifiableList(lineLocations);
|
||||
this.lowestLine = lowestLine;
|
||||
this.highestLine = highestLine;
|
||||
}
|
||||
}
|
||||
|
||||
private SoftReference softBaseLocationXRefsRef;
|
||||
private SoftReference softOtherLocationXRefsRef;
|
||||
private SoftReference variablesRef = null;
|
||||
private int firstIndex = -1;
|
||||
private int lastIndex = -1;
|
||||
private Location location;
|
||||
private SoftReference bytecodesRef = null;
|
||||
|
||||
ConcreteMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
|
||||
sun.jvm.hotspot.oops.Method saMethod ) {
|
||||
super(vm, declaringType, saMethod);
|
||||
}
|
||||
|
||||
int argSlotCount() throws AbsentInformationException {
|
||||
return (int) saMethod.getSizeOfParameters();
|
||||
}
|
||||
|
||||
private SoftLocationXRefs getLocations(SDE.Stratum stratum) {
|
||||
if (stratum.isJava()) {
|
||||
return getBaseLocations();
|
||||
}
|
||||
String stratumID = stratum.id();
|
||||
SoftLocationXRefs info =
|
||||
(softOtherLocationXRefsRef == null) ? null :
|
||||
(SoftLocationXRefs)softOtherLocationXRefsRef.get();
|
||||
if (info != null && info.stratumID.equals(stratumID)) {
|
||||
return info;
|
||||
}
|
||||
|
||||
List lineLocations = new ArrayList();
|
||||
Map lineMapper = new HashMap();
|
||||
int lowestLine = -1;
|
||||
int highestLine = -1;
|
||||
SDE.LineStratum lastLineStratum = null;
|
||||
SDE.Stratum baseStratum =
|
||||
declaringType.stratum(SDE.BASE_STRATUM_NAME);
|
||||
Iterator it = getBaseLocations().lineLocations.iterator();
|
||||
while(it.hasNext()) {
|
||||
LocationImpl loc = (LocationImpl)it.next();
|
||||
int baseLineNumber = loc.lineNumber(baseStratum);
|
||||
SDE.LineStratum lineStratum =
|
||||
stratum.lineStratum(declaringType,
|
||||
baseLineNumber);
|
||||
|
||||
if (lineStratum == null) {
|
||||
// location not mapped in this stratum
|
||||
continue;
|
||||
}
|
||||
|
||||
int lineNumber = lineStratum.lineNumber();
|
||||
|
||||
// remove unmapped and dup lines
|
||||
if ((lineNumber != -1) &&
|
||||
(!lineStratum.equals(lastLineStratum))) {
|
||||
lastLineStratum = lineStratum;
|
||||
// Remember the largest/smallest line number
|
||||
if (lineNumber > highestLine) {
|
||||
highestLine = lineNumber;
|
||||
}
|
||||
if ((lineNumber < lowestLine) || (lowestLine == -1)) {
|
||||
lowestLine = lineNumber;
|
||||
}
|
||||
|
||||
loc.addStratumLineInfo(
|
||||
new StratumLineInfo(stratumID,
|
||||
lineNumber,
|
||||
lineStratum.sourceName(),
|
||||
lineStratum.sourcePath()));
|
||||
|
||||
// Add to the location list
|
||||
lineLocations.add(loc);
|
||||
|
||||
// Add to the line -> locations map
|
||||
Integer key = new Integer(lineNumber);
|
||||
List mappedLocs = (List)lineMapper.get(key);
|
||||
if (mappedLocs == null) {
|
||||
mappedLocs = new ArrayList(1);
|
||||
lineMapper.put(key, mappedLocs);
|
||||
}
|
||||
mappedLocs.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
info = new SoftLocationXRefs(stratumID,
|
||||
lineMapper, lineLocations,
|
||||
lowestLine, highestLine);
|
||||
softOtherLocationXRefsRef = new SoftReference(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
private SoftLocationXRefs getBaseLocations() {
|
||||
SoftLocationXRefs info = (softBaseLocationXRefsRef == null) ? null :
|
||||
(SoftLocationXRefs)softBaseLocationXRefsRef.get();
|
||||
if (info != null) {
|
||||
return info;
|
||||
}
|
||||
|
||||
byte[] codeBuf = bytecodes();
|
||||
firstIndex = 0;
|
||||
lastIndex = codeBuf.length - 1;
|
||||
// This is odd; what is the Location of a Method?
|
||||
// A StackFrame can have a location, but a Method?
|
||||
// I guess it must be the Location for bci 0.
|
||||
location = new LocationImpl(virtualMachine(), this, 0);
|
||||
|
||||
boolean hasLineInfo = saMethod.hasLineNumberTable();
|
||||
LineNumberTableElement[] lntab = null;
|
||||
int count;
|
||||
|
||||
if (hasLineInfo) {
|
||||
lntab = saMethod.getLineNumberTable();
|
||||
count = lntab.length;
|
||||
} else {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
List lineLocations = new ArrayList(count);
|
||||
Map lineMapper = new HashMap();
|
||||
int lowestLine = -1;
|
||||
int highestLine = -1;
|
||||
for (int i = 0; i < count; i++) {
|
||||
long bci = lntab[i].getStartBCI();
|
||||
int lineNumber = lntab[i].getLineNumber();
|
||||
|
||||
/*
|
||||
* Some compilers will point multiple consecutive
|
||||
* lines at the same location. We need to choose
|
||||
* one of them so that we can consistently map back
|
||||
* and forth between line and location. So we choose
|
||||
* to record only the last line entry at a particular
|
||||
* location.
|
||||
*/
|
||||
if ((i + 1 == count) || (bci != lntab[i+1].getStartBCI())) {
|
||||
// Remember the largest/smallest line number
|
||||
if (lineNumber > highestLine) {
|
||||
highestLine = lineNumber;
|
||||
}
|
||||
if ((lineNumber < lowestLine) || (lowestLine == -1)) {
|
||||
lowestLine = lineNumber;
|
||||
}
|
||||
LocationImpl loc =
|
||||
new LocationImpl(virtualMachine(), this, bci);
|
||||
loc.addBaseLineInfo(
|
||||
new BaseLineInfo(lineNumber, declaringType));
|
||||
|
||||
// Add to the location list
|
||||
lineLocations.add(loc);
|
||||
|
||||
// Add to the line -> locations map
|
||||
Integer key = new Integer(lineNumber);
|
||||
List mappedLocs = (List)lineMapper.get(key);
|
||||
if (mappedLocs == null) {
|
||||
mappedLocs = new ArrayList(1);
|
||||
lineMapper.put(key, mappedLocs);
|
||||
}
|
||||
mappedLocs.add(loc);
|
||||
}
|
||||
}
|
||||
|
||||
info = new SoftLocationXRefs(SDE.BASE_STRATUM_NAME,
|
||||
lineMapper, lineLocations,
|
||||
lowestLine, highestLine);
|
||||
softBaseLocationXRefsRef = new SoftReference(info);
|
||||
return info;
|
||||
}
|
||||
|
||||
List sourceNameFilter(List list,
|
||||
SDE.Stratum stratum,
|
||||
String sourceName)
|
||||
throws AbsentInformationException {
|
||||
if (sourceName == null) {
|
||||
return list;
|
||||
} else {
|
||||
/* needs sourceName filteration */
|
||||
List locs = new ArrayList();
|
||||
Iterator it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
LocationImpl loc = (LocationImpl)it.next();
|
||||
if (loc.sourceName(stratum).equals(sourceName)) {
|
||||
locs.add(loc);
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
}
|
||||
|
||||
public List allLineLocations(SDE.Stratum stratum, String sourceName)
|
||||
throws AbsentInformationException {
|
||||
List lineLocations = getLocations(stratum).lineLocations;
|
||||
|
||||
if (lineLocations.size() == 0) {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(
|
||||
sourceNameFilter(lineLocations, stratum, sourceName));
|
||||
}
|
||||
|
||||
public List locationsOfLine(SDE.Stratum stratum, String sourceName,
|
||||
int lineNumber) throws AbsentInformationException {
|
||||
SoftLocationXRefs info = getLocations(stratum);
|
||||
|
||||
if (info.lineLocations.size() == 0) {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the locations which match the line number
|
||||
* passed in.
|
||||
*/
|
||||
List list = (List)info.lineMapper.get(
|
||||
new Integer(lineNumber));
|
||||
|
||||
if (list == null) {
|
||||
list = new ArrayList(0);
|
||||
}
|
||||
return Collections.unmodifiableList(
|
||||
sourceNameFilter(list, stratum, sourceName));
|
||||
}
|
||||
|
||||
LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
|
||||
long codeIndex) {
|
||||
if (firstIndex == -1) {
|
||||
getBaseLocations();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for invalid code index.
|
||||
*/
|
||||
if (codeIndex < firstIndex || codeIndex > lastIndex) {
|
||||
throw new InternalError(
|
||||
"Location with invalid code index");
|
||||
}
|
||||
|
||||
List lineLocations = getLocations(stratum).lineLocations;
|
||||
|
||||
/*
|
||||
* Check for absent line numbers.
|
||||
*/
|
||||
if (lineLocations.size() == 0) {
|
||||
return super.codeIndexToLineInfo(stratum, codeIndex);
|
||||
}
|
||||
|
||||
Iterator iter = lineLocations.iterator();
|
||||
/*
|
||||
* Treat code before the beginning of the first line table
|
||||
* entry as part of the first line. javac will generate
|
||||
* code like this for some local classes. This "prolog"
|
||||
* code contains assignments from locals in the enclosing
|
||||
* scope to synthetic fields in the local class. Same for
|
||||
* other language prolog code.
|
||||
*/
|
||||
LocationImpl bestMatch = (LocationImpl)iter.next();
|
||||
while (iter.hasNext()) {
|
||||
LocationImpl current = (LocationImpl)iter.next();
|
||||
if (current.codeIndex() > codeIndex) {
|
||||
break;
|
||||
}
|
||||
bestMatch = current;
|
||||
}
|
||||
return bestMatch.getLineInfo(stratum);
|
||||
}
|
||||
|
||||
public Location locationOfCodeIndex(long codeIndex) {
|
||||
if (firstIndex == -1) {
|
||||
getBaseLocations();
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for invalid code index.
|
||||
*/
|
||||
if (codeIndex < firstIndex || codeIndex > lastIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new LocationImpl(virtualMachine(), this, codeIndex);
|
||||
}
|
||||
|
||||
public List variables() throws AbsentInformationException {
|
||||
return getVariables();
|
||||
}
|
||||
|
||||
public List variablesByName(String name) throws AbsentInformationException {
|
||||
List variables = getVariables();
|
||||
|
||||
List retList = new ArrayList(2);
|
||||
Iterator iter = variables.iterator();
|
||||
while(iter.hasNext()) {
|
||||
LocalVariable variable = (LocalVariable)iter.next();
|
||||
if (variable.name().equals(name)) {
|
||||
retList.add(variable);
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public List arguments() throws AbsentInformationException {
|
||||
if (argumentTypeNames().size() == 0) {
|
||||
return new ArrayList(0);
|
||||
}
|
||||
List variables = getVariables();
|
||||
List retList = new ArrayList(variables.size());
|
||||
Iterator iter = variables.iterator();
|
||||
while(iter.hasNext()) {
|
||||
LocalVariable variable = (LocalVariable)iter.next();
|
||||
if (variable.isArgument()) {
|
||||
retList.add(variable);
|
||||
}
|
||||
}
|
||||
return retList;
|
||||
}
|
||||
|
||||
public byte[] bytecodes() {
|
||||
byte[] bytecodes = (bytecodesRef == null) ? null :
|
||||
(byte[])bytecodesRef.get();
|
||||
if (bytecodes == null) {
|
||||
bytecodes = saMethod.getByteCode();
|
||||
bytecodesRef = new SoftReference(bytecodes);
|
||||
}
|
||||
/*
|
||||
* Arrays are always modifiable, so it is a little unsafe
|
||||
* to return the cached bytecodes directly; instead, we
|
||||
* make a clone at the cost of using more memory.
|
||||
*/
|
||||
return (byte[])bytecodes.clone();
|
||||
}
|
||||
|
||||
public Location location() {
|
||||
if (location == null) {
|
||||
getBaseLocations();
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
private List getVariables() throws AbsentInformationException {
|
||||
List variables = (variablesRef == null) ? null :
|
||||
(List)variablesRef.get();
|
||||
if (variables != null) {
|
||||
return variables;
|
||||
}
|
||||
|
||||
// if there are no locals, there won't be a LVT
|
||||
if (saMethod.getMaxLocals() == 0) {
|
||||
variables = Collections.unmodifiableList(new ArrayList(0));
|
||||
variablesRef = new SoftReference(variables);
|
||||
return variables;
|
||||
}
|
||||
|
||||
if (! saMethod.hasLocalVariableTable()) {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
//Build up the JDI view of local variable table.
|
||||
LocalVariableTableElement[] locals = saMethod.getLocalVariableTable();
|
||||
int localCount = locals.length;
|
||||
variables = new ArrayList(localCount);
|
||||
for (int ii = 0; ii < localCount; ii++) {
|
||||
String name =
|
||||
saMethod.getConstants().getSymbolAt(locals[ii].getNameCPIndex()).asString();
|
||||
/*
|
||||
* Skip "this$*", "this+*", "this" entries because they are never real
|
||||
* variables from the JLS perspective. "this+*" is new with 1.5.
|
||||
* Instead of using '+', we check for java letter or digit to avoid
|
||||
* depending on javac's current choice of '+'.
|
||||
*/
|
||||
boolean isInternalName = name.startsWith("this") &&
|
||||
(name.length() == 4 || name.charAt(4)=='$' || !Character.isJavaIdentifierPart(name.charAt(4)));
|
||||
if (! isInternalName) {
|
||||
int slot = locals[ii].getSlot();
|
||||
long codeIndex = locals[ii].getStartBCI();
|
||||
int length = locals[ii].getLength();
|
||||
Location scopeStart = new LocationImpl(virtualMachine(),
|
||||
this, codeIndex);
|
||||
Location scopeEnd =
|
||||
new LocationImpl(virtualMachine(), this,
|
||||
codeIndex + length - 1);
|
||||
String signature =
|
||||
saMethod.getConstants().getSymbolAt(locals[ii].getDescriptorCPIndex()).asString();
|
||||
|
||||
int genericSigIndex = locals[ii].getSignatureCPIndex();
|
||||
String genericSignature = null;
|
||||
if (genericSigIndex != 0) {
|
||||
genericSignature = saMethod.getConstants().getSymbolAt(genericSigIndex).asString();
|
||||
}
|
||||
|
||||
LocalVariable variable =
|
||||
new LocalVariableImpl(virtualMachine(), this,
|
||||
slot, scopeStart, scopeEnd,
|
||||
name, signature, genericSignature);
|
||||
// Add to the variable list
|
||||
variables.add(variable);
|
||||
}
|
||||
}
|
||||
|
||||
variables = Collections.unmodifiableList(variables);
|
||||
variablesRef = new SoftReference(variables);
|
||||
return variables;
|
||||
}
|
||||
}
|
@ -1,631 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.InternalException;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.ref.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
|
||||
abstract class ConnectorImpl implements Connector {
|
||||
Map defaultArguments = new LinkedHashMap();
|
||||
|
||||
// Used by BooleanArgument
|
||||
static String trueString = null;
|
||||
static String falseString;
|
||||
|
||||
|
||||
/** This is not public in VirtualMachineManagerImpl
|
||||
ThreadGroup mainGroupForJDI() {
|
||||
return ((VirtualMachineManagerImpl)manager).mainGroupForJDI();
|
||||
}
|
||||
***/
|
||||
|
||||
// multiple debuggee support for SA/JDI
|
||||
private static List freeVMClasses; // List<SoftReference<Class>>
|
||||
private static ClassLoader myLoader;
|
||||
// debug mode for SA/JDI connectors
|
||||
static final protected boolean DEBUG;
|
||||
static {
|
||||
myLoader = ConnectorImpl.class.getClassLoader();
|
||||
freeVMClasses = new ArrayList(0);
|
||||
DEBUG = System.getProperty("sun.jvm.hotspot.jdi.ConnectorImpl.DEBUG") != null;
|
||||
}
|
||||
|
||||
// add a new free VirtualMachineImpl class
|
||||
private static synchronized void addFreeVMImplClass(Class clazz) {
|
||||
if (DEBUG) {
|
||||
System.out.println("adding free VirtualMachineImpl class");
|
||||
}
|
||||
freeVMClasses.add(new SoftReference(clazz));
|
||||
}
|
||||
|
||||
// returns null if we don't have anything free
|
||||
private static synchronized Class getFreeVMImplClass() {
|
||||
while (!freeVMClasses.isEmpty()) {
|
||||
SoftReference ref = (SoftReference) freeVMClasses.remove(0);
|
||||
Object o = ref.get();
|
||||
if (o != null) {
|
||||
if (DEBUG) {
|
||||
System.out.println("re-using loaded VirtualMachineImpl");
|
||||
}
|
||||
return (Class) o;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Class getVMImplClassFrom(ClassLoader cl)
|
||||
throws ClassNotFoundException {
|
||||
return Class.forName("sun.jvm.hotspot.jdi.VirtualMachineImpl", true, cl);
|
||||
}
|
||||
|
||||
/* SA has not been designed to support multiple debuggee VMs
|
||||
* at-a-time. But, JDI supports multiple debuggee VMs. We
|
||||
* support multiple debuggee VMs in SA/JDI, by creating a new
|
||||
* class loader instance (refer to comment in SAJDIClassLoader
|
||||
* for details). But, to avoid excessive class loading (and
|
||||
* thereby resulting in larger footprint), we re-use 'dispose'd
|
||||
* VirtualMachineImpl classes.
|
||||
*/
|
||||
protected static Class loadVirtualMachineImplClass()
|
||||
throws ClassNotFoundException {
|
||||
Class vmImplClass = getFreeVMImplClass();
|
||||
if (vmImplClass == null) {
|
||||
ClassLoader cl = new SAJDIClassLoader(myLoader);
|
||||
vmImplClass = getVMImplClassFrom(cl);
|
||||
}
|
||||
return vmImplClass;
|
||||
}
|
||||
|
||||
/* We look for System property sun.jvm.hotspot.jdi.<vm version>.
|
||||
* This property should have the value of JDK HOME directory for
|
||||
* the given <vm version>.
|
||||
*/
|
||||
private static String getSAClassPathForVM(String vmVersion) {
|
||||
final String prefix = "sun.jvm.hotspot.jdi.";
|
||||
// look for exact match of VM version
|
||||
String jvmHome = System.getProperty(prefix + vmVersion);
|
||||
if (DEBUG) {
|
||||
System.out.println("looking for System property " + prefix + vmVersion);
|
||||
}
|
||||
|
||||
if (jvmHome == null) {
|
||||
// omit chars after first '-' in VM version and try
|
||||
// for example, in '1.5.0-b55' we take '1.5.0'
|
||||
int index = vmVersion.indexOf('-');
|
||||
if (index != -1) {
|
||||
vmVersion = vmVersion.substring(0, index);
|
||||
if (DEBUG) {
|
||||
System.out.println("looking for System property " + prefix + vmVersion);
|
||||
}
|
||||
jvmHome = System.getProperty(prefix + vmVersion);
|
||||
}
|
||||
|
||||
if (jvmHome == null) {
|
||||
// System property is not set
|
||||
if (DEBUG) {
|
||||
System.out.println("can't locate JDK home for " + vmVersion);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
System.out.println("JDK home for " + vmVersion + " is " + jvmHome);
|
||||
}
|
||||
|
||||
// sa-jdi is in $JDK_HOME/lib directory
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(jvmHome);
|
||||
buf.append(File.separatorChar);
|
||||
buf.append("lib");
|
||||
buf.append(File.separatorChar);
|
||||
buf.append("sa-jdi.jar");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/* This method loads VirtualMachineImpl class by a ClassLoader
|
||||
* configured with sa-jdi.jar path of given 'vmVersion'. This is
|
||||
* used for cross VM version debugging. Refer to comments in
|
||||
* SAJDIClassLoader as well.
|
||||
*/
|
||||
protected static Class loadVirtualMachineImplClass(String vmVersion)
|
||||
throws ClassNotFoundException {
|
||||
if (DEBUG) {
|
||||
System.out.println("attemping to load sa-jdi.jar for version " + vmVersion);
|
||||
}
|
||||
String classPath = getSAClassPathForVM(vmVersion);
|
||||
if (classPath != null) {
|
||||
ClassLoader cl = new SAJDIClassLoader(myLoader, classPath);
|
||||
return getVMImplClassFrom(cl);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* Is the given throwable an instanceof VMVersionMismatchException?
|
||||
* Note that we can't do instanceof check because the exception
|
||||
* class might have been loaded by a different class loader.
|
||||
*/
|
||||
private static boolean isVMVersionMismatch(Throwable throwable) {
|
||||
String className = throwable.getClass().getName();
|
||||
return className.equals("sun.jvm.hotspot.runtime.VMVersionMismatchException");
|
||||
}
|
||||
|
||||
/* gets target VM version from the given VMVersionMismatchException.
|
||||
* Note that we need to reflectively call the method because of we may
|
||||
* have got this from different classloader's namespace */
|
||||
private static String getVMVersion(Throwable throwable)
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
// assert isVMVersionMismatch(throwable), "not a VMVersionMismatch"
|
||||
Class expClass = throwable.getClass();
|
||||
Method targetVersionMethod = expClass.getMethod("getTargetVersion", new Class[0]);
|
||||
return (String) targetVersionMethod.invoke(throwable);
|
||||
}
|
||||
|
||||
/** If the causal chain has a sun.jvm.hotspot.runtime.VMVersionMismatchException,
|
||||
attempt to load VirtualMachineImpl class for target VM version. */
|
||||
protected static Class handleVMVersionMismatch(InvocationTargetException ite) {
|
||||
Throwable cause = ite.getCause();
|
||||
if (DEBUG) {
|
||||
System.out.println("checking for version mismatch...");
|
||||
}
|
||||
while (cause != null) {
|
||||
try {
|
||||
if (isVMVersionMismatch(cause)) {
|
||||
if (DEBUG) {
|
||||
System.out.println("Triggering cross VM version support...");
|
||||
}
|
||||
return loadVirtualMachineImplClass(getVMVersion(cause));
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
if (DEBUG) {
|
||||
System.out.println("failed to load VirtualMachineImpl class");
|
||||
exp.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
cause = cause.getCause();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void checkNativeLink(SecurityManager sm, String os) {
|
||||
if (os.equals("SunOS") || os.equals("Linux") || os.contains("OS X")) {
|
||||
// link "saproc" - SA native library on SunOS, Linux, and Mac OS X
|
||||
sm.checkLink("saproc");
|
||||
} else if (os.startsWith("Windows")) {
|
||||
// link "sawindbg" - SA native library on Windows.
|
||||
sm.checkLink("sawindbg");
|
||||
} else {
|
||||
throw new RuntimeException(os + " is not yet supported");
|
||||
}
|
||||
}
|
||||
|
||||
// we set an observer to detect VirtualMachineImpl.dispose call
|
||||
// and on dispose we add corresponding VirtualMachineImpl.class to
|
||||
// free VirtualMachimeImpl Class list.
|
||||
protected static void setVMDisposeObserver(final Object vm) {
|
||||
try {
|
||||
Method setDisposeObserverMethod = vm.getClass().getDeclaredMethod("setDisposeObserver",
|
||||
new Class[] { java.util.Observer.class });
|
||||
setDisposeObserverMethod.setAccessible(true);
|
||||
setDisposeObserverMethod.invoke(vm,
|
||||
new Object[] {
|
||||
new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
if (DEBUG) {
|
||||
System.out.println("got VM.dispose notification");
|
||||
}
|
||||
addFreeVMImplClass(vm.getClass());
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception exp) {
|
||||
if (DEBUG) {
|
||||
System.out.println("setVMDisposeObserver() got an exception:");
|
||||
exp.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Map defaultArguments() {
|
||||
Map defaults = new LinkedHashMap();
|
||||
Collection values = defaultArguments.values();
|
||||
|
||||
Iterator iter = values.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ArgumentImpl argument = (ArgumentImpl)iter.next();
|
||||
defaults.put(argument.name(), argument.clone());
|
||||
}
|
||||
return defaults;
|
||||
}
|
||||
|
||||
void addStringArgument(String name, String label, String description,
|
||||
String defaultValue, boolean mustSpecify) {
|
||||
defaultArguments.put(name,
|
||||
new StringArgumentImpl(name, label,
|
||||
description,
|
||||
defaultValue,
|
||||
mustSpecify));
|
||||
}
|
||||
|
||||
void addBooleanArgument(String name, String label, String description,
|
||||
boolean defaultValue, boolean mustSpecify) {
|
||||
defaultArguments.put(name,
|
||||
new BooleanArgumentImpl(name, label,
|
||||
description,
|
||||
defaultValue,
|
||||
mustSpecify));
|
||||
}
|
||||
|
||||
void addIntegerArgument(String name, String label, String description,
|
||||
String defaultValue, boolean mustSpecify,
|
||||
int min, int max) {
|
||||
defaultArguments.put(name,
|
||||
new IntegerArgumentImpl(name, label,
|
||||
description,
|
||||
defaultValue,
|
||||
mustSpecify,
|
||||
min, max));
|
||||
}
|
||||
|
||||
void addSelectedArgument(String name, String label, String description,
|
||||
String defaultValue, boolean mustSpecify,
|
||||
List list) {
|
||||
defaultArguments.put(name,
|
||||
new SelectedArgumentImpl(name, label,
|
||||
description,
|
||||
defaultValue,
|
||||
mustSpecify, list));
|
||||
}
|
||||
|
||||
ArgumentImpl argument(String name, Map arguments)
|
||||
throws IllegalConnectorArgumentsException {
|
||||
|
||||
ArgumentImpl argument = (ArgumentImpl)arguments.get(name);
|
||||
if (argument == null) {
|
||||
throw new IllegalConnectorArgumentsException(
|
||||
"Argument missing", name);
|
||||
}
|
||||
String value = argument.value();
|
||||
if (value == null || value.length() == 0) {
|
||||
if (argument.mustSpecify()) {
|
||||
throw new IllegalConnectorArgumentsException(
|
||||
"Argument unspecified", name);
|
||||
}
|
||||
} else if(!argument.isValid(value)) {
|
||||
throw new IllegalConnectorArgumentsException(
|
||||
"Argument invalid", name);
|
||||
}
|
||||
|
||||
return argument;
|
||||
}
|
||||
|
||||
String getString(String key) {
|
||||
//fixme jjh; needs i18n
|
||||
// this is not public return ((VirtualMachineManagerImpl)manager).getString(key);
|
||||
return key;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String string = name() + " (defaults: ";
|
||||
Iterator iter = defaultArguments().values().iterator();
|
||||
boolean first = true;
|
||||
while (iter.hasNext()) {
|
||||
ArgumentImpl argument = (ArgumentImpl)iter.next();
|
||||
if (!first) {
|
||||
string += ", ";
|
||||
}
|
||||
string += argument.toString();
|
||||
first = false;
|
||||
}
|
||||
return string + ")";
|
||||
}
|
||||
|
||||
abstract class ArgumentImpl implements Connector.Argument, Cloneable, Serializable {
|
||||
private String name;
|
||||
private String label;
|
||||
private String description;
|
||||
private String value;
|
||||
private boolean mustSpecify;
|
||||
|
||||
ArgumentImpl(String name, String label, String description,
|
||||
String value,
|
||||
boolean mustSpecify) {
|
||||
this.name = name;
|
||||
this.label = label;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.mustSpecify = mustSpecify;
|
||||
}
|
||||
|
||||
public abstract boolean isValid(String value);
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException("Can't set null value");
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean mustSpecify() {
|
||||
return mustSpecify;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof Connector.Argument)) {
|
||||
Connector.Argument other = (Connector.Argument)obj;
|
||||
return (name().equals(other.name())) &&
|
||||
(description().equals(other.description())) &&
|
||||
(mustSpecify() == other.mustSpecify()) &&
|
||||
(value().equals(other.value()));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return description().hashCode();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Object should always support clone
|
||||
throw (InternalException) new InternalException().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name() + "=" + value();
|
||||
}
|
||||
}
|
||||
|
||||
class BooleanArgumentImpl extends ConnectorImpl.ArgumentImpl
|
||||
implements Connector.BooleanArgument {
|
||||
|
||||
BooleanArgumentImpl(String name, String label, String description,
|
||||
boolean value,
|
||||
boolean mustSpecify) {
|
||||
super(name, label, description, null, mustSpecify);
|
||||
if(trueString == null) {
|
||||
trueString = getString("true");
|
||||
falseString = getString("false");
|
||||
}
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the argument.
|
||||
*/
|
||||
public void setValue(boolean value) {
|
||||
setValue(stringValueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value is a string
|
||||
* representation of a boolean value.
|
||||
* @see #stringValueOf(boolean)
|
||||
*/
|
||||
public boolean isValid(String value) {
|
||||
return value.equals(trueString) || value.equals(falseString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string representation of the <code>value</code>
|
||||
* parameter.
|
||||
* Does not set or examine the value or the argument.
|
||||
* @return the localized String representation of the
|
||||
* boolean value.
|
||||
*/
|
||||
public String stringValueOf(boolean value) {
|
||||
return value? trueString : falseString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the argument as a boolean. Since
|
||||
* the argument may not have been set or may have an invalid
|
||||
* value {@link #isValid(String)} should be called on
|
||||
* {@link #value()} to check its validity. If it is invalid
|
||||
* the boolean returned by this method is undefined.
|
||||
* @return the value of the argument as a boolean.
|
||||
*/
|
||||
public boolean booleanValue() {
|
||||
return value().equals(trueString);
|
||||
}
|
||||
}
|
||||
|
||||
class IntegerArgumentImpl extends ConnectorImpl.ArgumentImpl
|
||||
implements Connector.IntegerArgument {
|
||||
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
IntegerArgumentImpl(String name, String label, String description,
|
||||
String value,
|
||||
boolean mustSpecify, int min, int max) {
|
||||
super(name, label, description, value, mustSpecify);
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the argument.
|
||||
* The value should be checked with {@link #isValid(int)}
|
||||
* before setting it; invalid values will throw an exception
|
||||
* when the connection is established - for example,
|
||||
* on {@link LaunchingConnector#launch}
|
||||
*/
|
||||
public void setValue(int value) {
|
||||
setValue(stringValueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value represents an int that is
|
||||
* <code>{@link #min()} <= value <= {@link #max()}</code>
|
||||
*/
|
||||
public boolean isValid(String value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return isValid(Integer.decode(value).intValue());
|
||||
} catch(NumberFormatException exc) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if
|
||||
* <code>{@link #min()} <= value <= {@link #max()}</code>
|
||||
*/
|
||||
public boolean isValid(int value) {
|
||||
return min <= value && value <= max;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the string representation of the <code>value</code>
|
||||
* parameter.
|
||||
* Does not set or examine the value or the argument.
|
||||
* @return the String representation of the
|
||||
* int value.
|
||||
*/
|
||||
public String stringValueOf(int value) {
|
||||
// *** Should this be internationalized????
|
||||
// *** Even Brian Beck was unsure if an Arabic programmer
|
||||
// *** would expect port numbers in Arabic numerals,
|
||||
// *** so punt for now.
|
||||
return ""+value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value of the argument as a int. Since
|
||||
* the argument may not have been set or may have an invalid
|
||||
* value {@link #isValid(String)} should be called on
|
||||
* {@link #value()} to check its validity. If it is invalid
|
||||
* the int returned by this method is undefined.
|
||||
* @return the value of the argument as a int.
|
||||
*/
|
||||
public int intValue() {
|
||||
if (value() == null) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
return Integer.decode(value()).intValue();
|
||||
} catch(NumberFormatException exc) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The upper bound for the value.
|
||||
* @return the maximum allowed value for this argument.
|
||||
*/
|
||||
public int max() {
|
||||
return max;
|
||||
}
|
||||
|
||||
/**
|
||||
* The lower bound for the value.
|
||||
* @return the minimum allowed value for this argument.
|
||||
*/
|
||||
public int min() {
|
||||
return min;
|
||||
}
|
||||
}
|
||||
|
||||
class StringArgumentImpl extends ConnectorImpl.ArgumentImpl
|
||||
implements Connector.StringArgument {
|
||||
|
||||
StringArgumentImpl(String name, String label, String description,
|
||||
String value,
|
||||
boolean mustSpecify) {
|
||||
super(name, label, description, value, mustSpecify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> always
|
||||
*/
|
||||
public boolean isValid(String value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class SelectedArgumentImpl extends ConnectorImpl.ArgumentImpl
|
||||
implements Connector.SelectedArgument {
|
||||
|
||||
private final List choices;
|
||||
|
||||
SelectedArgumentImpl(String name, String label, String description,
|
||||
String value,
|
||||
boolean mustSpecify, List choices) {
|
||||
super(name, label, description, value, mustSpecify);
|
||||
this.choices = Collections.unmodifiableList(
|
||||
new ArrayList(choices));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the possible values for the argument
|
||||
* @return {@link List} of {@link String}
|
||||
*/
|
||||
public List choices() {
|
||||
return choices;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs basic sanity check of argument.
|
||||
* @return <code>true</code> if value is one of {@link #choices()}.
|
||||
*/
|
||||
public boolean isValid(String value) {
|
||||
return choices.contains(value);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class DoubleTypeImpl extends PrimitiveTypeImpl implements DoubleType {
|
||||
DoubleTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "D";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedDoubleValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class DoubleValueImpl extends PrimitiveValueImpl
|
||||
implements DoubleValue {
|
||||
private double value;
|
||||
|
||||
DoubleValueImpl(VirtualMachine aVm,double aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof DoubleValue)) {
|
||||
return (value == ((DoubleValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int compareTo(DoubleValue doubleVal) {
|
||||
double other = doubleVal.value();
|
||||
if (value() < other) {
|
||||
return -1;
|
||||
} else if (value() == other) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theDoubleType();
|
||||
}
|
||||
|
||||
public double value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0.0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to short");
|
||||
} else {
|
||||
return super.checkedShortValue();
|
||||
}
|
||||
}
|
||||
|
||||
int checkedIntValue() throws InvalidTypeException {
|
||||
if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to int");
|
||||
} else {
|
||||
return super.checkedIntValue();
|
||||
}
|
||||
}
|
||||
|
||||
long checkedLongValue() throws InvalidTypeException {
|
||||
long longValue = (long)value;
|
||||
if (longValue != value) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to long");
|
||||
} else {
|
||||
return super.checkedLongValue();
|
||||
}
|
||||
}
|
||||
|
||||
float checkedFloatValue() throws InvalidTypeException {
|
||||
float floatValue = (float)value;
|
||||
if (floatValue != value) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to float");
|
||||
} else {
|
||||
return super.checkedFloatValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.Array;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.FieldIdentifier;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class FieldImpl extends TypeComponentImpl implements Field {
|
||||
private JNITypeParser signatureParser;
|
||||
private sun.jvm.hotspot.oops.Field saField;
|
||||
|
||||
FieldImpl( VirtualMachine vm, ReferenceTypeImpl declaringType,
|
||||
sun.jvm.hotspot.oops.Field saField) {
|
||||
super(vm, declaringType);
|
||||
this.saField = saField;
|
||||
getParser();
|
||||
}
|
||||
|
||||
private void getParser() {
|
||||
if (signatureParser == null) {
|
||||
Symbol sig1 = saField.getSignature();
|
||||
signature = sig1.asString();
|
||||
signatureParser = new JNITypeParser(signature);
|
||||
}
|
||||
}
|
||||
|
||||
sun.jvm.hotspot.oops.Field ref() {
|
||||
return saField;
|
||||
}
|
||||
|
||||
// get the value of static field
|
||||
ValueImpl getValue() {
|
||||
return getValue(saField.getFieldHolder().getJavaMirror());
|
||||
}
|
||||
|
||||
// get the value of this Field from a specific Oop
|
||||
ValueImpl getValue(Oop target) {
|
||||
ValueImpl valueImpl;
|
||||
sun.jvm.hotspot.oops.Field saField = (sun.jvm.hotspot.oops.Field) ref();
|
||||
sun.jvm.hotspot.oops.FieldType ft = saField.getFieldType();
|
||||
if (ft.isArray()) {
|
||||
sun.jvm.hotspot.oops.OopField of = (sun.jvm.hotspot.oops.OopField)saField;
|
||||
valueImpl = (ArrayReferenceImpl) vm.arrayMirror((Array)of.getValue(target));
|
||||
} else if (ft.isObject()) {
|
||||
sun.jvm.hotspot.oops.OopField of = (sun.jvm.hotspot.oops.OopField)saField;
|
||||
valueImpl = (ObjectReferenceImpl) vm.objectMirror(of.getValue(target));
|
||||
} else if (ft.isByte()) {
|
||||
sun.jvm.hotspot.oops.ByteField bf = (sun.jvm.hotspot.oops.ByteField)saField;
|
||||
valueImpl = (ByteValueImpl) vm.mirrorOf(bf.getValue(target));
|
||||
} else if (ft.isChar()) {
|
||||
sun.jvm.hotspot.oops.CharField cf = (sun.jvm.hotspot.oops.CharField)saField;
|
||||
valueImpl = (CharValueImpl) vm.mirrorOf(cf.getValue(target));
|
||||
} else if (ft.isDouble()) {
|
||||
sun.jvm.hotspot.oops.DoubleField df = (sun.jvm.hotspot.oops.DoubleField)saField;
|
||||
valueImpl = (DoubleValueImpl) vm.mirrorOf(df.getValue(target));
|
||||
} else if (ft.isFloat()) {
|
||||
sun.jvm.hotspot.oops.FloatField ff = (sun.jvm.hotspot.oops.FloatField)saField;
|
||||
valueImpl = (FloatValueImpl) vm.mirrorOf(ff.getValue(target));
|
||||
} else if (ft.isInt()) {
|
||||
sun.jvm.hotspot.oops.IntField iif = (sun.jvm.hotspot.oops.IntField)saField;
|
||||
valueImpl = (IntegerValueImpl) vm.mirrorOf(iif.getValue(target));
|
||||
} else if (ft.isLong()) {
|
||||
sun.jvm.hotspot.oops.LongField lf = (sun.jvm.hotspot.oops.LongField)saField;
|
||||
valueImpl = (LongValueImpl) vm.mirrorOf(lf.getValue(target));
|
||||
} else if (ft.isShort()) {
|
||||
sun.jvm.hotspot.oops.ShortField sf = (sun.jvm.hotspot.oops.ShortField)saField;
|
||||
valueImpl = (ShortValueImpl) vm.mirrorOf(sf.getValue(target));
|
||||
} else if (ft.isBoolean()) {
|
||||
sun.jvm.hotspot.oops.BooleanField bf = (sun.jvm.hotspot.oops.BooleanField)saField;
|
||||
valueImpl = (BooleanValueImpl) vm.mirrorOf(bf.getValue(target));
|
||||
} else {
|
||||
throw new RuntimeException("Should not reach here");
|
||||
}
|
||||
return valueImpl;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof FieldImpl)) {
|
||||
FieldImpl other = (FieldImpl)obj;
|
||||
return (declaringType().equals(other.declaringType())) &&
|
||||
(ref().equals(other.ref())) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isTransient() {
|
||||
return saField.isTransient();
|
||||
}
|
||||
|
||||
public boolean isVolatile() {
|
||||
return saField.isVolatile();
|
||||
}
|
||||
|
||||
public boolean isEnumConstant() {
|
||||
return saField.isEnumConstant();
|
||||
}
|
||||
|
||||
public Type type() throws ClassNotLoadedException {
|
||||
// So, we do it just like JDI does by searching the enclosing type.
|
||||
return findType(signature());
|
||||
}
|
||||
|
||||
public String typeName() { //fixme jjh: jpda version creates redundant JNITypeParsers
|
||||
getParser();
|
||||
return signatureParser.typeName();
|
||||
}
|
||||
|
||||
public String genericSignature() {
|
||||
Symbol genSig = saField.getGenericSignature();
|
||||
return (genSig != null)? genSig.asString() : null;
|
||||
}
|
||||
|
||||
// From interface Comparable
|
||||
public int compareTo(Field field) {
|
||||
ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
|
||||
int rc = declaringType.compareTo(field.declaringType());
|
||||
if (rc == 0) {
|
||||
rc = declaringType.indexOf(this) -
|
||||
declaringType.indexOf(field);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
// from interface Mirror
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
buf.append(declaringType().name());
|
||||
buf.append('.');
|
||||
buf.append(name());
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public String name() {
|
||||
FieldIdentifier myName = saField.getID();
|
||||
return myName.getName();
|
||||
}
|
||||
|
||||
// From interface Accessible
|
||||
public int modifiers() {
|
||||
return saField.getAccessFlagsObj().getStandardFlags();
|
||||
}
|
||||
|
||||
public boolean isPackagePrivate() {
|
||||
return saField.isPackagePrivate();
|
||||
}
|
||||
|
||||
public boolean isPrivate() {
|
||||
return saField.isPrivate();
|
||||
}
|
||||
|
||||
public boolean isProtected() {
|
||||
return saField.isProtected();
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return saField.isPublic();
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return saField.isStatic();
|
||||
}
|
||||
|
||||
public boolean isFinal() {
|
||||
return saField.isFinal();
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return saField.isSynthetic();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return saField.hashCode();
|
||||
}
|
||||
|
||||
|
||||
private Type findType(String signature) throws ClassNotLoadedException {
|
||||
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
|
||||
return enclosing.findType(signature);
|
||||
}
|
||||
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class FloatTypeImpl extends PrimitiveTypeImpl implements FloatType {
|
||||
FloatTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "F";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedFloatValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,151 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class FloatValueImpl extends PrimitiveValueImpl
|
||||
implements FloatValue {
|
||||
private float value;
|
||||
|
||||
FloatValueImpl(VirtualMachine aVm,float aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof FloatValue)) {
|
||||
return (value == ((FloatValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(FloatValue floatVal) {
|
||||
float other = floatVal.value();
|
||||
if (value() < other) {
|
||||
return -1;
|
||||
} else if (value() == other) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theFloatType();
|
||||
}
|
||||
|
||||
public float value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0.0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to short");
|
||||
} else {
|
||||
return super.checkedShortValue();
|
||||
}
|
||||
}
|
||||
|
||||
int checkedIntValue() throws InvalidTypeException {
|
||||
int intValue = (int)value;
|
||||
if (intValue != value) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to int");
|
||||
} else {
|
||||
return super.checkedIntValue();
|
||||
}
|
||||
}
|
||||
|
||||
long checkedLongValue() throws InvalidTypeException {
|
||||
long longValue = (long)value;
|
||||
if (longValue != value) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to long");
|
||||
} else {
|
||||
return super.checkedLongValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class IntegerTypeImpl extends PrimitiveTypeImpl implements IntegerType {
|
||||
IntegerTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
return "I";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedIntValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class IntegerValueImpl extends PrimitiveValueImpl
|
||||
implements IntegerValue {
|
||||
private int value;
|
||||
|
||||
IntegerValueImpl(VirtualMachine aVm,int aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof IntegerValue)) {
|
||||
return (value == ((IntegerValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(IntegerValue integerVal) {
|
||||
return value() - integerVal.value();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theIntegerType();
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to short");
|
||||
} else {
|
||||
return super.checkedShortValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,215 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
|
||||
import com.sun.jdi.ClassNotPreparedException;
|
||||
import com.sun.jdi.ClassType;
|
||||
import com.sun.jdi.InterfaceType;
|
||||
import com.sun.jdi.Method;
|
||||
import com.sun.jdi.ReferenceType;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
|
||||
public class InterfaceTypeImpl extends ReferenceTypeImpl
|
||||
implements InterfaceType {
|
||||
private SoftReference superInterfacesCache = null;
|
||||
private SoftReference subInterfacesCache = null;
|
||||
private SoftReference implementorsCache = null;
|
||||
|
||||
protected InterfaceTypeImpl(VirtualMachine aVm, InstanceKlass aRef) {
|
||||
super(aVm, aRef);
|
||||
}
|
||||
|
||||
public List superinterfaces() throws ClassNotPreparedException {
|
||||
List superinterfaces = (superInterfacesCache != null)? (List) superInterfacesCache.get() : null;
|
||||
if (superinterfaces == null) {
|
||||
checkPrepared();
|
||||
superinterfaces = Collections.unmodifiableList(getInterfaces());
|
||||
superInterfacesCache = new SoftReference(superinterfaces);
|
||||
}
|
||||
return superinterfaces;
|
||||
}
|
||||
|
||||
public List subinterfaces() {
|
||||
List subinterfaces = (subInterfacesCache != null)? (List) subInterfacesCache.get() : null;
|
||||
if (subinterfaces == null) {
|
||||
List all = vm.allClasses();
|
||||
subinterfaces = new ArrayList();
|
||||
Iterator iter = all.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType refType = (ReferenceType)iter.next();
|
||||
if (refType instanceof InterfaceType) {
|
||||
InterfaceType interfaze = (InterfaceType)refType;
|
||||
if (interfaze.isPrepared() && interfaze.superinterfaces().contains(this)) {
|
||||
subinterfaces.add(interfaze);
|
||||
}
|
||||
}
|
||||
}
|
||||
subinterfaces = Collections.unmodifiableList(subinterfaces);
|
||||
subInterfacesCache = new SoftReference(subinterfaces);
|
||||
}
|
||||
return subinterfaces;
|
||||
}
|
||||
|
||||
public List implementors() {
|
||||
List implementors = (implementorsCache != null)? (List) implementorsCache.get() : null;
|
||||
if (implementors == null) {
|
||||
List all = vm.allClasses();
|
||||
implementors = new ArrayList();
|
||||
Iterator iter = all.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType refType = (ReferenceType)iter.next();
|
||||
if (refType instanceof ClassType) {
|
||||
ClassType clazz = (ClassType)refType;
|
||||
if (clazz.isPrepared() && clazz.interfaces().contains(this)) {
|
||||
implementors.add(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
implementors = Collections.unmodifiableList(implementors);
|
||||
implementorsCache = new SoftReference(implementors);
|
||||
}
|
||||
return implementors;
|
||||
}
|
||||
|
||||
@Override
|
||||
void addVisibleMethods(Map<String, Method> methodMap, Set<InterfaceType> seenInterfaces) {
|
||||
/*
|
||||
* Add methods from
|
||||
* parent types first, so that the methods in this class will
|
||||
* overwrite them in the hash table
|
||||
*/
|
||||
Iterator<InterfaceType> iter = superinterfaces().iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
if (!seenInterfaces.contains(interfaze)) {
|
||||
interfaze.addVisibleMethods(methodMap, seenInterfaces);
|
||||
seenInterfaces.add(interfaze);
|
||||
}
|
||||
}
|
||||
|
||||
addToMethodMap(methodMap, methods());
|
||||
}
|
||||
|
||||
List getAllMethods() {
|
||||
ArrayList list = new ArrayList(methods());
|
||||
/*
|
||||
* It's more efficient if don't do this
|
||||
* recursively.
|
||||
*/
|
||||
List interfaces = allSuperinterfaces();
|
||||
Iterator iter = interfaces.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceType interfaze = (InterfaceType)iter.next();
|
||||
list.addAll(interfaze.methods());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
List allSuperinterfaces() {
|
||||
ArrayList list = new ArrayList();
|
||||
addSuperinterfaces(list);
|
||||
return list;
|
||||
}
|
||||
|
||||
void addSuperinterfaces(List list) {
|
||||
/*
|
||||
* This code is a little strange because it
|
||||
* builds the list with a more suitable order than the
|
||||
* depth-first approach a normal recursive solution would
|
||||
* take. Instead, all direct superinterfaces precede all
|
||||
* indirect ones.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Get a list of direct superinterfaces that's not already in the
|
||||
* list being built.
|
||||
*/
|
||||
List immediate = new ArrayList(superinterfaces());
|
||||
Iterator iter = immediate.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceType interfaze = (InterfaceType)iter.next();
|
||||
if (list.contains(interfaze)) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Add all new direct superinterfaces
|
||||
*/
|
||||
list.addAll(immediate);
|
||||
|
||||
/*
|
||||
* Recurse for all new direct superinterfaces.
|
||||
*/
|
||||
iter = immediate.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
interfaze.addSuperinterfaces(list);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isAssignableTo(ReferenceType type) {
|
||||
|
||||
// Exact match?
|
||||
if (this.equals(type)) {
|
||||
return true;
|
||||
} else {
|
||||
// Try superinterfaces.
|
||||
List supers = superinterfaces();
|
||||
Iterator iter = supers.iterator();
|
||||
while (iter.hasNext()) {
|
||||
InterfaceTypeImpl interfaze = (InterfaceTypeImpl)iter.next();
|
||||
if (interfaze.isAssignableTo(type)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
List inheritedTypes() {
|
||||
return superinterfaces();
|
||||
}
|
||||
|
||||
public boolean isInitialized() {
|
||||
return isPrepared();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "interface " + name() + " (" + loaderString() + ")";
|
||||
}
|
||||
}
|
@ -1,240 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class JNITypeParser {
|
||||
|
||||
static final char SIGNATURE_ENDCLASS = ';';
|
||||
static final char SIGNATURE_FUNC = '(';
|
||||
static final char SIGNATURE_ENDFUNC = ')';
|
||||
|
||||
private String signature;
|
||||
private List typeNameList;
|
||||
private List signatureList;
|
||||
private int currentIndex;
|
||||
|
||||
JNITypeParser(String signature) {
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
static String typeNameToSignature(String signature) {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
int firstIndex = signature.indexOf('[');
|
||||
int index = firstIndex;
|
||||
while (index != -1) {
|
||||
buffer.append('[');
|
||||
index = signature.indexOf('[', index + 1);
|
||||
}
|
||||
|
||||
if (firstIndex != -1) {
|
||||
signature = signature.substring(0, firstIndex);
|
||||
}
|
||||
|
||||
if (signature.equals("boolean")) {
|
||||
buffer.append('Z');
|
||||
} else if (signature.equals("byte")) {
|
||||
buffer.append('B');
|
||||
} else if (signature.equals("char")) {
|
||||
buffer.append('C');
|
||||
} else if (signature.equals("short")) {
|
||||
buffer.append('S');
|
||||
} else if (signature.equals("int")) {
|
||||
buffer.append('I');
|
||||
} else if (signature.equals("long")) {
|
||||
buffer.append('J');
|
||||
} else if (signature.equals("float")) {
|
||||
buffer.append('F');
|
||||
} else if (signature.equals("double")) {
|
||||
buffer.append('D');
|
||||
} else {
|
||||
buffer.append('L');
|
||||
buffer.append(signature.replace('.', '/'));
|
||||
buffer.append(';');
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
String typeName() {
|
||||
return (String)typeNameList().get(typeNameList().size()-1);
|
||||
}
|
||||
|
||||
List argumentTypeNames() {
|
||||
return typeNameList().subList(0, typeNameList().size() - 1);
|
||||
}
|
||||
|
||||
String signature() {
|
||||
return (String)signatureList().get(signatureList().size()-1);
|
||||
}
|
||||
|
||||
List argumentSignatures() {
|
||||
return signatureList().subList(0, signatureList().size() - 1);
|
||||
}
|
||||
|
||||
int dimensionCount() {
|
||||
int count = 0;
|
||||
String signature = signature();
|
||||
while (signature.charAt(count) == '[') {
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
String componentSignature(int level) {
|
||||
return signature().substring(level);
|
||||
}
|
||||
|
||||
private synchronized List signatureList() {
|
||||
if (signatureList == null) {
|
||||
signatureList = new ArrayList(10);
|
||||
String elem;
|
||||
|
||||
currentIndex = 0;
|
||||
|
||||
while(currentIndex < signature.length()) {
|
||||
elem = nextSignature();
|
||||
signatureList.add(elem);
|
||||
}
|
||||
if (signatureList.size() == 0) {
|
||||
throw new IllegalArgumentException("Invalid JNI signature '" +
|
||||
signature + "'");
|
||||
}
|
||||
}
|
||||
return signatureList;
|
||||
}
|
||||
|
||||
private synchronized List typeNameList() {
|
||||
if (typeNameList == null) {
|
||||
typeNameList = new ArrayList(10);
|
||||
String elem;
|
||||
|
||||
currentIndex = 0;
|
||||
|
||||
while(currentIndex < signature.length()) {
|
||||
elem = nextTypeName();
|
||||
typeNameList.add(elem);
|
||||
}
|
||||
if (typeNameList.size() == 0) {
|
||||
throw new IllegalArgumentException("Invalid JNI signature '" +
|
||||
signature + "'");
|
||||
}
|
||||
}
|
||||
return typeNameList;
|
||||
}
|
||||
|
||||
private String nextSignature() {
|
||||
char key = signature.charAt(currentIndex++);
|
||||
|
||||
switch(key) {
|
||||
case '[':
|
||||
return key + nextSignature();
|
||||
|
||||
case 'L':
|
||||
int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
|
||||
currentIndex);
|
||||
String retVal = signature.substring(currentIndex - 1,
|
||||
endClass + 1);
|
||||
currentIndex = endClass + 1;
|
||||
return retVal;
|
||||
|
||||
case 'V':
|
||||
case 'Z':
|
||||
case 'B':
|
||||
case 'C':
|
||||
case 'S':
|
||||
case 'I':
|
||||
case 'J':
|
||||
case 'F':
|
||||
case 'D':
|
||||
return String.valueOf(key);
|
||||
|
||||
case SIGNATURE_FUNC:
|
||||
case SIGNATURE_ENDFUNC:
|
||||
return nextSignature();
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid JNI signature character '" + key + "'");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String nextTypeName() {
|
||||
char key = signature.charAt(currentIndex++);
|
||||
|
||||
switch(key) {
|
||||
case '[':
|
||||
return nextTypeName() + "[]";
|
||||
|
||||
case 'B':
|
||||
return "byte";
|
||||
|
||||
case 'C':
|
||||
return "char";
|
||||
|
||||
case 'L':
|
||||
int endClass = signature.indexOf(SIGNATURE_ENDCLASS,
|
||||
currentIndex);
|
||||
String retVal = signature.substring(currentIndex,
|
||||
endClass);
|
||||
retVal = retVal.replace('/','.');
|
||||
currentIndex = endClass + 1;
|
||||
return retVal;
|
||||
|
||||
case 'F':
|
||||
return "float";
|
||||
|
||||
case 'D':
|
||||
return "double";
|
||||
|
||||
case 'I':
|
||||
return "int";
|
||||
|
||||
case 'J':
|
||||
return "long";
|
||||
|
||||
case 'S':
|
||||
return "short";
|
||||
|
||||
case 'V':
|
||||
return "void";
|
||||
|
||||
case 'Z':
|
||||
return "boolean";
|
||||
|
||||
case SIGNATURE_ENDFUNC:
|
||||
case SIGNATURE_FUNC:
|
||||
return nextTypeName();
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid JNI signature character '" + key + "'");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
// from JVMTI specification - refer to jvmti.xml
|
||||
public interface JVMTIThreadState {
|
||||
public static final int JVMTI_THREAD_STATE_ALIVE = 0x0001;
|
||||
public static final int JVMTI_THREAD_STATE_TERMINATED = 0x0002;
|
||||
public static final int JVMTI_THREAD_STATE_RUNNABLE = 0x0004;
|
||||
public static final int JVMTI_THREAD_STATE_WAITING = 0x0080;
|
||||
public static final int JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010;
|
||||
public static final int JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020;
|
||||
public static final int JVMTI_THREAD_STATE_SLEEPING = 0x0040;
|
||||
public static final int JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100;
|
||||
public static final int JVMTI_THREAD_STATE_PARKED = 0x0200;
|
||||
public static final int JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400;
|
||||
public static final int JVMTI_THREAD_STATE_SUSPENDED = 0x100000;
|
||||
public static final int JVMTI_THREAD_STATE_INTERRUPTED = 0x200000;
|
||||
public static final int JVMTI_THREAD_STATE_IN_NATIVE = 0x400000;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
interface LineInfo {
|
||||
|
||||
String liStratum();
|
||||
|
||||
int liLineNumber();
|
||||
|
||||
String liSourceName() throws AbsentInformationException;
|
||||
|
||||
String liSourcePath() throws AbsentInformationException;
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class LocalVariableImpl extends MirrorImpl
|
||||
implements LocalVariable, ValueContainer
|
||||
{
|
||||
private final Method method;
|
||||
private final int slot;
|
||||
private final Location scopeStart;
|
||||
private final Location scopeEnd;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
private final String genericSignature;
|
||||
|
||||
LocalVariableImpl(VirtualMachine vm, Method method,
|
||||
int slot, Location scopeStart, Location scopeEnd,
|
||||
String name, String signature, String genericSignature) {
|
||||
super(vm);
|
||||
this.method = method;
|
||||
this.slot = slot;
|
||||
this.scopeStart = scopeStart;
|
||||
this.scopeEnd = scopeEnd;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
this.genericSignature = genericSignature;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof LocalVariableImpl)) {
|
||||
LocalVariableImpl other = (LocalVariableImpl)obj;
|
||||
return (method.equals(other.method) &&
|
||||
slot() == other.slot() &&
|
||||
super.equals(obj));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return (int)method.hashCode() + slot();
|
||||
}
|
||||
|
||||
public int compareTo(LocalVariable localVar) {
|
||||
LocalVariableImpl other = (LocalVariableImpl) localVar;
|
||||
int rc = method.compareTo(other.method);
|
||||
if (rc == 0) {
|
||||
rc = slot() - other.slot();
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a text representation of the declared type
|
||||
* of this variable.
|
||||
*/
|
||||
public String typeName() {
|
||||
JNITypeParser parser = new JNITypeParser(signature);
|
||||
return parser.typeName();
|
||||
}
|
||||
|
||||
public Type type() throws ClassNotLoadedException {
|
||||
return findType(signature());
|
||||
}
|
||||
|
||||
public Type findType(String signature) throws ClassNotLoadedException {
|
||||
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)method.declaringType();
|
||||
return enclosing.findType(signature);
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public String genericSignature() {
|
||||
return genericSignature;
|
||||
}
|
||||
|
||||
public boolean isVisible(StackFrame frame) {
|
||||
//validateMirror(frame);
|
||||
Method frameMethod = frame.location().method();
|
||||
|
||||
if (!frameMethod.equals(method)) {
|
||||
throw new IllegalArgumentException(
|
||||
"frame method different than variable's method");
|
||||
}
|
||||
|
||||
// this is here to cover the possibility that we will
|
||||
// allow LocalVariables for native methods. If we do
|
||||
// so we will have to re-examinine this.
|
||||
if (frameMethod.isNative()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ((scopeStart.compareTo(frame.location()) <= 0)
|
||||
&& (scopeEnd.compareTo(frame.location()) >= 0));
|
||||
}
|
||||
|
||||
public boolean isArgument() {
|
||||
try {
|
||||
MethodImpl method = (MethodImpl)scopeStart.method();
|
||||
return (slot < method.argSlotCount());
|
||||
} catch (AbsentInformationException e) {
|
||||
// If this variable object exists, there shouldn't be absent info
|
||||
throw (InternalException) new InternalException().initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
int slot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compilers/VMs can have byte code ranges for variables of the
|
||||
* same names that overlap. This is because the byte code ranges
|
||||
* aren't necessarily scopes; they may have more to do with the
|
||||
* lifetime of the variable's slot, depending on implementation.
|
||||
*
|
||||
* This method determines whether this variable hides an
|
||||
* identically named variable; ie, their byte code ranges overlap
|
||||
* this one starts after the given one. If it returns true this
|
||||
* variable should be preferred when looking for a single variable
|
||||
* with its name when both variables are visible.
|
||||
*/
|
||||
boolean hides(LocalVariable other) {
|
||||
LocalVariableImpl otherImpl = (LocalVariableImpl)other;
|
||||
if (!method.equals(otherImpl.method) ||
|
||||
!name.equals(otherImpl.name)) {
|
||||
return false;
|
||||
} else {
|
||||
return (scopeStart.compareTo(otherImpl.scopeStart) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name() + " in " + method.toString() +
|
||||
"@" + scopeStart.toString();
|
||||
}
|
||||
}
|
@ -1,224 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class LocationImpl extends MirrorImpl implements Location {
|
||||
private final ReferenceTypeImpl declaringType;
|
||||
private Method method;
|
||||
private sun.jvm.hotspot.oops.Method methodRef;
|
||||
private long codeIndex;
|
||||
private LineInfo baseLineInfo = null;
|
||||
private LineInfo otherLineInfo = null;
|
||||
|
||||
LocationImpl(VirtualMachine vm,
|
||||
Method method, long codeIndex) {
|
||||
super(vm);
|
||||
|
||||
this.method = method;
|
||||
this.codeIndex = method.isNative()? -1 : codeIndex;
|
||||
this.declaringType = (ReferenceTypeImpl)method.declaringType();
|
||||
}
|
||||
|
||||
/*
|
||||
* This constructor allows lazy creation of the method mirror. This
|
||||
* can be a performance savings if the method mirror does not yet
|
||||
* exist.
|
||||
*/
|
||||
LocationImpl(VirtualMachine vm, ReferenceType declaringType,
|
||||
sun.jvm.hotspot.oops.Method methodRef, long codeIndex) {
|
||||
super(vm);
|
||||
|
||||
this.method = null;
|
||||
this.codeIndex = codeIndex;
|
||||
this.declaringType = (ReferenceTypeImpl)declaringType;
|
||||
this.methodRef = methodRef;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof Location)) {
|
||||
Location other = (Location)obj;
|
||||
return (method().equals(other.method())) &&
|
||||
(codeIndex() == other.codeIndex()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: better hash code?
|
||||
*/
|
||||
return method().hashCode() + (int)codeIndex();
|
||||
}
|
||||
|
||||
public int compareTo(Location other) {
|
||||
int rc = method().compareTo(other.method());
|
||||
if (rc == 0) {
|
||||
long diff = codeIndex() - other.codeIndex();
|
||||
if (diff < 0)
|
||||
return -1;
|
||||
else if (diff > 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
public ReferenceType declaringType() {
|
||||
return declaringType;
|
||||
}
|
||||
|
||||
public Method method() {
|
||||
if (method == null) {
|
||||
method = declaringType.getMethodMirror(methodRef);
|
||||
if (method.isNative()) {
|
||||
codeIndex = -1;
|
||||
}
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
public long codeIndex() {
|
||||
method(); // be sure information is up-to-date
|
||||
return codeIndex;
|
||||
}
|
||||
|
||||
LineInfo getBaseLineInfo(SDE.Stratum stratum) {
|
||||
LineInfo lineInfo;
|
||||
|
||||
/* check if there is cached info to use */
|
||||
if (baseLineInfo != null) {
|
||||
return baseLineInfo;
|
||||
}
|
||||
|
||||
/* compute the line info */
|
||||
MethodImpl methodImpl = (MethodImpl)method();
|
||||
lineInfo = methodImpl.codeIndexToLineInfo(stratum,
|
||||
codeIndex());
|
||||
|
||||
/* cache it */
|
||||
addBaseLineInfo(lineInfo);
|
||||
|
||||
return lineInfo;
|
||||
}
|
||||
|
||||
LineInfo getLineInfo(SDE.Stratum stratum) {
|
||||
LineInfo lineInfo;
|
||||
|
||||
/* base stratum is done slighly differently */
|
||||
if (stratum.isJava()) {
|
||||
return getBaseLineInfo(stratum);
|
||||
}
|
||||
|
||||
/* check if there is cached info to use */
|
||||
lineInfo = otherLineInfo; // copy because of concurrency
|
||||
if (lineInfo != null &&
|
||||
stratum.id().equals(lineInfo.liStratum())) {
|
||||
return lineInfo;
|
||||
}
|
||||
int baseLineNumber = lineNumber(SDE.BASE_STRATUM_NAME);
|
||||
SDE.LineStratum lineStratum =
|
||||
stratum.lineStratum(declaringType, baseLineNumber);
|
||||
|
||||
if (lineStratum != null && lineStratum.lineNumber() != -1) {
|
||||
lineInfo = new StratumLineInfo(stratum.id(),
|
||||
lineStratum.lineNumber(),
|
||||
lineStratum.sourceName(),
|
||||
lineStratum.sourcePath());
|
||||
} else {
|
||||
/* find best match */
|
||||
MethodImpl methodImpl = (MethodImpl)method();
|
||||
lineInfo = methodImpl.codeIndexToLineInfo(stratum,
|
||||
codeIndex());
|
||||
}
|
||||
|
||||
/* cache it */
|
||||
addStratumLineInfo(lineInfo);
|
||||
|
||||
return lineInfo;
|
||||
}
|
||||
|
||||
void addStratumLineInfo(LineInfo lineInfo) {
|
||||
otherLineInfo = lineInfo;
|
||||
}
|
||||
|
||||
void addBaseLineInfo(LineInfo lineInfo) {
|
||||
baseLineInfo = lineInfo;
|
||||
}
|
||||
|
||||
public String sourceName() throws AbsentInformationException {
|
||||
return sourceName(vm.getDefaultStratum());
|
||||
}
|
||||
|
||||
public String sourceName(String stratumID)
|
||||
throws AbsentInformationException {
|
||||
return sourceName(declaringType.stratum(stratumID));
|
||||
}
|
||||
|
||||
String sourceName(SDE.Stratum stratum)
|
||||
throws AbsentInformationException {
|
||||
return getLineInfo(stratum).liSourceName();
|
||||
}
|
||||
|
||||
public String sourcePath() throws AbsentInformationException {
|
||||
return sourcePath(vm.getDefaultStratum());
|
||||
}
|
||||
|
||||
public String sourcePath(String stratumID)
|
||||
throws AbsentInformationException {
|
||||
return sourcePath(declaringType.stratum(stratumID));
|
||||
}
|
||||
|
||||
String sourcePath(SDE.Stratum stratum)
|
||||
throws AbsentInformationException {
|
||||
return getLineInfo(stratum).liSourcePath();
|
||||
}
|
||||
|
||||
public int lineNumber() {
|
||||
return lineNumber(vm.getDefaultStratum());
|
||||
}
|
||||
|
||||
public int lineNumber(String stratumID) {
|
||||
return lineNumber(declaringType.stratum(stratumID));
|
||||
}
|
||||
|
||||
int lineNumber(SDE.Stratum stratum) {
|
||||
return getLineInfo(stratum).liLineNumber();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (lineNumber() == -1) {
|
||||
return method().toString() + "+" + codeIndex();
|
||||
} else {
|
||||
return declaringType().name() + ":" + lineNumber();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class LongTypeImpl extends PrimitiveTypeImpl implements LongType {
|
||||
LongTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "J";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedLongValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class LongValueImpl extends PrimitiveValueImpl
|
||||
implements LongValue {
|
||||
private long value;
|
||||
|
||||
LongValueImpl(VirtualMachine aVm,long aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof LongValue)) {
|
||||
return (value == ((LongValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(LongValue longVal) {
|
||||
long other = longVal.value();
|
||||
if (value() < other) {
|
||||
return -1;
|
||||
} else if (value() == other) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theLongType();
|
||||
}
|
||||
|
||||
public long value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
if ((value > Short.MAX_VALUE) || (value < Short.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to short");
|
||||
} else {
|
||||
return super.checkedShortValue();
|
||||
}
|
||||
}
|
||||
|
||||
int checkedIntValue() throws InvalidTypeException {
|
||||
if ((value > Integer.MAX_VALUE) || (value < Integer.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to int");
|
||||
} else {
|
||||
return super.checkedIntValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,272 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.LocalVariableTableElement;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class MethodImpl extends TypeComponentImpl implements Method {
|
||||
private JNITypeParser signatureParser;
|
||||
protected sun.jvm.hotspot.oops.Method saMethod;
|
||||
|
||||
abstract int argSlotCount() throws AbsentInformationException;
|
||||
abstract List allLineLocations(SDE.Stratum stratum,
|
||||
String sourceName)
|
||||
throws AbsentInformationException;
|
||||
abstract List locationsOfLine(SDE.Stratum stratum,
|
||||
String sourceName,
|
||||
int lineNumber)
|
||||
throws AbsentInformationException;
|
||||
|
||||
static MethodImpl createMethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
|
||||
sun.jvm.hotspot.oops.Method saMethod) {
|
||||
// Someday might have to add concrete and non-concrete subclasses.
|
||||
if (saMethod.isNative() || saMethod.isAbstract()) {
|
||||
return new NonConcreteMethodImpl(vm, declaringType, saMethod);
|
||||
} else {
|
||||
return new ConcreteMethodImpl(vm, declaringType, saMethod);
|
||||
}
|
||||
}
|
||||
|
||||
MethodImpl(VirtualMachine vm, ReferenceTypeImpl declaringType,
|
||||
sun.jvm.hotspot.oops.Method saMethod ) {
|
||||
super(vm, declaringType);
|
||||
this.saMethod = saMethod;
|
||||
getParser();
|
||||
}
|
||||
|
||||
private JNITypeParser getParser() {
|
||||
if (signatureParser == null) {
|
||||
Symbol sig1 = saMethod.getSignature();
|
||||
signature = sig1.asString();
|
||||
signatureParser = new JNITypeParser(signature);
|
||||
}
|
||||
return signatureParser;
|
||||
}
|
||||
|
||||
// Object ref() {
|
||||
sun.jvm.hotspot.oops.Method ref() {
|
||||
return saMethod;
|
||||
}
|
||||
|
||||
public String genericSignature() {
|
||||
Symbol genSig = saMethod.getGenericSignature();
|
||||
return (genSig != null)? genSig.asString() : null;
|
||||
}
|
||||
|
||||
public String returnTypeName() {
|
||||
return getParser().typeName();
|
||||
}
|
||||
|
||||
public Type returnType() throws ClassNotLoadedException {
|
||||
return findType(getParser().signature());
|
||||
}
|
||||
|
||||
private Type findType(String signature) throws ClassNotLoadedException {
|
||||
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
|
||||
return enclosing.findType(signature);
|
||||
}
|
||||
|
||||
public List argumentTypeNames() {
|
||||
return getParser().argumentTypeNames();
|
||||
}
|
||||
|
||||
List argumentSignatures() {
|
||||
return getParser().argumentSignatures();
|
||||
}
|
||||
|
||||
Type argumentType(int index) throws ClassNotLoadedException {
|
||||
ReferenceTypeImpl enclosing = (ReferenceTypeImpl)declaringType();
|
||||
String signature = (String)argumentSignatures().get(index);
|
||||
return enclosing.findType(signature);
|
||||
}
|
||||
|
||||
public List argumentTypes() throws ClassNotLoadedException {
|
||||
int size = argumentSignatures().size();
|
||||
ArrayList types = new ArrayList(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
Type type = argumentType(i);
|
||||
types.add(type);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
public boolean isAbstract() {
|
||||
return saMethod.isAbstract();
|
||||
}
|
||||
|
||||
public boolean isBridge() {
|
||||
return saMethod.isBridge();
|
||||
}
|
||||
|
||||
public boolean isSynchronized() {
|
||||
return saMethod.isSynchronized();
|
||||
}
|
||||
|
||||
public boolean isNative() {
|
||||
return saMethod.isNative();
|
||||
}
|
||||
|
||||
public boolean isVarArgs() {
|
||||
return saMethod.isVarArgs();
|
||||
}
|
||||
|
||||
public boolean isConstructor() {
|
||||
return saMethod.isConstructor();
|
||||
}
|
||||
|
||||
public boolean isStaticInitializer() {
|
||||
return saMethod.isStaticInitializer();
|
||||
}
|
||||
|
||||
public boolean isObsolete() {
|
||||
return saMethod.isObsolete();
|
||||
}
|
||||
|
||||
public final List allLineLocations()
|
||||
throws AbsentInformationException {
|
||||
return allLineLocations(vm.getDefaultStratum(), null);
|
||||
}
|
||||
|
||||
public List allLineLocations(String stratumID,
|
||||
String sourceName)
|
||||
throws AbsentInformationException {
|
||||
return allLineLocations(declaringType.stratum(stratumID),
|
||||
sourceName);
|
||||
}
|
||||
|
||||
public final List locationsOfLine(int lineNumber)
|
||||
throws AbsentInformationException {
|
||||
return locationsOfLine(vm.getDefaultStratum(),
|
||||
null, lineNumber);
|
||||
}
|
||||
|
||||
public List locationsOfLine(String stratumID,
|
||||
String sourceName,
|
||||
int lineNumber)
|
||||
throws AbsentInformationException {
|
||||
return locationsOfLine(declaringType.stratum(stratumID),
|
||||
sourceName, lineNumber);
|
||||
}
|
||||
|
||||
LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
|
||||
long codeIndex) {
|
||||
if (stratum.isJava()) {
|
||||
return new BaseLineInfo(-1, declaringType);
|
||||
} else {
|
||||
return new StratumLineInfo(stratum.id(), -1,
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof MethodImpl)) {
|
||||
MethodImpl other = (MethodImpl)obj;
|
||||
return (declaringType().equals(other.declaringType())) &&
|
||||
(ref().equals(other.ref())) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// From interface Comparable
|
||||
public int compareTo(Method method) {
|
||||
ReferenceTypeImpl declaringType = (ReferenceTypeImpl)declaringType();
|
||||
int rc = declaringType.compareTo(method.declaringType());
|
||||
if (rc == 0) {
|
||||
rc = declaringType.indexOf(this) -
|
||||
declaringType.indexOf(method);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
// from interface Mirror
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(declaringType().name());
|
||||
sb.append(".");
|
||||
sb.append(name());
|
||||
sb.append("(");
|
||||
boolean first = true;
|
||||
for (Iterator it = argumentTypeNames().iterator(); it.hasNext();) {
|
||||
if (!first) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append((String)it.next());
|
||||
first = false;
|
||||
}
|
||||
sb.append(")");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String name() {
|
||||
Symbol myName = saMethod.getName();
|
||||
return myName.asString();
|
||||
}
|
||||
|
||||
public int modifiers() {
|
||||
return saMethod.getAccessFlagsObj().getStandardFlags();
|
||||
}
|
||||
|
||||
public boolean isPackagePrivate() {
|
||||
return saMethod.isPackagePrivate();
|
||||
}
|
||||
|
||||
public boolean isPrivate() {
|
||||
return saMethod.isPrivate();
|
||||
}
|
||||
|
||||
public boolean isProtected() {
|
||||
return saMethod.isProtected();
|
||||
}
|
||||
|
||||
public boolean isPublic() {
|
||||
return saMethod.isPublic();
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return saMethod.isStatic();
|
||||
}
|
||||
|
||||
public boolean isSynthetic() {
|
||||
return saMethod.isSynthetic();
|
||||
}
|
||||
|
||||
public boolean isFinal() {
|
||||
return saMethod.isFinal();
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return saMethod.hashCode();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
abstract class MirrorImpl extends Object implements Mirror {
|
||||
protected VirtualMachineImpl vm;
|
||||
|
||||
MirrorImpl(VirtualMachine aVm) {
|
||||
super();
|
||||
|
||||
// Yes, its a bit of a hack. But by doing it this
|
||||
// way, this is the only place we have to change
|
||||
// typing to substitute a new impl.
|
||||
vm = (VirtualMachineImpl)aVm;
|
||||
}
|
||||
|
||||
public VirtualMachine virtualMachine() {
|
||||
return vm;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof Mirror)) {
|
||||
Mirror other = (Mirror)obj;
|
||||
return vm.equals(other.virtualMachine());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return vm.hashCode();
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
// FIXME: This class should implement com.sun.jdi.MonitorInfo.
|
||||
// So fix this when hotspot is started to build with
|
||||
// jdk1.6.
|
||||
public class MonitorInfoImpl extends MirrorImpl {
|
||||
|
||||
/* Once false, monitorInfo should not be used.
|
||||
* access synchronized on (vm.state())
|
||||
*/
|
||||
private boolean isValid = true;
|
||||
|
||||
ObjectReference monitor;
|
||||
ThreadReference thread;
|
||||
int stack_depth;
|
||||
|
||||
MonitorInfoImpl(VirtualMachine vm, ObjectReference mon,
|
||||
ThreadReference thread, int dpth) {
|
||||
super(vm);
|
||||
this.monitor = mon;
|
||||
this.thread = thread;
|
||||
this.stack_depth = dpth;
|
||||
}
|
||||
|
||||
private void validateMonitorInfo() {
|
||||
if (!isValid) {
|
||||
throw new InvalidStackFrameException("Thread has been resumed");
|
||||
}
|
||||
}
|
||||
|
||||
public ObjectReference monitor() {
|
||||
validateMonitorInfo();
|
||||
return monitor;
|
||||
}
|
||||
|
||||
public int stackDepth() {
|
||||
validateMonitorInfo();
|
||||
return stack_depth;
|
||||
}
|
||||
|
||||
public ThreadReference thread() {
|
||||
validateMonitorInfo();
|
||||
return thread;
|
||||
}
|
||||
}
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.ListIterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Represents non-concrete (that is, native or abstract) methods.
|
||||
* Private to MethodImpl.
|
||||
*/
|
||||
public class NonConcreteMethodImpl extends MethodImpl {
|
||||
|
||||
private Location location = null;
|
||||
|
||||
NonConcreteMethodImpl(VirtualMachine vm,
|
||||
ReferenceTypeImpl declaringType,
|
||||
sun.jvm.hotspot.oops.Method saMethod) {
|
||||
super(vm, declaringType, saMethod);
|
||||
}
|
||||
|
||||
public Location location() {
|
||||
if (isAbstract()) {
|
||||
return null;
|
||||
}
|
||||
if (location == null) {
|
||||
location = new LocationImpl(vm, this, -1);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
public List allLineLocations(String stratumID,
|
||||
String sourceName) {
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
public List allLineLocations(SDE.Stratum stratum,
|
||||
String sourceName) {
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
public List locationsOfLine(String stratumID,
|
||||
String sourceName,
|
||||
int lineNumber) {
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
public List locationsOfLine(SDE.Stratum stratum,
|
||||
String sourceName,
|
||||
int lineNumber) {
|
||||
return new ArrayList(0);
|
||||
}
|
||||
|
||||
public Location locationOfCodeIndex(long codeIndex) {
|
||||
return null;
|
||||
}
|
||||
|
||||
LineInfo codeIndexToLineInfo(SDE.Stratum stratum,
|
||||
long codeIndex) {
|
||||
|
||||
if (stratum.isJava()) {
|
||||
return new BaseLineInfo(-1, declaringType);
|
||||
} else {
|
||||
return new StratumLineInfo(stratum.id(), -1,
|
||||
null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public List variables() throws AbsentInformationException {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
|
||||
public List variablesByName(String name) throws AbsentInformationException {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
|
||||
public List arguments() throws AbsentInformationException {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
|
||||
public byte[] bytecodes() {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
int argSlotCount() throws AbsentInformationException {
|
||||
throw new InternalException("should not get here");
|
||||
}
|
||||
}
|
@ -1,367 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.io.*;
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.Mark;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.Array;
|
||||
import sun.jvm.hotspot.oops.OopUtilities;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.oops.DefaultHeapVisitor;
|
||||
import sun.jvm.hotspot.runtime.JavaThread;
|
||||
import sun.jvm.hotspot.runtime.JavaVFrame;
|
||||
import sun.jvm.hotspot.runtime.MonitorInfo;
|
||||
import sun.jvm.hotspot.runtime.ObjectMonitor;
|
||||
import sun.jvm.hotspot.runtime.Threads;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ObjectReferenceImpl extends ValueImpl implements ObjectReference {
|
||||
private Oop saObject;
|
||||
private long myID;
|
||||
private boolean monitorInfoCached = false;
|
||||
private ThreadReferenceImpl owningThread = null;
|
||||
private List waitingThreads = null; // List<ThreadReferenceImpl>
|
||||
private int entryCount = 0;
|
||||
|
||||
private static long nextID = 0L;
|
||||
private static synchronized long nextID() {
|
||||
return nextID++;
|
||||
}
|
||||
|
||||
ObjectReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Oop oRef) {
|
||||
super(aVm);
|
||||
saObject = oRef;
|
||||
myID = nextID();
|
||||
}
|
||||
|
||||
protected Oop ref() {
|
||||
return saObject;
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return referenceType();
|
||||
}
|
||||
|
||||
public ReferenceType referenceType() {
|
||||
Klass myKlass = ref().getKlass();
|
||||
return vm.referenceType(myKlass);
|
||||
}
|
||||
|
||||
public Value getValue(Field sig) {
|
||||
List list = new ArrayList(1);
|
||||
list.add(sig);
|
||||
Map map = getValues(list);
|
||||
return(Value)map.get(sig);
|
||||
}
|
||||
|
||||
public Map getValues(List theFields) {
|
||||
//validateMirrors(theFields);
|
||||
|
||||
List staticFields = new ArrayList(0);
|
||||
int size = theFields.size();
|
||||
List instanceFields = new ArrayList(size);
|
||||
|
||||
for (int i=0; i<size; i++) {
|
||||
sun.jvm.hotspot.jdi.FieldImpl field =
|
||||
(sun.jvm.hotspot.jdi.FieldImpl)theFields.get(i);
|
||||
|
||||
// Make sure the field is valid
|
||||
((ReferenceTypeImpl)referenceType()).validateFieldAccess(field);
|
||||
|
||||
// FIX ME! We need to do some sanity checking
|
||||
// here; make sure the field belongs to this
|
||||
// object.
|
||||
if (field.isStatic()) {
|
||||
staticFields.add(field);
|
||||
} else {
|
||||
instanceFields.add(field);
|
||||
}
|
||||
}
|
||||
|
||||
// Look up static field(s) first to mimic the JDI implementation
|
||||
Map map;
|
||||
if (staticFields.size() > 0) {
|
||||
map = referenceType().getValues(staticFields);
|
||||
} else {
|
||||
map = new HashMap(size);
|
||||
}
|
||||
|
||||
// Then get instance field(s)
|
||||
size = instanceFields.size();
|
||||
for (int ii=0; ii<size; ii++){
|
||||
FieldImpl fieldImpl = (FieldImpl)instanceFields.get(ii);
|
||||
map.put(fieldImpl, fieldImpl.getValue(saObject));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void setValue(Field field, Value value)
|
||||
throws InvalidTypeException, ClassNotLoadedException {
|
||||
vm.throwNotReadOnlyException("ObjectReference.setValue(...)");
|
||||
}
|
||||
|
||||
public Value invokeMethod(ThreadReference threadIntf, Method methodIntf,
|
||||
List arguments, int options)
|
||||
throws InvalidTypeException,
|
||||
IncompatibleThreadStateException,
|
||||
InvocationException,
|
||||
ClassNotLoadedException {
|
||||
vm.throwNotReadOnlyException("ObjectReference.invokeMethod(...)");
|
||||
return null;
|
||||
}
|
||||
|
||||
public void disableCollection() {
|
||||
vm.throwNotReadOnlyException("ObjectReference.disableCollection()");
|
||||
}
|
||||
|
||||
public void enableCollection() {
|
||||
vm.throwNotReadOnlyException("ObjectReference.enableCollection()");
|
||||
}
|
||||
|
||||
public boolean isCollected() {
|
||||
vm.throwNotReadOnlyException("ObjectReference.isCollected()");
|
||||
return false;
|
||||
}
|
||||
|
||||
public long uniqueID() {
|
||||
return myID;
|
||||
}
|
||||
|
||||
public List waitingThreads() throws IncompatibleThreadStateException {
|
||||
if (vm.canGetMonitorInfo() == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (! monitorInfoCached) {
|
||||
computeMonitorInfo();
|
||||
}
|
||||
return waitingThreads;
|
||||
}
|
||||
|
||||
|
||||
public ThreadReference owningThread() throws IncompatibleThreadStateException {
|
||||
if (vm.canGetMonitorInfo() == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (! monitorInfoCached) {
|
||||
computeMonitorInfo();
|
||||
}
|
||||
return owningThread;
|
||||
}
|
||||
|
||||
|
||||
public int entryCount() throws IncompatibleThreadStateException {
|
||||
if (vm.canGetMonitorInfo() == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (! monitorInfoCached) {
|
||||
computeMonitorInfo();
|
||||
}
|
||||
return entryCount;
|
||||
}
|
||||
|
||||
// new method since 1.6.
|
||||
// Real body will be supplied later.
|
||||
public List referringObjects(long maxReferrers) {
|
||||
if (!vm.canGetInstanceInfo()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"target does not support getting instances");
|
||||
}
|
||||
if (maxReferrers < 0) {
|
||||
throw new IllegalArgumentException("maxReferrers is less than zero: "
|
||||
+ maxReferrers);
|
||||
}
|
||||
final ObjectReference obj = this;
|
||||
final List objects = new ArrayList(0);
|
||||
final long max = maxReferrers;
|
||||
vm.saObjectHeap().iterate(new DefaultHeapVisitor() {
|
||||
private long refCount = 0;
|
||||
public boolean doObj(Oop oop) {
|
||||
try {
|
||||
ObjectReference objref = vm.objectMirror(oop);
|
||||
List fields = objref.referenceType().allFields();
|
||||
for (int i=0; i < fields.size(); i++) {
|
||||
Field fld = (Field)fields.get(i);
|
||||
if (objref.getValue(fld).equals(obj) && !objects.contains(objref)) {
|
||||
objects.add(objref);
|
||||
refCount++;
|
||||
}
|
||||
}
|
||||
if (max > 0 && refCount >= max) {
|
||||
return true;
|
||||
}
|
||||
} catch (RuntimeException x) {
|
||||
// Ignore RuntimeException thrown from vm.objectMirror(oop)
|
||||
// for bad oop. It is possible to see some bad oop
|
||||
// because heap might be iterating at no safepoint.
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
});
|
||||
return objects;
|
||||
}
|
||||
|
||||
// refer to JvmtiEnvBase::count_locked_objects.
|
||||
// Count the number of objects for a lightweight monitor. The obj
|
||||
// parameter is object that owns the monitor so this routine will
|
||||
// count the number of times the same object was locked by frames
|
||||
// in JavaThread. i.e., we count total number of times the same
|
||||
// object is (lightweight) locked by given thread.
|
||||
private int countLockedObjects(JavaThread jt, Oop obj) {
|
||||
int res = 0;
|
||||
JavaVFrame frame = jt.getLastJavaVFrameDbg();
|
||||
while (frame != null) {
|
||||
List monitors = frame.getMonitors();
|
||||
OopHandle givenHandle = obj.getHandle();
|
||||
for (Iterator itr = monitors.iterator(); itr.hasNext();) {
|
||||
MonitorInfo mi = (MonitorInfo) itr.next();
|
||||
if (mi.eliminated() && frame.isCompiledFrame()) continue; // skip eliminated monitor
|
||||
if (givenHandle.equals(mi.owner())) {
|
||||
res++;
|
||||
}
|
||||
}
|
||||
frame = (JavaVFrame) frame.javaSender();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// wrappers on same named method of Threads class
|
||||
// returns List<JavaThread>
|
||||
private List getPendingThreads(ObjectMonitor mon) {
|
||||
return vm.saVM().getThreads().getPendingThreads(mon);
|
||||
}
|
||||
|
||||
// returns List<JavaThread>
|
||||
private List getWaitingThreads(ObjectMonitor mon) {
|
||||
return vm.saVM().getThreads().getWaitingThreads(mon);
|
||||
}
|
||||
|
||||
private JavaThread owningThreadFromMonitor(Address addr) {
|
||||
return vm.saVM().getThreads().owningThreadFromMonitor(addr);
|
||||
}
|
||||
|
||||
// refer to JvmtiEnv::GetObjectMonitorUsage
|
||||
private void computeMonitorInfo() {
|
||||
monitorInfoCached = true;
|
||||
Mark mark = saObject.getMark();
|
||||
ObjectMonitor mon = null;
|
||||
Address owner = null;
|
||||
// check for heavyweight monitor
|
||||
if (! mark.hasMonitor()) {
|
||||
// check for lightweight monitor
|
||||
if (mark.hasLocker()) {
|
||||
owner = mark.locker().getAddress(); // save the address of the Lock word
|
||||
}
|
||||
// implied else: no owner
|
||||
} else {
|
||||
// this object has a heavyweight monitor
|
||||
mon = mark.monitor();
|
||||
|
||||
// The owner field of a heavyweight monitor may be NULL for no
|
||||
// owner, a JavaThread * or it may still be the address of the
|
||||
// Lock word in a JavaThread's stack. A monitor can be inflated
|
||||
// by a non-owning JavaThread, but only the owning JavaThread
|
||||
// can change the owner field from the Lock word to the
|
||||
// JavaThread * and it may not have done that yet.
|
||||
owner = mon.owner();
|
||||
}
|
||||
|
||||
// find the owning thread
|
||||
if (owner != null) {
|
||||
owningThread = vm.threadMirror(owningThreadFromMonitor(owner));
|
||||
}
|
||||
|
||||
// compute entryCount
|
||||
if (owningThread != null) {
|
||||
if (owningThread.getJavaThread().getAddress().equals(owner)) {
|
||||
// the owner field is the JavaThread *
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(false, "must have heavyweight monitor with JavaThread * owner");
|
||||
}
|
||||
entryCount = (int) mark.monitor().recursions() + 1;
|
||||
} else {
|
||||
// The owner field is the Lock word on the JavaThread's stack
|
||||
// so the recursions field is not valid. We have to count the
|
||||
// number of recursive monitor entries the hard way.
|
||||
entryCount = countLockedObjects(owningThread.getJavaThread(), saObject);
|
||||
}
|
||||
}
|
||||
|
||||
// find the contenders & waiters
|
||||
waitingThreads = new ArrayList();
|
||||
if (mon != null) {
|
||||
// this object has a heavyweight monitor. threads could
|
||||
// be contenders or waiters
|
||||
// add all contenders
|
||||
List pendingThreads = getPendingThreads(mon);
|
||||
// convert the JavaThreads to ThreadReferenceImpls
|
||||
for (Iterator itrPend = pendingThreads.iterator(); itrPend.hasNext();) {
|
||||
waitingThreads.add(vm.threadMirror((JavaThread) itrPend.next()));
|
||||
}
|
||||
|
||||
// add all waiters (threads in Object.wait())
|
||||
// note that we don't do this JVMTI way. To do it JVMTI way,
|
||||
// we would need to access ObjectWaiter list maintained in
|
||||
// ObjectMonitor::_queue. But we don't have this struct exposed
|
||||
// in vmStructs. We do waiters list in a way similar to getting
|
||||
// pending threads list
|
||||
List objWaitingThreads = getWaitingThreads(mon);
|
||||
// convert the JavaThreads to ThreadReferenceImpls
|
||||
for (Iterator itrWait = objWaitingThreads.iterator(); itrWait.hasNext();) {
|
||||
waitingThreads.add(vm.threadMirror((JavaThread) itrWait.next()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof ObjectReferenceImpl)) {
|
||||
ObjectReferenceImpl other = (ObjectReferenceImpl)obj;
|
||||
return (ref().equals(other.ref())) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return saObject.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "instance of " + referenceType().name() + "(id=" + uniqueID() + ")";
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
abstract class PrimitiveTypeImpl extends TypeImpl implements PrimitiveType {
|
||||
|
||||
PrimitiveTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
/*
|
||||
* Converts the given primitive value to a value of this type.
|
||||
*/
|
||||
abstract PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException;
|
||||
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public abstract class PrimitiveValueImpl extends ValueImpl
|
||||
implements PrimitiveValue {
|
||||
|
||||
PrimitiveValueImpl(VirtualMachine aVm) {
|
||||
super(aVm);
|
||||
}
|
||||
|
||||
abstract public boolean booleanValue();
|
||||
abstract public byte byteValue();
|
||||
abstract public char charValue();
|
||||
abstract public short shortValue();
|
||||
abstract public int intValue();
|
||||
abstract public long longValue();
|
||||
abstract public float floatValue();
|
||||
abstract public double doubleValue();
|
||||
|
||||
/*
|
||||
* The checked versions of the value accessors throw
|
||||
* InvalidTypeException if the required conversion is
|
||||
* narrowing and would result in the loss of information
|
||||
* (either magnitude or precision).
|
||||
*
|
||||
* Default implementations here do no checking; subclasses
|
||||
* override as necessary to do the proper checking.
|
||||
*/
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
return byteValue();
|
||||
}
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
return charValue();
|
||||
}
|
||||
short checkedShortValue() throws InvalidTypeException {
|
||||
return shortValue();
|
||||
}
|
||||
int checkedIntValue() throws InvalidTypeException {
|
||||
return intValue();
|
||||
}
|
||||
long checkedLongValue() throws InvalidTypeException {
|
||||
return longValue();
|
||||
}
|
||||
float checkedFloatValue() throws InvalidTypeException {
|
||||
return floatValue();
|
||||
}
|
||||
|
||||
final boolean checkedBooleanValue() throws InvalidTypeException {
|
||||
/*
|
||||
* Always disallow a conversion to boolean from any other
|
||||
* primitive
|
||||
*/
|
||||
if (this instanceof BooleanValue) {
|
||||
return booleanValue();
|
||||
} else {
|
||||
throw new InvalidTypeException("Can't convert non-boolean value to boolean");
|
||||
}
|
||||
}
|
||||
|
||||
final double checkedDoubleValue() throws InvalidTypeException {
|
||||
/*
|
||||
* Can't overflow by converting to double, so this method
|
||||
* is never overridden
|
||||
*/
|
||||
return doubleValue();
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,156 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.Bootstrap;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import com.sun.jdi.VirtualMachineManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SACoreAttachingConnector extends ConnectorImpl implements AttachingConnector {
|
||||
|
||||
static final String ARG_COREFILE = "core";
|
||||
static final String ARG_JAVA_EXECUTABLE = "javaExecutable";
|
||||
private Transport transport;
|
||||
|
||||
public SACoreAttachingConnector(com.sun.tools.jdi.VirtualMachineManagerService ignored) {
|
||||
this();
|
||||
}
|
||||
|
||||
public SACoreAttachingConnector() {
|
||||
super();
|
||||
//fixme jjh Must create resources for these strings
|
||||
addStringArgument(
|
||||
ARG_JAVA_EXECUTABLE,
|
||||
"Java Executable", //getString("sa.javaExecutable.label"),
|
||||
"Pathname of Java Executable", //getString("sa.javaExecutable.description");
|
||||
"",
|
||||
true);
|
||||
|
||||
addStringArgument(
|
||||
ARG_COREFILE,
|
||||
"Corefile", // getString("sa.CoreFile.label"),
|
||||
"Pathname of a corefile from a Java Process", //getString("sa.CoreFile.description"),
|
||||
"core",
|
||||
false);
|
||||
|
||||
transport = new Transport() {
|
||||
public String name() {
|
||||
return "filesystem";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// security check to see whether the caller can perform attach
|
||||
private void checkCoreAttach(String corefile) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
try {
|
||||
// whether the caller can link against SA native library?
|
||||
checkNativeLink(sm, System.getProperty("os.name"));
|
||||
// check whether the caller can read the core file?
|
||||
sm.checkRead(corefile);
|
||||
} catch (SecurityException se) {
|
||||
throw new SecurityException("permission denied to attach to " + corefile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualMachine createVirtualMachine(Class vmImplClass,
|
||||
String javaExec, String corefile)
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
java.lang.reflect.Method connectByCoreMethod = vmImplClass.getMethod(
|
||||
"createVirtualMachineForCorefile",
|
||||
new Class[] {
|
||||
VirtualMachineManager.class,
|
||||
String.class, String.class,
|
||||
Integer.TYPE
|
||||
});
|
||||
return (VirtualMachine) connectByCoreMethod.invoke(null,
|
||||
new Object[] {
|
||||
Bootstrap.virtualMachineManager(),
|
||||
javaExec,
|
||||
corefile,
|
||||
new Integer(0)
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualMachine attach(Map arguments) throws IOException,
|
||||
IllegalConnectorArgumentsException {
|
||||
String javaExec = argument(ARG_JAVA_EXECUTABLE, arguments).value();
|
||||
if (javaExec == null || javaExec.equals("")) {
|
||||
throw new IllegalConnectorArgumentsException("javaExec should be non-null and non-empty",
|
||||
ARG_JAVA_EXECUTABLE);
|
||||
}
|
||||
String corefile = argument(ARG_COREFILE, arguments).value();
|
||||
if (corefile == null || corefile.equals("")) {
|
||||
throw new IllegalConnectorArgumentsException("corefile should be non-null and non-empty",
|
||||
ARG_COREFILE);
|
||||
}
|
||||
|
||||
checkCoreAttach(corefile);
|
||||
|
||||
VirtualMachine myVM = null;
|
||||
try {
|
||||
try {
|
||||
Class vmImplClass = loadVirtualMachineImplClass();
|
||||
myVM = createVirtualMachine(vmImplClass, javaExec, corefile);
|
||||
} catch (InvocationTargetException ite) {
|
||||
Class vmImplClass = handleVMVersionMismatch(ite);
|
||||
if (vmImplClass != null) {
|
||||
return createVirtualMachine(vmImplClass, javaExec, corefile);
|
||||
} else {
|
||||
throw ite;
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
if (DEBUG) {
|
||||
System.out.println("VirtualMachineImpl() got an exception:");
|
||||
ee.printStackTrace();
|
||||
System.out.println("coreFile = " + corefile + ", javaExec = " + javaExec);
|
||||
}
|
||||
throw (IOException) new IOException().initCause(ee);
|
||||
}
|
||||
setVMDisposeObserver(myVM);
|
||||
return myVM;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return "sun.jvm.hotspot.jdi.SACoreAttachingConnector";
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return getString("This connector allows you to attach to a core file using the Serviceability Agent");
|
||||
}
|
||||
|
||||
public Transport transport() {
|
||||
return transport;
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
public final class SADebugServer {
|
||||
// do not allow instance creation
|
||||
private SADebugServer() {}
|
||||
|
||||
private static void usage() {
|
||||
java.io.PrintStream out = System.out;
|
||||
out.println("Usage: jsadebugd [options] <pid> [server-id]");
|
||||
out.println("\t\t(to connect to a live java process)");
|
||||
out.println(" or jsadebugd [options] <executable> <core> [server-id]");
|
||||
out.println("\t\t(to connect to a core file produced by <executable>)");
|
||||
out.println("\t\tserver-id is an optional unique id for this debug server, needed ");
|
||||
out.println("\t\tif multiple debug servers are run on the same machine");
|
||||
out.println("where options include:");
|
||||
out.println(" -h | -help\tto print this help message");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if ((args.length < 1) || (args.length > 3)) {
|
||||
usage();
|
||||
}
|
||||
|
||||
// Attempt to handle "-h" or "-help"
|
||||
if (args[0].startsWith("-")) {
|
||||
usage();
|
||||
}
|
||||
|
||||
// By default SA agent classes prefer Windows process debugger
|
||||
// to windbg debugger. SA expects special properties to be set
|
||||
// to choose other debuggers. We will set those here before
|
||||
// attaching to SA agent.
|
||||
|
||||
System.setProperty("sun.jvm.hotspot.debugger.useWindbgDebugger", "true");
|
||||
|
||||
// delegate to the actual SA debug server.
|
||||
sun.jvm.hotspot.DebugServer.main(args);
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.Bootstrap;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import com.sun.jdi.VirtualMachineManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SADebugServerAttachingConnector extends ConnectorImpl implements AttachingConnector {
|
||||
|
||||
static final String ARG_DEBUG_SERVER_NAME = "debugServerName";
|
||||
private Transport transport;
|
||||
|
||||
public SADebugServerAttachingConnector(com.sun.tools.jdi.VirtualMachineManagerService ignored) {
|
||||
this();
|
||||
}
|
||||
|
||||
public SADebugServerAttachingConnector() {
|
||||
// fixme jjh create resources for the these strings,
|
||||
addStringArgument(
|
||||
ARG_DEBUG_SERVER_NAME,
|
||||
"Debug Server", //getString("sa.debugServer.label"),
|
||||
"Name of a remote SA Debug Server", //getString("sa.debugServer.description");
|
||||
"",
|
||||
true);
|
||||
transport = new Transport() {
|
||||
public String name() {
|
||||
return "RMI";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private VirtualMachine createVirtualMachine(Class vmImplClass,
|
||||
String debugServerName)
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
java.lang.reflect.Method connectByServerMethod =
|
||||
vmImplClass.getMethod(
|
||||
"createVirtualMachineForServer",
|
||||
new Class[] {
|
||||
VirtualMachineManager.class,
|
||||
String.class,
|
||||
Integer.TYPE
|
||||
});
|
||||
return (VirtualMachine) connectByServerMethod.invoke(null,
|
||||
new Object[] {
|
||||
Bootstrap.virtualMachineManager(),
|
||||
debugServerName,
|
||||
new Integer(0)
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualMachine attach(Map arguments) throws IOException,
|
||||
IllegalConnectorArgumentsException {
|
||||
String debugServerName = argument(ARG_DEBUG_SERVER_NAME, arguments).value();
|
||||
if (debugServerName == null || debugServerName.equals("")) {
|
||||
throw new IllegalConnectorArgumentsException("debugServerName should be non-null and non-empty",
|
||||
ARG_DEBUG_SERVER_NAME);
|
||||
}
|
||||
VirtualMachine myVM;
|
||||
try {
|
||||
try {
|
||||
Class vmImplClass = loadVirtualMachineImplClass();
|
||||
myVM = createVirtualMachine(vmImplClass, debugServerName);
|
||||
} catch (InvocationTargetException ite) {
|
||||
Class vmImplClass = handleVMVersionMismatch(ite);
|
||||
if (vmImplClass != null) {
|
||||
return createVirtualMachine(vmImplClass, debugServerName);
|
||||
} else {
|
||||
throw ite;
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
if (DEBUG) {
|
||||
System.out.println("VirtualMachineImpl() got an exception:");
|
||||
ee.printStackTrace();
|
||||
System.out.println("debug server name = " + debugServerName);
|
||||
}
|
||||
throw (IOException) new IOException().initCause(ee);
|
||||
}
|
||||
setVMDisposeObserver(myVM);
|
||||
return myVM;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return "sun.jvm.hotspot.jdi.SADebugServerAttachingConnector";
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return getString("This connector allows you to attach to a Java Process via a debug server with the Serviceability Agent");
|
||||
}
|
||||
|
||||
public Transport transport() {
|
||||
return transport;
|
||||
}
|
||||
}
|
@ -1,154 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
|
||||
/*
|
||||
* This class loader is used for two different reasons:
|
||||
*
|
||||
* 1) To support multiple simultaneous debuggees.
|
||||
*
|
||||
* SA's architecture does not allow us to use multiple simultaneous
|
||||
* debuggees. This is because of lots of static fields caching
|
||||
* vmStruct fields and singleton assumption in classes such as
|
||||
* 'sun.jvm.hotspot.runtime.VM'. Hence, we use instances of this
|
||||
* class loader to create a separate namespace for each debuggee VM.
|
||||
*
|
||||
* 2) To support cross VM version debugging.
|
||||
*
|
||||
* SA has very close dependency on VM data structures. Due to this, a
|
||||
* version of SA can only support debuggees running a same dot-dot release and
|
||||
* update releases only. For eg. this version of SA supports only 1.4.2 and
|
||||
* 1.4.2_xx releases only. But, users may want to debug debuggees running
|
||||
* a different version of VM. To support this, we use an instance of this
|
||||
* class loader to load classes from corresponding sa-jdi.jar.
|
||||
*
|
||||
* Note that JDI classes would still be loaded from the debugger's tools.jar
|
||||
* and not from debuggee's tools.jar. This means that if JDI interface evolved
|
||||
* b/w debuggee and debugger VM versions, user may still get problems. This is
|
||||
* the case when debugger runs on 1.5.0 and debuggee runs on 1.4.2. Because JDI
|
||||
* evolved b/w these versions (generics, enum, varargs etc.), 1.4.2 sa-jdi.jar
|
||||
* won't implement 1.5.0 JDI properly and user would get verifier errors. This
|
||||
* class loader solution is suited for different dot-dot release where JDI will
|
||||
* not evolve but VM data structures might change and SA implementation might
|
||||
* have to change. For example, a debuggee running 1.5.1 VM can be debugged
|
||||
* with debugger running on 1.5.0 VM. Here, JDI is same but VM data structures
|
||||
* could still change.
|
||||
*/
|
||||
|
||||
class SAJDIClassLoader extends URLClassLoader {
|
||||
private static final boolean DEBUG;
|
||||
static {
|
||||
DEBUG = System.getProperty("sun.jvm.hotspot.jdi.SAJDIClassLoader.DEBUG") != null;
|
||||
}
|
||||
|
||||
private ClassLoader parent;
|
||||
private boolean classPathSet;
|
||||
|
||||
SAJDIClassLoader(ClassLoader parent) {
|
||||
super(new URL[0], parent);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
SAJDIClassLoader(ClassLoader parent, String classPath) {
|
||||
this(parent);
|
||||
this.classPathSet = true;
|
||||
try {
|
||||
addURL(new File(classPath).toURI().toURL());
|
||||
} catch(MalformedURLException mue) {
|
||||
throw new RuntimeException(mue);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Class loadClass(String name)
|
||||
throws ClassNotFoundException {
|
||||
// First, check if the class has already been loaded
|
||||
Class c = findLoadedClass(name);
|
||||
if (c == null) {
|
||||
/* If we are loading any class in 'sun.jvm.hotspot.' or any of the
|
||||
* sub-packages (except for 'debugger' sub-pkg. please refer below),
|
||||
* we load it by 'this' loader. Or else, we forward the request to
|
||||
* 'parent' loader, system loader etc. (rest of the code follows
|
||||
* the patten in java.lang.ClassLoader.loadClass).
|
||||
*
|
||||
* 'sun.jvm.hotspot.debugger.' and sub-package classes are
|
||||
* also loaded by parent loader. This is done for two reasons:
|
||||
*
|
||||
* 1. to avoid code bloat by too many classes.
|
||||
* 2. to avoid loading same native library multiple times
|
||||
* from multiple class loaders (which results in getting a
|
||||
* UnsatisifiedLinkageError from System.loadLibrary).
|
||||
*/
|
||||
|
||||
if (name.startsWith("sun.jvm.hotspot.") &&
|
||||
!name.startsWith("sun.jvm.hotspot.debugger.")) {
|
||||
return findClass(name);
|
||||
}
|
||||
if (parent != null) {
|
||||
c = parent.loadClass(name);
|
||||
} else {
|
||||
c = findSystemClass(name);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
protected Class findClass(String name) throws ClassNotFoundException {
|
||||
if (DEBUG) {
|
||||
System.out.println("SA/JDI loader: about to load " + name);
|
||||
}
|
||||
if (classPathSet) {
|
||||
return super.findClass(name);
|
||||
} else {
|
||||
byte[] b = null;
|
||||
try {
|
||||
InputStream in = getResourceAsStream(name.replace('.', '/') + ".class");
|
||||
// Read until end of stream is reached
|
||||
b = new byte[1024];
|
||||
int total = 0;
|
||||
int len = 0;
|
||||
while ((len = in.read(b, total, b.length - total)) != -1) {
|
||||
total += len;
|
||||
if (total >= b.length) {
|
||||
byte[] tmp = new byte[total * 2];
|
||||
System.arraycopy(b, 0, tmp, 0, total);
|
||||
b = tmp;
|
||||
}
|
||||
}
|
||||
// Trim array to correct size, if necessary
|
||||
if (total != b.length) {
|
||||
byte[] tmp = new byte[total];
|
||||
System.arraycopy(b, 0, tmp, 0, total);
|
||||
b = tmp;
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
throw (ClassNotFoundException) new ClassNotFoundException().initCause(exp);
|
||||
}
|
||||
return defineClass(name, b, 0, b.length);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.Bootstrap;
|
||||
import com.sun.jdi.VirtualMachine;
|
||||
import com.sun.jdi.VirtualMachineManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SAPIDAttachingConnector extends ConnectorImpl implements AttachingConnector {
|
||||
static final String ARG_PID = "pid";
|
||||
private Transport transport;
|
||||
|
||||
public SAPIDAttachingConnector(com.sun.tools.jdi.VirtualMachineManagerService ignored) {
|
||||
this();
|
||||
}
|
||||
|
||||
public SAPIDAttachingConnector() {
|
||||
super();
|
||||
// fixme jjh: create resources for the these strings,
|
||||
addStringArgument(
|
||||
ARG_PID,
|
||||
"PID", //getString("sa.pid.label"),
|
||||
"PID of a Java process", //getString("sa.pid.description");
|
||||
"",
|
||||
true);
|
||||
transport = new Transport() {
|
||||
public String name() {
|
||||
return "local process";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// security check to see whether the caller can perform attach
|
||||
private void checkProcessAttach(int pid) {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
String os = System.getProperty("os.name");
|
||||
try {
|
||||
// Whether the caller can perform link against SA native library?
|
||||
checkNativeLink(sm, os);
|
||||
if (os.equals("SunOS") || os.equals("Linux")) {
|
||||
// Whether the caller can read /proc/<pid> file?
|
||||
sm.checkRead("/proc/" + pid);
|
||||
}
|
||||
} catch (SecurityException se) {
|
||||
throw new SecurityException("permission denied to attach to " + pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private VirtualMachine createVirtualMachine(Class virtualMachineImplClass, int pid)
|
||||
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
|
||||
java.lang.reflect.Method createByPIDMethod
|
||||
= virtualMachineImplClass.getMethod("createVirtualMachineForPID",
|
||||
new Class[] {
|
||||
VirtualMachineManager.class,
|
||||
Integer.TYPE, Integer.TYPE
|
||||
});
|
||||
return (VirtualMachine) createByPIDMethod.invoke(null,
|
||||
new Object[] {
|
||||
Bootstrap.virtualMachineManager(),
|
||||
new Integer(pid),
|
||||
new Integer(0)
|
||||
});
|
||||
}
|
||||
|
||||
public VirtualMachine attach(Map arguments) throws IOException,
|
||||
IllegalConnectorArgumentsException {
|
||||
int pid = 0;
|
||||
try {
|
||||
pid = Integer.parseInt(argument(ARG_PID, arguments).value());
|
||||
} catch (NumberFormatException nfe) {
|
||||
throw (IllegalConnectorArgumentsException) new IllegalConnectorArgumentsException
|
||||
(nfe.getMessage(), ARG_PID).initCause(nfe);
|
||||
}
|
||||
|
||||
checkProcessAttach(pid);
|
||||
|
||||
VirtualMachine myVM = null;
|
||||
try {
|
||||
try {
|
||||
Class vmImplClass = loadVirtualMachineImplClass();
|
||||
myVM = createVirtualMachine(vmImplClass, pid);
|
||||
} catch (InvocationTargetException ite) {
|
||||
Class vmImplClass = handleVMVersionMismatch(ite);
|
||||
if (vmImplClass != null) {
|
||||
return createVirtualMachine(vmImplClass, pid);
|
||||
} else {
|
||||
throw ite;
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
if (DEBUG) {
|
||||
System.out.println("VirtualMachineImpl() got an exception:");
|
||||
ee.printStackTrace();
|
||||
System.out.println("pid = " + pid);
|
||||
}
|
||||
throw (IOException) new IOException().initCause(ee);
|
||||
}
|
||||
setVMDisposeObserver(myVM);
|
||||
return myVM;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return "sun.jvm.hotspot.jdi.SAPIDAttachingConnector";
|
||||
}
|
||||
|
||||
public String description() {
|
||||
return getString("This connector allows you to attach to a Java process using the Serviceability Agent");
|
||||
}
|
||||
|
||||
public Transport transport() {
|
||||
return transport;
|
||||
}
|
||||
}
|
@ -1,685 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
|
||||
class SDE {
|
||||
private static final int INIT_SIZE_FILE = 3;
|
||||
private static final int INIT_SIZE_LINE = 100;
|
||||
private static final int INIT_SIZE_STRATUM = 3;
|
||||
|
||||
static final String BASE_STRATUM_NAME = "Java";
|
||||
|
||||
/* for C capatibility */
|
||||
static final String NullString = null;
|
||||
|
||||
private class FileTableRecord {
|
||||
int fileId;
|
||||
String sourceName;
|
||||
String sourcePath; // do not read - use accessor
|
||||
boolean isConverted = false;
|
||||
|
||||
/**
|
||||
* Return the sourcePath, computing it if not set.
|
||||
* If set, convert '/' in the sourcePath to the
|
||||
* local file separator.
|
||||
*/
|
||||
String getSourcePath(ReferenceTypeImpl refType) {
|
||||
if (!isConverted) {
|
||||
if (sourcePath == null) {
|
||||
sourcePath = refType.baseSourceDir() + sourceName;
|
||||
} else {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for (int i = 0; i < sourcePath.length(); ++i) {
|
||||
char ch = sourcePath.charAt(i);
|
||||
if (ch == '/') {
|
||||
buf.append(File.separatorChar);
|
||||
} else {
|
||||
buf.append(ch);
|
||||
}
|
||||
}
|
||||
sourcePath = buf.toString();
|
||||
}
|
||||
isConverted = true;
|
||||
}
|
||||
return sourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
private class LineTableRecord {
|
||||
int jplsStart;
|
||||
int jplsEnd;
|
||||
int jplsLineInc;
|
||||
int njplsStart;
|
||||
int njplsEnd;
|
||||
int fileId;
|
||||
}
|
||||
|
||||
private class StratumTableRecord {
|
||||
String id;
|
||||
int fileIndex;
|
||||
int lineIndex;
|
||||
}
|
||||
|
||||
class Stratum {
|
||||
private final int sti; /* stratum index */
|
||||
|
||||
private Stratum(int sti) {
|
||||
this.sti = sti;
|
||||
}
|
||||
|
||||
String id() {
|
||||
return stratumTable[sti].id;
|
||||
}
|
||||
|
||||
boolean isJava() {
|
||||
return sti == baseStratumIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the sourceNames for this stratum.
|
||||
* Look from our starting fileIndex upto the starting
|
||||
* fileIndex of next stratum - can do this since there
|
||||
* is always a terminator stratum.
|
||||
* Default sourceName (the first one) must be first.
|
||||
*/
|
||||
List sourceNames(ReferenceTypeImpl refType) {
|
||||
int i;
|
||||
int fileIndexStart = stratumTable[sti].fileIndex;
|
||||
/* one past end */
|
||||
int fileIndexEnd = stratumTable[sti+1].fileIndex;
|
||||
List result = new ArrayList(fileIndexEnd - fileIndexStart);
|
||||
for (i = fileIndexStart; i < fileIndexEnd; ++i) {
|
||||
result.add(fileTable[i].sourceName);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the sourcePaths for this stratum.
|
||||
* Look from our starting fileIndex upto the starting
|
||||
* fileIndex of next stratum - can do this since there
|
||||
* is always a terminator stratum.
|
||||
* Default sourcePath (the first one) must be first.
|
||||
*/
|
||||
List sourcePaths(ReferenceTypeImpl refType) {
|
||||
int i;
|
||||
int fileIndexStart = stratumTable[sti].fileIndex;
|
||||
/* one past end */
|
||||
int fileIndexEnd = stratumTable[sti+1].fileIndex;
|
||||
List result = new ArrayList(fileIndexEnd - fileIndexStart);
|
||||
for (i = fileIndexStart; i < fileIndexEnd; ++i) {
|
||||
result.add(fileTable[i].getSourcePath(refType));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LineStratum lineStratum(ReferenceTypeImpl refType,
|
||||
int jplsLine) {
|
||||
int lti = stiLineTableIndex(sti, jplsLine);
|
||||
if (lti < 0) {
|
||||
return null;
|
||||
} else {
|
||||
return new LineStratum(sti, lti, refType,
|
||||
jplsLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class LineStratum {
|
||||
private final int sti; /* stratum index */
|
||||
private final int lti; /* line table index */
|
||||
private final ReferenceTypeImpl refType;
|
||||
private final int jplsLine;
|
||||
private String sourceName = null;
|
||||
private String sourcePath = null;
|
||||
|
||||
private LineStratum(int sti, int lti,
|
||||
ReferenceTypeImpl refType,
|
||||
int jplsLine) {
|
||||
this.sti = sti;
|
||||
this.lti = lti;
|
||||
this.refType = refType;
|
||||
this.jplsLine = jplsLine;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof LineStratum)) {
|
||||
LineStratum other = (LineStratum)obj;
|
||||
return (lti == other.lti) &&
|
||||
(sti == other.sti) &&
|
||||
(lineNumber() == other.lineNumber()) &&
|
||||
(refType.equals(other.refType));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int lineNumber() {
|
||||
return stiLineNumber(sti, lti, jplsLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the source name and source path for
|
||||
* this line, converting or constructing
|
||||
* the source path if needed.
|
||||
*/
|
||||
void getSourceInfo() {
|
||||
if (sourceName != null) {
|
||||
// already done
|
||||
return;
|
||||
}
|
||||
int fti = stiFileTableIndex(sti, lti);
|
||||
if (fti == -1) {
|
||||
throw new InternalError(
|
||||
"Bad SourceDebugExtension, no matching source id " +
|
||||
lineTable[lti].fileId + " jplsLine: " + jplsLine);
|
||||
}
|
||||
FileTableRecord ftr = fileTable[fti];
|
||||
sourceName = ftr.sourceName;
|
||||
sourcePath = ftr.getSourcePath(refType);
|
||||
}
|
||||
|
||||
String sourceName() {
|
||||
getSourceInfo();
|
||||
return sourceName;
|
||||
}
|
||||
|
||||
String sourcePath() {
|
||||
getSourceInfo();
|
||||
return sourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
private FileTableRecord[] fileTable = null;
|
||||
private LineTableRecord[] lineTable = null;
|
||||
private StratumTableRecord[] stratumTable = null;
|
||||
|
||||
private int fileIndex = 0;
|
||||
private int lineIndex = 0;
|
||||
private int stratumIndex = 0;
|
||||
private int currentFileId = 0;
|
||||
|
||||
private int defaultStratumIndex = -1;
|
||||
private int baseStratumIndex = -2; /* so as not to match -1 above */
|
||||
private int sdePos = 0;
|
||||
|
||||
final String sourceDebugExtension;
|
||||
String jplsFilename = null;
|
||||
String defaultStratumId = null;
|
||||
boolean isValid = false;
|
||||
|
||||
SDE(String sourceDebugExtension) {
|
||||
this.sourceDebugExtension = sourceDebugExtension;
|
||||
decode();
|
||||
}
|
||||
|
||||
SDE() {
|
||||
this.sourceDebugExtension = null;
|
||||
createProxyForAbsentSDE();
|
||||
}
|
||||
|
||||
char sdePeek() {
|
||||
if (sdePos >= sourceDebugExtension.length()) {
|
||||
syntax();
|
||||
}
|
||||
return sourceDebugExtension.charAt(sdePos);
|
||||
}
|
||||
|
||||
char sdeRead() {
|
||||
if (sdePos >= sourceDebugExtension.length()) {
|
||||
syntax();
|
||||
}
|
||||
return sourceDebugExtension.charAt(sdePos++);
|
||||
}
|
||||
|
||||
void sdeAdvance() {
|
||||
sdePos++;
|
||||
}
|
||||
|
||||
void syntax() {
|
||||
throw new InternalError("bad SourceDebugExtension syntax - position " +
|
||||
sdePos);
|
||||
}
|
||||
|
||||
void syntax(String msg) {
|
||||
throw new InternalError("bad SourceDebugExtension syntax: " + msg);
|
||||
}
|
||||
|
||||
void assureLineTableSize() {
|
||||
int len = lineTable == null? 0 : lineTable.length;
|
||||
if (lineIndex >= len) {
|
||||
int i;
|
||||
int newLen = len == 0? INIT_SIZE_LINE : len * 2;
|
||||
LineTableRecord[] newTable = new LineTableRecord[newLen];
|
||||
for (i = 0; i < len; ++i) {
|
||||
newTable[i] = lineTable[i];
|
||||
}
|
||||
for (; i < newLen; ++i) {
|
||||
newTable[i] = new LineTableRecord();
|
||||
}
|
||||
lineTable = newTable;
|
||||
}
|
||||
}
|
||||
|
||||
void assureFileTableSize() {
|
||||
int len = fileTable == null? 0 : fileTable.length;
|
||||
if (fileIndex >= len) {
|
||||
int i;
|
||||
int newLen = len == 0? INIT_SIZE_FILE : len * 2;
|
||||
FileTableRecord[] newTable = new FileTableRecord[newLen];
|
||||
for (i = 0; i < len; ++i) {
|
||||
newTable[i] = fileTable[i];
|
||||
}
|
||||
for (; i < newLen; ++i) {
|
||||
newTable[i] = new FileTableRecord();
|
||||
}
|
||||
fileTable = newTable;
|
||||
}
|
||||
}
|
||||
|
||||
void assureStratumTableSize() {
|
||||
int len = stratumTable == null? 0 : stratumTable.length;
|
||||
if (stratumIndex >= len) {
|
||||
int i;
|
||||
int newLen = len == 0? INIT_SIZE_STRATUM : len * 2;
|
||||
StratumTableRecord[] newTable = new StratumTableRecord[newLen];
|
||||
for (i = 0; i < len; ++i) {
|
||||
newTable[i] = stratumTable[i];
|
||||
}
|
||||
for (; i < newLen; ++i) {
|
||||
newTable[i] = new StratumTableRecord();
|
||||
}
|
||||
stratumTable = newTable;
|
||||
}
|
||||
}
|
||||
|
||||
String readLine() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char ch;
|
||||
|
||||
ignoreWhite();
|
||||
while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
|
||||
sb.append((char)ch);
|
||||
}
|
||||
// check for CR LF
|
||||
if ((ch == '\r') && (sdePeek() == '\n')) {
|
||||
sdeRead();
|
||||
}
|
||||
ignoreWhite(); // leading white
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private int defaultStratumTableIndex() {
|
||||
if ((defaultStratumIndex == -1) && (defaultStratumId != null)) {
|
||||
defaultStratumIndex =
|
||||
stratumTableIndex(defaultStratumId);
|
||||
}
|
||||
return defaultStratumIndex;
|
||||
}
|
||||
|
||||
int stratumTableIndex(String stratumId) {
|
||||
int i;
|
||||
|
||||
if (stratumId == null) {
|
||||
return defaultStratumTableIndex();
|
||||
}
|
||||
for (i = 0; i < (stratumIndex-1); ++i) {
|
||||
if (stratumTable[i].id.equals(stratumId)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return defaultStratumTableIndex();
|
||||
}
|
||||
|
||||
Stratum stratum(String stratumID) {
|
||||
int sti = stratumTableIndex(stratumID);
|
||||
return new Stratum(sti);
|
||||
}
|
||||
|
||||
List availableStrata() {
|
||||
List strata = new ArrayList();
|
||||
|
||||
for (int i = 0; i < (stratumIndex-1); ++i) {
|
||||
StratumTableRecord rec = stratumTable[i];
|
||||
strata.add(rec.id);
|
||||
}
|
||||
return strata;
|
||||
}
|
||||
|
||||
/*****************************
|
||||
* below functions/methods are written to compile under either Java or C
|
||||
*
|
||||
* Needed support functions:
|
||||
* sdePeek()
|
||||
* sdeRead()
|
||||
* sdeAdvance()
|
||||
* readLine()
|
||||
* assureLineTableSize()
|
||||
* assureFileTableSize()
|
||||
* assureStratumTableSize()
|
||||
* syntax()
|
||||
*
|
||||
* stratumTableIndex(String)
|
||||
*
|
||||
* Needed support variables:
|
||||
* lineTable
|
||||
* lineIndex
|
||||
* fileTable
|
||||
* fileIndex
|
||||
* currentFileId
|
||||
*
|
||||
* Needed types:
|
||||
* String
|
||||
*
|
||||
* Needed constants:
|
||||
* NullString
|
||||
*/
|
||||
|
||||
void ignoreWhite() {
|
||||
char ch;
|
||||
|
||||
while (((ch = sdePeek()) == ' ') || (ch == '\t')) {
|
||||
sdeAdvance();
|
||||
}
|
||||
}
|
||||
|
||||
void ignoreLine() {
|
||||
char ch;
|
||||
|
||||
while (((ch = sdeRead()) != '\n') && (ch != '\r')) {
|
||||
}
|
||||
/* check for CR LF */
|
||||
if ((ch == '\r') && (sdePeek() == '\n')) {
|
||||
sdeAdvance();
|
||||
}
|
||||
ignoreWhite(); /* leading white */
|
||||
}
|
||||
|
||||
int readNumber() {
|
||||
int value = 0;
|
||||
char ch;
|
||||
|
||||
ignoreWhite();
|
||||
while (((ch = sdePeek()) >= '0') && (ch <= '9')) {
|
||||
sdeAdvance();
|
||||
value = (value * 10) + ch - '0';
|
||||
}
|
||||
ignoreWhite();
|
||||
return value;
|
||||
}
|
||||
|
||||
void storeFile(int fileId, String sourceName, String sourcePath) {
|
||||
assureFileTableSize();
|
||||
fileTable[fileIndex].fileId = fileId;
|
||||
fileTable[fileIndex].sourceName = sourceName;
|
||||
fileTable[fileIndex].sourcePath = sourcePath;
|
||||
++fileIndex;
|
||||
}
|
||||
|
||||
void fileLine() {
|
||||
int hasAbsolute = 0; /* acts as boolean */
|
||||
int fileId;
|
||||
String sourceName;
|
||||
String sourcePath = null;
|
||||
|
||||
/* is there an absolute filename? */
|
||||
if (sdePeek() == '+') {
|
||||
sdeAdvance();
|
||||
hasAbsolute = 1;
|
||||
}
|
||||
fileId = readNumber();
|
||||
sourceName = readLine();
|
||||
if (hasAbsolute == 1) {
|
||||
sourcePath = readLine();
|
||||
}
|
||||
|
||||
storeFile(fileId, sourceName, sourcePath);
|
||||
}
|
||||
|
||||
void storeLine(int jplsStart, int jplsEnd, int jplsLineInc,
|
||||
int njplsStart, int njplsEnd, int fileId) {
|
||||
assureLineTableSize();
|
||||
lineTable[lineIndex].jplsStart = jplsStart;
|
||||
lineTable[lineIndex].jplsEnd = jplsEnd;
|
||||
lineTable[lineIndex].jplsLineInc = jplsLineInc;
|
||||
lineTable[lineIndex].njplsStart = njplsStart;
|
||||
lineTable[lineIndex].njplsEnd = njplsEnd;
|
||||
lineTable[lineIndex].fileId = fileId;
|
||||
++lineIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse line translation info. Syntax is
|
||||
* <NJ-start-line> [ # <file-id> ] [ , <line-count> ] :
|
||||
* <J-start-line> [ , <line-increment> ] CR
|
||||
*/
|
||||
void lineLine() {
|
||||
int lineCount = 1;
|
||||
int lineIncrement = 1;
|
||||
int njplsStart;
|
||||
int jplsStart;
|
||||
|
||||
njplsStart = readNumber();
|
||||
|
||||
/* is there a fileID? */
|
||||
if (sdePeek() == '#') {
|
||||
sdeAdvance();
|
||||
currentFileId = readNumber();
|
||||
}
|
||||
|
||||
/* is there a line count? */
|
||||
if (sdePeek() == ',') {
|
||||
sdeAdvance();
|
||||
lineCount = readNumber();
|
||||
}
|
||||
|
||||
if (sdeRead() != ':') {
|
||||
syntax();
|
||||
}
|
||||
jplsStart = readNumber();
|
||||
if (sdePeek() == ',') {
|
||||
sdeAdvance();
|
||||
lineIncrement = readNumber();
|
||||
}
|
||||
ignoreLine(); /* flush the rest */
|
||||
|
||||
storeLine(jplsStart,
|
||||
jplsStart + (lineCount * lineIncrement) -1,
|
||||
lineIncrement,
|
||||
njplsStart,
|
||||
njplsStart + lineCount -1,
|
||||
currentFileId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Until the next stratum section, everything after this
|
||||
* is in stratumId - so, store the current indicies.
|
||||
*/
|
||||
void storeStratum(String stratumId) {
|
||||
/* remove redundant strata */
|
||||
if (stratumIndex > 0) {
|
||||
if ((stratumTable[stratumIndex-1].fileIndex
|
||||
== fileIndex) &&
|
||||
(stratumTable[stratumIndex-1].lineIndex
|
||||
== lineIndex)) {
|
||||
/* nothing changed overwrite it */
|
||||
--stratumIndex;
|
||||
}
|
||||
}
|
||||
/* store the results */
|
||||
assureStratumTableSize();
|
||||
stratumTable[stratumIndex].id = stratumId;
|
||||
stratumTable[stratumIndex].fileIndex = fileIndex;
|
||||
stratumTable[stratumIndex].lineIndex = lineIndex;
|
||||
++stratumIndex;
|
||||
currentFileId = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* The beginning of a stratum's info
|
||||
*/
|
||||
void stratumSection() {
|
||||
storeStratum(readLine());
|
||||
}
|
||||
|
||||
void fileSection() {
|
||||
ignoreLine();
|
||||
while (sdePeek() != '*') {
|
||||
fileLine();
|
||||
}
|
||||
}
|
||||
|
||||
void lineSection() {
|
||||
ignoreLine();
|
||||
while (sdePeek() != '*') {
|
||||
lineLine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore a section we don't know about.
|
||||
*/
|
||||
void ignoreSection() {
|
||||
ignoreLine();
|
||||
while (sdePeek() != '*') {
|
||||
ignoreLine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A base "Java" stratum is always available, though
|
||||
* it is not in the SourceDebugExtension.
|
||||
* Create the base stratum.
|
||||
*/
|
||||
void createJavaStratum() {
|
||||
baseStratumIndex = stratumIndex;
|
||||
storeStratum(BASE_STRATUM_NAME);
|
||||
storeFile(1, jplsFilename, NullString);
|
||||
/* JPL line numbers cannot exceed 65535 */
|
||||
storeLine(1, 65536, 1, 1, 65536, 1);
|
||||
storeStratum("Aux"); /* in case they don't declare */
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a SourceDebugExtension which is in SourceMap format.
|
||||
* This is the entry point into the recursive descent parser.
|
||||
*/
|
||||
void decode() {
|
||||
/* check for "SMAP" - allow EOF if not ours */
|
||||
if ((sourceDebugExtension.length() < 4) ||
|
||||
(sdeRead() != 'S') ||
|
||||
(sdeRead() != 'M') ||
|
||||
(sdeRead() != 'A') ||
|
||||
(sdeRead() != 'P')) {
|
||||
return; /* not our info */
|
||||
}
|
||||
ignoreLine(); /* flush the rest */
|
||||
jplsFilename = readLine();
|
||||
defaultStratumId = readLine();
|
||||
createJavaStratum();
|
||||
while (true) {
|
||||
if (sdeRead() != '*') {
|
||||
syntax();
|
||||
}
|
||||
switch (sdeRead()) {
|
||||
case 'S':
|
||||
stratumSection();
|
||||
break;
|
||||
case 'F':
|
||||
fileSection();
|
||||
break;
|
||||
case 'L':
|
||||
lineSection();
|
||||
break;
|
||||
case 'E':
|
||||
/* set end points */
|
||||
storeStratum("*terminator*");
|
||||
isValid = true;
|
||||
return;
|
||||
default:
|
||||
ignoreSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void createProxyForAbsentSDE() {
|
||||
jplsFilename = null;
|
||||
defaultStratumId = BASE_STRATUM_NAME;
|
||||
defaultStratumIndex = stratumIndex;
|
||||
createJavaStratum();
|
||||
storeStratum("*terminator*");
|
||||
}
|
||||
|
||||
/***************** query functions ***********************/
|
||||
|
||||
private int stiLineTableIndex(int sti, int jplsLine) {
|
||||
int i;
|
||||
int lineIndexStart;
|
||||
int lineIndexEnd;
|
||||
|
||||
lineIndexStart = stratumTable[sti].lineIndex;
|
||||
/* one past end */
|
||||
lineIndexEnd = stratumTable[sti+1].lineIndex;
|
||||
for (i = lineIndexStart; i < lineIndexEnd; ++i) {
|
||||
if ((jplsLine >= lineTable[i].jplsStart) &&
|
||||
(jplsLine <= lineTable[i].jplsEnd)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int stiLineNumber(int sti, int lti, int jplsLine) {
|
||||
return lineTable[lti].njplsStart +
|
||||
(((jplsLine - lineTable[lti].jplsStart) /
|
||||
lineTable[lti].jplsLineInc));
|
||||
}
|
||||
|
||||
private int fileTableIndex(int sti, int fileId) {
|
||||
int i;
|
||||
int fileIndexStart = stratumTable[sti].fileIndex;
|
||||
/* one past end */
|
||||
int fileIndexEnd = stratumTable[sti+1].fileIndex;
|
||||
for (i = fileIndexStart; i < fileIndexEnd; ++i) {
|
||||
if (fileTable[i].fileId == fileId) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int stiFileTableIndex(int sti, int lti) {
|
||||
return fileTableIndex(sti, lineTable[lti].fileId);
|
||||
}
|
||||
|
||||
boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class ShortTypeImpl extends PrimitiveTypeImpl implements ShortType {
|
||||
ShortTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
|
||||
public String signature() {
|
||||
return "S";
|
||||
}
|
||||
|
||||
PrimitiveValue convert(PrimitiveValue value) throws InvalidTypeException {
|
||||
return vm.mirrorOf(((PrimitiveValueImpl)value).checkedShortValue());
|
||||
}
|
||||
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class ShortValueImpl extends PrimitiveValueImpl
|
||||
implements ShortValue {
|
||||
private short value;
|
||||
|
||||
ShortValueImpl(VirtualMachine aVm,short aValue) {
|
||||
super(aVm);
|
||||
|
||||
value = aValue;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof ShortValue)) {
|
||||
return (value == ((ShortValue)obj).value()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
/*
|
||||
* TO DO: Better hash code
|
||||
*/
|
||||
return intValue();
|
||||
}
|
||||
|
||||
public int compareTo(ShortValue shortVal) {
|
||||
return value() - shortVal.value();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theShortType();
|
||||
}
|
||||
|
||||
public short value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean booleanValue() {
|
||||
return(value == 0)?false:true;
|
||||
}
|
||||
|
||||
public byte byteValue() {
|
||||
return(byte)value;
|
||||
}
|
||||
|
||||
public char charValue() {
|
||||
return(char)value;
|
||||
}
|
||||
|
||||
public short shortValue() {
|
||||
return(short)value;
|
||||
}
|
||||
|
||||
public int intValue() {
|
||||
return(int)value;
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return(long)value;
|
||||
}
|
||||
|
||||
public float floatValue() {
|
||||
return(float)value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return(double)value;
|
||||
}
|
||||
|
||||
byte checkedByteValue() throws InvalidTypeException {
|
||||
if ((value > Byte.MAX_VALUE) || (value < Byte.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to byte");
|
||||
} else {
|
||||
return super.checkedByteValue();
|
||||
}
|
||||
}
|
||||
|
||||
char checkedCharValue() throws InvalidTypeException {
|
||||
if ((value > Character.MAX_VALUE) || (value < Character.MIN_VALUE)) {
|
||||
throw new InvalidTypeException("Can't convert " + value + " to char");
|
||||
} else {
|
||||
return super.checkedCharValue();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "" + value;
|
||||
}
|
||||
}
|
@ -1,314 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.ObjectHeap;
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.oops.Array;
|
||||
import sun.jvm.hotspot.oops.ObjArray;
|
||||
import sun.jvm.hotspot.oops.TypeArray;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.runtime.BasicType;
|
||||
import sun.jvm.hotspot.runtime.JavaVFrame;
|
||||
import sun.jvm.hotspot.runtime.StackValue;
|
||||
import sun.jvm.hotspot.runtime.StackValueCollection;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Collections;
|
||||
|
||||
public class StackFrameImpl extends MirrorImpl
|
||||
implements StackFrame
|
||||
{
|
||||
/* Once false, frame should not be used.
|
||||
* access synchronized on (vm.state())
|
||||
*/
|
||||
private boolean isValid = true;
|
||||
|
||||
private final ThreadReferenceImpl thread;
|
||||
private final JavaVFrame saFrame;
|
||||
private final Location location;
|
||||
private Map visibleVariables = null;
|
||||
private ObjectReference thisObject = null;
|
||||
|
||||
StackFrameImpl(VirtualMachine vm, ThreadReferenceImpl thread,
|
||||
JavaVFrame jvf) {
|
||||
super(vm);
|
||||
this.thread = thread;
|
||||
this.saFrame = jvf;
|
||||
|
||||
sun.jvm.hotspot.oops.Method SAMethod = jvf.getMethod();
|
||||
|
||||
ReferenceType rt = ((VirtualMachineImpl)vm).referenceType(SAMethod.getMethodHolder());
|
||||
|
||||
this.location = new LocationImpl(vm, rt, SAMethod, (long)jvf.getBCI());
|
||||
}
|
||||
|
||||
private void validateStackFrame() {
|
||||
if (!isValid) {
|
||||
throw new InvalidStackFrameException("Thread has been resumed");
|
||||
}
|
||||
}
|
||||
|
||||
JavaVFrame getJavaVFrame() {
|
||||
return saFrame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the frame location.
|
||||
* Need not be synchronized since it cannot be provably stale.
|
||||
*/
|
||||
public Location location() {
|
||||
validateStackFrame();
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the thread holding the frame.
|
||||
* Need not be synchronized since it cannot be provably stale.
|
||||
*/
|
||||
public ThreadReference thread() {
|
||||
validateStackFrame();
|
||||
return thread;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof StackFrameImpl)) {
|
||||
StackFrameImpl other = (StackFrameImpl)obj;
|
||||
return (saFrame.equals(other.saFrame));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return saFrame.hashCode();
|
||||
}
|
||||
|
||||
public ObjectReference thisObject() {
|
||||
validateStackFrame();
|
||||
MethodImpl currentMethod = (MethodImpl)location.method();
|
||||
if (currentMethod.isStatic() || currentMethod.isNative()) {
|
||||
return null;
|
||||
}
|
||||
if (thisObject == null) {
|
||||
StackValueCollection values = saFrame.getLocals();
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(values.size() > 0, "this is missing");
|
||||
}
|
||||
// 'this' at index 0.
|
||||
if (values.get(0).getType() == BasicType.getTConflict()) {
|
||||
return null;
|
||||
}
|
||||
OopHandle handle = values.oopHandleAt(0);
|
||||
ObjectHeap heap = vm.saObjectHeap();
|
||||
thisObject = vm.objectMirror(heap.newOop(handle));
|
||||
}
|
||||
return thisObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the visible variable map.
|
||||
* Need not be synchronized since it cannot be provably stale.
|
||||
*/
|
||||
private void createVisibleVariables() throws AbsentInformationException {
|
||||
if (visibleVariables == null) {
|
||||
List allVariables = location.method().variables();
|
||||
Map map = new HashMap(allVariables.size());
|
||||
|
||||
Iterator iter = allVariables.iterator();
|
||||
while (iter.hasNext()) {
|
||||
LocalVariableImpl variable = (LocalVariableImpl)iter.next();
|
||||
String name = variable.name();
|
||||
if (variable.isVisible(this)) {
|
||||
LocalVariable existing = (LocalVariable)map.get(name);
|
||||
if ((existing == null) ||
|
||||
variable.hides(existing)) {
|
||||
map.put(name, variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
visibleVariables = map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the list of visible variable in the frame.
|
||||
* Need not be synchronized since it cannot be provably stale.
|
||||
*/
|
||||
public List visibleVariables() throws AbsentInformationException {
|
||||
validateStackFrame();
|
||||
createVisibleVariables();
|
||||
List mapAsList = new ArrayList(visibleVariables.values());
|
||||
Collections.sort(mapAsList);
|
||||
return mapAsList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a particular variable in the frame.
|
||||
* Need not be synchronized since it cannot be provably stale.
|
||||
*/
|
||||
public LocalVariable visibleVariableByName(String name) throws AbsentInformationException {
|
||||
validateStackFrame();
|
||||
createVisibleVariables();
|
||||
return (LocalVariable)visibleVariables.get(name);
|
||||
}
|
||||
|
||||
public Value getValue(LocalVariable variable) {
|
||||
List list = new ArrayList(1);
|
||||
list.add(variable);
|
||||
Map map = getValues(list);
|
||||
return (Value)map.get(variable);
|
||||
}
|
||||
|
||||
public Map getValues(List variables) {
|
||||
validateStackFrame();
|
||||
StackValueCollection values = saFrame.getLocals();
|
||||
|
||||
int count = variables.size();
|
||||
Map map = new HashMap(count);
|
||||
for (int ii=0; ii<count; ++ii) {
|
||||
LocalVariableImpl variable = (LocalVariableImpl)variables.get(ii);
|
||||
if (!variable.isVisible(this)) {
|
||||
throw new IllegalArgumentException(variable.name() +
|
||||
" is not valid at this frame location");
|
||||
}
|
||||
ValueImpl valueImpl;
|
||||
int ss = variable.slot();
|
||||
char c = variable.signature().charAt(0);
|
||||
BasicType variableType = BasicType.charToBasicType(c);
|
||||
valueImpl = getSlotValue(values, variableType, ss);
|
||||
map.put(variable, valueImpl);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public List getArgumentValues() {
|
||||
validateStackFrame();
|
||||
StackValueCollection values = saFrame.getLocals();
|
||||
MethodImpl mmm = (MethodImpl)location.method();
|
||||
if (mmm.isNative())
|
||||
return null;
|
||||
List argSigs = mmm.argumentSignatures();
|
||||
int count = argSigs.size();
|
||||
List res = new ArrayList(0);
|
||||
|
||||
int slot = mmm.isStatic()? 0 : 1;
|
||||
for (int ii = 0; ii < count; ++slot, ++ii) {
|
||||
char sigChar = ((String)argSigs.get(ii)).charAt(0);
|
||||
BasicType variableType = BasicType.charToBasicType(sigChar);
|
||||
res.add(getSlotValue(values, variableType, slot));
|
||||
if (sigChar == 'J' || sigChar == 'D') {
|
||||
slot++;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private ValueImpl getSlotValue(StackValueCollection values,
|
||||
BasicType variableType, int ss) {
|
||||
ValueImpl valueImpl = null;
|
||||
OopHandle handle = null;
|
||||
ObjectHeap heap = vm.saObjectHeap();
|
||||
if (values.get(ss).getType() == BasicType.getTConflict()) {
|
||||
// Dead locals, so just represent them as a zero of the appropriate type
|
||||
if (variableType == BasicType.T_BOOLEAN) {
|
||||
valueImpl = (BooleanValueImpl) vm.mirrorOf(false);
|
||||
} else if (variableType == BasicType.T_CHAR) {
|
||||
valueImpl = (CharValueImpl) vm.mirrorOf((char)0);
|
||||
} else if (variableType == BasicType.T_FLOAT) {
|
||||
valueImpl = (FloatValueImpl) vm.mirrorOf((float)0);
|
||||
} else if (variableType == BasicType.T_DOUBLE) {
|
||||
valueImpl = (DoubleValueImpl) vm.mirrorOf((double)0);
|
||||
} else if (variableType == BasicType.T_BYTE) {
|
||||
valueImpl = (ByteValueImpl) vm.mirrorOf((byte)0);
|
||||
} else if (variableType == BasicType.T_SHORT) {
|
||||
valueImpl = (ShortValueImpl) vm.mirrorOf((short)0);
|
||||
} else if (variableType == BasicType.T_INT) {
|
||||
valueImpl = (IntegerValueImpl) vm.mirrorOf((int)0);
|
||||
} else if (variableType == BasicType.T_LONG) {
|
||||
valueImpl = (LongValueImpl) vm.mirrorOf((long)0);
|
||||
} else if (variableType == BasicType.T_OBJECT) {
|
||||
// we may have an [Ljava/lang/Object; - i.e., Object[] with the
|
||||
// elements themselves may be arrays because every array is an Object.
|
||||
handle = null;
|
||||
valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
|
||||
} else if (variableType == BasicType.T_ARRAY) {
|
||||
handle = null;
|
||||
valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
|
||||
} else if (variableType == BasicType.T_VOID) {
|
||||
valueImpl = new VoidValueImpl(vm);
|
||||
} else {
|
||||
throw new RuntimeException("Should not read here");
|
||||
}
|
||||
} else {
|
||||
if (variableType == BasicType.T_BOOLEAN) {
|
||||
valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
|
||||
} else if (variableType == BasicType.T_CHAR) {
|
||||
valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
|
||||
} else if (variableType == BasicType.T_FLOAT) {
|
||||
valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
|
||||
} else if (variableType == BasicType.T_DOUBLE) {
|
||||
valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
|
||||
} else if (variableType == BasicType.T_BYTE) {
|
||||
valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
|
||||
} else if (variableType == BasicType.T_SHORT) {
|
||||
valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
|
||||
} else if (variableType == BasicType.T_INT) {
|
||||
valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
|
||||
} else if (variableType == BasicType.T_LONG) {
|
||||
valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
|
||||
} else if (variableType == BasicType.T_OBJECT) {
|
||||
// we may have an [Ljava/lang/Object; - i.e., Object[] with the
|
||||
// elements themselves may be arrays because every array is an Object.
|
||||
handle = values.oopHandleAt(ss);
|
||||
valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
|
||||
} else if (variableType == BasicType.T_ARRAY) {
|
||||
handle = values.oopHandleAt(ss);
|
||||
valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
|
||||
} else if (variableType == BasicType.T_VOID) {
|
||||
valueImpl = new VoidValueImpl(vm);
|
||||
} else {
|
||||
throw new RuntimeException("Should not read here");
|
||||
}
|
||||
}
|
||||
|
||||
return valueImpl;
|
||||
}
|
||||
|
||||
public void setValue(LocalVariable variableIntf, Value valueIntf)
|
||||
throws InvalidTypeException, ClassNotLoadedException {
|
||||
|
||||
vm.throwNotReadOnlyException("StackFrame.setValue()");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return location.toString() + " in thread " + thread.toString();
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
class StratumLineInfo implements LineInfo {
|
||||
private final String stratumID;
|
||||
private final int lineNumber;
|
||||
private final String sourceName;
|
||||
private final String sourcePath;
|
||||
|
||||
StratumLineInfo(String stratumID, int lineNumber,
|
||||
String sourceName, String sourcePath) {
|
||||
this.stratumID = stratumID;
|
||||
this.lineNumber = lineNumber;
|
||||
this.sourceName = sourceName;
|
||||
this.sourcePath = sourcePath;
|
||||
}
|
||||
|
||||
public String liStratum() {
|
||||
return stratumID;
|
||||
}
|
||||
|
||||
public int liLineNumber() {
|
||||
return lineNumber;
|
||||
}
|
||||
|
||||
public String liSourceName()
|
||||
throws AbsentInformationException {
|
||||
if (sourceName == null) {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
return sourceName;
|
||||
}
|
||||
|
||||
public String liSourcePath()
|
||||
throws AbsentInformationException {
|
||||
if (sourcePath == null) {
|
||||
throw new AbsentInformationException();
|
||||
}
|
||||
return sourcePath;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.OopUtilities;
|
||||
|
||||
public class StringReferenceImpl extends ObjectReferenceImpl
|
||||
implements StringReference
|
||||
{
|
||||
private String value;
|
||||
|
||||
StringReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Instance oRef) {
|
||||
super(aVm,oRef);
|
||||
value = OopUtilities.stringOopToString(oRef);
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "\"" + value() + "\"";
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.OopUtilities;
|
||||
import sun.jvm.hotspot.runtime.JavaThread;
|
||||
import com.sun.jdi.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ThreadGroupReferenceImpl extends ObjectReferenceImpl
|
||||
implements ThreadGroupReference
|
||||
{
|
||||
ThreadGroupReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.oops.Oop oRef) {
|
||||
super(aVm, oRef);
|
||||
}
|
||||
|
||||
protected String description() {
|
||||
return "ThreadGroupReference " + uniqueID();
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return OopUtilities.threadGroupOopGetName(ref());
|
||||
}
|
||||
|
||||
public ThreadGroupReference parent() {
|
||||
return (ThreadGroupReferenceImpl)vm.threadGroupMirror(
|
||||
(Instance)OopUtilities.threadGroupOopGetParent(ref()));
|
||||
}
|
||||
|
||||
public void suspend() {
|
||||
vm.throwNotReadOnlyException("ThreadGroupReference.suspend()");
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
vm.throwNotReadOnlyException("ThreadGroupReference.resume()");
|
||||
}
|
||||
|
||||
public List threads() {
|
||||
// Each element of this array is the Oop for a thread;
|
||||
// NOTE it is not the JavaThread that we need to create
|
||||
// a ThreadReferenceImpl.
|
||||
Oop[] myThreads = OopUtilities.threadGroupOopGetThreads(ref());
|
||||
|
||||
ArrayList myList = new ArrayList(myThreads.length);
|
||||
for (int ii = 0; ii < myThreads.length; ii++) {
|
||||
JavaThread jt = OopUtilities.threadOopGetJavaThread(myThreads[ii]);
|
||||
if (jt != null) {
|
||||
ThreadReferenceImpl xx = (ThreadReferenceImpl)vm.threadMirror(jt);
|
||||
myList.add(xx);
|
||||
}
|
||||
}
|
||||
return myList;
|
||||
}
|
||||
|
||||
public List threadGroups() {
|
||||
Oop[] myGroups = OopUtilities.threadGroupOopGetGroups(ref());
|
||||
ArrayList myList = new ArrayList(myGroups.length);
|
||||
for (int ii = 0; ii < myGroups.length; ii++) {
|
||||
ThreadGroupReferenceImpl xx = (ThreadGroupReferenceImpl)vm.threadGroupMirror(
|
||||
(Instance)myGroups[ii]);
|
||||
myList.add(xx);
|
||||
|
||||
}
|
||||
return myList;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "instance of " + referenceType().name() +
|
||||
"(name='" + name() + "', " + "id=" + uniqueID() + ")";
|
||||
}
|
||||
}
|
@ -1,400 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import sun.jvm.hotspot.debugger.OopHandle;
|
||||
import sun.jvm.hotspot.runtime.VMObject;
|
||||
import sun.jvm.hotspot.runtime.JavaThread;
|
||||
import sun.jvm.hotspot.runtime.OSThread;
|
||||
//import sun.jvm.hotspot.runtime.StackFrameStream;
|
||||
import sun.jvm.hotspot.runtime.JavaVFrame;
|
||||
import sun.jvm.hotspot.runtime.JavaThreadState;
|
||||
import sun.jvm.hotspot.runtime.MonitorInfo;
|
||||
import sun.jvm.hotspot.runtime.ObjectMonitor;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.ObjectHeap;
|
||||
import sun.jvm.hotspot.oops.Instance;
|
||||
import sun.jvm.hotspot.oops.OopUtilities;
|
||||
import sun.jvm.hotspot.oops.Klass;
|
||||
import sun.jvm.hotspot.utilities.Assert;
|
||||
import com.sun.jdi.*;
|
||||
import java.util.*;
|
||||
|
||||
public class ThreadReferenceImpl extends ObjectReferenceImpl
|
||||
implements ThreadReference, /* imports */ JVMTIThreadState {
|
||||
|
||||
private JavaThread myJavaThread;
|
||||
private ArrayList frames; // StackFrames
|
||||
private List ownedMonitors; // List<ObjectReferenceImpl>
|
||||
private List ownedMonitorsInfo; // List<MonitorInfo>
|
||||
private ObjectReferenceImpl currentContendingMonitor;
|
||||
|
||||
ThreadReferenceImpl(VirtualMachine aVm, sun.jvm.hotspot.runtime.JavaThread aRef) {
|
||||
// We are given a JavaThread and save it in our myJavaThread field.
|
||||
// But, our parent class is an ObjectReferenceImpl so we need an Oop
|
||||
// for it. JavaThread is a wrapper around a Thread Oop so we get
|
||||
// that Oop and give it to our super.
|
||||
// We can get it back again by calling ref().
|
||||
super(aVm, (Instance)aRef.getThreadObj());
|
||||
myJavaThread = aRef;
|
||||
}
|
||||
|
||||
ThreadReferenceImpl(VirtualMachine vm, Instance oRef) {
|
||||
// Instance must be of type java.lang.Thread
|
||||
super(vm, oRef);
|
||||
|
||||
// JavaThread retrieved from java.lang.Thread instance may be null.
|
||||
// This is the case for threads not-started and for zombies. Wherever
|
||||
// appropriate, check for null instead of resulting in NullPointerException.
|
||||
myJavaThread = OopUtilities.threadOopGetJavaThread(oRef);
|
||||
}
|
||||
|
||||
// return value may be null. refer to the comment in constructor.
|
||||
JavaThread getJavaThread() {
|
||||
return myJavaThread;
|
||||
}
|
||||
|
||||
protected String description() {
|
||||
return "ThreadReference " + uniqueID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Note that we only cache the name string while suspended because
|
||||
* it can change via Thread.setName arbitrarily
|
||||
*/
|
||||
public String name() {
|
||||
return OopUtilities.threadOopGetName(ref());
|
||||
}
|
||||
|
||||
public void suspend() {
|
||||
vm.throwNotReadOnlyException("ThreadReference.suspend()");
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
vm.throwNotReadOnlyException("ThreadReference.resume()");
|
||||
}
|
||||
|
||||
public int suspendCount() {
|
||||
// all threads are "suspended" when we attach to process or core.
|
||||
// we interpret this as one suspend.
|
||||
return 1;
|
||||
}
|
||||
|
||||
public void stop(ObjectReference throwable) throws InvalidTypeException {
|
||||
vm.throwNotReadOnlyException("ThreadReference.stop()");
|
||||
}
|
||||
|
||||
public void interrupt() {
|
||||
vm.throwNotReadOnlyException("ThreadReference.interrupt()");
|
||||
}
|
||||
|
||||
// refer to jvmtiEnv::GetThreadState
|
||||
private int jvmtiGetThreadState() {
|
||||
// get most state bits
|
||||
int state = OopUtilities.threadOopGetThreadStatus(ref());
|
||||
// add more state bits
|
||||
if (myJavaThread != null) {
|
||||
JavaThreadState jts = myJavaThread.getThreadState();
|
||||
if (myJavaThread.isBeingExtSuspended()) {
|
||||
state |= JVMTI_THREAD_STATE_SUSPENDED;
|
||||
}
|
||||
if (jts == JavaThreadState.IN_NATIVE) {
|
||||
state |= JVMTI_THREAD_STATE_IN_NATIVE;
|
||||
}
|
||||
OSThread osThread = myJavaThread.getOSThread();
|
||||
if (osThread != null && osThread.interrupted()) {
|
||||
state |= JVMTI_THREAD_STATE_INTERRUPTED;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public int status() {
|
||||
int state = jvmtiGetThreadState();
|
||||
int status = THREAD_STATUS_UNKNOWN;
|
||||
// refer to map2jdwpThreadStatus in util.c (back-end)
|
||||
if (! ((state & JVMTI_THREAD_STATE_ALIVE) != 0) ) {
|
||||
if ((state & JVMTI_THREAD_STATE_TERMINATED) != 0) {
|
||||
status = THREAD_STATUS_ZOMBIE;
|
||||
} else {
|
||||
status = THREAD_STATUS_NOT_STARTED;
|
||||
}
|
||||
} else {
|
||||
if ((state & JVMTI_THREAD_STATE_SLEEPING) != 0) {
|
||||
status = THREAD_STATUS_SLEEPING;
|
||||
} else if ((state & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
|
||||
status = THREAD_STATUS_MONITOR;
|
||||
} else if ((state & JVMTI_THREAD_STATE_WAITING) != 0) {
|
||||
status = THREAD_STATUS_WAIT;
|
||||
} else if ((state & JVMTI_THREAD_STATE_RUNNABLE) != 0) {
|
||||
status = THREAD_STATUS_RUNNING;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public boolean isSuspended() { //fixme jjh
|
||||
// If we want to support doing this for a VM which was being
|
||||
// debugged, then we need to fix this.
|
||||
// In the meantime, we will say all threads are suspended,
|
||||
// otherwise, some things won't work, like the jdb 'up' cmd.
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isAtBreakpoint() { //fixme jjh
|
||||
// If we want to support doing this for a VM which was being
|
||||
// debugged, then we need to fix this.
|
||||
return false;
|
||||
}
|
||||
|
||||
public ThreadGroupReference threadGroup() {
|
||||
return (ThreadGroupReferenceImpl)vm.threadGroupMirror(
|
||||
(Instance)OopUtilities.threadOopGetThreadGroup(ref()));
|
||||
}
|
||||
|
||||
public int frameCount() throws IncompatibleThreadStateException { //fixme jjh
|
||||
privateFrames(0, -1);
|
||||
return frames.size();
|
||||
}
|
||||
|
||||
public List frames() throws IncompatibleThreadStateException {
|
||||
return privateFrames(0, -1);
|
||||
}
|
||||
|
||||
public StackFrame frame(int index) throws IncompatibleThreadStateException {
|
||||
List list = privateFrames(index, 1);
|
||||
return (StackFrame)list.get(0);
|
||||
}
|
||||
|
||||
public List frames(int start, int length)
|
||||
throws IncompatibleThreadStateException {
|
||||
if (length < 0) {
|
||||
throw new IndexOutOfBoundsException(
|
||||
"length must be greater than or equal to zero");
|
||||
}
|
||||
return privateFrames(start, length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private version of frames() allows "-1" to specify all
|
||||
* remaining frames.
|
||||
*/
|
||||
|
||||
private List privateFrames(int start, int length)
|
||||
throws IncompatibleThreadStateException {
|
||||
if (myJavaThread == null) {
|
||||
// for zombies and yet-to-be-started threads we need to throw exception
|
||||
throw new IncompatibleThreadStateException();
|
||||
}
|
||||
if (frames == null) {
|
||||
frames = new ArrayList(10);
|
||||
JavaVFrame myvf = myJavaThread.getLastJavaVFrameDbg();
|
||||
while (myvf != null) {
|
||||
StackFrame myFrame = new StackFrameImpl(vm, this, myvf);
|
||||
//fixme jjh null should be a Location
|
||||
frames.add(myFrame);
|
||||
myvf = (JavaVFrame)myvf.javaSender();
|
||||
}
|
||||
}
|
||||
|
||||
List retVal;
|
||||
if (frames.size() == 0) {
|
||||
retVal = new ArrayList(0);
|
||||
} else {
|
||||
int toIndex = start + length;
|
||||
if (length == -1) {
|
||||
toIndex = frames.size();
|
||||
}
|
||||
retVal = frames.subList(start, toIndex);
|
||||
}
|
||||
return Collections.unmodifiableList(retVal);
|
||||
}
|
||||
|
||||
// refer to JvmtiEnvBase::get_owned_monitors
|
||||
public List ownedMonitors() throws IncompatibleThreadStateException {
|
||||
if (vm.canGetOwnedMonitorInfo() == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (myJavaThread == null) {
|
||||
throw new IncompatibleThreadStateException();
|
||||
}
|
||||
|
||||
if (ownedMonitors != null) {
|
||||
return ownedMonitors;
|
||||
}
|
||||
|
||||
ownedMonitorsWithStackDepth();
|
||||
|
||||
for (Iterator omi = ownedMonitorsInfo.iterator(); omi.hasNext(); ) {
|
||||
//FIXME : Change the MonitorInfoImpl cast to com.sun.jdi.MonitorInfo
|
||||
// when hotspot start building with jdk1.6.
|
||||
ownedMonitors.add(((MonitorInfoImpl)omi.next()).monitor());
|
||||
}
|
||||
|
||||
return ownedMonitors;
|
||||
}
|
||||
|
||||
// new method since 1.6.
|
||||
// Real body will be supplied later.
|
||||
public List ownedMonitorsAndFrames() throws IncompatibleThreadStateException {
|
||||
if (!vm.canGetMonitorFrameInfo()) {
|
||||
throw new UnsupportedOperationException(
|
||||
"target does not support getting Monitor Frame Info");
|
||||
}
|
||||
|
||||
if (myJavaThread == null) {
|
||||
throw new IncompatibleThreadStateException();
|
||||
}
|
||||
|
||||
if (ownedMonitorsInfo != null) {
|
||||
return ownedMonitorsInfo;
|
||||
}
|
||||
|
||||
ownedMonitorsWithStackDepth();
|
||||
return ownedMonitorsInfo;
|
||||
}
|
||||
|
||||
private void ownedMonitorsWithStackDepth() {
|
||||
|
||||
ownedMonitorsInfo = new ArrayList();
|
||||
List lockedObjects = new ArrayList(); // List<OopHandle>
|
||||
List stackDepth = new ArrayList(); // List<int>
|
||||
ObjectMonitor waitingMonitor = myJavaThread.getCurrentWaitingMonitor();
|
||||
ObjectMonitor pendingMonitor = myJavaThread.getCurrentPendingMonitor();
|
||||
OopHandle waitingObj = null;
|
||||
if (waitingMonitor != null) {
|
||||
// save object of current wait() call (if any) for later comparison
|
||||
waitingObj = waitingMonitor.object();
|
||||
}
|
||||
OopHandle pendingObj = null;
|
||||
if (pendingMonitor != null) {
|
||||
// save object of current enter() call (if any) for later comparison
|
||||
pendingObj = pendingMonitor.object();
|
||||
}
|
||||
|
||||
JavaVFrame frame = myJavaThread.getLastJavaVFrameDbg();
|
||||
int depth=0;
|
||||
while (frame != null) {
|
||||
List frameMonitors = frame.getMonitors(); // List<MonitorInfo>
|
||||
for (Iterator miItr = frameMonitors.iterator(); miItr.hasNext(); ) {
|
||||
sun.jvm.hotspot.runtime.MonitorInfo mi = (sun.jvm.hotspot.runtime.MonitorInfo) miItr.next();
|
||||
if (mi.eliminated() && frame.isCompiledFrame()) {
|
||||
continue; // skip eliminated monitor
|
||||
}
|
||||
OopHandle obj = mi.owner();
|
||||
if (obj == null) {
|
||||
// this monitor doesn't have an owning object so skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
if (obj.equals(waitingObj)) {
|
||||
// the thread is waiting on this monitor so it isn't really owned
|
||||
continue;
|
||||
}
|
||||
|
||||
if (obj.equals(pendingObj)) {
|
||||
// the thread is pending on this monitor so it isn't really owned
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean found = false;
|
||||
for (Iterator loItr = lockedObjects.iterator(); loItr.hasNext(); ) {
|
||||
// check for recursive locks
|
||||
if (obj.equals(loItr.next())) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
// already have this object so don't include it
|
||||
continue;
|
||||
}
|
||||
// add the owning object to our list
|
||||
lockedObjects.add(obj);
|
||||
stackDepth.add(new Integer(depth));
|
||||
}
|
||||
frame = (JavaVFrame) frame.javaSender();
|
||||
depth++;
|
||||
}
|
||||
|
||||
// now convert List<OopHandle> to List<ObjectReference>
|
||||
ObjectHeap heap = vm.saObjectHeap();
|
||||
Iterator stk = stackDepth.iterator();
|
||||
for (Iterator loItr = lockedObjects.iterator(); loItr.hasNext(); ) {
|
||||
Oop obj = heap.newOop((OopHandle)loItr.next());
|
||||
ownedMonitorsInfo.add(new MonitorInfoImpl(vm, vm.objectMirror(obj), this,
|
||||
((Integer)stk.next()).intValue()));
|
||||
}
|
||||
}
|
||||
|
||||
// refer to JvmtiEnvBase::get_current_contended_monitor
|
||||
public ObjectReference currentContendedMonitor()
|
||||
throws IncompatibleThreadStateException {
|
||||
if (vm.canGetCurrentContendedMonitor() == false) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
if (myJavaThread == null) {
|
||||
throw new IncompatibleThreadStateException();
|
||||
}
|
||||
ObjectMonitor mon = myJavaThread.getCurrentWaitingMonitor();
|
||||
if (mon == null) {
|
||||
// thread is not doing an Object.wait() call
|
||||
mon = myJavaThread.getCurrentPendingMonitor();
|
||||
if (mon != null) {
|
||||
OopHandle handle = mon.object();
|
||||
// If obj == NULL, then ObjectMonitor is raw which doesn't count
|
||||
// as contended for this API
|
||||
return vm.objectMirror(vm.saObjectHeap().newOop(handle));
|
||||
} else {
|
||||
// no contended ObjectMonitor
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
// thread is doing an Object.wait() call
|
||||
OopHandle handle = mon.object();
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(handle != null, "Object.wait() should have an object");
|
||||
}
|
||||
Oop obj = vm.saObjectHeap().newOop(handle);
|
||||
return vm.objectMirror(obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void popFrames(StackFrame frame) throws IncompatibleThreadStateException {
|
||||
vm.throwNotReadOnlyException("ThreadReference.popFrames()");
|
||||
}
|
||||
|
||||
public void forceEarlyReturn(Value returnValue) throws IncompatibleThreadStateException {
|
||||
vm.throwNotReadOnlyException("ThreadReference.forceEarlyReturn()");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "instance of " + referenceType().name() +
|
||||
"(name='" + name() + "', " + "id=" + uniqueID() + ")";
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import sun.jvm.hotspot.oops.Symbol;
|
||||
import sun.jvm.hotspot.oops.Oop;
|
||||
import sun.jvm.hotspot.oops.InstanceKlass;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* There is no SA class that corresponds to this. Therefore,
|
||||
* all the methods in this class which involve the SA mirror class
|
||||
* have to be implemented in the subclasses.
|
||||
*/
|
||||
abstract public class TypeComponentImpl extends MirrorImpl
|
||||
implements TypeComponent {
|
||||
|
||||
protected final ReferenceTypeImpl declaringType;
|
||||
protected String signature;
|
||||
|
||||
TypeComponentImpl(VirtualMachine vm, ReferenceTypeImpl declaringType) {
|
||||
super(vm);
|
||||
this.declaringType = declaringType;
|
||||
}
|
||||
|
||||
public ReferenceType declaringType() {
|
||||
return declaringType;
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
abstract public String name();
|
||||
abstract public int modifiers();
|
||||
abstract public boolean isPackagePrivate();
|
||||
abstract public boolean isPrivate();
|
||||
abstract public boolean isProtected();
|
||||
abstract public boolean isPublic();
|
||||
abstract public boolean isStatic();
|
||||
abstract public boolean isFinal();
|
||||
abstract public int hashCode();
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public abstract class TypeImpl extends MirrorImpl implements Type
|
||||
{
|
||||
private String typeName;
|
||||
|
||||
TypeImpl(VirtualMachine aVm) {
|
||||
super(aVm);
|
||||
}
|
||||
|
||||
public abstract String signature();
|
||||
|
||||
public String name() {
|
||||
if (typeName == null) {
|
||||
JNITypeParser parser = new JNITypeParser(signature());
|
||||
typeName = parser.typeName();
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if ((obj != null) && (obj instanceof Type)) {
|
||||
Type other = (Type)obj;
|
||||
return signature().equals(other.signature()) &&
|
||||
super.equals(obj);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return signature().hashCode();
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import sun.jvm.hotspot.runtime.ClassConstants;
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public interface VMModifiers extends ClassConstants {
|
||||
int PUBLIC = (int) JVM_ACC_PUBLIC; /* visible to everyone */
|
||||
int PRIVATE = (int) JVM_ACC_PRIVATE; /* visible only to the defining class */
|
||||
int PROTECTED = (int) JVM_ACC_PROTECTED; /* visible to subclasses */
|
||||
int STATIC = (int) JVM_ACC_STATIC; /* instance variable is static */
|
||||
int FINAL = (int) JVM_ACC_FINAL; /* no further subclassing, overriding */
|
||||
int SYNCHRONIZED = (int) JVM_ACC_SYNCHRONIZED; /* wrap method call in monitor lock */
|
||||
int VOLATILE = (int) JVM_ACC_VOLATILE; /* can cache in registers */
|
||||
int BRIDGE = (int) JVM_ACC_BRIDGE; /* bridge method generated by compiler */
|
||||
int TRANSIENT = (int) JVM_ACC_TRANSIENT; /* not persistant */
|
||||
int VARARGS = (int) JVM_ACC_VARARGS; /* method declared with variable number of args */
|
||||
int IS_ENUM_CONSTANT = (int) JVM_ACC_ENUM; /* field is declared as element of enum */
|
||||
int NATIVE = (int) JVM_ACC_NATIVE; /* implemented in C */
|
||||
int INTERFACE = (int) JVM_ACC_INTERFACE; /* class is an interface */
|
||||
int ABSTRACT = (int) JVM_ACC_ABSTRACT; /* no definition provided */
|
||||
int SYNTHETIC = (int) JVM_ACC_SYNTHETIC; /* not in source code */
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
/*
|
||||
* This interface allows us to pass fields, variables, and
|
||||
* array components through the same interfaces. This currently allows
|
||||
* more common code for type checking. In the future we could use it for
|
||||
* more.
|
||||
*/
|
||||
interface ValueContainer {
|
||||
Type type() throws ClassNotLoadedException;
|
||||
Type findType(String signature) throws ClassNotLoadedException;
|
||||
String typeName();
|
||||
String signature();
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
abstract class ValueImpl extends MirrorImpl implements Value {
|
||||
ValueImpl(VirtualMachine aVm) {
|
||||
super(aVm);
|
||||
}
|
||||
|
||||
// type() is in the subclasses
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class VoidTypeImpl extends TypeImpl implements VoidType {
|
||||
VoidTypeImpl(VirtualMachine vm) {
|
||||
super(vm);
|
||||
}
|
||||
|
||||
public String signature() {
|
||||
return "V";
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name();
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.jdi;
|
||||
|
||||
import com.sun.jdi.*;
|
||||
|
||||
public class VoidValueImpl extends ValueImpl implements VoidValue {
|
||||
|
||||
VoidValueImpl(VirtualMachine aVm) {
|
||||
super(aVm);
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return (obj != null) && (obj instanceof VoidValue) && super.equals(obj);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return type().hashCode();
|
||||
}
|
||||
|
||||
public Type type() {
|
||||
return vm.theVoidType();
|
||||
}
|
||||
|
||||
ValueImpl prepareForAssignmentTo(ValueContainer destination)
|
||||
throws InvalidTypeException {
|
||||
|
||||
throw new InvalidTypeException();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "<void value>";
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,11 +31,10 @@ import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.jdi.JVMTIThreadState;
|
||||
|
||||
/** A utility class encapsulating useful oop operations */
|
||||
|
||||
public class OopUtilities implements /* imports */ JVMTIThreadState {
|
||||
public class OopUtilities {
|
||||
|
||||
// FIXME: access should be synchronized and cleared when VM is
|
||||
// resumed
|
||||
@ -78,6 +77,8 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
|
||||
// java.util.concurrent.locks.AbstractOwnableSynchronizer fields
|
||||
private static OopField absOwnSyncOwnerThreadField;
|
||||
|
||||
private static final int JVMTI_THREAD_STATE_ALIVE = 0x0001;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,7 +33,6 @@ import sun.jvm.hotspot.types.AddressField;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
import sun.jvm.hotspot.utilities.*;
|
||||
import sun.jvm.hotspot.jdi.JVMTIThreadState;
|
||||
|
||||
/** A utility class encapsulating useful oop operations */
|
||||
|
||||
|
@ -1,39 +0,0 @@
|
||||
|
||||
This dir contains a test for the JDI-SA implementation.
|
||||
|
||||
sagtest.java, sagtarg.java are a normal JDI regression test
|
||||
that uses TargetAdapter.java, TargetListener.java, TestScaffold.java,
|
||||
and VMConnection.java.
|
||||
|
||||
This test starts the debuggee, sagtarg.java, which just does a wait.
|
||||
The test then calls sagdoit.java which calls all the JDJI interface
|
||||
functions. Well, it doesn't call them all yet, but that is the plan.
|
||||
At least all that are interesting to the JDI-SA client. The result of
|
||||
each call is sent to stdout
|
||||
|
||||
The script runjpda.sh runs this test. It then runs the targ part of
|
||||
the test and calls gcore on it to get a core dump into file sagcore.
|
||||
Do
|
||||
runjpda.sh >& kk
|
||||
|
||||
to run this.
|
||||
|
||||
NOTE that this produces 1000s of lines of output
|
||||
so be sure to redirect to a file.
|
||||
|
||||
File sagclient.java is a test program that uses the JDI-SA
|
||||
client to connect to a core file or pid and then calls sagdoit
|
||||
which calls the JDI methods.
|
||||
|
||||
The script runsa.sh can be used to run sagclient on sagcore:
|
||||
runsa.sh sagcore >& kk1
|
||||
|
||||
You can then look at the differences between the runjpda.sh
|
||||
and the runsa.sh run to see if there are bugs. Note that the
|
||||
order of things might be different.
|
||||
|
||||
|
||||
-----------------------------------------
|
||||
|
||||
runjdb.sh contains a script that will run jdb on a core file
|
||||
using the JDI-sa binding.
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import sun.jvm.hotspot.tools.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.util.jar.*;
|
||||
|
||||
/**
|
||||
This is a sanity checking tool for Serviceability Agent. To use this class,
|
||||
refer to sasanity.sh script in the current directory.
|
||||
*/
|
||||
|
||||
public class SASanityChecker extends Tool {
|
||||
private static final String saJarName;
|
||||
private static final Map c2types;
|
||||
|
||||
static {
|
||||
saJarName = System.getProperty("SASanityChecker.SAJarName", "sa-jdi.jar");
|
||||
c2types = new HashMap();
|
||||
Object value = new Object();
|
||||
c2types.put("sun.jvm.hotspot.code.ExceptionBlob", value);
|
||||
c2types.put("sun.jvm.hotspot.code.DeoptimizationBlob", value);
|
||||
c2types.put("sun.jvm.hotspot.code.UncommonTrapBlob", value);
|
||||
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String classPath = System.getProperty("java.class.path");
|
||||
StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);
|
||||
String saJarPath = null;
|
||||
while (st.hasMoreTokens()) {
|
||||
saJarPath = st.nextToken();
|
||||
if (saJarPath.endsWith(saJarName)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (saJarPath == null) {
|
||||
throw new RuntimeException(saJarName + " is not the CLASSPATH");
|
||||
}
|
||||
|
||||
String cpuDot = "." + VM.getVM().getCPU() + ".";
|
||||
String platformDot = "." + VM.getVM().getOS() + "_" + VM.getVM().getCPU() + ".";
|
||||
boolean isClient = VM.getVM().isClientCompiler();
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(saJarPath);
|
||||
JarInputStream jis = new JarInputStream(fis);
|
||||
JarEntry je = null;
|
||||
while ( (je = jis.getNextJarEntry()) != null) {
|
||||
String entryName = je.getName();
|
||||
int dotClassIndex = entryName.indexOf(".class");
|
||||
if (dotClassIndex == -1) {
|
||||
// skip non-.class stuff
|
||||
continue;
|
||||
}
|
||||
|
||||
entryName = entryName.substring(0, dotClassIndex).replace('/', '.');
|
||||
|
||||
// skip debugger, asm classes, type classes and jdi binding classes
|
||||
if (entryName.startsWith("sun.jvm.hotspot.debugger.") ||
|
||||
entryName.startsWith("sun.jvm.hotspot.asm.") ||
|
||||
entryName.startsWith("sun.jvm.hotspot.type.") ||
|
||||
entryName.startsWith("sun.jvm.hotspot.jdi.") ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String runtimePkgPrefix = "sun.jvm.hotspot.runtime.";
|
||||
int runtimeIndex = entryName.indexOf(runtimePkgPrefix);
|
||||
if (runtimeIndex != -1) {
|
||||
// look for further dot. if there, it has to be sub-package.
|
||||
// in runtime sub-packages include only current platform classes.
|
||||
if (entryName.substring(runtimePkgPrefix.length() + 1, entryName.length()).indexOf('.') != -1) {
|
||||
if (entryName.indexOf(cpuDot) == -1 &&
|
||||
entryName.indexOf(platformDot) == -1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isClient) {
|
||||
if (c2types.get(entryName) != null) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if (entryName.equals("sun.jvm.hotspot.c1.Runtime1")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("checking " + entryName + " ..");
|
||||
// force init of the class to uncover any vmStructs mismatch
|
||||
Class.forName(entryName);
|
||||
}
|
||||
} catch (Exception exp) {
|
||||
System.out.println();
|
||||
System.out.println("FAILED");
|
||||
System.out.println();
|
||||
throw new RuntimeException(exp.getMessage());
|
||||
}
|
||||
System.out.println();
|
||||
System.out.println("PASSED");
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SASanityChecker checker = new SASanityChecker();
|
||||
checker.start(args);
|
||||
checker.stop();
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
# This file identifies the root of the test-suite hierarchy.
|
||||
# It also contains test-suite configuration information.
|
||||
# DO NOT EDIT without first contacting jdk-regtest@eng.
|
||||
|
||||
# The list of keywords supported in this test suite
|
||||
keys=2d dnd i18n
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.event.*;
|
||||
|
||||
/**
|
||||
* Base TargetListener implementation
|
||||
*/
|
||||
public class TargetAdapter implements TargetListener {
|
||||
boolean shouldRemoveListener = false;
|
||||
|
||||
public void removeThisListener() {
|
||||
shouldRemoveListener = true;
|
||||
}
|
||||
|
||||
public boolean shouldRemoveListener() {
|
||||
return shouldRemoveListener;
|
||||
}
|
||||
|
||||
public void eventSetReceived(EventSet set) {}
|
||||
public void eventSetComplete(EventSet set) {}
|
||||
public void eventReceived(Event event) {}
|
||||
public void breakpointReached(BreakpointEvent event) {}
|
||||
public void exceptionThrown(ExceptionEvent event) {}
|
||||
public void stepCompleted(StepEvent event) {}
|
||||
public void classPrepared(ClassPrepareEvent event) {}
|
||||
public void classUnloaded(ClassUnloadEvent event) {}
|
||||
public void methodEntered(MethodEntryEvent event) {}
|
||||
public void methodExited(MethodExitEvent event) {}
|
||||
public void fieldAccessed(AccessWatchpointEvent event) {}
|
||||
public void fieldModified(ModificationWatchpointEvent event) {}
|
||||
public void threadStarted(ThreadStartEvent event) {}
|
||||
public void threadDied(ThreadDeathEvent event) {}
|
||||
public void vmStarted(VMStartEvent event) {}
|
||||
public void vmDied(VMDeathEvent event) {}
|
||||
public void vmDisconnected(VMDisconnectEvent event) {}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.event.*;
|
||||
|
||||
/**
|
||||
* Event listener framework
|
||||
*/
|
||||
public interface TargetListener {
|
||||
boolean shouldRemoveListener();
|
||||
|
||||
void eventSetReceived(EventSet set);
|
||||
void eventSetComplete(EventSet set);
|
||||
void eventReceived(Event event);
|
||||
void breakpointReached(BreakpointEvent event);
|
||||
void exceptionThrown(ExceptionEvent event);
|
||||
void stepCompleted(StepEvent event);
|
||||
void classPrepared(ClassPrepareEvent event);
|
||||
void classUnloaded(ClassUnloadEvent event);
|
||||
void methodEntered(MethodEntryEvent event);
|
||||
void methodExited(MethodExitEvent event);
|
||||
void fieldAccessed(AccessWatchpointEvent event);
|
||||
void fieldModified(ModificationWatchpointEvent event);
|
||||
void threadStarted(ThreadStartEvent event);
|
||||
void threadDied(ThreadDeathEvent event);
|
||||
void vmStarted(VMStartEvent event);
|
||||
void vmDied(VMDeathEvent event);
|
||||
void vmDisconnected(VMDisconnectEvent event);
|
||||
}
|
@ -1,758 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.request.*;
|
||||
import com.sun.jdi.event.*;
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Framework used by all JDI regression tests
|
||||
*/
|
||||
abstract public class TestScaffold extends TargetAdapter {
|
||||
private boolean shouldTrace = false;
|
||||
private VMConnection connection;
|
||||
private VirtualMachine vm;
|
||||
private EventRequestManager requestManager;
|
||||
private List listeners = Collections.synchronizedList(new LinkedList());
|
||||
|
||||
/**
|
||||
* We create a VMDeathRequest, SUSPEND_ALL, to sync the BE and FE.
|
||||
*/
|
||||
//private VMDeathRequest ourVMDeathRequest = null;
|
||||
Object ourVMDeathRequest = null;
|
||||
|
||||
/**
|
||||
* We create an ExceptionRequest, SUSPEND_NONE so that we can
|
||||
* catch it and output a msg if an exception occurs in the
|
||||
* debuggee.
|
||||
*/
|
||||
private ExceptionRequest ourExceptionRequest = null;
|
||||
|
||||
/**
|
||||
* If we do catch an uncaught exception, we set this true
|
||||
* so the testcase can find out if it wants to.
|
||||
*/
|
||||
private boolean exceptionCaught = false;
|
||||
ThreadReference vmStartThread = null;
|
||||
boolean vmDied = false;
|
||||
boolean vmDisconnected = false;
|
||||
final String[] args;
|
||||
protected boolean testFailed = false;
|
||||
|
||||
static private class ArgInfo {
|
||||
String targetVMArgs = "";
|
||||
String targetAppCommandLine = "";
|
||||
String connectorSpec = "com.sun.jdi.CommandLineLaunch:";
|
||||
int traceFlags = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* An easy way to sleep for awhile
|
||||
*/
|
||||
public void mySleep(int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException ee) {
|
||||
}
|
||||
}
|
||||
|
||||
boolean getExceptionCaught() {
|
||||
return exceptionCaught;
|
||||
}
|
||||
|
||||
void setExceptionCaught(boolean value) {
|
||||
exceptionCaught = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if eventSet contains the VMDeathEvent for the request in
|
||||
* the ourVMDeathRequest ivar.
|
||||
*/
|
||||
private boolean containsOurVMDeathRequest(EventSet eventSet) {
|
||||
if (ourVMDeathRequest != null) {
|
||||
Iterator myIter = eventSet.iterator();
|
||||
while (myIter.hasNext()) {
|
||||
Event myEvent = (Event)myIter.next();
|
||||
if (!(myEvent instanceof VMDeathEvent)) {
|
||||
// We assume that an EventSet contains only VMDeathEvents
|
||||
// or no VMDeathEvents.
|
||||
break;
|
||||
}
|
||||
if (ourVMDeathRequest.equals(myEvent.request())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* The following methods override those in our base class, TargetAdapter.
|
||||
*************************************************************************/
|
||||
|
||||
/**
|
||||
* Events handled directly by scaffold always resume (well, almost always)
|
||||
*/
|
||||
public void eventSetComplete(EventSet set) {
|
||||
// The listener in connect(..) resumes after receiving our
|
||||
// special VMDeathEvent. We can't also do the resume
|
||||
// here or we will probably get a VMDisconnectedException
|
||||
if (!containsOurVMDeathRequest(set)) {
|
||||
traceln("TS: set.resume() called");
|
||||
set.resume();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets up default requests.
|
||||
* Testcases can override this to change default behavior.
|
||||
*/
|
||||
protected void createDefaultEventRequests() {
|
||||
createDefaultVMDeathRequest();
|
||||
createDefaultExceptionRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* We want the BE to stop when it issues a VMDeathEvent in order to
|
||||
* give the FE time to complete handling events that occured before
|
||||
* the VMDeath. When we get the VMDeathEvent for this request in
|
||||
* the listener in connect(), we will do a resume.
|
||||
* If a testcase wants to do something special with VMDeathEvent's,
|
||||
* then it should override this method with an empty method or
|
||||
* whatever in order to suppress the automatic resume. The testcase
|
||||
* will then be responsible for the handling of VMDeathEvents. It
|
||||
* has to be sure that it does a resume if it gets a VMDeathEvent
|
||||
* with SUSPEND_ALL, and it has to be sure that it doesn't do a
|
||||
* resume after getting a VMDeath with SUSPEND_NONE (the automatically
|
||||
* generated VMDeathEvent.)
|
||||
*/
|
||||
protected void createDefaultVMDeathRequest() {
|
||||
// ourVMDeathRequest = requestManager.createVMDeathRequest();
|
||||
// ourVMDeathRequest.setSuspendPolicy(EventRequest.SUSPEND_ALL);
|
||||
// ourVMDeathRequest.enable();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will allow us to print a warning if a debuggee gets an
|
||||
* unexpected exception. The unexpected exception will be handled in
|
||||
* the exceptionThrown method in the listener created in the connect()
|
||||
* method.
|
||||
* If a testcase does not want an uncaught exception to cause a
|
||||
* msg, it must override this method.
|
||||
*/
|
||||
protected void createDefaultExceptionRequest() {
|
||||
ourExceptionRequest = requestManager.createExceptionRequest(null,
|
||||
false, true);
|
||||
|
||||
// We can't afford to make this be other than SUSPEND_NONE. Otherwise,
|
||||
// it would have to be resumed. If our connect() listener resumes it,
|
||||
// what about the case where the EventSet contains other events with
|
||||
// SUSPEND_ALL and there are other listeners who expect the BE to still
|
||||
// be suspended when their handlers get called?
|
||||
ourExceptionRequest.setSuspendPolicy(EventRequest.SUSPEND_NONE);
|
||||
ourExceptionRequest.enable();
|
||||
}
|
||||
|
||||
private class EventHandler implements Runnable {
|
||||
EventHandler() {
|
||||
Thread thread = new Thread(this);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
private void notifyEvent(TargetListener listener, Event event) {
|
||||
if (event instanceof BreakpointEvent) {
|
||||
listener.breakpointReached((BreakpointEvent)event);
|
||||
} else if (event instanceof ExceptionEvent) {
|
||||
listener.exceptionThrown((ExceptionEvent)event);
|
||||
} else if (event instanceof StepEvent) {
|
||||
listener.stepCompleted((StepEvent)event);
|
||||
} else if (event instanceof ClassPrepareEvent) {
|
||||
listener.classPrepared((ClassPrepareEvent)event);
|
||||
} else if (event instanceof ClassUnloadEvent) {
|
||||
listener.classUnloaded((ClassUnloadEvent)event);
|
||||
} else if (event instanceof MethodEntryEvent) {
|
||||
listener.methodEntered((MethodEntryEvent)event);
|
||||
} else if (event instanceof MethodExitEvent) {
|
||||
listener.methodExited((MethodExitEvent)event);
|
||||
} else if (event instanceof AccessWatchpointEvent) {
|
||||
listener.fieldAccessed((AccessWatchpointEvent)event);
|
||||
} else if (event instanceof ModificationWatchpointEvent) {
|
||||
listener.fieldModified((ModificationWatchpointEvent)event);
|
||||
} else if (event instanceof ThreadStartEvent) {
|
||||
listener.threadStarted((ThreadStartEvent)event);
|
||||
} else if (event instanceof ThreadDeathEvent) {
|
||||
listener.threadDied((ThreadDeathEvent)event);
|
||||
} else if (event instanceof VMStartEvent) {
|
||||
listener.vmStarted((VMStartEvent)event);
|
||||
} else if (event instanceof VMDeathEvent) {
|
||||
listener.vmDied((VMDeathEvent)event);
|
||||
} else if (event instanceof VMDisconnectEvent) {
|
||||
listener.vmDisconnected((VMDisconnectEvent)event);
|
||||
} else {
|
||||
throw new InternalError("Unknown event type: " + event.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
private void traceSuspendPolicy(int policy) {
|
||||
if (shouldTrace) {
|
||||
switch (policy) {
|
||||
case EventRequest.SUSPEND_NONE:
|
||||
traceln("TS: eventHandler: suspend = SUSPEND_NONE");
|
||||
break;
|
||||
case EventRequest.SUSPEND_ALL:
|
||||
traceln("TS: eventHandler: suspend = SUSPEND_ALL");
|
||||
break;
|
||||
case EventRequest.SUSPEND_EVENT_THREAD:
|
||||
traceln("TS: eventHandler: suspend = SUSPEND_EVENT_THREAD");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
boolean connected = true;
|
||||
do {
|
||||
try {
|
||||
EventSet set = vm.eventQueue().remove();
|
||||
traceSuspendPolicy(set.suspendPolicy());
|
||||
synchronized (listeners) {
|
||||
ListIterator iter = listeners.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
TargetListener listener = (TargetListener)iter.next();
|
||||
traceln("TS: eventHandler: listener = " + listener);
|
||||
listener.eventSetReceived(set);
|
||||
if (listener.shouldRemoveListener()) {
|
||||
iter.remove();
|
||||
} else {
|
||||
Iterator jter = set.iterator();
|
||||
while (jter.hasNext()) {
|
||||
Event event = (Event)jter.next();
|
||||
traceln("TS: eventHandler: event = " + event.getClass());
|
||||
|
||||
if (event instanceof VMDisconnectEvent) {
|
||||
connected = false;
|
||||
}
|
||||
listener.eventReceived(event);
|
||||
if (listener.shouldRemoveListener()) {
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
notifyEvent(listener, event);
|
||||
if (listener.shouldRemoveListener()) {
|
||||
iter.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
traceln("TS: eventHandler: end of events loop");
|
||||
if (!listener.shouldRemoveListener()) {
|
||||
traceln("TS: eventHandler: calling ESC");
|
||||
listener.eventSetComplete(set);
|
||||
if (listener.shouldRemoveListener()) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
traceln("TS: eventHandler: end of listeners loop");
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
traceln("TS: eventHandler: InterruptedException");
|
||||
} catch (Exception e) {
|
||||
failure("FAILED: Exception occured in eventHandler: " + e);
|
||||
e.printStackTrace();
|
||||
connected = false;
|
||||
synchronized(TestScaffold.this) {
|
||||
// This will make the waiters such as waitForVMDisconnect
|
||||
// exit their wait loops.
|
||||
vmDisconnected = true;
|
||||
TestScaffold.this.notifyAll();
|
||||
}
|
||||
}
|
||||
traceln("TS: eventHandler: End of outerloop");
|
||||
} while (connected);
|
||||
traceln("TS: eventHandler: finished");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public TestScaffold(String[] args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void enableScaffoldTrace() {
|
||||
this.shouldTrace = true;
|
||||
}
|
||||
|
||||
public void disableScaffoldTrace() {
|
||||
this.shouldTrace = false;
|
||||
}
|
||||
|
||||
|
||||
protected void startUp(String targetName) {
|
||||
List argList = new ArrayList(Arrays.asList(args));
|
||||
argList.add(targetName);
|
||||
println("run args: " + argList);
|
||||
connect((String[]) argList.toArray(args));
|
||||
waitForVMStart();
|
||||
}
|
||||
|
||||
protected BreakpointEvent startToMain(String targetName) {
|
||||
startUp(targetName);
|
||||
traceln("TS: back from startUp");
|
||||
BreakpointEvent bpr = resumeTo(targetName, "main", "([Ljava/lang/String;)V");
|
||||
waitForInput();
|
||||
return bpr;
|
||||
}
|
||||
|
||||
protected void waitForInput() {
|
||||
if (System.getProperty("jpda.wait") != null) {
|
||||
try {
|
||||
System.err.println("Press <enter> to continue");
|
||||
System.in.read();
|
||||
System.err.println("running...");
|
||||
|
||||
} catch(Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test cases should implement tests in runTests and should
|
||||
* initiate testing by calling run().
|
||||
*/
|
||||
abstract protected void runTests() throws Exception;
|
||||
|
||||
final public void startTests() throws Exception {
|
||||
try {
|
||||
runTests();
|
||||
} finally {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
protected void println(String str) {
|
||||
System.err.println(str);
|
||||
}
|
||||
|
||||
protected void print(String str) {
|
||||
System.err.print(str);
|
||||
}
|
||||
|
||||
protected void traceln(String str) {
|
||||
if (shouldTrace) {
|
||||
println(str);
|
||||
}
|
||||
}
|
||||
|
||||
protected void failure(String str) {
|
||||
println(str);
|
||||
testFailed = true;
|
||||
}
|
||||
|
||||
private ArgInfo parseArgs(String args[]) {
|
||||
ArgInfo argInfo = new ArgInfo();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i].equals("-connect")) {
|
||||
i++;
|
||||
argInfo.connectorSpec = args[i];
|
||||
} else if (args[i].equals("-trace")) {
|
||||
i++;
|
||||
argInfo.traceFlags = Integer.decode(args[i]).intValue();
|
||||
} else if (args[i].startsWith("-J")) {
|
||||
argInfo.targetVMArgs += (args[i].substring(2) + ' ');
|
||||
|
||||
/*
|
||||
* classpath can span two arguments so we need to handle
|
||||
* it specially.
|
||||
*/
|
||||
if (args[i].equals("-J-classpath")) {
|
||||
i++;
|
||||
argInfo.targetVMArgs += (args[i] + ' ');
|
||||
}
|
||||
} else {
|
||||
argInfo.targetAppCommandLine += (args[i] + ' ');
|
||||
}
|
||||
}
|
||||
return argInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called to connect to a debuggee VM. It starts the VM and
|
||||
* installs a listener to catch VMStartEvent, our default events, and
|
||||
* VMDisconnectedEvent. When these events appear, that is remembered
|
||||
* and waiters are notified.
|
||||
* This is normally called in the main thread of the test case.
|
||||
* It starts up an EventHandler thread that gets events coming in
|
||||
* from the debuggee and distributes them to listeners. That thread
|
||||
* keeps running until a VMDisconnectedEvent occurs or some exception
|
||||
* occurs during its processing.
|
||||
*
|
||||
* The 'listenUntilVMDisconnect' method adds 'this' as a listener.
|
||||
* This means that 'this's vmDied method will get called. This has a
|
||||
* default impl in TargetAdapter.java which can be overridden in the
|
||||
* testcase.
|
||||
*
|
||||
* waitForRequestedEvent also adds an adaptor listener that listens
|
||||
* for the particular event it is supposed to wait for (and it also
|
||||
* catches VMDisconnectEvents.) This listener is removed once
|
||||
* its eventReceived method is called.
|
||||
* waitForRequestedEvent is called by most of the methods to do bkpts,
|
||||
* etc.
|
||||
*/
|
||||
public void connect(String args[]) {
|
||||
ArgInfo argInfo = parseArgs(args);
|
||||
|
||||
argInfo.targetVMArgs += VMConnection.getDebuggeeVMOptions();
|
||||
connection = new VMConnection(argInfo.connectorSpec,
|
||||
argInfo.traceFlags);
|
||||
|
||||
addListener(new TargetAdapter() {
|
||||
public void eventSetComplete(EventSet set) {
|
||||
if (TestScaffold.this.containsOurVMDeathRequest(set)) {
|
||||
traceln("TS: connect: set.resume() called");
|
||||
set.resume();
|
||||
|
||||
// Note that we want to do the above resume before
|
||||
// waking up any sleepers.
|
||||
synchronized(TestScaffold.this) {
|
||||
TestScaffold.this.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vmStarted(VMStartEvent event) {
|
||||
synchronized(TestScaffold.this) {
|
||||
vmStartThread = event.thread();
|
||||
TestScaffold.this.notifyAll();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* By default, we catch uncaught exceptions and print a msg.
|
||||
* The testcase must override the createDefaultExceptionRequest
|
||||
* method if it doesn't want this behavior.
|
||||
*/
|
||||
public void exceptionThrown(ExceptionEvent event) {
|
||||
if (TestScaffold.this.ourExceptionRequest != null &&
|
||||
TestScaffold.this.ourExceptionRequest.equals(
|
||||
event.request())) {
|
||||
println("Note: Unexpected Debuggee Exception: " +
|
||||
event.exception().referenceType().name() +
|
||||
" at line " + event.location().lineNumber());
|
||||
TestScaffold.this.exceptionCaught = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void vmDied(VMDeathEvent event) {
|
||||
vmDied = true;
|
||||
traceln("TS: vmDied called");
|
||||
}
|
||||
|
||||
public void vmDisconnected(VMDisconnectEvent event) {
|
||||
synchronized(TestScaffold.this) {
|
||||
vmDisconnected = true;
|
||||
TestScaffold.this.notifyAll();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (connection.connector().name().equals("com.sun.jdi.CommandLineLaunch")) {
|
||||
if (argInfo.targetVMArgs.length() > 0) {
|
||||
if (connection.connectorArg("options").length() > 0) {
|
||||
throw new IllegalArgumentException("VM options in two places");
|
||||
}
|
||||
connection.setConnectorArg("options", argInfo.targetVMArgs);
|
||||
}
|
||||
if (argInfo.targetAppCommandLine.length() > 0) {
|
||||
if (connection.connectorArg("main").length() > 0) {
|
||||
throw new IllegalArgumentException("Command line in two places");
|
||||
}
|
||||
connection.setConnectorArg("main", argInfo.targetAppCommandLine);
|
||||
}
|
||||
}
|
||||
|
||||
vm = connection.open();
|
||||
requestManager = vm.eventRequestManager();
|
||||
createDefaultEventRequests();
|
||||
new EventHandler();
|
||||
}
|
||||
|
||||
|
||||
public VirtualMachine vm() {
|
||||
return vm;
|
||||
}
|
||||
|
||||
public EventRequestManager eventRequestManager() {
|
||||
return requestManager;
|
||||
}
|
||||
|
||||
public void addListener(TargetListener listener) {
|
||||
traceln("TS: Adding listener " + listener);
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(TargetListener listener) {
|
||||
traceln("TS: Removing listener " + listener);
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
protected void listenUntilVMDisconnect() {
|
||||
try {
|
||||
addListener (this);
|
||||
} catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
testFailed = true;
|
||||
} finally {
|
||||
// Allow application to complete and shut down
|
||||
resumeToVMDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized ThreadReference waitForVMStart() {
|
||||
while ((vmStartThread == null) && !vmDisconnected) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
if (vmStartThread == null) {
|
||||
throw new VMDisconnectedException();
|
||||
}
|
||||
|
||||
return vmStartThread;
|
||||
}
|
||||
|
||||
public synchronized void waitForVMDisconnect() {
|
||||
traceln("TS: waitForVMDisconnect");
|
||||
while (!vmDisconnected) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
traceln("TS: waitForVMDisconnect: done");
|
||||
}
|
||||
|
||||
public Event waitForRequestedEvent(final EventRequest request) {
|
||||
class EventNotification {
|
||||
Event event;
|
||||
boolean disconnected = false;
|
||||
}
|
||||
final EventNotification en = new EventNotification();
|
||||
|
||||
TargetAdapter adapter = new TargetAdapter() {
|
||||
public void eventReceived(Event event) {
|
||||
if (request.equals(event.request())) {
|
||||
traceln("TS:Listener2: got requested event");
|
||||
synchronized (en) {
|
||||
en.event = event;
|
||||
en.notifyAll();
|
||||
}
|
||||
removeThisListener();
|
||||
} else if (event instanceof VMDisconnectEvent) {
|
||||
traceln("TS:Listener2: got VMDisconnectEvent");
|
||||
synchronized (en) {
|
||||
en.disconnected = true;
|
||||
en.notifyAll();
|
||||
}
|
||||
removeThisListener();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
addListener(adapter);
|
||||
|
||||
try {
|
||||
synchronized (en) {
|
||||
traceln("TS: waitForRequestedEvent: vm.resume called");
|
||||
vm.resume();
|
||||
|
||||
while (!en.disconnected && (en.event == null)) {
|
||||
en.wait();
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (en.disconnected) {
|
||||
throw new RuntimeException("VM Disconnected before requested event occurred");
|
||||
}
|
||||
return en.event;
|
||||
}
|
||||
|
||||
private StepEvent doStep(ThreadReference thread, int gran, int depth) {
|
||||
final StepRequest sr =
|
||||
requestManager.createStepRequest(thread, gran, depth);
|
||||
|
||||
sr.addClassExclusionFilter("java.*");
|
||||
sr.addClassExclusionFilter("sun.*");
|
||||
sr.addClassExclusionFilter("com.sun.*");
|
||||
sr.addCountFilter(1);
|
||||
sr.enable();
|
||||
StepEvent retEvent = (StepEvent)waitForRequestedEvent(sr);
|
||||
requestManager.deleteEventRequest(sr);
|
||||
return retEvent;
|
||||
}
|
||||
|
||||
public StepEvent stepIntoInstruction(ThreadReference thread) {
|
||||
return doStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO);
|
||||
}
|
||||
|
||||
public StepEvent stepIntoLine(ThreadReference thread) {
|
||||
return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO);
|
||||
}
|
||||
|
||||
public StepEvent stepOverInstruction(ThreadReference thread) {
|
||||
return doStep(thread, StepRequest.STEP_MIN, StepRequest.STEP_OVER);
|
||||
}
|
||||
|
||||
public StepEvent stepOverLine(ThreadReference thread) {
|
||||
return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER);
|
||||
}
|
||||
|
||||
public StepEvent stepOut(ThreadReference thread) {
|
||||
return doStep(thread, StepRequest.STEP_LINE, StepRequest.STEP_OUT);
|
||||
}
|
||||
|
||||
public BreakpointEvent resumeTo(Location loc) {
|
||||
final BreakpointRequest request =
|
||||
requestManager.createBreakpointRequest(loc);
|
||||
request.addCountFilter(1);
|
||||
request.enable();
|
||||
return (BreakpointEvent)waitForRequestedEvent(request);
|
||||
}
|
||||
|
||||
public ReferenceType findReferenceType(String name) {
|
||||
List rts = vm.classesByName(name);
|
||||
Iterator iter = rts.iterator();
|
||||
while (iter.hasNext()) {
|
||||
ReferenceType rt = (ReferenceType)iter.next();
|
||||
if (rt.name().equals(name)) {
|
||||
return rt;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Method findMethod(ReferenceType rt, String name, String signature) {
|
||||
List methods = rt.methods();
|
||||
Iterator iter = methods.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Method method = (Method)iter.next();
|
||||
if (method.name().equals(name) &&
|
||||
method.signature().equals(signature)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location findLocation(ReferenceType rt, int lineNumber)
|
||||
throws AbsentInformationException {
|
||||
List locs = rt.locationsOfLine(lineNumber);
|
||||
if (locs.size() == 0) {
|
||||
throw new IllegalArgumentException("Bad line number");
|
||||
} else if (locs.size() > 1) {
|
||||
throw new IllegalArgumentException("Line number has multiple locations");
|
||||
}
|
||||
|
||||
return (Location)locs.get(0);
|
||||
}
|
||||
|
||||
public BreakpointEvent resumeTo(String clsName, String methodName,
|
||||
String methodSignature) {
|
||||
ReferenceType rt = findReferenceType(clsName);
|
||||
if (rt == null) {
|
||||
rt = resumeToPrepareOf(clsName).referenceType();
|
||||
}
|
||||
|
||||
Method method = findMethod(rt, methodName, methodSignature);
|
||||
if (method == null) {
|
||||
throw new IllegalArgumentException("Bad method name/signature");
|
||||
}
|
||||
|
||||
return resumeTo(method.location());
|
||||
}
|
||||
|
||||
public BreakpointEvent resumeTo(String clsName, int lineNumber) throws AbsentInformationException {
|
||||
ReferenceType rt = findReferenceType(clsName);
|
||||
if (rt == null) {
|
||||
rt = resumeToPrepareOf(clsName).referenceType();
|
||||
}
|
||||
|
||||
return resumeTo(findLocation(rt, lineNumber));
|
||||
}
|
||||
|
||||
public ClassPrepareEvent resumeToPrepareOf(String className) {
|
||||
final ClassPrepareRequest request =
|
||||
requestManager.createClassPrepareRequest();
|
||||
request.addClassFilter(className);
|
||||
request.addCountFilter(1);
|
||||
request.enable();
|
||||
return (ClassPrepareEvent)waitForRequestedEvent(request);
|
||||
}
|
||||
|
||||
public void resumeToVMDisconnect() {
|
||||
try {
|
||||
traceln("TS: resumeToVMDisconnect: vm.resume called");
|
||||
vm.resume();
|
||||
} catch (VMDisconnectedException e) {
|
||||
// clean up below
|
||||
}
|
||||
waitForVMDisconnect();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
shutdown(null);
|
||||
}
|
||||
|
||||
public void shutdown(String message) {
|
||||
traceln("TS: shutdown: vmDied= " + vmDied +
|
||||
", vmDisconnected= " + vmDisconnected +
|
||||
", connection = " + connection);
|
||||
|
||||
if ((connection != null)) {
|
||||
try {
|
||||
connection.disposeVM();
|
||||
} catch (VMDisconnectedException e) {
|
||||
// Shutting down after the VM has gone away. This is
|
||||
// not an error, and we just ignore it.
|
||||
}
|
||||
} else {
|
||||
traceln("TS: shutdown: disposeVM not called");
|
||||
}
|
||||
if (message != null) {
|
||||
println(message);
|
||||
}
|
||||
|
||||
vmDied = true;
|
||||
vmDisconnected = true;
|
||||
}
|
||||
}
|
@ -1,378 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.connect.*;
|
||||
import com.sun.jdi.request.EventRequestManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.io.*;
|
||||
|
||||
|
||||
/**
|
||||
* Manages a VM conection for the JDI test framework.
|
||||
*/
|
||||
class VMConnection {
|
||||
private VirtualMachine vm;
|
||||
private Process process = null;
|
||||
private int outputCompleteCount = 0;
|
||||
|
||||
private final Connector connector;
|
||||
private final Map connectorArgs;
|
||||
private final int traceFlags;
|
||||
|
||||
/**
|
||||
* Return a String containing VM Options to pass to the debugee
|
||||
* or an empty string if there are none.
|
||||
* These are read from the first non-comment line
|
||||
* in file test/com/sun/jdi/@debuggeeVMOptions.
|
||||
*/
|
||||
static public String getDebuggeeVMOptions() {
|
||||
|
||||
// When we run under jtreg, test.src contains the pathname of
|
||||
// the test/com/sun/jdi dir.
|
||||
BufferedReader reader;
|
||||
final String filename = "@debuggeeVMOptions";
|
||||
String srcDir = System.getProperty("test.src");
|
||||
|
||||
if (srcDir == null) {
|
||||
srcDir = System.getProperty("user.dir");
|
||||
}
|
||||
srcDir = srcDir + File.separator;
|
||||
|
||||
File myDir = new File(srcDir);
|
||||
|
||||
File myFile = new File(myDir, filename);
|
||||
if (!myFile.canRead()) {
|
||||
try {
|
||||
// We have some subdirs of test/com/sun/jdi so in case we
|
||||
// are in one of them, look in our parent dir for the file.
|
||||
myFile = new File(myDir.getCanonicalFile().getParent(),
|
||||
filename);
|
||||
if (!myFile.canRead()) {
|
||||
return "";
|
||||
}
|
||||
} catch (IOException ee) {
|
||||
System.out.println("-- Error 1 trying to access file " +
|
||||
myFile.getPath() + ": " + ee);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
String wholePath = myFile.getPath();
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(myFile));
|
||||
} catch (FileNotFoundException ee) {
|
||||
System.out.println("-- Error 2 trying to access file " +
|
||||
wholePath + ": " + ee);
|
||||
return "";
|
||||
}
|
||||
|
||||
String line;
|
||||
String retVal = "";
|
||||
while (true) {
|
||||
try {
|
||||
line = reader.readLine();
|
||||
} catch (IOException ee) {
|
||||
System.out.println("-- Error reading options from file " +
|
||||
wholePath + ": " + ee);
|
||||
break;
|
||||
}
|
||||
if (line == null) {
|
||||
System.out.println("-- No debuggee VM options found in file " +
|
||||
wholePath);
|
||||
break;
|
||||
}
|
||||
line = line.trim();
|
||||
if (line.length() != 0 && !line.startsWith("#")) {
|
||||
System.out.println("-- Added debuggeeVM options from file " +
|
||||
wholePath + ": " + line);
|
||||
retVal = line;
|
||||
break;
|
||||
}
|
||||
// Else, read he next line.
|
||||
}
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ee) {
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private Connector findConnector(String name) {
|
||||
List connectors = Bootstrap.virtualMachineManager().allConnectors();
|
||||
Iterator iter = connectors.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Connector connector = (Connector)iter.next();
|
||||
if (connector.name().equals(name)) {
|
||||
return connector;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map parseConnectorArgs(Connector connector, String argString) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(argString, ",");
|
||||
Map arguments = connector.defaultArguments();
|
||||
|
||||
while (tokenizer.hasMoreTokens()) {
|
||||
String token = tokenizer.nextToken();
|
||||
int index = token.indexOf('=');
|
||||
if (index == -1) {
|
||||
throw new IllegalArgumentException("Illegal connector argument: " +
|
||||
token);
|
||||
}
|
||||
String name = token.substring(0, index);
|
||||
String value = token.substring(index + 1);
|
||||
Connector.Argument argument = (Connector.Argument)arguments.get(name);
|
||||
if (argument == null) {
|
||||
throw new IllegalArgumentException("Argument " + name +
|
||||
"is not defined for connector: " +
|
||||
connector.name());
|
||||
}
|
||||
argument.setValue(value);
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
VMConnection(String connectSpec, int traceFlags) {
|
||||
String nameString;
|
||||
String argString;
|
||||
int index = connectSpec.indexOf(':');
|
||||
if (index == -1) {
|
||||
nameString = connectSpec;
|
||||
argString = "";
|
||||
} else {
|
||||
nameString = connectSpec.substring(0, index);
|
||||
argString = connectSpec.substring(index + 1);
|
||||
}
|
||||
|
||||
connector = findConnector(nameString);
|
||||
if (connector == null) {
|
||||
throw new IllegalArgumentException("No connector named: " +
|
||||
nameString);
|
||||
}
|
||||
|
||||
connectorArgs = parseConnectorArgs(connector, argString);
|
||||
this.traceFlags = traceFlags;
|
||||
}
|
||||
|
||||
synchronized VirtualMachine open() {
|
||||
if (connector instanceof LaunchingConnector) {
|
||||
vm = launchTarget();
|
||||
} else if (connector instanceof AttachingConnector) {
|
||||
vm = attachTarget();
|
||||
} else if (connector instanceof ListeningConnector) {
|
||||
vm = listenTarget();
|
||||
} else {
|
||||
throw new InternalError("Invalid connect type");
|
||||
}
|
||||
vm.setDebugTraceMode(traceFlags);
|
||||
System.out.println("JVM version:" + vm.version());
|
||||
System.out.println("JDI version: " + Bootstrap.virtualMachineManager().majorInterfaceVersion() +
|
||||
"." + Bootstrap.virtualMachineManager().minorInterfaceVersion());
|
||||
System.out.println("JVM description: " + vm.description());
|
||||
|
||||
return vm;
|
||||
}
|
||||
|
||||
boolean setConnectorArg(String name, String value) {
|
||||
/*
|
||||
* Too late if the connection already made
|
||||
*/
|
||||
if (vm != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Connector.Argument argument = (Connector.Argument)connectorArgs.get(name);
|
||||
if (argument == null) {
|
||||
return false;
|
||||
}
|
||||
argument.setValue(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
String connectorArg(String name) {
|
||||
Connector.Argument argument = (Connector.Argument)connectorArgs.get(name);
|
||||
if (argument == null) {
|
||||
return "";
|
||||
}
|
||||
return argument.value();
|
||||
}
|
||||
|
||||
public synchronized VirtualMachine vm() {
|
||||
if (vm == null) {
|
||||
throw new InternalError("VM not connected");
|
||||
} else {
|
||||
return vm;
|
||||
}
|
||||
}
|
||||
|
||||
boolean isOpen() {
|
||||
return (vm != null);
|
||||
}
|
||||
|
||||
boolean isLaunch() {
|
||||
return (connector instanceof LaunchingConnector);
|
||||
}
|
||||
|
||||
Connector connector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
boolean isListen() {
|
||||
return (connector instanceof ListeningConnector);
|
||||
}
|
||||
|
||||
boolean isAttach() {
|
||||
return (connector instanceof AttachingConnector);
|
||||
}
|
||||
|
||||
private synchronized void notifyOutputComplete() {
|
||||
outputCompleteCount++;
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
private synchronized void waitOutputComplete() {
|
||||
// Wait for stderr and stdout
|
||||
if (process != null) {
|
||||
while (outputCompleteCount < 2) {
|
||||
try {wait();} catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void disposeVM() {
|
||||
try {
|
||||
if (vm != null) {
|
||||
vm.dispose();
|
||||
vm = null;
|
||||
}
|
||||
} finally {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
process = null;
|
||||
}
|
||||
waitOutputComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpStream(InputStream stream) throws IOException {
|
||||
PrintStream outStream = System.out;
|
||||
BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(stream));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
outStream.println(line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Thread that will retrieve and display any output.
|
||||
* Needs to be high priority, else debugger may exit before
|
||||
* it can be displayed.
|
||||
*/
|
||||
private void displayRemoteOutput(final InputStream stream) {
|
||||
Thread thr = new Thread("output reader") {
|
||||
public void run() {
|
||||
try {
|
||||
dumpStream(stream);
|
||||
} catch (IOException ex) {
|
||||
System.err.println("IOException reading output of child java interpreter:"
|
||||
+ ex.getMessage());
|
||||
} finally {
|
||||
notifyOutputComplete();
|
||||
}
|
||||
}
|
||||
};
|
||||
thr.setPriority(Thread.MAX_PRIORITY-1);
|
||||
thr.start();
|
||||
}
|
||||
|
||||
private void dumpFailedLaunchInfo(Process process) {
|
||||
try {
|
||||
dumpStream(process.getErrorStream());
|
||||
dumpStream(process.getInputStream());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Unable to display process output: " +
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/* launch child target vm */
|
||||
private VirtualMachine launchTarget() {
|
||||
LaunchingConnector launcher = (LaunchingConnector)connector;
|
||||
try {
|
||||
VirtualMachine vm = launcher.launch(connectorArgs);
|
||||
process = vm.process();
|
||||
displayRemoteOutput(process.getErrorStream());
|
||||
displayRemoteOutput(process.getInputStream());
|
||||
return vm;
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
System.err.println("\n Unable to launch target VM.");
|
||||
} catch (IllegalConnectorArgumentsException icae) {
|
||||
icae.printStackTrace();
|
||||
System.err.println("\n Internal debugger error.");
|
||||
} catch (VMStartException vmse) {
|
||||
System.err.println(vmse.getMessage() + "\n");
|
||||
dumpFailedLaunchInfo(vmse.process());
|
||||
System.err.println("\n Target VM failed to initialize.");
|
||||
}
|
||||
return null; // Shuts up the compiler
|
||||
}
|
||||
|
||||
/* attach to running target vm */
|
||||
private VirtualMachine attachTarget() {
|
||||
AttachingConnector attacher = (AttachingConnector)connector;
|
||||
try {
|
||||
return attacher.attach(connectorArgs);
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
System.err.println("\n Unable to attach to target VM.");
|
||||
} catch (IllegalConnectorArgumentsException icae) {
|
||||
icae.printStackTrace();
|
||||
System.err.println("\n Internal debugger error.");
|
||||
}
|
||||
return null; // Shuts up the compiler
|
||||
}
|
||||
|
||||
/* listen for connection from target vm */
|
||||
private VirtualMachine listenTarget() {
|
||||
ListeningConnector listener = (ListeningConnector)connector;
|
||||
try {
|
||||
String retAddress = listener.startListening(connectorArgs);
|
||||
System.out.println("Listening at address: " + retAddress);
|
||||
vm = listener.accept(connectorArgs);
|
||||
listener.stopListening(connectorArgs);
|
||||
return vm;
|
||||
} catch (IOException ioe) {
|
||||
ioe.printStackTrace();
|
||||
System.err.println("\n Unable to attach to target VM.");
|
||||
} catch (IllegalConnectorArgumentsException icae) {
|
||||
icae.printStackTrace();
|
||||
System.err.println("\n Internal debugger error.");
|
||||
}
|
||||
return null; // Shuts up the compiler
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
$JAVA_HOME/bin/java -showversion ${OPTIONS} -classpath $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.tools.StackTrace $*
|
@ -1,26 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
$JAVA_HOME/bin/java -d64 -showversion ${OPTIONS} -classpath $JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.tools.StackTrace $*
|
@ -1,133 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.connect.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.io.IOException;
|
||||
|
||||
/* This class is used to test multi VM connectivity feature of
|
||||
* SA/JDI. Accepts two PIDs as arguments. Connects to first VM
|
||||
*, Connects to second VM and disposes them in that order.
|
||||
*/
|
||||
|
||||
public class multivm {
|
||||
static AttachingConnector myPIDConn;
|
||||
static VirtualMachine vm1;
|
||||
static VirtualMachine vm2;
|
||||
static VirtualMachineManager vmmgr;
|
||||
|
||||
public static void println(String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
System.err.println("Usage: java multivm <pid1> <pid2>");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
vmmgr = Bootstrap.virtualMachineManager();
|
||||
List attachingConnectors = vmmgr.attachingConnectors();
|
||||
if (attachingConnectors.isEmpty()) {
|
||||
System.err.println( "ERROR: No attaching connectors");
|
||||
return;
|
||||
}
|
||||
Iterator myIt = attachingConnectors.iterator();
|
||||
while (myIt.hasNext()) {
|
||||
AttachingConnector tmpCon = (AttachingConnector)myIt.next();
|
||||
if (tmpCon.name().equals(
|
||||
"sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
|
||||
myPIDConn = tmpCon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int pid1 = 0, pid2 = 0;
|
||||
String pidText = null;
|
||||
switch (args.length) {
|
||||
case (2):
|
||||
try {
|
||||
pidText = args[0];
|
||||
pid1 = Integer.parseInt(pidText);
|
||||
System.out.println( "pid1: " + pid1);
|
||||
vm1 = attachPID(pid1);
|
||||
pidText = args[1];
|
||||
pid2 = Integer.parseInt(pidText);
|
||||
System.out.println( "pid2: " + pid2);
|
||||
vm2 = attachPID(pid2);
|
||||
} catch (NumberFormatException e) {
|
||||
println(e.getMessage());
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
if (vm1 != null) {
|
||||
System.out.println("vm1: attached ok!");
|
||||
System.out.println(vm1.version());
|
||||
sagdoit mine = new sagdoit(vm1);
|
||||
mine.doAll();
|
||||
}
|
||||
|
||||
if (vm2 != null) {
|
||||
System.out.println("vm2: attached ok!");
|
||||
System.out.println(vm2.version());
|
||||
sagdoit mine = new sagdoit(vm2);
|
||||
mine.doAll();
|
||||
}
|
||||
|
||||
if (vm1 != null) {
|
||||
vm1.dispose();
|
||||
}
|
||||
|
||||
if (vm2 != null) {
|
||||
vm2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtualMachine attachPID(int pid) {
|
||||
Map connArgs = myPIDConn.defaultArguments();
|
||||
System.out.println("connArgs = " + connArgs);
|
||||
VirtualMachine vm;
|
||||
Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
|
||||
connArg.setValue(Integer.toString(pid));
|
||||
|
||||
try {
|
||||
vm = myPIDConn.attach(connArgs);
|
||||
} catch (IOException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
|
||||
vm = null;
|
||||
} catch (IllegalConnectorArgumentsException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
|
||||
vm = null;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
doUsage()
|
||||
{
|
||||
cat <<EOF
|
||||
Run multivm.class using Serviceability Agent to talk to 2 pids
|
||||
simultaneousely. i.e, before detaching one attach another.
|
||||
Usage: multivm.sh <jdk-pathname> <pid1> <pid2>
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ $# = 4 ] ; then
|
||||
doUsage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
jdk=$1
|
||||
javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
|
||||
|
||||
mkdir -p workdir
|
||||
if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ multivm.java -nt ./workdir/multivm.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp multivm.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
$jdk/bin/java -Dsun.jvm.hotspot.jdi.ConnectorImpl.DEBUG -Dsun.jvm.hotspot.jdi.SAJDIClassLoader.DEBUG -Djava.class.path=$javacp multivm $2 $3
|
@ -1,108 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
# jdb is a .c file that seems to discard the setting of CLASSPATH.
|
||||
# So, we have to run jdb by calling java directly :-(
|
||||
|
||||
# License file for development version of dbx
|
||||
LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense
|
||||
export LM_LICENSE_FILE
|
||||
|
||||
doUsage()
|
||||
{
|
||||
cat <<EOF
|
||||
Usage: runjdb.sh corefile -jdk jdk-pathname -sa sa-pathname
|
||||
sa-pathname is the path of a JDI-SA build dir.
|
||||
EOF
|
||||
}
|
||||
|
||||
jdk=
|
||||
javaArgs=
|
||||
args=
|
||||
sa=
|
||||
while [ $# != 0 ] ; do
|
||||
case $1 in
|
||||
-vv)
|
||||
set -x
|
||||
;;
|
||||
-jdk)
|
||||
jdk=$2
|
||||
shift
|
||||
;;
|
||||
-sa)
|
||||
sa=$2
|
||||
shift
|
||||
;;
|
||||
-help | help)
|
||||
doUsage
|
||||
exit
|
||||
;;
|
||||
-*)
|
||||
javaArgs="$javaArgs $1"
|
||||
;;
|
||||
*)
|
||||
if [ ! -z "$args" ] ; then
|
||||
echo "Error: Only one core file or pid can be specified"
|
||||
exit 1
|
||||
fi
|
||||
echo "$1" | grep -s '^[0-9]*$' > /dev/null
|
||||
if [ $? = 0 ] ; then
|
||||
# it is a pid
|
||||
args="$args $1"
|
||||
echo "Error: A pid is not yet allowed"
|
||||
exit 1
|
||||
else
|
||||
# It is a core.
|
||||
# We have to pass the name of the program that produced the
|
||||
# core, and the core file itself.
|
||||
args="$1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$jdk" ] ; then
|
||||
echo "Error: -jdk jdk-pathname is required"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "$sa" ] ; then
|
||||
echo "Error: -sa sa-pathname is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$args" ] ; then
|
||||
echo "Error: a core file or pid must be specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
$jdk/bin/jdb -J-Xbootclasspath/a:$sa -connect \
|
||||
sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=$args,javaExecutable=$jdk/bin/java
|
||||
|
||||
|
||||
#$jdk/bin/java -Xbootclasspath/a:$mmm/ws/merlin-sa/build/agent \
|
||||
# com.sun.tools.example.debug.tty.TTY -connect \
|
||||
# sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore,javaExecutable=$jdk/bin/java
|
@ -1,133 +0,0 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
# This script runs the test program, sagtest.java, with the regular
|
||||
# JPDA jdi.
|
||||
# It then starts up the debuggee part of the test, sagtarg.java,
|
||||
# and calls gcore to create file sagcore for use in running
|
||||
# the SA JDI client.
|
||||
|
||||
set -x
|
||||
# jdk is a jdk with the vm from the sa workspace
|
||||
while [ $# != 0 ] ; do
|
||||
case $1 in
|
||||
-vv)
|
||||
set -x
|
||||
;;
|
||||
-gui)
|
||||
theClass=sun.jvm.hotspot.HSDB
|
||||
;;
|
||||
-jdk)
|
||||
jdk=$2
|
||||
shift
|
||||
;;
|
||||
-jdbx)
|
||||
do=jdbx
|
||||
;;
|
||||
-jdb)
|
||||
do=jdb
|
||||
;;
|
||||
-help | help)
|
||||
doUsage
|
||||
exit
|
||||
;;
|
||||
-dontkill)
|
||||
dontkill=true
|
||||
;;
|
||||
-d64)
|
||||
d64=-d64
|
||||
;;
|
||||
-*)
|
||||
javaArgs="$javaArgs $1"
|
||||
;;
|
||||
*)
|
||||
echo "$1" | grep -s '^[0-9]*$' > /dev/null
|
||||
if [ $? = 0 ] ; then
|
||||
# it is a pid
|
||||
args="$args $1"
|
||||
else
|
||||
# It is a core.
|
||||
# We have to pass the name of the program that produced the
|
||||
# core, and the core file itself.
|
||||
args="$jdk/bin/java $1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# First, run the sagtest.java with the regular JPDA jdi
|
||||
workdir=./workdir
|
||||
mkdir -p $workdir
|
||||
CLASSPATH=$jdk/classes:$jdk/lib/tools.jar:$workdir
|
||||
export CLASSPATH
|
||||
|
||||
$jdk/bin/javac -g -source 1.5 -classpath $jdk/classes:$jdk/lib/tools.jar:$workdir -J-Xms40m -d $workdir \
|
||||
TestScaffold.java \
|
||||
VMConnection.java \
|
||||
TargetListener.java \
|
||||
TargetAdapter.java \
|
||||
sagdoit.java \
|
||||
sagtarg.java \
|
||||
sagtest.java
|
||||
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$jdk/bin/java $javaArgs -Dtest.classes=$workdir sagtest
|
||||
|
||||
# Now run create a core file for use in running sa-jdi
|
||||
|
||||
if [ ! core.satest -nt sagtarg.class ] ; then
|
||||
tmp=/tmp/sagsetup
|
||||
rm -f $tmp
|
||||
$jdk/bin/java $d64 sagtarg > $tmp &
|
||||
pid=$!
|
||||
while [ ! -s $tmp ] ; do
|
||||
# Kludge alert!
|
||||
sleep 2
|
||||
done
|
||||
#rm -f $tmp
|
||||
|
||||
# force core dump of the debuggee
|
||||
OS=`uname`
|
||||
if [ "$OS" = "Linux" ]; then
|
||||
# Linux does not have gcore command. Instead, we use 'gdb's
|
||||
# gcore command. Note that only some versions of gdb support
|
||||
# gdb command.
|
||||
echo "gcore" > gdbscript
|
||||
gdb -batch -p $pid -x gdbscript
|
||||
rm -f gdbscript
|
||||
else
|
||||
gcore $* $pid
|
||||
fi
|
||||
mv core.$pid sagcore
|
||||
|
||||
if [ "$dontkill" != "true" ]; then
|
||||
kill -9 $pid
|
||||
fi
|
||||
fi
|
||||
|
@ -1,183 +0,0 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
# This jdk must be hopper or better; it must have the
|
||||
# SA connectors in VirtualMachineManagerImpl.
|
||||
jdk=/java/re/jdk/1.4.1/promoted/latest/binaries/solaris-sparc
|
||||
#jdk=/net/mmm/export/mmm/jdk1.4fcs.sa
|
||||
|
||||
doUsage()
|
||||
{
|
||||
cat <<EOF
|
||||
Run sagclient.class using Serviceability Agent to talk to a corefile/pid/debugserver.
|
||||
Usage: runsa.sh [-jdk <jdk-pathname>] [-jdb] [ -jdbx ] [ -d64 ] [ -remote ] [ pid | corefile | debugserver ]
|
||||
|
||||
-jdk means to use that jdk. Default is 1.4.1/latest.
|
||||
-jdbx means to run it under jdbx
|
||||
-jdb means to connect using jdb instead of the sagclient program.
|
||||
-remote debugserver means you want to connect to a remote debug server
|
||||
|
||||
The corefile must have been produced by the same java as is running SA.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
doUsage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# License file for development version of dbx
|
||||
#LM_LICENSE_FILE=7588@extend.eng:/usr/dist/local/config/sparcworks/license.dat:7588@setlicense
|
||||
#export LM_LICENSE_FILE
|
||||
|
||||
do=
|
||||
args=
|
||||
theClass=sagclient
|
||||
javaArgs=
|
||||
|
||||
while [ $# != 0 ] ; do
|
||||
case $1 in
|
||||
-vv)
|
||||
set -x
|
||||
;;
|
||||
-jdk)
|
||||
jdk=$2
|
||||
shift
|
||||
;;
|
||||
-jdbx)
|
||||
do=jdbx
|
||||
;;
|
||||
-jdb)
|
||||
do=jdb
|
||||
;;
|
||||
-help | help)
|
||||
doUsage
|
||||
exit
|
||||
;;
|
||||
-d64)
|
||||
d64=-d64
|
||||
;;
|
||||
-remote)
|
||||
shift
|
||||
args="$1"
|
||||
do=remote
|
||||
;;
|
||||
-*)
|
||||
javaArgs="$javaArgs $1"
|
||||
;;
|
||||
*)
|
||||
echo "$1" | grep -s '^[0-9]*$' > /dev/null
|
||||
if [ $? = 0 ] ; then
|
||||
# it is a pid
|
||||
args="$args $1"
|
||||
else
|
||||
# It is a core.
|
||||
# We have to pass the name of the program that produced the
|
||||
# core, and the core file itself.
|
||||
args="$jdk/bin/java $1"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ -z "$jdk" ] ; then
|
||||
error "--Error: runsa.sh: Must specify -jdk <jdk-pathname>."
|
||||
error " Do runsa.sh -help for more info"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
# If jjh makes this, then the classes are in .../build/agent.
|
||||
# if someone else does, they are in .
|
||||
classesDir=../../../../../../build/agent
|
||||
if [ ! -r $classesDir ] ; then
|
||||
classesDir=.
|
||||
if [ ! -r $classesDir ] ; then
|
||||
echo "-- Error: runsa.sh can't find the SA classes"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
#javacp="/net/mmm/export/mmm/ws/sabaseline/build/solaris/solaris_sparc_compiler1/generated/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
|
||||
|
||||
javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
|
||||
|
||||
|
||||
extraArgs="-showversion $javaArgs"
|
||||
#extraArgs="-DdbxSvcAgentDSOPathName=/net/mmm/export/mmm/ws/m/b2/sa/src/os/solaris/agent/64bit/libsvc_agent_dbx.so $extraArgs"
|
||||
#extraArgs="-DdbxSvcAgentDSOPathName=/net/jano.eng/export/disk05/hotspot/sa/solaris/sparcv9/lib/libsvc_agent_dbx.so $extraArgs"
|
||||
|
||||
mkdir -p workdir
|
||||
if [ sagclient.java -nt ./workdir/sagclient.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp sagclient.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$do" = jdbx ] ; then
|
||||
set -x
|
||||
dbx=/net/sparcworks.eng/export/set/sparcworks2/dbx_70_nightly/dev/buildbin/Derived-sparc-S2-opt/bin/dbx
|
||||
|
||||
# Have to do this export for jdbx to work. -cp and -classpath don't work.
|
||||
CLASSPATH=$javacp
|
||||
export CLASSPATH
|
||||
#extraArgs="-Djava.class.path=$mhs/../sa/build/agent sun.jvm.hotspot.HSDB $*"
|
||||
jvm_invocation="$jdk/bin/java -Xdebug \
|
||||
-Dsun.boot.class.path=$jdk/classes \
|
||||
$extraArgs"
|
||||
#export jvm_invocation
|
||||
|
||||
JAVASRCPATH=$mhs/../sa/src/share/vm/agent
|
||||
export JAVASRCPATH
|
||||
|
||||
#operand is pathname of .class file, eg ./jj.class.
|
||||
echo run $args
|
||||
clss=`echo $theClass | sed -e 's@\.@/@'`
|
||||
if [ -r ./workdir/$clss.class ] ; then
|
||||
# kludge for running sagclient
|
||||
$dbx ./workdir/$clss.class
|
||||
else
|
||||
# kludge for running HSDB
|
||||
$dbx $mhs/../sa/build/agent/$clss.class
|
||||
fi
|
||||
elif [ "$do" = jdb ] ; then
|
||||
# This hasn't been tested.
|
||||
$jdk/bin/jdb -J-Xbootclasspath/a:$classesDir -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:core=sagcore
|
||||
elif [ "$do" = remote ] ; then
|
||||
$jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
|
||||
else
|
||||
$jdk/bin/java $d64 -Djava.class.path=$javacp $extraArgs $theClass $args
|
||||
|
||||
fi
|
@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.connect.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.io.IOException;
|
||||
|
||||
public class sagclient {
|
||||
static AttachingConnector myCoreConn;
|
||||
static AttachingConnector myPIDConn;
|
||||
static AttachingConnector myDbgSvrConn;
|
||||
static VirtualMachine vm;
|
||||
static VirtualMachineManager vmmgr;
|
||||
|
||||
public static void println(String msg) {
|
||||
System.out.println("jj: " + msg);
|
||||
}
|
||||
|
||||
|
||||
public static void main(String args[]) {
|
||||
vmmgr = Bootstrap.virtualMachineManager();
|
||||
List attachingConnectors = vmmgr.attachingConnectors();
|
||||
if (attachingConnectors.isEmpty()) {
|
||||
System.err.println( "ERROR: No attaching connectors");
|
||||
return;
|
||||
}
|
||||
Iterator myIt = attachingConnectors.iterator();
|
||||
while (myIt.hasNext()) {
|
||||
AttachingConnector tmpCon = (AttachingConnector)myIt.next();
|
||||
if (tmpCon.name().equals(
|
||||
"sun.jvm.hotspot.jdi.SACoreAttachingConnector")) {
|
||||
myCoreConn = tmpCon;
|
||||
} else if (tmpCon.name().equals(
|
||||
"sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
|
||||
myPIDConn = tmpCon;
|
||||
} else if (tmpCon.name().equals(
|
||||
"sun.jvm.hotspot.jdi.SADebugServerAttachingConnector")) {
|
||||
myDbgSvrConn = tmpCon;
|
||||
}
|
||||
}
|
||||
String execPath = null;
|
||||
String pidText = null;
|
||||
String coreFilename = null;
|
||||
String debugServer = null;
|
||||
int pid = 0;
|
||||
switch (args.length) {
|
||||
case (0):
|
||||
break;
|
||||
case (1):
|
||||
// If all numbers, it is a PID to attach to
|
||||
// Else, it is a pathname to a .../bin/java for a core file.
|
||||
try {
|
||||
pidText = args[0];
|
||||
pid = Integer.parseInt(pidText);
|
||||
System.out.println( "pid: " + pid);
|
||||
vm = attachPID(pid);
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("trying remote server ..");
|
||||
debugServer = args[0];
|
||||
System.out.println( "remote server: " + debugServer);
|
||||
vm = attachDebugServer(debugServer);
|
||||
}
|
||||
break;
|
||||
|
||||
case (2):
|
||||
execPath = args[0];
|
||||
coreFilename = args[1];
|
||||
System.out.println( "jdk: " + execPath);
|
||||
System.out.println( "core: " + coreFilename);
|
||||
vm = attachCore(coreFilename, execPath);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (vm != null) {
|
||||
System.out.println("sagclient: attached ok!");
|
||||
sagdoit mine = new sagdoit(vm);
|
||||
mine.doAll();
|
||||
vm.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtualMachine attachCore(String coreFilename, String execPath) {
|
||||
Map connArgs = myCoreConn.defaultArguments();
|
||||
System.out.println("connArgs = " + connArgs);
|
||||
VirtualMachine vm;
|
||||
Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("core");
|
||||
connArg.setValue(coreFilename);
|
||||
|
||||
connArg = (Connector.StringArgument)connArgs.get("javaExecutable");
|
||||
connArg.setValue(execPath);
|
||||
try {
|
||||
vm = myCoreConn.attach(connArgs);
|
||||
} catch (IOException ee) {
|
||||
System.err.println("ERROR: myCoreConn.attach got IO Exception:" + ee);
|
||||
vm = null;
|
||||
} catch (IllegalConnectorArgumentsException ee) {
|
||||
System.err.println("ERROR: myCoreConn.attach got illegal args exception:" + ee);
|
||||
vm = null;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
|
||||
private static VirtualMachine attachPID(int pid) {
|
||||
Map connArgs = myPIDConn.defaultArguments();
|
||||
System.out.println("connArgs = " + connArgs);
|
||||
VirtualMachine vm;
|
||||
Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
|
||||
connArg.setValue(Integer.toString(pid));
|
||||
|
||||
try {
|
||||
vm = myPIDConn.attach(connArgs);
|
||||
} catch (IOException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
|
||||
vm = null;
|
||||
} catch (IllegalConnectorArgumentsException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
|
||||
vm = null;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
|
||||
|
||||
private static VirtualMachine attachDebugServer(String debugServer) {
|
||||
Map connArgs = myDbgSvrConn.defaultArguments();
|
||||
System.out.println("connArgs = " + connArgs);
|
||||
VirtualMachine vm;
|
||||
Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("debugServerName");
|
||||
connArg.setValue(debugServer);
|
||||
|
||||
try {
|
||||
vm = myDbgSvrConn.attach(connArgs);
|
||||
} catch (IOException ee) {
|
||||
System.err.println("ERROR: myDbgSvrConn.attach got IO Exception:" + ee);
|
||||
vm = null;
|
||||
} catch (IllegalConnectorArgumentsException ee) {
|
||||
System.err.println("ERROR: myDbgSvrConn.attach got illegal args exception:" + ee);
|
||||
vm = null;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
}
|
@ -1,329 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
// This just contains a bunch of methods that call various JDI methods.
|
||||
// It is called from the sagtest.java jtreg test to get this info for the standard
|
||||
// JDI and from the sagclient.java test to get this info for the SA JDI.
|
||||
|
||||
class comparator implements Comparator {
|
||||
|
||||
public int compare(Object o1, Object o2) {
|
||||
ReferenceType rt1 = (ReferenceType)o1;
|
||||
ReferenceType rt2 = (ReferenceType)o2;
|
||||
return rt1.signature().compareTo(rt2.signature());
|
||||
}
|
||||
|
||||
public boolean equals(Object oo) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class sagdoit {
|
||||
|
||||
VirtualMachine myVm;
|
||||
int margin = 0;
|
||||
static String blanks = " ";
|
||||
static int nblanks = blanks.length();
|
||||
|
||||
sagdoit(VirtualMachine vm) {
|
||||
super();
|
||||
myVm = vm;
|
||||
}
|
||||
|
||||
void indent(int count) {
|
||||
margin += count;
|
||||
}
|
||||
|
||||
void pp(String msg) {
|
||||
System.out.println(blanks.substring(nblanks - margin) + msg);
|
||||
}
|
||||
|
||||
public void doAll() {
|
||||
doThreadGroups();
|
||||
//System.out.println("NOTE: dumping of class info is disabled in sagdoit.java");
|
||||
//System.out.println(" just to keep the output small while working on objects");
|
||||
doClasses(); //fixme jj: uncomment this to see all class info
|
||||
|
||||
}
|
||||
public void doThreadGroups() {
|
||||
doThreadGroupList(myVm.topLevelThreadGroups());
|
||||
}
|
||||
|
||||
private void doThreadGroupList(List groups) {
|
||||
// sort; need a comparator
|
||||
if (groups == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator myIter = groups.iterator();
|
||||
while(myIter.hasNext()) {
|
||||
ThreadGroupReference aGroup = (ThreadGroupReference)myIter.next();
|
||||
doOneThreadGroup(aGroup);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void doOneThreadGroup(ThreadGroupReference xx) {
|
||||
pp("threadGroup:" + xx.name());
|
||||
indent(4);
|
||||
pp("parent() = " + xx.parent());
|
||||
pp("threads:");
|
||||
indent(4);
|
||||
doThreadList(xx.threads());
|
||||
indent(-4);
|
||||
pp("threadGroups:");
|
||||
indent(4);
|
||||
doThreadGroupList(xx.threadGroups());
|
||||
indent(-4);
|
||||
indent(-4);
|
||||
}
|
||||
|
||||
public void doThreads() {
|
||||
doThreadList(myVm.allThreads());
|
||||
}
|
||||
|
||||
public void doThreadList(List threads) {
|
||||
if (threads == null) {
|
||||
return;
|
||||
}
|
||||
Iterator myIter = threads.iterator();
|
||||
while(myIter.hasNext()) {
|
||||
ThreadReference aThread = (ThreadReference)myIter.next();
|
||||
doOneThread(aThread);
|
||||
}
|
||||
}
|
||||
|
||||
public void doOneThread(ThreadReference xx) {
|
||||
pp("Thread: " + xx.name());
|
||||
indent(4);
|
||||
pp("suspendCount() = " + xx.suspendCount());
|
||||
|
||||
//void stop(ObjectReference throwable) throws InvalidTypeException;
|
||||
//void interrupt();
|
||||
pp("status() = " + xx.status());
|
||||
pp("isSuspended() = " + xx.isSuspended());
|
||||
pp("isAtBreakpoint() = " + xx.isAtBreakpoint());
|
||||
|
||||
pp("threadGroup() = " + xx.threadGroup());
|
||||
indent(-4);
|
||||
|
||||
indent(4);
|
||||
try {
|
||||
List allFrames = xx.frames();
|
||||
for (int ii = 0; ii < xx.frameCount(); ii++) {
|
||||
StackFrame oneFrame = xx.frame(ii);
|
||||
pp("frame(" + ii + ") = " + oneFrame);
|
||||
doOneFrame(oneFrame);
|
||||
}
|
||||
//List frames(int start, int length) throws IncompatibleThreadStateException;
|
||||
// unsupported List allMonitors = xx.ownedMonitors();
|
||||
// unsupported pp("currentContendedMonitor() = " + xx.currentContendedMonitor());
|
||||
} catch (IncompatibleThreadStateException ee) {
|
||||
pp("GOT IncompatibleThreadStateException: " + ee);
|
||||
}
|
||||
indent(-4);
|
||||
}
|
||||
|
||||
public void doOneFrame(StackFrame frame) {
|
||||
|
||||
List localVars = null;
|
||||
try {
|
||||
localVars = frame.visibleVariables();
|
||||
} catch (AbsentInformationException ee) {
|
||||
// we compile with -g so this shouldn't happen
|
||||
return;
|
||||
}
|
||||
indent(4);
|
||||
for (Iterator it = localVars.iterator(); it.hasNext();) {
|
||||
LocalVariable lv = (LocalVariable) it.next();
|
||||
pp("lv name = " + lv.name() +
|
||||
", type = " + lv.typeName() +
|
||||
", sig = " + lv.signature() +
|
||||
", gsig = " + lv.genericSignature() +
|
||||
", isVis = " + lv.isVisible(frame) +
|
||||
", isArg = " + lv.isArgument());
|
||||
}
|
||||
indent(-4);
|
||||
}
|
||||
|
||||
public void doClasses() {
|
||||
List myClasses = myVm.allClasses();
|
||||
myClasses = new ArrayList(myClasses);
|
||||
Collections.sort(myClasses, new comparator());
|
||||
for (int ii = 0; ii < myClasses.size(); ii++) {
|
||||
// Spec says each is a ReferenceType
|
||||
//System.out.println("class " + (ii + 1) + " is " + myClasses.get(ii));
|
||||
ReferenceType aClass = (ReferenceType)myClasses.get(ii);
|
||||
System.out.println("class " + (ii + 1) + " is " + aClass.signature());
|
||||
doOneClass(aClass);
|
||||
// Uncomment this to just do a few classes.
|
||||
//if ( ii > 4) break;
|
||||
}
|
||||
}
|
||||
|
||||
public void doOneClass(ReferenceType xx) {
|
||||
indent(5);
|
||||
// inherited from Mirror
|
||||
pp("toString() = " + xx.toString());
|
||||
pp("virtualMachine() = " + xx.virtualMachine());
|
||||
|
||||
// inherited from Type
|
||||
pp("name() = " + xx.name());
|
||||
pp("signature() = " + xx.signature());
|
||||
|
||||
// ReferenceType fields
|
||||
doReferenceTypeFields(xx);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
String className = xx.getClass().getName();
|
||||
pp("subclass = " + className);
|
||||
|
||||
Class referenceType = null;
|
||||
Class arrayType = null;
|
||||
Class classType = null;
|
||||
Class interfaceType = null;
|
||||
|
||||
try {
|
||||
referenceType = Class.forName("com.sun.jdi.ReferenceType");
|
||||
arrayType = Class.forName("com.sun.jdi.ArrayType");
|
||||
interfaceType = Class.forName("com.sun.jdi.InterfaceType");
|
||||
classType = Class.forName("com.sun.jdi.ClassType");
|
||||
} catch (ClassNotFoundException ee) {
|
||||
}
|
||||
|
||||
|
||||
if (referenceType.isInstance(xx)) {
|
||||
pp("ReferenceType fields");
|
||||
ReferenceType rr = (ReferenceType)xx;
|
||||
|
||||
if (arrayType.isInstance(xx)) {
|
||||
pp("ArrayType fields");
|
||||
}
|
||||
|
||||
if (classType.isInstance(xx)) {
|
||||
pp("ClassType fields");
|
||||
}
|
||||
|
||||
if (interfaceType.isInstance(xx)) {
|
||||
pp("InterfaceType fields");
|
||||
}
|
||||
}
|
||||
indent(-5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void doReferenceTypeFields(ReferenceType xx) {
|
||||
Object zz;
|
||||
pp("classLoader() = " + xx.classLoader());
|
||||
try {zz =xx.sourceName();} catch(AbsentInformationException ee) { zz = ee;} pp("sourceName() = " + zz);
|
||||
try {zz =xx.sourceNames("stratum");} catch(AbsentInformationException ee) { zz = ee;} pp("sourceNames() = " + zz);
|
||||
try {zz =xx.sourcePaths("stratum");} catch(AbsentInformationException ee) { zz = ee;} pp("sourcePaths() = " + zz);
|
||||
//try {zz =xx.sourceDebugExtension();} catch(AbsentInformationException ee) { zz = ee;} pp("sourceDebugExtension() = " + zz);
|
||||
//fixme: jj; should sourceDebugExtension throw UnsupportedOperationException?
|
||||
try {zz =xx.sourceDebugExtension();} catch(Exception ee) { zz = ee;} pp("sourceDebugExtension() = " + zz);
|
||||
// If xx is an array, this can cause a ClassNotLoadedException on the
|
||||
// component type. Is that a JDI bug?
|
||||
pp("isStatic() = " + xx.isStatic());
|
||||
pp("isAbstract() = " + xx.isAbstract());
|
||||
pp("isFinal() = " + xx.isFinal());
|
||||
pp("isPrepared() = " + xx.isPrepared());
|
||||
pp("isVerified() = " + xx.isVerified());
|
||||
pp("isInitialized() = " + xx.isInitialized());
|
||||
pp("failedToInitialize() = " + xx.failedToInitialize());
|
||||
pp("fields() = " + xx.fields());
|
||||
pp("visibleFields() = " + xx.visibleFields());
|
||||
pp("allFields() = " + xx.allFields());
|
||||
pp("fieldByName(String fieldName) = " + xx.fieldByName("fieldName"));
|
||||
pp("methods() = " + xx.methods());
|
||||
|
||||
|
||||
List meths = xx.methods();
|
||||
Iterator iter = meths.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Method mm = (Method)iter.next();
|
||||
pp(" name/sig:" + mm.name() + "/" + mm.signature());
|
||||
}
|
||||
|
||||
pp(" visibleMethods() = " + xx.visibleMethods());
|
||||
|
||||
//if (1 == 1) return;
|
||||
|
||||
pp("allMethods() = " + xx.allMethods());
|
||||
|
||||
|
||||
pp("methodsByName(String name) = " + xx.methodsByName("name"));
|
||||
pp("methodsByName(String name, String signature) = " + xx.methodsByName("name", "signature"));
|
||||
pp("nestedTypes() = " + xx.nestedTypes());
|
||||
//pp("getValue(Field field) = " + xx.getValue("field"));
|
||||
pp("getValue(Field field) = " + "fixme: jjh");
|
||||
//pp("getValues(List fields) = " + xx.getValues(new List[] = {"fields"}));
|
||||
pp("getValues(List fields) = " + "fixme: jjh");
|
||||
pp("classObject() = " + xx.classObject());
|
||||
//x pp("allLineLocations() = " + xx.allLineLocations());
|
||||
//x pp("allLineLocations(String stratum, String sourceName) = " + xx.allLineLocations("stratum", "sourceName"));
|
||||
//x pp("locationsOfLine(int lineNumber) = " + xx.locationsOfLine(89));
|
||||
//x pp("locationsOfLine(String stratum, String sourceName, int lineNumber) = " + xx.locationsOfLine("stratum", "sourceName", 89));
|
||||
pp("availableStrata() = " + xx.availableStrata());
|
||||
pp("defaultStratum() = " + xx.defaultStratum());
|
||||
pp("equals(Object obj) = " + xx.equals(xx));
|
||||
pp("hashCode() = " + xx.hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// try {
|
||||
// ReferenceType rr = (ReferenceType)xx;
|
||||
// pp("ReferenceType fields");
|
||||
|
||||
// try {
|
||||
// ArrayType ff = (ArrayType)xx;
|
||||
// pp("ArrayType fields");
|
||||
|
||||
// } catch(ClassCastException ee) {
|
||||
// }
|
||||
|
||||
// try {
|
||||
// ClassType ff = (ClassType)xx;
|
||||
// pp("ClassType fields");
|
||||
|
||||
// } catch(ClassCastException ee) {
|
||||
// }
|
||||
|
||||
// try {
|
||||
// InterfaceType ff = (InterfaceType)xx;
|
||||
// pp("InterfaceType fields");
|
||||
|
||||
// } catch(ClassCastException ee) {
|
||||
// }
|
||||
|
||||
// } catch(ClassCastException ee) {
|
||||
// }
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
// This is the target debuggee for sagtest.java.
|
||||
// It just waits which lets the test call all the JDI
|
||||
// methods on it.
|
||||
|
||||
import java.util.List;
|
||||
|
||||
interface MyInterface {
|
||||
public void myMethod();
|
||||
}
|
||||
|
||||
|
||||
abstract class MySuper implements MyInterface {
|
||||
}
|
||||
|
||||
class sagtarg extends MySuper {
|
||||
public static void main(String[] args){
|
||||
String stringVar = "localVar1";
|
||||
int intVar = 89;
|
||||
List<String> genVar = null;
|
||||
System.out.println("Howdy!");
|
||||
String myStr = "";
|
||||
synchronized(myStr) {
|
||||
try {
|
||||
myStr.wait();
|
||||
} catch (InterruptedException ee) {
|
||||
}
|
||||
}
|
||||
System.out.println("Goodbye from sagtarg!");
|
||||
}
|
||||
|
||||
public void myMethod() {
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test * @bug 0000000
|
||||
* @summary This is just an exercise of various JDI elements for use in
|
||||
* testing the SA/JDI client
|
||||
*
|
||||
* @author jjh
|
||||
*
|
||||
* @run build TestScaffold VMConnection TargetListener TargetAdapter sagdoit
|
||||
* @run compile -g -source 1.5 sagtarg.java
|
||||
* @run main sagtest
|
||||
*/
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.event.*;
|
||||
import com.sun.jdi.request.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/********** target program **********/
|
||||
|
||||
// The target program is sagtarg.java
|
||||
|
||||
/********** test program **********/
|
||||
|
||||
public class sagtest extends TestScaffold {
|
||||
ReferenceType targetClass;
|
||||
ThreadReference mainThread;
|
||||
|
||||
sagtest (String args[]) {
|
||||
super(args);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new sagtest(args).startTests();
|
||||
}
|
||||
|
||||
/********** event handlers **********/
|
||||
|
||||
|
||||
/********** test core **********/
|
||||
|
||||
protected void runTests() throws Exception {
|
||||
/*
|
||||
* Get to the top of main()
|
||||
* to determine targetClass and mainThread
|
||||
*/
|
||||
BreakpointEvent bpe = startToMain("sagtarg");
|
||||
targetClass = bpe.location().declaringType();
|
||||
mainThread = bpe.thread();
|
||||
EventRequestManager erm = vm().eventRequestManager();
|
||||
stepOverLine(mainThread); //stop on 18
|
||||
stepOverLine(mainThread); //stop on 19
|
||||
stepOverLine(mainThread); //stop on 20
|
||||
stepOverLine(mainThread); //stop on 21
|
||||
stepOverLine(mainThread); //stop on 22
|
||||
|
||||
sagdoit mine = new sagdoit(vm());
|
||||
mine.doAll();
|
||||
|
||||
if (!testFailed) {
|
||||
println("sagtest: passed");
|
||||
} else {
|
||||
throw new Exception("sagtest: failed");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
# This script is used to run sanity check on vmStructs.
|
||||
# Each SA class is checked against a given VM. "PASSED" is
|
||||
# printed if vmStructs are consistent. Else, "FAILED" is
|
||||
# printed and an exception stack trace follows.
|
||||
|
||||
usage() {
|
||||
echo "usage: ./sasanity.sh <jdk>"
|
||||
echo "<jdk> is the 1.5 j2se directory against which you want to run sanity check"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$1" == "" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "$1" == "-help" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
jdk=$1
|
||||
shift
|
||||
OS=`uname`
|
||||
|
||||
javacp=$jdk/lib/sa-jdi.jar:./workdir
|
||||
|
||||
mkdir -p workdir
|
||||
if [ SASanityChecker.java -nt ./workdir/SASanityChecker.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp SASanityChecker.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ sagtarg.java -nt ./workdir/sagtarg.class ]; then
|
||||
$jdk/bin/javac -g -classpath -d $workdir sagtarg.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
tmp=/tmp/sagsetup
|
||||
rm -f $tmp
|
||||
$jdk/bin/java $* sagtarg > $tmp &
|
||||
pid=$!
|
||||
while [ ! -s $tmp ] ; do
|
||||
# Kludge alert!
|
||||
sleep 2
|
||||
done
|
||||
|
||||
$jdk/bin/java -showversion ${OPTIONS} -classpath $javacp $* SASanityChecker $pid
|
||||
kill -9 $pid
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
import com.sun.jdi.*;
|
||||
import com.sun.jdi.connect.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.Iterator;
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/* This class is used to test multi VM connectivity feature of
|
||||
* SA/JDI. Accepts two PIDs as arguments. Connects to first VM
|
||||
*, disposes it, connects to second VM, disposes second VM.
|
||||
*/
|
||||
|
||||
|
||||
public class serialvm {
|
||||
static AttachingConnector myPIDConn;
|
||||
static VirtualMachine vm1;
|
||||
static VirtualMachine vm2;
|
||||
static VirtualMachineManager vmmgr;
|
||||
|
||||
public static void println(String msg) {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
private static void usage() {
|
||||
System.err.println("Usage: java serialvm <pid1> <pid2>");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
vmmgr = Bootstrap.virtualMachineManager();
|
||||
List attachingConnectors = vmmgr.attachingConnectors();
|
||||
if (attachingConnectors.isEmpty()) {
|
||||
System.err.println( "ERROR: No attaching connectors");
|
||||
return;
|
||||
}
|
||||
Iterator myIt = attachingConnectors.iterator();
|
||||
while (myIt.hasNext()) {
|
||||
AttachingConnector tmpCon = (AttachingConnector)myIt.next();
|
||||
if (tmpCon.name().equals(
|
||||
"sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
|
||||
myPIDConn = tmpCon;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int pid1 = 0, pid2 = 0;
|
||||
String pidText = null;
|
||||
switch (args.length) {
|
||||
case (2):
|
||||
try {
|
||||
pidText = args[0];
|
||||
pid1 = Integer.parseInt(pidText);
|
||||
System.out.println( "pid1: " + pid1);
|
||||
pidText = args[1];
|
||||
pid2 = Integer.parseInt(pidText);
|
||||
System.out.println( "pid2: " + pid2);
|
||||
} catch (NumberFormatException e) {
|
||||
println(e.getMessage());
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
|
||||
// attach, dispose, attach2, dispose2 pattern
|
||||
// as opposed to attach1, attach2, dispose1, dispose2
|
||||
vm1 = attachPID(pid1);
|
||||
if (vm1 != null) {
|
||||
System.out.println("vm1: attached ok!");
|
||||
System.out.println(vm1.version());
|
||||
sagdoit mine = new sagdoit(vm1);
|
||||
mine.doAll();
|
||||
}
|
||||
if (vm1 != null) {
|
||||
vm1.dispose();
|
||||
}
|
||||
|
||||
vm2 = attachPID(pid2);
|
||||
if (vm2 != null) {
|
||||
System.out.println("vm2: attached ok!");
|
||||
System.out.println(vm2.version());
|
||||
sagdoit mine = new sagdoit(vm2);
|
||||
mine.doAll();
|
||||
}
|
||||
|
||||
|
||||
if (vm2 != null) {
|
||||
vm2.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static VirtualMachine attachPID(int pid) {
|
||||
Map connArgs = myPIDConn.defaultArguments();
|
||||
System.out.println("connArgs = " + connArgs);
|
||||
VirtualMachine vm;
|
||||
Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
|
||||
connArg.setValue(Integer.toString(pid));
|
||||
|
||||
try {
|
||||
vm = myPIDConn.attach(connArgs);
|
||||
} catch (IOException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
|
||||
vm = null;
|
||||
} catch (IllegalConnectorArgumentsException ee) {
|
||||
System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
|
||||
vm = null;
|
||||
}
|
||||
return vm;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
#!/bin/ksh
|
||||
#
|
||||
# Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
#
|
||||
|
||||
doUsage()
|
||||
{
|
||||
cat <<EOF
|
||||
Run serialvm.class using Serviceability Agent to talk to 2 pids one
|
||||
after another in serial fashion.
|
||||
Usage: serialvm.sh <jdk-pathname> <pid1> <pid2>
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ $# = 4 ] ; then
|
||||
doUsage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
jdk=$1
|
||||
javacp="$jdk/lib/sa-jdi.jar:$classesDir:$jdk/lib/tools.jar:$jdk/classes:./workdir"
|
||||
|
||||
mkdir -p workdir
|
||||
if [ sagdoit.java -nt ./workdir/sagdoit.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp sagdoit.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [ serialvm.java -nt ./workdir/serialvm.class ] ; then
|
||||
$jdk/bin/javac -d ./workdir -classpath $javacp serialvm.java
|
||||
if [ $? != 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
$jdk/bin/java -Dsun.jvm.hotspot.jdi.ConnectorImpl.DEBUG -Dsun.jvm.hotspot.jdi.SAJDIClassLoader.DEBUG -Djava.class.path=$javacp serialvm $2 $3
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.ProcessTools;
|
||||
import jdk.test.lib.OutputAnalyzer;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.apps.LingeredApp;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Started failing on 2016.06.24 due to 8160376 on MacOS X so
|
||||
* quarantine it on that platform:
|
||||
* @requires os.family != "mac"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib/share/classes
|
||||
* @library /testlibrary
|
||||
* @build jdk.test.lib.*
|
||||
* @build jdk.test.lib.apps.*
|
||||
* @run main TestClassLoaderStats
|
||||
*/
|
||||
public class TestClassLoaderStats {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!Platform.shouldSAAttach()) {
|
||||
System.out.println("SA attach not expected to work - test skipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
LingeredApp app = null;
|
||||
try {
|
||||
List<String> vmArgs = new ArrayList<String>();
|
||||
vmArgs.add("-XX:+UsePerfData");
|
||||
vmArgs.addAll(Utils.getVmOptions());
|
||||
app = LingeredApp.startApp(vmArgs);
|
||||
|
||||
System.out.println("Attaching sun.jvm.hotspot.tools.ClassLoaderStats to " + app.getPid());
|
||||
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+UsePerfData",
|
||||
"sun.jvm.hotspot.tools.ClassLoaderStats",
|
||||
Long.toString(app.getPid()));
|
||||
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
|
||||
System.out.println(output.getOutput());
|
||||
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain("Debugger attached successfully.");
|
||||
// The class loader stats header needs to be presented in the output:
|
||||
output.shouldMatch("class_loader\\W+classes\\W+bytes\\W+parent_loader\\W+alive?\\W+type");
|
||||
output.stderrShouldNotMatch("[E|e]xception");
|
||||
output.stderrShouldNotMatch("[E|e]rror");
|
||||
} finally {
|
||||
LingeredApp.stopApp(app);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import jdk.test.lib.OutputAnalyzer;
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.ProcessTools;
|
||||
import jdk.test.lib.Utils;
|
||||
import jdk.test.lib.apps.LingeredApp;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Started failing on 2016.06.24 due to 8160376 on MacOS X so
|
||||
* quarantine it on that platform:
|
||||
* @requires os.family != "mac"
|
||||
* @modules java.base/jdk.internal.misc
|
||||
* @library /test/lib/share/classes
|
||||
* @library /testlibrary
|
||||
* @build jdk.test.lib.*
|
||||
* @build jdk.test.lib.apps.*
|
||||
* @run main TestStackTrace
|
||||
*/
|
||||
public class TestStackTrace {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (!Platform.shouldSAAttach()) {
|
||||
System.out.println("SA attach not expected to work - test skipped.");
|
||||
return;
|
||||
}
|
||||
|
||||
LingeredApp app = null;
|
||||
try {
|
||||
List<String> vmArgs = new ArrayList<String>();
|
||||
vmArgs.add("-XX:+UsePerfData");
|
||||
vmArgs.addAll(Utils.getVmOptions());
|
||||
app = LingeredApp.startApp(vmArgs);
|
||||
|
||||
System.out.println("Attaching sun.jvm.hotspot.tools.StackTrace to " + app.getPid());
|
||||
ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(
|
||||
"-XX:+UsePerfData",
|
||||
"sun.jvm.hotspot.tools.StackTrace",
|
||||
Long.toString(app.getPid()));
|
||||
OutputAnalyzer output = ProcessTools.executeProcess(processBuilder);
|
||||
System.out.println(output.getOutput());
|
||||
|
||||
output.shouldHaveExitValue(0);
|
||||
output.shouldContain("Debugger attached successfully.");
|
||||
output.stderrShouldNotMatch("[E|e]xception");
|
||||
output.stderrShouldNotMatch("[E|e]rror");
|
||||
} finally {
|
||||
LingeredApp.stopApp(app);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user