You are viewing a plain text version of this content. The canonical link for it is here.
Posted to kato-commits@incubator.apache.org by mo...@apache.org on 2009/11/23 15:54:15 UTC
svn commit: r883384 [20/47] - in /incubator/kato/trunk/org.apache.kato: ./
kato.anttasks/src/main/java/org/apache/kato/anttasks/
kato.anttasks/src/main/java/org/apache/kato/anttasks/sitebuilder/
kato.anttasks/src/main/java/org/apache/kato/anttasks/tck/...
Modified: incubator/kato/trunk/org.apache.kato/kato.jdi/src/main/java/org/apache/kato/tools/jdi/KatoReader.java
URL: http://svn.apache.org/viewvc/incubator/kato/trunk/org.apache.kato/kato.jdi/src/main/java/org/apache/kato/tools/jdi/KatoReader.java?rev=883384&r1=883383&r2=883384&view=diff
==============================================================================
--- incubator/kato/trunk/org.apache.kato/kato.jdi/src/main/java/org/apache/kato/tools/jdi/KatoReader.java (original)
+++ incubator/kato/trunk/org.apache.kato/kato.jdi/src/main/java/org/apache/kato/tools/jdi/KatoReader.java Mon Nov 23 15:53:48 2009
@@ -1,3658 +1,3658 @@
-/*******************************************************************************
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- ******************************************************************************/
-package org.apache.kato.tools.jdi;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.reflect.Modifier;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-import java.util.logging.Level;
-
-import javax.tools.diagnostics.FactoryRegistry;
-import javax.tools.diagnostics.image.CorruptData;
-import javax.tools.diagnostics.image.CorruptDataException;
-import javax.tools.diagnostics.image.DataUnavailable;
-import javax.tools.diagnostics.image.DiagnosticException;
-import javax.tools.diagnostics.image.Image;
-import javax.tools.diagnostics.image.ImageAddressSpace;
-import javax.tools.diagnostics.image.ImageProcess;
-import javax.tools.diagnostics.image.MemoryAccessException;
-import javax.tools.diagnostics.runtime.java.JavaClass;
-import javax.tools.diagnostics.runtime.java.JavaClassLoader;
-import javax.tools.diagnostics.runtime.java.JavaField;
-import javax.tools.diagnostics.runtime.java.JavaHeap;
-import javax.tools.diagnostics.runtime.java.JavaLocation;
-import javax.tools.diagnostics.runtime.java.JavaMethod;
-import javax.tools.diagnostics.runtime.java.JavaMonitor;
-import javax.tools.diagnostics.runtime.java.JavaObject;
-import javax.tools.diagnostics.runtime.java.JavaRuntime;
-import javax.tools.diagnostics.runtime.java.JavaStackFrame;
-import javax.tools.diagnostics.runtime.java.JavaThread;
-import javax.tools.diagnostics.runtime.java.JavaVariable;
-
-
-/**
- * KatoReader
- *
- * KatoReader is our second conversion layer (after JDWPServer). KatoReader has two functions:
- * <ol>
- * <li> Convert JDWP <--> Kato</li>
- * <li> Provide several convenience methods </li>
- * </ol>
- *
- * <ol>
- * <li>
- * <p>
- * KatoReader directly takes the raw protocol (in it's object version) and runs some calls to
- * get the JDWP reply. Only a small portion of the JDWP protocol is specified in a way that
- * we can reliably create objects, so a lot of time the KatoReader methods will extract their
- * own information from a raw byte 'data' segment of the original packet. On the reply, we
- * copy some of the information from the CommandPacket (such as sequence and origin socket)
- * and then create a data segment.
- * </p>
- * <br/>
- * <p>
- * Most of the time the data segment is constructed using a Byte vector (that's Big Byte).
- * We do this so that we can easily add and remove to the vector, and add to the front if
- * we need to. The JDWPServer converts the standard Packet stuff back to bytes and appends
- * our data segment on the outgoing packet.
- * </p>
- * </li>
- * <li>
- * We provide bytes <--> int, bytes <--> long, vector --> byte[], and a few other assorted
- * methods for doing standard stuff.
- * </li>
- * </ol>
- *
- */
-public class KatoReader implements CacherProvider{
- private HashMap<Long, JavaClass> classes;
- // Image is actually an 'image' of the core at crash time.
- // Since it's the basis of every query, I'm saving it over queries
- private Image image = null;
- private HashMap<Long,String> vctrs;
- private String pathToCore;
- private int errorCode;
- private JDWPServer svr;
-
- public static final int FLAG_REPLY_PACKET = 0x80;
-
- private int LAST_ID = 1;
- private HashMap<Integer, JavaMethod> intToMethod;
- private HashMap<JavaMethod, Integer> methodToInt;
- private Vector<JavaField> fieldList;
- private JDILogger logr;
- public static final int ERROR_NONE = 0;
- public static final int ERROR_INVALID_OBJECT = 20;
- public static final int ERROR_INVALID_CLASS = 21;
- public static final int ERROR_INVALID_THREAD = 10;
- public static final int ERROR_INVALID_SLOT = 35;
- public static final int ERROR_NOT_IMPLEMENTED = 99;
- public static final int ERROR_ABSENT_INFORMATION = 101;
- public static final int ERROR_INTERNAL = 113;
- public static final int ERROR_INVALID_ARRAY = 508;
-
- public static final int INVALID_EVENT_TYPE = 102;
-
- private HashMap<Long, JavaObject> objectMap;
- private HashMap<Long, JavaMonitor> monitorMap;
-
- public static final int COMMANDSET_VIRTUAL_MACHINE = 1;
- public static final int COMMANDSET_REFERENCE_TYPE = 2;
- public static final int COMMANDSET_CLASS_TYPE = 3;
- public static final int COMMANDSET_ARRAY_TYPE = 4;
- public static final int COMMANDSET_INTERFACE_TYPE = 5;
- public static final int COMMANDSET_METHOD = 6;
-
- public static final int COMMANDSET_FIELD = 8;
- public static final int COMMANDSET_OBJECT_REFERENCE = 9;
- public static final int COMMANDSET_STRING_REFERENCE = 10;
- public static final int COMMANDSET_THREAD_REFERENCE = 11;
- public static final int COMMANDSET_THREAD_GROUP_REFERENCE = 12;
- public static final int COMMANDSET_ARRAY_REFERENCE = 13;
- public static final int COMMANDSET_CLASS_LOADER_REFERENCE = 14;
- public static final int COMMANDSET_EVENT_REQUEST = 15;
- public static final int COMMANDSET_STACK_FRAME = 16;
- public static final int COMMANDSET_CLASS_OBJECT_REFERENCE = 17;
- public static final int COMMANDSET_EVENT = 64;
-
- public static final int VIRTUAL_MACHINE_VERSION = 1;
- public static final int VIRTUAL_MACHINE_CLASSES_BY_SIGNATURE = 2;
- public static final int VIRTUAL_MACHINE_ALL_CLASSES = 3;
- public static final int VIRTUAL_MACHINE_ALL_THREADS = 4;
- public static final int VIRTUAL_MACHINE_TOP_LEVEL_THREAD_GROUPS = 5;
- public static final int VIRTUAL_MACHINE_DISPOSE = 6;
- public static final int VIRTUAL_MACHINE_IDSIZES = 7;
- public static final int VIRTUAL_MACHINE_SUSPEND = 8;
- public static final int VIRTUAL_MACHINE_RESUME = 9;
- public static final int VIRTUAL_MACHINE_EXIT = 10;
- public static final int VIRTUAL_MACHINE_CREATE_STRING = 11;
- public static final int VIRTUAL_MACHINE_CAPABILITIES = 12;
- public static final int VIRTUAL_MACHINE_CLASS_PATHS = 13;
- public static final int VIRTUAL_MACHINE_DISPOSE_OBJECTS = 14;
- public static final int VIRTUAL_MACHINE_HOLD_EVENTS = 15;
- public static final int VIRTUAL_MACHINE_RELEASE_EVENTS = 16;
- public static final int VIRTUAL_MACHINE_CAPABILITIES_NEW = 17;
- public static final int VIRTUAL_MACHINE_REDEFINE_CLASSES = 18;
- public static final int VIRTUAL_MACHINE_SET_DEFAULT_STRATUM = 19;
-
- public static final int REFERENCE_TYPE_SIGNATURE = 1;
- public static final int REFERENCE_TYPE_CLASS_LOADER = 2;
- public static final int REFERENCE_TYPE_MODIFIERS = 3;
- public static final int REFERENCE_TYPE_FIELDS = 4;
- public static final int REFERENCE_TYPE_METHODS = 5;
- public static final int REFERENCE_TYPE_GET_VALUES = 6;
- public static final int REFERENCE_TYPE_SOURCE_FILE = 7;
- public static final int REFERENCE_TYPE_NESTED_TYPES = 8;
- public static final int REFERENCE_TYPE_STATUS = 9;
- public static final int REFERENCE_TYPE_INTERFACES = 10;
- public static final int REFERENCE_TYPE_CLASS_OBJECT = 11;
- public static final int REFERENCE_TYPE_SOURCE_DEBUG_EXTENSION = 12;
-
- public static final int TAG_ARRAY = 91;
- public static final int TAG_BYTE = 66;
- public static final int TAG_CHAR = 67;
- public static final int TAG_OBJECT = 76;
- public static final int TAG_FLOAT = 70;
- public static final int TAG_DOUBLE = 68;
- public static final int TAG_INT = 73;
- public static final int TAG_LONG = 74;
- public static final int TAG_SHORT = 83;
- public static final int TAG_VOID = 86;
- public static final int TAG_BOOLEAN = 90;
- public static final int TAG_STRING = 115;
- public static final int TAG_THREAD = 116;
- public static final int TAG_THREAD_GROUP = 103;
- public static final int TAG_CLASS_LOADER = 108;
- public static final int TAG_CLASS_OBJECT = 99;
-
-
-
-
-
- public KatoReader(){
-
- }
-
- /**
- * Constructor to init Kato reader
- *
- * @param ipathToCore Path to core (absolute or relative)
- * @param isvr JDWPServer used for communication back up
- * @param logger JDILogger to use to log against
- * @throws Exception An error passed up from the Kato api, or sanity test fail
- */
- public KatoReader(String ipathToCore, JDWPServer isvr, JDILogger logger) throws Exception{
- logr = logger;
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "KatoReader 1.0"); //$NON-NLS-1$
- pathToCore = ipathToCore;
- svr = isvr;
- vctrs = new HashMap<Long, String>();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Starting to read core file"); //$NON-NLS-1$
- startRead();
-
- }
-
- /**
- * Given a Kato JavaField and JavaObject, add the tagged value to the vector vctr
- *
- * @param vctr Current byte vector for the data segment of the packet
- * @param jObject Object to which get the value from
- * @param jField The field of a class to get the value from
- * @return false if the operation failed, true if it succeeds
- * @throws Exception Exception passed up if underlying Kato calls fail
- */
-
- private boolean getValueFromField(Vector<Byte> vctr, JavaObject jObject, JavaField jField) throws Exception{
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + jField.getName() + "("+jField.getSignature()+")"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- byte signature = (byte)jField.getSignature().charAt(0);
- if (jField.getSignature().equals("Ljava/lang/String;")){ //$NON-NLS-1$
- signature = (byte)'s';
- }
- vctr.add(signature);
- switch (signature){
- case '[':
- try{
- if(jField.get(jObject) instanceof JavaObject){
- JavaObject jOut = (JavaObject)jField.get(jObject);
- if (!objectMap.containsKey(jOut.getID().getAddress())){
- objectMap.put(jOut.getID().getAddress(), jOut);
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " ARRAY: " + jOut.getID().getAddress()); //$NON-NLS-1$
- addLongToVector(vctr, jOut.getID().getAddress());
-
- }else if (jField.get(jObject) instanceof JavaClass){
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " ARRAY: Actually a class?!"); //$NON-NLS-1$
- addLongToVector(vctr, 0);
- }else{
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " ARRAY: Not JavaObject"); //$NON-NLS-1$
- if (jField.get(jObject) == null){
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " ARRAY: is null"); //$NON-NLS-1$
- }
- addLongToVector(vctr, 0);
- }
- }
- catch(NullPointerException exxy){
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " ARRAY: Attemped access to field is null"); //$NON-NLS-1$
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- addLongToVector(vctr, 0);
- }
- break;
- case 's':
- {
- try{
- //Add the string to the lookup table
- JavaObject jOut = (JavaObject)jField.get(jObject);
- vctrs.put(jOut.getID().getAddress(), jField.getString(jObject));
- }
- catch(NullPointerException exxy){}
- catch(CorruptDataException exxy){
- //Take back what I said
- int size = vctr.size();
- vctr.remove(size-1);
- vctr.add((byte)'L');
- }
- }
-
- case 'L':
- case 't':
- case 'g':
- case 'l':
- case 'c':
- {
- try{
- if(jField.get(jObject) instanceof JavaObject){
- JavaObject jOut = (JavaObject)jField.get(jObject);
- addLongToVector(vctr, jOut.getID().getAddress());
- if (!objectMap.containsKey(jOut.getID().getAddress())){
- objectMap.put(jOut.getID().getAddress(), jOut);
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + jOut.getID().getAddress()); //$NON-NLS-1$
- }else{
- addLongToVector(vctr, 0);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Not JavaObject " + jField.get(jObject).getClass().getName()); //$NON-NLS-1$
- }
-
-
- }
- catch(NullPointerException exxy){
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Attemped access to field is null"); //$NON-NLS-1$
- addLongToVector(vctr, 0);
- }
- }
- break;
- case 'F':
- {
- int bits = Float.floatToRawIntBits(jField.getFloat(jObject));
- addIntToVector(vctr, bits);
- }
- break;
- case 'D':
- {
- long bits = Double.doubleToRawLongBits(jField.getDouble(jObject));
- addLongToVector(vctr, bits);
- }
- break;
- case 'S':
- vctr.add((byte)((jField.getShort(jObject) >> 8) & 0xFF));
- vctr.add((byte)(jField.getShort(jObject) & 0xFF));
- break;
- case 'B':
- vctr.add(jField.getByte(jObject));
- break;
- case 'C':
- vctr.add((byte)((jField.getChar(jObject) >> 8) & 0xFF));
- vctr.add((byte)(jField.getChar(jObject) & 0xFF));
- break;
- case 'Z':
- try{
- if (jField.getBoolean(jObject)){
- vctr.add((byte)1);
- }else{
- vctr.add((byte)0);
- }
- }catch(IllegalArgumentException exxy){
- vctr.add((byte)0);
- }
- break;
- case 'I':
- addIntToVector(vctr, jField.getInt(jObject));
- break;
- case 'J':
- addLongToVector(vctr, jField.getLong(jObject));
- break;
- default:
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Unhandled type!"); //$NON-NLS-1$
- return false;
- }
- return true;
-
- }
-
- public Packet query(Packet pckt) throws Exception{
- if(image == null){
- try{
- startRead();
-
- }catch (Exception exxy){
- throw exxy;
- }
- }
- CommandPacket cpckt = (CommandPacket)pckt;
- try{
- switch(cpckt.getCommandSet()){
- case COMMANDSET_VIRTUAL_MACHINE:
- return virtualMachine(cpckt);
- case COMMANDSET_REFERENCE_TYPE:
- return referenceType(cpckt);
- case COMMANDSET_CLASS_TYPE:
- return classType(cpckt);
- case COMMANDSET_METHOD:
- return method(cpckt);
- case COMMANDSET_OBJECT_REFERENCE:
- return objectReference(cpckt);
- case COMMANDSET_STRING_REFERENCE:
- return stringReference(cpckt);
- case COMMANDSET_THREAD_REFERENCE:
- return threadReference(cpckt);
- case COMMANDSET_ARRAY_REFERENCE:
- return arrayReference(cpckt);
- case COMMANDSET_EVENT_REQUEST:
- return eventRequest(cpckt);
- case COMMANDSET_STACK_FRAME:
- return stackFrame(cpckt);
- case COMMANDSET_CLASS_LOADER_REFERENCE:
- return classLoaderRef(cpckt);
- // Added for jdb
- case COMMANDSET_THREAD_GROUP_REFERENCE:
- return threadGroupReference(cpckt);
- default:
- logr.logError(JDILogger.LEVEL_VERBOSE, "Unknown command set: "+cpckt.getCommandSet()); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NOT_IMPLEMENTED);
- return rpckt;
- }
- }
- catch(CorruptDataException exxy){
- logr.logError(JDILogger.LEVEL_VERBOSE, "Corrupt data."); //$NON-NLS-1$
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INTERNAL);
- rpckt.setData("CorruptDataException"); //$NON-NLS-1$
- return rpckt;
- }
- catch(Exception exxy){
- logr.logError(JDILogger.LEVEL_VERBOSE, "Exception occured: " + exxy.getMessage()); //$NON-NLS-1$
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INTERNAL);
- rpckt.setData("Exception"); //$NON-NLS-1$
- return rpckt;
- }
- }
-
- /**
- * Load in the core file stored in pathToCore, into image.
- * @throws Exception Upstream error
- */
-
- public void startRead() throws Exception{
- logr.log(JDILogger.LEVEL_VERBOSE, "Starting to read " + pathToCore); //$NON-NLS-1$
-
- File f = new File(pathToCore);
- try {
- FactoryRegistry registry=null;
- registry=FactoryRegistry.getDefaultRegistry();
-
- image = registry.getImage(f);
- } catch (IOException e) {
- logr.logError(JDILogger.LEVEL_QUIET, "Could not find/use required file(s)"); //$NON-NLS-1$
- e.printStackTrace(new PrintStream(logr.getErrorStream()));
- errorCode = 4;
- throw e;
- }
-
- if (image == null) {
- return;
- }
-
- logr.log(JDILogger.LEVEL_VERBOSE, "Extra Information"); //$NON-NLS-1$
-
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " Creation Time:" + image.getCreationTime()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " Host Name: " + image.getHostName()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " Installed Memory: " + image.getInstalledMemory() + " bytes"); //$NON-NLS-1$ //$NON-NLS-2$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " Processor Count: " + image.getProcessorCount()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " Processor Type: " + image.getProcessorType()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, "Processor Subtype: " + image.getProcessorSubType()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " System Type: " + image.getSystemType()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- logr.log(JDILogger.LEVEL_VERBOSE, " System Subtype: " + image.getSystemSubType()); //$NON-NLS-1$
- }catch(Exception exxy){}
- try{
- Iterator itr = image.getIPAddresses();
- while (itr.hasNext()){
- InetAddress addr = (InetAddress)itr.next();
- logr.log(JDILogger.LEVEL_VERBOSE, "IP: " + addr.toString()); //$NON-NLS-1$
-
- }
- }catch(Exception exxy){}
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building class list"); //$NON-NLS-1$
- this.classes = buildClasses();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Generating object list"); //$NON-NLS-1$
- this.objectMap = generateObjectHashmap();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building field list"); //$NON-NLS-1$
- this.fieldList = buildFields();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building method list"); //$NON-NLS-1$
- this.monitorMap = buildMonitors();
- buildMethods();
- }
-
- /**
- * Get the method object given a methodID
- * @param methodID Address of the method as stored in the vector
- * @return The Kato JavaMethod
- */
- private JavaMethod getMethod(long methodID){
- if (intToMethod == null){
- buildMethods();
- }
- return intToMethod.get(methodID);
-
- }
-
- /**
- * Get the field object given a fieldID
- * @param fieldID Address of a given field as stored in the vector
- * @return The Kato JavaField
- */
- private JavaField getField(long fieldID){
- if (fieldList == null){
- fieldList = buildFields();
- }
- return fieldList.elementAt((int)fieldID);
-
- }
-
- private HashMap<Long, JavaMonitor> buildMonitors(){
- HashMap<Long, JavaMonitor> monitors = new HashMap<Long, JavaMonitor>();
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
- while ( prIt.hasNext( ) ){
- ImageProcess process = (ImageProcess) prIt.next( );
-
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- List<JavaMonitor> jms = javaRT.getMonitors();
- for (JavaMonitor jm: jms){
- monitors.put(jm.getObject().getID().getAddress(), jm);
- }
- }
- }
- }
- return monitors;
- }
-
- /**
- * Build the field vector by going through all the classes
- * @return A vector containing a list of JDIJavaFields
- */
- private Vector<JavaField> buildFields(){
- Vector<JavaField> fieldList = new Vector<JavaField>();
- Iterator<JavaClass> jClasses = classes.values().iterator();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building field list..."); //$NON-NLS-1$
- while(jClasses.hasNext()){
- JavaClass jClass = jClasses.next();
- Iterator jFields = jClass.getDeclaredFields().iterator();
- while(jFields.hasNext()){
- JavaField jField = (JavaField)jFields.next();
- try{
- fieldList.add(jField);
-
- }catch(Exception exxy){
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- this.svr.stop();
-
- }
-
-
- }
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Built list of " + fieldList.size() + " fields"); //$NON-NLS-1$ //$NON-NLS-2$
- return fieldList;
-
- }
-
- /**
- * Generate a list of fowards and backwards int to JavaMethod list.
- */
- private void buildMethods(){
- intToMethod = new HashMap<Integer, JavaMethod>();
- methodToInt = new HashMap<JavaMethod, Integer>();
- Iterator<JavaClass> jClasses = classes.values().iterator();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building method list..."); //$NON-NLS-1$
- while(jClasses.hasNext()){
- JavaClass jClass = jClasses.next();
- Iterator jMethods = jClass.getDeclaredMethods().iterator();
- while(jMethods.hasNext()){
- JavaMethod jMethod = (JavaMethod)jMethods.next();
- try{
- int index = intToMethod.size();
- intToMethod.put(index, jMethod);
- methodToInt.put(jMethod, index);
- //logr.log(JDILogger.LEVEL_VERBOSE, jClass.getName()+"."+jMethod.getName()+"#"+methodList.indexOf(jMethod));
- }catch(Exception exxy){
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- System.exit(1);
- }
-
-
- }
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Built list of " + intToMethod.size() + " methods"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /**
- * Given a JavaMethod and class id, return the id of the method
- * @param refType The class id as found in the JavaClass vector
- * @param jMethod The Kato JavaMethod object
- * @return A unique ID for this method
- */
-
- private long getMethodId(long refType, JavaMethod jMethod){
- int id = methodToInt.get(jMethod);
- if (id < 0 || id > methodToInt.size()){
- logr.logError(JDILogger.LEVEL_VERBOSE, " Could not find method in list"); //$NON-NLS-1$
- id = -1;
- }
- return id;
- }
-
- /**
- * Given a JavaField and class id, return the id of the field
- * @param refType The class id as found in the JavaClass vector
- * @param jField The Kato JavaField object
- * @return A unique ID for this field
- */
-
- private long getFieldId(long refType, JavaField jField){
- int id = fieldList.indexOf(jField);
- if (id < 0 || id > fieldList.size()){
- logr.logError(JDILogger.LEVEL_VERBOSE, " Could not find field in list"); //$NON-NLS-1$
- id = -1;
- }
- return id;
- }
-
-
- /**
- * Given a vector, objectID, and fieldID, add the tagged value to the vector
- * @param vctr The Byte vector for the current data segment
- * @param objectID The unique objectID of the object we're inquiring about
- * @param fieldID The unique fieldID of the field we're inquiring about
- * @return false if we fail, true if we succeed
- * @throws Exception Upstream exception thrown
- */
- private boolean getFieldFromObject(Vector<Byte> vctr, long objectID, long fieldID) throws Exception{
-
- JavaField jField = getField(fieldID);
- JavaObject jObject = getObject(objectID);
- if (jField != null && jObject != null){
- return getValueFromField(vctr, jObject, jField);
- }
- logr.logError(JDILogger.LEVEL_VERBOSE, " Object " +objectID + " is not in the list of objects."); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- logr.logError(JDILogger.LEVEL_VERBOSE, " Cannot find class field from object"); //$NON-NLS-1$
- return false;
- }
-
- /**
- * Given a vector, reffTypeID, and fieldID, add the tagged value to the vector
- * @param vctr The Byte vector for the current data segment
- * @param refType The unique class ID of the object we're inquiring about
- * @param fieldID The unique fieldID of the field we're inquiring about
- * @return false if we fail, true if we succeed
- * @throws Exception Upstream exception thrown
- */
- private boolean getFieldFromClass(Vector<Byte> vctr, long refType, long fieldID) throws Exception{
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- JavaField jField = getField(fieldID);
- if (jField != null){
- return getValueFromField(vctr, javaClass.getObject(), jField);
- }
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " No such field"); //$NON-NLS-1$
-
- }else{
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " No such class"); //$NON-NLS-1$
- return false;
- }
-
- return false;
- }
-
- /**
- * Build a hashmap using the JavaClass address as a unique ID and key
- * @return A hashmap containing all the classes and addresses
- */
- private HashMap<Long, JavaClass> buildClasses() {
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building class list"); //$NON-NLS-1$
- HashMap<Long, JavaClass> classes = new HashMap<Long, JavaClass>();
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
- while ( prIt.hasNext( ) ){
- ImageProcess process = (ImageProcess) prIt.next( );
-
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator classLoaders = javaRT.getJavaClassLoaders().iterator();
- while (classLoaders.hasNext()){
-
- JavaClassLoader javaCL = (JavaClassLoader)classLoaders.next();
- Iterator javaClasses = javaCL.getDefinedClasses().iterator();
-
- while (javaClasses.hasNext()){
- JavaClass javaClass = (JavaClass)javaClasses.next();
-
- classes.put(javaClass.getID().getAddress(), javaClass);
-
-
- }
- }
- }
- }
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Built list of " + classes.size() + " classes"); //$NON-NLS-1$ //$NON-NLS-2$
- return classes;
- }
-
- /**
- * Transforms a JavaObject into a real java/lang/String object.
- * Does this by extracting the following fields from java/lang/String:
- * <pre>
- * int offset, count;
- * char[] value;
- * </pre>
- *
- * @param object
- * JavaObject representation of a java.lang.String object.
- * @return String or null if there were problems.
- * @throws IllegalArgumentException thrown if JavaObject not java/lang/String
- */
- public static String javaObjectToString(JavaObject object)
- throws IllegalArgumentException {
-
- if (object == null) {
- return null;
- }
-
- String className = null;
- JavaClass stringClass = null;
-
- try {
- stringClass = object.getJavaClass();
- className = stringClass.getName();
- } catch (CorruptDataException e) {
- e.printStackTrace();
- return null;
- }
-
- if (!className.equals("java/lang/String")) {
- throw new IllegalArgumentException(
- "Mismatched types - expecting java/lang/String, got `"
- + className + "'");
- }
-
- int offset = 0, count = 0;
- char[] value = null;
- JavaObject valueArray = null;
- boolean gotValue = false, gotOffset = false, gotCount = false;
-
- // Get all fields, pick out interesting ones.
- for (Object fobj : stringClass.getDeclaredFields()) {
-
-
- if (fobj instanceof CorruptData) {
- continue;
- }
-
- JavaField field = (JavaField) fobj;
- try {
- String fieldName = field.getName();
-
- if (fieldName.equals("offset")) {
- offset = field.getInt(object);
- gotOffset = true;
- } else if (fieldName.equals("count")) {
- count = field.getInt(object);
- gotCount = true;
- } else if (fieldName.equals("value")) {
- valueArray = (JavaObject) field.get(object);
- gotValue = true;
- }
-
- } catch (DiagnosticException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- try {
- // Check we got all of the fields.
- if ((gotOffset || gotCount || gotValue) == false) {
- return null;
- } else {
- int length = (int) valueArray.getArraySize();
- value = new char[length];
- try {
- valueArray.arraycopy(0, value, 0, length);
- } catch (IndexOutOfBoundsException e) {
- e.printStackTrace();
- return null;
- }
- }
-
- return new String(value, offset, count);
- } catch (CorruptDataException e) {
- e.printStackTrace();
- return null;
- } catch (MemoryAccessException e) {
- e.printStackTrace();
- return null;
- }
- }
- /**
- * Convert a Vector to a byte array
- * @param vctr The Vector to convert
- * @return An array consisting of bytes (Not Bytes)
- */
-
-
- public static byte[] vectorToByte(Vector<Byte> vctr){
- Byte []barray = new Byte[vctr.size()];
- vctr.copyInto(barray);
- //TODO - A better way to do this?
- byte []barray2 = new byte[barray.length];
- for (int i = 0; i < barray.length; i++){
- barray2[i] = barray[i];
- }
- return barray2;
- }
-
-
- /**
- * getByteFromInt is used to break down an int into a byte
- * @param orig The original integer
- * @param index Which byte to get (0-3 inclusive)
- * @return The byte
- */
- public static byte getByteFromInt(int orig, int index){
- if (index < 0 || index > 3)
- throw new ArrayIndexOutOfBoundsException();
- //Mask out the 4 bytes
- int mask = 0xFF;
-
- //Align the mask to what we want
- mask = mask << (index*8);
-
- //Mask out the byte we want
- orig = orig & mask;
-
- //Align back our new value
- orig = orig >> (index*8);
-
- //Truncate the rest of the useless bytes
- return (byte)orig;
-
- }
-
- /**
- * Add a 64bit long to the end of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inLong The long to add
- */
-
- public static void addLongToVector(Vector<Byte> vctr, long inLong){
- int topInt = (int)(inLong >> 32) & 0xFFFFFFFF;
- int bottomInt = (int)inLong & 0xFFFFFFFF;
-
- vctr.add(getByteFromInt(topInt, 3));
- vctr.add(getByteFromInt(topInt, 2));
- vctr.add(getByteFromInt(topInt, 1));
- vctr.add(getByteFromInt(topInt, 0));
-
- vctr.add(getByteFromInt(bottomInt, 3));
- vctr.add(getByteFromInt(bottomInt, 2));
- vctr.add(getByteFromInt(bottomInt, 1));
- vctr.add(getByteFromInt(bottomInt, 0));
- }
-
- /**
- * Add a 32bit int to the front of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inInt The int to add
- */
- public static void addIntToVectorFront(Vector<Byte> vctr, int inInt){
- vctr.add(0, getByteFromInt(inInt, 3));
- vctr.add(1, getByteFromInt(inInt, 2));
- vctr.add(2, getByteFromInt(inInt, 1));
- vctr.add(3, getByteFromInt(inInt, 0));
- }
-
- /**
- * Add a 32bit int to the end of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inInt The int to add
- */
- public static void addIntToVector(Vector<Byte> vctr, int inInt){
- vctr.add(getByteFromInt(inInt, 3));
- vctr.add(getByteFromInt(inInt, 2));
- vctr.add(getByteFromInt(inInt, 1));
- vctr.add(getByteFromInt(inInt, 0));
- }
-
- /**
- * Add a 16bit short to the front of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inShort The short to add
- */
- public static void addShortToVectorFront(Vector<Byte> vctr, short inShort){
- vctr.add(0, getByteFromInt(inShort, 1));
- vctr.add(1, getByteFromInt(inShort, 0));
- }
-
- /**
- * Add a 16bit short to the end of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inShort The int to add
- */
- public static void addShortToVector(Vector<Byte> vctr, int inShort){
- vctr.add(getByteFromInt(inShort, 1));
- vctr.add(getByteFromInt(inShort, 0));
- }
-
- /**
- * Add a 16bit char to the front of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inChar The short to add
- */
- public static void addCharToVectorFront(Vector<Byte> vctr, int inChar){
- vctr.add(0, getByteFromInt(inChar, 1));
- vctr.add(1, getByteFromInt(inChar, 0));
- }
-
- /**
- * Add a 16bit char to the end of the Byte Vector
- * @param vctr Vector to add the bytes to
- * @param inChar The int to add
- */
- public static void addCharToVector(Vector<Byte> vctr, int inChar){
- vctr.add(getByteFromInt(inChar, 1));
- vctr.add(getByteFromInt(inChar, 0));
- }
- /**
- * Add a string to the end of the Byte Vector as specified in the JDWP docs (4 byte length + ASCII chars)
- * @param vctr Vector to add the bytes to
- * @param inString The string to add
- */
- public static void addStringToVector(Vector<Byte> vctr, String inString){
- addIntToVector(vctr, inString.length());
-
- byte[] str = inString.getBytes();
- for (int i = 0; i < str.length; i++){
- vctr.add(str[i]);
- }
- }
-
- /**
- * Given a byte array, extract a string as defined in the JDWP specs
- * @param inData The byte array to pull the data from
- * @param offset The index of the string (which is the length of the string)
- * @return The resultant string
- */
- public static String getStringFromBytes(byte []inData, int offset){
- int length = createIntFromBytes(inData, offset, 4);
- String ret = ""; //$NON-NLS-1$
- for(int i = offset + 4; i < offset + 4 + length; i++){
- ret = ret + (char)inData[i];
- }
-
-
- return ret;
- }
-
- /**
- * Given a byte array, extract a 32bit int
- * @param inData The byte array to pull the data from
- * @param offset The index of the int
- * @param size How many bytes to extract
- * @return The 32bit int
- */
- public static int createIntFromBytes(byte []inData, int offset, int size){
-
-
- int ret = 0;
- if (size == 0)
- size = 4;
- if (size != 4){
- throw new NumberFormatException("createIntFromBytes should be 4 bytes"); //$NON-NLS-1$
- }
- for(int i = offset; i < offset + size; i++){
- ret = ret << 8;
- ret |= (inData[i] & 0xFF);
- }
-
- return ret;
-
- }
-
- /**
- * Given a byte array, extract a 64bit long
- * @param inData The byte array to pull the data from
- * @param offset The index of the int
- * @param size How many bytes to extract
- * @return The 64bit long
- */
- public static long createLongFromBytes(byte []inData, int offset, int size){
- long ret = 0;
- if (size == 0)
- size = 8;
- if (size != 8){
- throw new NumberFormatException("createLongFromBytes should be 8 bytes"); //$NON-NLS-1$
- }
- for(int i = offset; i < offset + size; i++){
- ret = ret << 8;
- ret |= (inData[i] & 0xFF);
- }
-
- return ret;
-
- }
-
- /**
- * Return whether a class is an interface or not
- * @param classID The id of the class
- * @return true if the class is an interface
- * @throws CorruptDataException
- */
- private boolean isInterface(long classID) throws CorruptDataException{
- //Use modifier
- if (classes == null){
- buildClasses();
- }
- JavaClass jClass = getClass(classID);
- if (jClass != null){
- if (Modifier.isInterface(jClass.getModifiers())){
- return true;
- }
- }
- return false;
- }
-
- /**
- * Given a classID, get the Kato JavaClass
- * @param classID The unique class ID
- * @return The Kato JavaClass
- * @throws CorruptDataException
- */
- private JavaClass getClass(long classID){
- if (classes == null){
- classes = buildClasses();
- }
- JavaClass jcl = classes.get(classID);
- if (jcl == null){
- /**
- * Attemp to get directly, useful for system class loader which isn't covered
- * by build classes as it is not part of the class loader loaded classes.
- */
-
- }
- return classes.get(classID);
-
- }
-
- /**
- * Given a classID, check to see if the ID is actually a class or an object
- * @param classID The classID
- * @return true if classID is a class, false if it is not
- * @throws CorruptDataException
- */
- private boolean isClass(long classID){
- if (classes == null){
- classes = buildClasses();
- }
- return classes.containsKey(classID);
- }
-
- /**
- * Given a classID and a methodID, get the lowest line number known in all stack frames
- * @param refType The class ID of the method
- * @param methodID The method ID
- * @return The lowest known line number
- * @throws Exception
- */
- private int findLowestLineRef(long refType, long methodID) throws Exception{
- int lowest = 1999999999;
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- JavaThread thd = (JavaThread) tmpobj;
- Iterator frames = thd.getStackFrames().iterator();
- while(frames.hasNext()){
- JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
- JavaLocation jLocation = jStackFrame.getLocation();
- JavaMethod jMethod = jLocation.getMethod();
- JavaClass jClass = jMethod.getDeclaringClass();
-
-
- if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
- int line = -1;
- try{
- line = jLocation.getLineNumber();
- }
- catch(Exception exxy){}
- if (line > 0){
- if (lowest > line){
- lowest = line;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return lowest;
- }
-
- /**
- * Given a classID and a methodID, get the highest line number known in all stack frames
- * @param refType The class ID of the method
- * @param methodID The method ID
- * @return The highest known line number
- * @throws Exception
- */
- private int findHighestLineRef(long refType, long methodID) throws Exception{
- int highest = 0;
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- JavaThread thd = (JavaThread) tmpobj;
- Iterator frames = thd.getStackFrames().iterator();
- while(frames.hasNext()){
- JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
- JavaLocation jLocation = jStackFrame.getLocation();
- JavaMethod jMethod = jLocation.getMethod();
- JavaClass jClass = jMethod.getDeclaringClass();
-
-
- if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
- int line = -1;
- try{
- line = jLocation.getLineNumber();
- }
- catch(Exception exxy){}
- if (line > 0){
- if (line > highest){
- highest = line;
- }
- }
- }
- }
- }
- }
- }
- }
- }
- return highest;
- }
-
- /**
- * Take care of the virtualMachine command set of the JDWP specs.
- * @param cpckt The incoming command packet request
- * @return The reply packet to be returned to the client
- * @throws Exception
- */
- public ReplyPacket virtualMachine(CommandPacket cpckt) throws Exception{
- if (cpckt.getCommand() == VIRTUAL_MACHINE_VERSION){
- logr.log(JDILogger.LEVEL_VERBOSE, "Version()"); //$NON-NLS-1$
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
- while ( prIt.hasNext( ) ){
- ImageProcess process = (ImageProcess) prIt.next( );
-
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- //Since there doesn't seem to be a matching Kato call to get
- //the information for JDWP, lets call NOT_IMPLEMENTED, but really
- //attach some information back
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- String description = "JDI Post Mortem Debugger"; //$NON-NLS-1$
- String vmVersion = javaRT.getVersion();
- String vmName = "JDI PMD"; //$NON-NLS-1$
-
- int jdwpMajor = 1;
- int jdwpMinor = 4;
-
- //We now have all the information for the reply. Put it all together
- Vector<Byte> vctr = new Vector<Byte>();
- addStringToVector(vctr, description);
- addIntToVector(vctr, jdwpMajor);
- addIntToVector(vctr, jdwpMinor);
- addStringToVector(vctr, vmVersion);
- addStringToVector(vctr, vmName);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
-
- }
- }
- }
-
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CLASS_PATHS){
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "This does not return the actual class path, simply allows JDB to work.");
- Vector<Byte> vctr = new Vector<Byte>();
- addStringToVector(vctr, "");
- addIntToVector(vctr, 0);
- addIntToVector(vctr, 0);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- } else if (cpckt.getCommand() == VIRTUAL_MACHINE_CLASSES_BY_SIGNATURE){
- Vector<Byte> vctr = new Vector<Byte>();
- byte []inData = cpckt.getByteData();
- String signature = getStringFromBytes(inData, 0);
- if (signature.charAt(0) == 'L'){
- signature = signature.substring(1, signature.length() - 1);
- }
- logr.log(JDILogger.LEVEL_VERBOSE, "ClassesBySignature(" + signature + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- int count = 0;
- Iterator <JavaClass> javaClasses = classes.values().iterator();
- while (javaClasses.hasNext()){
- JavaClass javaClass = javaClasses.next();
- String searched = javaClass.getName();
-
- if (searched.equals(signature)){
- count++;
- if (javaClass.isArray()){
- vctr.add((byte)3);
- }else if (isInterface(javaClass.getID().getAddress())){
- vctr.add((byte)2);
- }else{
- vctr.add((byte)1);
- }
- //vctr.add((byte)1);
- addLongToVector(vctr, javaClass.getID().getAddress());
- //Verified Prepared and Initialized
- addIntToVector(vctr, 1 | 2 | 4);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Match: " + javaClass.getName() +" " + Long.toHexString(javaClass.getID().getAddress())); //$NON-NLS-1$
- }else{
- String mangledName = "" + searched + ""; //$NON-NLS-1$ //$NON-NLS-2$
- if (mangledName.equals(signature)){
- count++;
- if (javaClass.isArray()){
- vctr.add((byte)3);
- }else if (isInterface(javaClass.getID().getAddress())){
- vctr.add((byte)2);
- }else{
- vctr.add((byte)1);
- }
- //vctr.add((byte)1);
- addLongToVector(vctr, javaClass.getID().getAddress());
- //Verified Prepared and Initialized
- addIntToVector(vctr, 1 | 2 | 4);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Mangled Match: " + javaClass.getName()); //$NON-NLS-1$
- }else{
- String secondMangle = "[" + searched + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- if (secondMangle.equals(signature)){
- count++;
- if (javaClass.isArray()){
- vctr.add((byte)3);
- }else if (isInterface(javaClass.getID().getAddress())){
- vctr.add((byte)2);
- }else{
- vctr.add((byte)1);
- }
- //vctr.add((byte)1);
- addLongToVector(vctr, javaClass.getID().getAddress());
- //Verified Prepared and Initialized
- addIntToVector(vctr, 1 | 2 | 4);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Really mangled match: " + javaClass.getName()); //$NON-NLS-1$
- }
- }
- }
-
- }
- //Add the count to the front of the vector
- addIntToVectorFront(vctr, count);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, count+" matches"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_ALL_CLASSES){
- logr.log(JDILogger.LEVEL_VERBOSE, "AllClasses()"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- int count = 0;
- Iterator <JavaClass> classList = classes.values().iterator();
- while(classList.hasNext()){
- JavaClass javaClass = (JavaClass)classList.next();
- long typeID = javaClass.getID().getAddress();
- String signature;
-
- if (javaClass.isArray()){
- vctr.add((byte)3);
- signature = "" + javaClass.getName() + ""; //$NON-NLS-1$ //$NON-NLS-2$
- }else if (isInterface(typeID)){
- vctr.add((byte)2);
- signature = "L" + javaClass.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- }else{
- vctr.add((byte)1);
- signature = "L" + javaClass.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- int status = 7;
- addLongToVector(vctr, typeID);
- addStringToVector(vctr, signature);
- addIntToVector(vctr, status);
- count++;
-
-
- }
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + count +" class(es) found"); //$NON-NLS-1$ //$NON-NLS-2$
- addIntToVectorFront(vctr, count);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_ALL_THREADS){
- logr.log(JDILogger.LEVEL_VERBOSE, "AllThreads()"); //$NON-NLS-1$
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- Vector<Byte> vctr = new Vector<Byte>();
- int count = 0;
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- count++;
- JavaThread thd = (JavaThread)tmpobj;
- long hash = thd.getObject().getID().getAddress();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread hash " + thd.getName() + " is " + hash); //$NON-NLS-1$ //$NON-NLS-2$
- addLongToVector(vctr, hash);
- }
-
- }
- addIntToVectorFront(vctr, count);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- byte []barray2 = vectorToByte(vctr);
- rpckt.setData(barray2);
- return rpckt;
-
-
- }
-
- }
- }
- }
- else if (cpckt.getCommand() == VIRTUAL_MACHINE_TOP_LEVEL_THREAD_GROUPS){
-
- // return an arbitrary thread group name, return all of them in a single group.
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- Vector<Byte> vctr = new Vector<Byte>();
- addIntToVector(vctr, 1);
- addLongToVector(vctr, 1);
- byte []barray = vectorToByte(vctr);
- rpckt.setData(barray);
- return rpckt;
-
-
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_DISPOSE){
- //This is a disconnect request
- logr.log(JDILogger.LEVEL_VERBOSE, "Dispose()"); //$NON-NLS-1$
- svr.disconnect(cpckt.getVSock());
- return null;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_IDSIZES){
- //Here we specify a 4 byte (32bit) id size for everything
- //1.7 says that there are 5 fields, each with the number of bytes
- //used to identify each id.
- logr.log(JDILogger.LEVEL_VERBOSE, "IDSizes()"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- //fieldID
- addIntToVector(vctr, 8);
- //methodID
- addIntToVector(vctr, 8);
- //objectID
- addIntToVector(vctr, 8);
- //referenceTypeID (refType)
- addIntToVector(vctr, 8);
- //frameID
- addIntToVector(vctr, 8);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_SUSPEND){
- //Suspend the whole VM. Which is what we're already doing
- //Just play along with it.
- logr.log(JDILogger.LEVEL_VERBOSE, "Suspend()"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_RESUME){
- //Resume the VM. Which we can't do.
- //Just pretend.
- logr.log(JDILogger.LEVEL_VERBOSE, "Resume()"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_EXIT){
- shutDownKato();
- //This is a disconnect request
- logr.log(JDILogger.LEVEL_VERBOSE, "Exit()"); //$NON-NLS-1$
- logr.log(JDILogger.LEVEL_NORMAL, "Remove client asked termination of server"); //$NON-NLS-1$
- svr.stop();
- svr = null;
- return null;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CREATE_STRING){
- Vector<Byte> vctr = new Vector<Byte>();
- addLongToVector(vctr, 0);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CAPABILITIES_NEW){
- logr.log(JDILogger.LEVEL_VERBOSE, "CapabilitiesNew()"); //$NON-NLS-1$
- //This is the capabilities request.
- byte canWatchFieldModification = 0;
- byte canWatchFieldAccess = 0;
- byte canGetBytecodes = 1;
- byte canGetSyntheticAttribute = 0;
- byte canGetOwnedMonitorInfo = 1;
- byte canGetCurrentContendedMonitor = 1;
- byte canGetMonitorInfo = 1;
- byte canRedefineClasses = 0;
- byte canAddMethod = 0;
- byte canUnrestrictedlyRedfineClasses = 0;
- byte canPopFrames = 0;
- byte canUseInstanceFilters = 0;
- byte canGetSourceDebugExtension = 1;
- byte canRequestVMDeathEvent = 0;
- byte canSetDefaultStratum = 0;
-
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add(canWatchFieldModification);
- vctr.add(canWatchFieldAccess);
- vctr.add(canGetBytecodes);
- vctr.add(canGetSyntheticAttribute);
- vctr.add(canGetOwnedMonitorInfo);
- vctr.add(canGetCurrentContendedMonitor);
- vctr.add(canGetMonitorInfo);
- vctr.add(canRedefineClasses);
- vctr.add(canAddMethod);
- vctr.add(canUnrestrictedlyRedfineClasses);
- vctr.add(canPopFrames);
- vctr.add(canUseInstanceFilters);
- vctr.add(canGetSourceDebugExtension);
- vctr.add(canRequestVMDeathEvent);
- vctr.add(canSetDefaultStratum);
- //Fill unused
- for (int i = 0; i < 17; i++){
- vctr.add((byte)0);
- }
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Unknown command "+cpckt.getCommandSet()+" "+cpckt.getCommand());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NOT_IMPLEMENTED);
- return rpckt;
-
-
- }
- /**
- * Take care of the referenceType command set of the JDWP specs.
- * @param cpckt The incoming command packet request
- * @return The reply packet to be returned to the client
- * @throws Exception
- */
- public ReplyPacket referenceType(CommandPacket cpckt) throws Exception{
- if (cpckt.getCommand() == REFERENCE_TYPE_SIGNATURE){
- Vector<Byte> vctr = new Vector<Byte>();
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Signature(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- if (javaClass.isArray()){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "" + javaClass.getName() + ""); //$NON-NLS-1$ //$NON-NLS-2$
- addStringToVector(vctr, "" + javaClass.getName() + ""); //$NON-NLS-1$ //$NON-NLS-2$
- }else{
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "L" + javaClass.getName() + ";"); //$NON-NLS-1$ //$NON-NLS-2$
- addStringToVector(vctr, "L" + javaClass.getName() + ";");
- } //$NON-NLS-1$ //$NON-NLS-2$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_CLASS_LOADER){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "ClassLoader(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- Vector<Byte> vctr = new Vector<Byte>();
- addLongToVector(vctr, javaClass.getClassLoader().getObject().getID().getAddress());
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + javaClass.getClassLoader().getObject().getID().getAddress()); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
-
- }
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_MODIFIERS){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Modifiers(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- Vector<Byte> vctr = new Vector<Byte>();
- addIntToVectorFront(vctr,javaClass.getModifiers());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_FIELDS){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Fields(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- Iterator javaFields = javaClass.getDeclaredFields().iterator();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, javaClass.getName() + ":"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- int count = 0;
- while (javaFields.hasNext()){
- JavaField jField = (JavaField)javaFields.next();
-
- long fieldID = getFieldId(refType, jField);
- String name = jField.getName();
- String signature = jField.getSignature();
- int modBits = jField.getModifiers();
- addLongToVector(vctr, fieldID);
- addStringToVector(vctr, name);
- addStringToVector(vctr, signature);
- addIntToVector(vctr, modBits);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + name + " (" + signature + "," + fieldID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- count++;
- }
- addIntToVectorFront(vctr,count);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Found " + count + " fields(s)"); //$NON-NLS-1$ //$NON-NLS-2$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_METHODS){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Methods(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- Iterator javaMethods = javaClass.getDeclaredMethods().iterator();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, javaClass.getName() + ":"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- int count = 0;
- while (javaMethods.hasNext()){
- JavaMethod jMethod = (JavaMethod)javaMethods.next();
- long methodID = getMethodId(refType, jMethod);
- String name = jMethod.getName();
- String signature = jMethod.getSignature();
- int modBits = jMethod.getModifiers();
- addLongToVector(vctr, methodID);
- addStringToVector(vctr, name);
- addStringToVector(vctr, signature);
- addIntToVector(vctr, modBits);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + name + " (" + signature + ", " + methodID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- count++;
- }
- addIntToVectorFront(vctr,count);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Found " + count + " method(s)"); //$NON-NLS-1$ //$NON-NLS-2$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_GET_VALUES){
- byte [] inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- int fields = createIntFromBytes(inData, 8, 4);
- logr.log(JDILogger.LEVEL_VERBOSE, "ReferenceType.GetValues(" + refType + ", " + fields + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Vector<Byte> vctr = new Vector<Byte>();
-
- addIntToVector(vctr, fields);
-
- for(int i = 0; i < fields; i++){
- long fieldID = createLongFromBytes(inData, 12 + (i * 8), 8);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + i + " of " + fields + " {" + fieldID+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (!getFieldFromClass(vctr, refType, fieldID)){
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }
- }
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_SOURCE_FILE){
- byte [] inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "SourceFile(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- JavaThread thd = (JavaThread) tmpobj;
- Iterator frames = thd.getStackFrames().iterator();
- while(frames.hasNext()){
- JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
- JavaLocation jLocation = jStackFrame.getLocation();
- JavaMethod jMethod = jLocation.getMethod();
- JavaClass jClass = jMethod.getDeclaringClass();
-
-
- if (jClass.getID().getAddress() == refType){
- Vector<Byte> vctr = new Vector<Byte>();
- try{
- addStringToVector(vctr, jLocation.getFilename());
- logr.log(JDILogger.LEVEL_VERBOSE, " " + jLocation.getFilename()); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
- catch(Exception exxy){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Missing source file name information"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_ABSENT_INFORMATION);
- return rpckt;
- }
- }
- }
- }
- }
- }
- }
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Not on stack, cannot retrieve information"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_ABSENT_INFORMATION);
- return rpckt;
-
- }else if (cpckt.getCommand() == REFERENCE_TYPE_INTERFACES){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Interfaces(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- Iterator javaInterfaces = javaClass.getInterfaces().iterator();
- logr.log(JDILogger.LEVEL_VERYVERBOSE, javaClass.getName() + ":"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- int count = 0;
- while (javaInterfaces.hasNext()){
- String iFaceName = (String)javaInterfaces.next();
- JavaClass jClass = javaClass.getClassLoader().findClass(iFaceName);
- long interfaceID;
- if (jClass == null){
- interfaceID = 0;
- }else{
- interfaceID = jClass.getID().getAddress();
- }
- addLongToVector(vctr, interfaceID);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + interfaceID); //$NON-NLS-1$
-
- count++;
- }
- addIntToVectorFront(vctr,count);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Found " + count + " interface(s)"); //$NON-NLS-1$ //$NON-NLS-2$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == REFERENCE_TYPE_CLASS_OBJECT){
- // Simply returns null for class object, jdb compatability
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "ObjectClass");
- Vector<Byte> vctr = new Vector<Byte>();
- addLongToVector(vctr, 0);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- }else if (cpckt.getCommand() == REFERENCE_TYPE_SOURCE_DEBUG_EXTENSION){
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "SourceDebugExtension(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- Vector<Byte> vctr = new Vector<Byte>();
- addStringToVector(vctr, ""); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Unknown command "+cpckt.getCommandSet()+" "+cpckt.getCommand());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NOT_IMPLEMENTED);
- return rpckt;
- }
-
- /**
- * Take care of the classType command set of the JDWP specs.
- * @param cpckt The incoming command packet request
- * @return The reply packet to be returned to the client
- * @throws Exception
- */
- private ReplyPacket classType(CommandPacket cpckt) throws Exception{
- if (cpckt.getCommand() == 1){
- Vector<Byte> vctr = new Vector<Byte>();
- byte []inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Superclass(" + refType + ")"); //$NON-NLS-1$ //$NON-NLS-2$
-
- JavaClass javaClass = getClass(refType);
- if (javaClass != null){
- try{
- JavaClass jSuperClass = javaClass.getSuperclass();
- addLongToVector(vctr, jSuperClass.getID().getAddress());
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " " + jSuperClass.getID().getAddress()); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }catch(NullPointerException exxy){
- addLongToVector(vctr, 0);
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Class "+javaClass.getName()+"{"+javaClass.getID().getAddress()+"} has no superclass"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Invalid class ID"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- } else if (cpckt.getCommand() == 3){
- Vector<Byte> vctr = new Vector<Byte>();
- byte []inData = cpckt.getByteData();
- long classID = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERYVERBOSE,"Tried to invoke static method! "+classID);
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Unknown command "+cpckt.getCommandSet()+" "+cpckt.getCommand());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NOT_IMPLEMENTED);
- return rpckt;
-
- }
-
- /**
- * Take care of the method command set of the JDWP specs.
- * @param cpckt The incoming command packet request
- * @return The reply packet to be returned to the client
- * @throws Exception
- */
- private ReplyPacket method(CommandPacket cpckt) throws Exception{
- if (cpckt.getCommand() == 1){
- byte [] inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- long methodID = createLongFromBytes(inData, 8, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "LineTable(" + refType + "," + methodID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- JavaThread thd = (JavaThread) tmpobj;
- Iterator frames = thd.getStackFrames().iterator();
- while(frames.hasNext()){
- JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
- JavaLocation jLocation = jStackFrame.getLocation();
- JavaMethod jMethod = jLocation.getMethod();
- JavaClass jClass = jMethod.getDeclaringClass();
-
- if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
- int line = -1;
- try{
- line = jLocation.getLineNumber();
- }
- catch(CorruptDataException exxy){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " CorruptData for:"); //$NON-NLS-1$
- }
- catch(DataUnavailable exxy){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " DataUnavailable for:"); //$NON-NLS-1$
- }
-
-
- Vector<Byte> vctr = new Vector<Byte>();
- if (line > 0){
-
- int lowest = findLowestLineRef(refType, methodID) - 1;
- int highest = findHighestLineRef(refType, methodID) + 1;
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " (L)" + jClass.getName() + "." + jMethod.getName() + ":" + lowest + "<" + line + ">" + highest); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
-// //Code index start
-// addLongToVector(vctr, lowest);
-// //Code index end
-// addLongToVector(vctr, highest);
-// //Number of lines
-// addIntToVector(vctr, highest - lowest);
-// for(int i = lowest; i <= highest; i++){
-// addLongToVector(vctr, i);
-// addIntToVector(vctr, i);
-// }
-
- //Code index start
- addLongToVector(vctr, 0);
- //Code index end
- addLongToVector(vctr, 99999999); // TODO go through local variable tables looking for highest reference?
- //Number of lines
- addIntToVector(vctr, 1);
- //for(int i = lowest; i <= highest; i++){
- addLongToVector(vctr, jLocation.getAddress().getAddress()-1);
- addIntToVector(vctr, jLocation.getLineNumber());
- //}
-
-
- }else{
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " (N)" + jClass.getName() + "." + jMethod.getName() + ":" + line); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- //Code index start
- addLongToVector(vctr, -1);
- //Code index end
- addLongToVector(vctr, -1);
- //Number of lines
- //We're native right now.
- addIntToVector(vctr, 0);
- }
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
- }
- }
- }
- }
- }
- }
-
- Vector<Byte> vctr = new Vector<Byte>();
- addLongToVector(vctr, -1);
- //Code index end
- addLongToVector(vctr, -1);
- //Number of lines
- //We're native right now.
- addIntToVector(vctr, 0);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }else if (cpckt.getCommand() == 2){
- byte [] inData = cpckt.getByteData();
- long refType = createLongFromBytes(inData, 0, 8);
- long methodID = createLongFromBytes(inData, 8, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "Method.VariableTable(" + refType + "," + methodID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- int slotsUsed = 0;
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
-
- while ( prIt.hasNext( ) )
- {
- ImageProcess process = (ImageProcess) prIt.next( );
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- Iterator thds = javaRT.getThreads().iterator();
- while(thds.hasNext()){
- Object tmpobj = thds.next();
- if (tmpobj instanceof CorruptData){
- //ignore this thread
- }else{
- JavaThread thd = (JavaThread) tmpobj;
- Iterator frames = thd.getStackFrames().iterator();
- while(frames.hasNext()){
- JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
- JavaLocation jLocation = jStackFrame.getLocation();
- JavaMethod jMethod = jLocation.getMethod();
- JavaClass jClass = jMethod.getDeclaringClass();
-
-
- if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){
- Vector<Byte> vctr = new Vector<Byte>();
-
- List vars = jMethod.getVariables();
- String sig = jMethod.getSignature();
-
- addIntToVector(vctr, methodSignatureSize(sig));
- addIntToVector(vctr, vars.size());
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " "+jLocation+
- " vars.size="+vars.size());
-
- for (Object nextVar : vars) {
- if (nextVar instanceof CorruptData) {
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Corrupt local variable data");
- continue;
- }
-
- JavaVariable var = (JavaVariable) nextVar;
-
- addLongToVector(vctr, var.getStart());
- addStringToVector(vctr, var.getName());
- addStringToVector(vctr, var.getSignature());
- addIntToVector(vctr, var.getLength());
- addIntToVector(vctr, var.getSlot());
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " start:"+var.getStart()+
- " name:`"+var.getName()+ "'"+
- " signature:`"+var.getSignature()+"'"+
- " length: "+var.getLength()+
- " slot: "+var.getSlot()); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
-
- return rpckt;
- }
- }
- }
- }
- }
- }
- }
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_ABSENT_INFORMATION);
- return rpckt;
- }
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Unknown command "+cpckt.getCommandSet()+" "+cpckt.getCommand());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NOT_IMPLEMENTED);
- return rpckt;
-
- }
-
-
- /**
- * Works out and returns the size of a method's arguments from it's signature.
- * doubles and longs and object references are regarded as
- *
- * @param signature JNI signature of method.
- * e.g. "(Ljava/lang/String;LB)I"
- * which would be:
- * int method(String arg0, long arg1, byte arg2);
- *
- *
- * @return size of arguments
- */
- public static int methodSignatureSize(String signature) {
- int state = 0;
- int size = 0;
-
-LOOP: for (int i=0; i < signature.length(); i++) {
- char c = signature.charAt(i);
-
- switch(state) {
- case 0: // First character must be a "("
- switch(c) {
- case '(':
- state = 1;
- break;
- default:
- throw new IllegalArgumentException("Bad character `"+c+"' in signature `"+signature+"' in state "+state);
- }
- break;
- case 1: // parse characters
- switch(c) {
- case 'Z':
- case 'B':
- case 'S':
- case 'C':
- case 'I':
- case 'F':
- size++;
- break;
- case 'D':
- case 'J':
- size +=2;
- break;
- case '[':
- size++;
- state = 2; // go to parse array state
- break;
- case 'L':
- size++;
- state = 3; // go to parse object state
- break;
- case ')':
- state = 4; // go to end state.
- break;
- default:
- throw new IllegalArgumentException("Bad character `"+c+"' in signature `"+signature+"' in state "+state);
- }
- break;
- case 2: // Parse array
- switch(c) {
- case 'L':
- state = 3;
- case '[':
- // remain in this state
- break;
- case 'Z':
- case 'B':
- case 'S':
- case 'C':
- case 'I':
- case 'F':
- case 'D':
- case 'J':
- state = 1; // go back to character parsing state
- break;
- default:
- throw new IllegalArgumentException("Bad character `"+c+"' in signature `"+signature+"' in state "+state);
- }
- case 3: // Parse object
- switch (c) {
- case ';':
- state = 1; // reached end of object descriptor. stop.
- break;
- default:
- // anything else is fair game.
- }
- case 4: // end state - return value remains - just ignore characters.
- break LOOP; // Exit the loop, we won't parse the return type.
- default:
- throw new IllegalStateException("In unexpected state "+state+ "in signature `"+signature+"'");
- }
- }
-
- return size;
- }
-
- /**
- * Create a hash map that stores objects for quick retrieval later
- * @return A hashmap of objects
- */
- private HashMap<Long, JavaObject> generateObjectHashmap(){
- HashMap<Long, JavaObject> objectMap = new HashMap<Long, JavaObject>();
- return objectMap;
- }
-
-
- /**
- * Given an objectID, return the object associated with it. Check the cache first.
- * @param objectID The unique ID of the object
- * @return The Kato JavaObject
- */
- private JavaObject getObject(long objectID){
- if (objectMap == null){
- this.objectMap = generateObjectHashmap();
- }
- JavaObject tmpObj = objectMap.get(objectID);
- if (tmpObj == null){
- //Last ditch attempt to try and get object
- //Sometimes an object is really a class.
- try{
- if (isClass(objectID)){
- logr.logError(JDILogger.LEVEL_VERBOSE, " Object is really a class"); //$NON-NLS-1$
- return getClass(objectID).getObject();
- }
- }catch(Exception exxy){}
- tmpObj = getSlowObject(objectID);
- if (tmpObj != null){
- objectMap.put(tmpObj.getID().getAddress(), tmpObj);
- }else{
- logr.logError(JDILogger.LEVEL_VERBOSE, " Error finding object " + objectID); //$NON-NLS-1$
- }
-
- }
- return tmpObj;
- }
-
-
- /**
- * Get the object associated with the ID
- * @param objectID The unique ID for that object
- * @return
- */
- private JavaObject getSlowObject(long objectID){
-
-
- Iterator asIt = image.getAddressSpaces( ).iterator();
- while ( asIt.hasNext( ) )
- {
- ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
- Iterator prIt = as.getProcesses( ).iterator();
- while ( prIt.hasNext( ) ){
- ImageProcess process = (ImageProcess) prIt.next( );
-
- Iterator runTimesIt = process.getRuntimes( ).iterator();
- while ( runTimesIt.hasNext( ) )
- {
- JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
- try {
- JavaObject jObject = javaRT.getObjectAtAddress(as.getPointer(objectID));
- if (jObject != null){
- return jObject;
- }
- } catch (CorruptDataException e) {
- //e.printStackTrace();
- } catch (IllegalArgumentException e) {
- //e.printStackTrace();
- } catch (MemoryAccessException e) {
- //e.printStackTrace();
- } catch (DataUnavailable e) {
- //e.printStackTrace();
- }
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Could not find class directly, searching through heap");
-
- // Old method for returning java objects
- Iterator heapList = javaRT.getHeaps().iterator();
-
- while (heapList.hasNext()){
- JavaHeap heap = (JavaHeap) heapList.next();
- Iterator objectList = heap.getObjects().iterator();
- while (objectList.hasNext()){
- JavaObject jObject = (JavaObject)objectList.next();
- if (jObject.getID().getAddress() == objectID){
- return jObject;
- }
- }
- }
-
- }
- }
- }
- return null;
- }
-
- /**
- * Given a the name for a class, iterate through all the classes
- * @param name The name of the class to search
- * @return The Kato JavaClass result
- * @throws Exception
- */
- private JavaClass findClassByName(String name) throws Exception{
- Iterator<JavaClass> jClasses = classes.values().iterator();
- while(jClasses.hasNext()){
- JavaClass jClass = jClasses.next();
- if (name.equalsIgnoreCase(jClass.getName())){
- return jClass;
- }
- }
- return null;
- }
-
- /**
- * Take care of the objectReference command set of the JDWP specs.
- * @param cpckt The incoming command packet request
- * @return The reply packet to be returned to the client
- * @throws Exception
- */
-
- private ReplyPacket objectReference(CommandPacket cpckt) throws Exception{
-
- if (cpckt.getCommand() == 1){
- //ReferenceType
- //Return the ID (reference) of the object's class and type
- byte [] inData = cpckt.getByteData();
- long object = createLongFromBytes(inData, 0, 8);
- logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.ReferenceType(" + object + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- //Search inside hashmap first
- if (objectMap.containsKey(object)){
- JavaObject jObject = getObject(object);
- if (jObject != null){
- try{
- int refTypeTag = 1;
-
- JavaClass jClass = jObject.getJavaClass();
- if (jClass == null){
-
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)1);
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type, returning object instead"); //$NON-NLS-1$
- JavaClass jOutClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
-
- addLongToVector(vctr, jOutClass.getID().getAddress());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type"); //$NON-NLS-1$
- return rpckt;
- }
- long typeID = jObject.getJavaClass().getID().getAddress();
- if (!classes.containsKey(typeID)){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Client may not have classID"); //$NON-NLS-1$
- }
-
-
- if (jObject.isArray()){
- refTypeTag = 3;
- }else if(isInterface(typeID)){
- refTypeTag = 2;
- }
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " refTagType " + refTypeTag); //$NON-NLS-1$
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " name " + jObject.getJavaClass().getName() + "{"+jObject.getJavaClass().getID().getAddress()+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)refTypeTag);
- addLongToVector(vctr, typeID);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }catch(CorruptDataException exxy){
- logr.logError(JDILogger.LEVEL_VERBOSE, " Corrupt data!"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)1);
- JavaClass jClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
-
- addLongToVector(vctr, jClass.getID().getAddress());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
-
- }
- }
- }else{
-
- JavaClass javaClass = getClass(object);
- if (javaClass != null){
- int refTypeTag = 1;
- long typeID = javaClass.getID().getAddress();
-
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)refTypeTag);
- addLongToVector(vctr, typeID);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }
-
- JavaObject jObject = getObject(object);
- if (jObject != null){
-
- // This is a copy from above, could be made into a method
-
-
- try{
- int refTypeTag = 1;
-
- JavaClass jClass = jObject.getJavaClass();
- if (jClass == null){
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "Found the object the slow route");
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)1);
- JavaClass jOutClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
-
- addLongToVector(vctr, jOutClass.getID().getAddress());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Cannot get class type"); //$NON-NLS-1$
- return rpckt;
- }
- long typeID = jObject.getJavaClass().getID().getAddress();
- if (!classes.containsKey(typeID)){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " Client may not have classID"); //$NON-NLS-1$
- }
-
- if (jObject.isArray()){
- refTypeTag = 3;
- }else if(isInterface(typeID)){
- refTypeTag = 2;
- }
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " refTagType " + refTypeTag); //$NON-NLS-1$
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " name " + jObject.getJavaClass().getName() + "{"+jObject.getJavaClass().getID().getAddress()+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)refTypeTag);
- addLongToVector(vctr, typeID);
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
- }catch(CorruptDataException exxy){
- logr.logError(JDILogger.LEVEL_VERBOSE, " Corrupt data!"); //$NON-NLS-1$
- Vector<Byte> vctr = new Vector<Byte>();
- vctr.add((byte)1);
- JavaClass jClass = findClassByName("java/lang/Object"); //$NON-NLS-1$
-
- addLongToVector(vctr, jClass.getID().getAddress());
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
- exxy.printStackTrace(new PrintStream(logr.getErrorStream()));
- rpckt.setData(vectorToByte(vctr));
- return rpckt;
-
- }
-
- }
- }
-
- logr.log(JDILogger.LEVEL_VERYVERBOSE, "No matches"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
- }else if (cpckt.getCommand() == 2){
- byte [] inData = cpckt.getByteData();
- long object = createLongFromBytes(inData, 0, 8);
- int fields = createIntFromBytes(inData, 8, 4);
- logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.GetValues(" + object + "," + fields + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Vector<Byte> vctr = new Vector<Byte>();
- addIntToVector(vctr, fields);
- for (int i = 0; i < fields; i++){
- long fieldID = createLongFromBytes(inData, 12 + (8*i), 8);
- if (objectMap.containsKey(object)){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " O:" + fieldID); //$NON-NLS-1$
- if (!getFieldFromObject(vctr, object, fieldID)){
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " O:" + fieldID+" Invalid Object/Field"); //$NON-NLS-1$
- ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
- return rpckt;
-
- }
-
- }else{
- logr.log(JDILogger.LEVEL_VERYVERBOSE, " C:" + fieldID); //$NON-NLS-1$
- if (!getFieldFromClass(vctr, object, fieldID)){
[... 4926 lines stripped ...]