Index: KatoReader.java =================================================================== --- KatoReader.java (revision 806490) +++ KatoReader.java (working copy) @@ -17,19 +17,21 @@ 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.DiagnosticException; import javax.tools.diagnostics.image.MemoryAccessException; import javax.tools.diagnostics.runtime.java.JavaClass; import javax.tools.diagnostics.runtime.java.JavaClassLoader; @@ -37,6 +39,7 @@ 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; @@ -44,7 +47,6 @@ import javax.tools.diagnostics.runtime.java.JavaVariable; - /** * DTFJReader * @@ -104,7 +106,11 @@ 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 objectMap; + private HashMap monitorMap; public static final int COMMANDSET_VIRTUAL_MACHINE = 1; public static final int COMMANDSET_REFERENCE_TYPE = 2; @@ -286,7 +292,7 @@ } catch(NullPointerException exxy){ logr.logError(JDILogger.LEVEL_VERYVERBOSE, " Attemped access to field is null"); //$NON-NLS-1$ - addIntToVector(vctr, 0); + addLongToVector(vctr, 0); } } break; @@ -370,8 +376,11 @@ return eventRequest(cpckt); case COMMANDSET_STACK_FRAME: return stackFrame(cpckt); + // Added for jdb + case COMMANDSET_THREAD_GROUP_REFERENCE: + return threadGroupReference(cpckt); default: - logr.logError(JDILogger.LEVEL_VERBOSE, "Unknown command set"); //$NON-NLS-1$ + 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; } @@ -459,6 +468,7 @@ 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(); } @@ -487,6 +497,30 @@ return fieldList.elementAt((int)fieldID); } + + private HashMap buildMonitors(){ + HashMap monitors = new HashMap(); + 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 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 @@ -1002,6 +1036,14 @@ 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); } @@ -1181,10 +1223,23 @@ } } - }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CLASSES_BY_SIGNATURE){ + }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 vctr = new Vector(); + 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 vctr = new Vector(); 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 javaClasses = classes.values().iterator(); @@ -1194,16 +1249,30 @@ if (searched.equals(signature)){ count++; - vctr.add((byte)1); + 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()); //$NON-NLS-1$ + logr.log(JDILogger.LEVEL_VERYVERBOSE, "Match: " + javaClass.getName() +" " + Long.toHexString(javaClass.getID().getAddress())); //$NON-NLS-1$ }else{ - String mangledName = "L" + searched + ";"; //$NON-NLS-1$ //$NON-NLS-2$ + String mangledName = "" + searched + ""; //$NON-NLS-1$ //$NON-NLS-2$ if (mangledName.equals(signature)){ count++; - vctr.add((byte)1); + 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); @@ -1212,7 +1281,14 @@ String secondMangle = "[" + searched + ";"; //$NON-NLS-1$ //$NON-NLS-2$ if (secondMangle.equals(signature)){ count++; - vctr.add((byte)1); + 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); @@ -1224,7 +1300,7 @@ } //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; @@ -1240,7 +1316,7 @@ if (javaClass.isArray()){ vctr.add((byte)3); - signature = "L" + javaClass.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ + 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$ @@ -1248,13 +1324,13 @@ 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++; - + } @@ -1305,6 +1381,19 @@ } } + } + 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 vctr = new Vector(); + 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$ @@ -1349,6 +1438,12 @@ svr.stop(); svr = null; return null; + }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CREATE_STRING){ + Vector vctr = new Vector(); + 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. @@ -1356,9 +1451,9 @@ byte canWatchFieldAccess = 0; byte canGetBytecodes = 1; byte canGetSyntheticAttribute = 0; - byte canGetOwnedMonitorInfo = 0; - byte canGetCurrentContendedMonitor = 0; - byte canGetMonitorInfo = 0; + byte canGetOwnedMonitorInfo = 1; + byte canGetCurrentContendedMonitor = 1; + byte canGetMonitorInfo = 1; byte canRedefineClasses = 0; byte canAddMethod = 0; byte canUnrestrictedlyRedfineClasses = 0; @@ -1392,6 +1487,7 @@ 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; @@ -1412,8 +1508,13 @@ JavaClass javaClass = getClass(refType); if (javaClass != null){ - 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$ + 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; @@ -1585,6 +1686,7 @@ 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; } @@ -1595,6 +1697,7 @@ } } } + 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; @@ -1611,7 +1714,7 @@ int count = 0; while (javaInterfaces.hasNext()){ String iFaceName = (String)javaInterfaces.next(); - JavaClass jClass = javaClass.getClassLoader().findClass(iFaceName); + JavaClass jClass = javaClass.getClassLoader().findClass(iFaceName); long interfaceID; if (jClass == null){ interfaceID = 0; @@ -1632,6 +1735,15 @@ 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 vctr = new Vector(); + 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); @@ -1642,6 +1754,7 @@ 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; } @@ -1674,13 +1787,17 @@ 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 vctr = new Vector(); + 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; @@ -1725,7 +1842,6 @@ JavaMethod jMethod = jLocation.getMethod(); JavaClass jClass = jMethod.getDeclaringClass(); - if (getMethodId(refType, jMethod) == methodID && jClass.getID().getAddress() == refType){ int line = -1; try{ @@ -1745,6 +1861,7 @@ 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 @@ -1755,12 +1872,25 @@ 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, 41); + addLongToVector(vctr, -1); //Code index end - addLongToVector(vctr, 43); + addLongToVector(vctr, -1); //Number of lines //We're native right now. addIntToVector(vctr, 0); @@ -1769,14 +1899,22 @@ rpckt.setData(vectorToByte(vctr)); return rpckt; } - } } } } } } - ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INTERNAL); + + Vector vctr = new Vector(); + 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(); @@ -1830,7 +1968,7 @@ } JavaVariable var = (JavaVariable) nextVar; - + addLongToVector(vctr, var.getStart()); addStringToVector(vctr, var.getName()); addStringToVector(vctr, var.getSignature()); @@ -1857,6 +1995,7 @@ 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; @@ -1966,7 +2105,6 @@ private HashMap generateObjectHashmap(){ HashMap objectMap = new HashMap(); return objectMap; - } @@ -1999,6 +2137,7 @@ } return tmpObj; } + /** * Get the object associated with the ID @@ -2006,6 +2145,8 @@ * @return */ private JavaObject getSlowObject(long objectID){ + + Iterator asIt = image.getAddressSpaces( ).iterator(); while ( asIt.hasNext( ) ) { @@ -2018,6 +2159,24 @@ 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()){ @@ -2069,7 +2228,6 @@ 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); @@ -2082,6 +2240,7 @@ Vector vctr = new Vector(); 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()); @@ -2094,14 +2253,17 @@ if (!classes.containsKey(typeID)){ logr.log(JDILogger.LEVEL_VERYVERBOSE, " Client may not have classID"); //$NON-NLS-1$ } - 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$ + 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 vctr = new Vector(); vctr.add((byte)refTypeTag); @@ -2137,6 +2299,66 @@ 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 vctr = new Vector(); + 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 vctr = new Vector(); + 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 vctr = new Vector(); + 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$ @@ -2171,6 +2393,37 @@ rpckt.setData(vectorToByte(vctr)); return rpckt; + }else if (cpckt.getCommand() == 5){ + // Monitor information, assume JNIEnv is the same as threadID... + byte[] inData = cpckt.getByteData(); + long object = createLongFromBytes(inData, 0, 8); + Vector vctr = new Vector(); + JavaMonitor jm = null; + logr.log(JDILogger.LEVEL_VERBOSE,"ObjectReference.MonitorInfo("+object+")"); + if ((jm = monitorMap.get(objectMap))!= null){ + JavaThread owningThread = jm.getOwner(); + + if (owningThread != null){ + addLongToVector(vctr, owningThread.getJNIEnv().getAddress()); + }else{ + addLongToVector(vctr, 0); + } + addIntToVector(vctr, 1); + addIntToVector(vctr, jm.getEnterWaiters().size()); + for (JavaThread thr : jm.getEnterWaiters()){ + addLongToVector(vctr, thr.getJNIEnv().getAddress()); + } + logr.log(JDILogger.LEVEL_VERYVERBOSE," "+jm.getEnterWaiters().size()+" waiting and owner is "+owningThread); + }else{ + addLongToVector(vctr, 0); + addIntToVector(vctr, 0); + addIntToVector(vctr, 0); + logr.log(JDILogger.LEVEL_VERYVERBOSE," no monitor information"); + } + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + }else if (cpckt.getCommand() == 6){ byte [] inData = cpckt.getByteData(); long object = createLongFromBytes(inData, 0, 8); @@ -2214,12 +2467,42 @@ return rpckt; } - + logr.log(JDILogger.LEVEL_VERYVERBOSE, "Invalid object"); ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT); return rpckt; + }else if (cpckt.getCommand() == 7){ + byte [] inData = cpckt.getByteData(); + long object = createLongFromBytes(inData, 0, 8); + JavaObject obj = getObject(object); + logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.DisableCollection(" + object + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + if (obj != null){ + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + return rpckt; + } + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT); + return rpckt; + }else if (cpckt.getCommand() == 8){ + logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.EnableCollection(" + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + return rpckt; + }else if (cpckt.getCommand() == 9){ + byte [] inData = cpckt.getByteData(); + long object = createLongFromBytes(inData, 0, 8); + logr.log(JDILogger.LEVEL_VERBOSE, "ObjectReference.IsCollected(" + object + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaObject obj = getObject(object); + if (obj != null){ + Vector vctr = new Vector(); + vctr.add((byte) 0); + 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; } + 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; @@ -2239,6 +2522,7 @@ byte[] inData = cpckt.getByteData(); long stringObject = createLongFromBytes(inData, 0, 8); logr.log(JDILogger.LEVEL_VERBOSE, "StringReference.Value("+stringObject+")"); //$NON-NLS-1$ //$NON-NLS-2$ + if (vctrs.containsKey(stringObject)){ Vector vctr = new Vector(); //Truncate down to int, and hope we don't have more than 2^32-1 objects @@ -2246,14 +2530,44 @@ ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); rpckt.setData(vectorToByte(vctr)); return rpckt; + }else{ + // This catches cases where we have not occupied vctrs with a string reference (added to support name labels on arrays of objects) + JavaObject obj = getObject(stringObject); + if (obj != null) { + for (JavaField field : obj.getJavaClass() + .getDeclaredFields()) { + if (field.getSignature().equals("[C")) { + JavaObject stringObj = (JavaObject) field.get(obj); + char charArray[] = new char[stringObj + .getArraySize()]; + + stringObj.arraycopy(0, charArray, 0, stringObj + .getArraySize()); + + + String stringRef = new String(charArray); + Vector vctr = new Vector(); + addStringToVector(vctr, stringRef); + ReplyPacket rpckt = new ReplyPacket(cpckt + .getSequence(), FLAG_REPLY_PACKET, + ERROR_NONE); + vctrs.put(stringObject, stringRef); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + + } + } + } } ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT); 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; - } + + private ReplyPacket threadReference(CommandPacket cpckt) throws Exception{ if (cpckt.getCommand() == 1){ @@ -2406,12 +2720,13 @@ //ThreadGroup //This call returns the group of the input thread. //TODO - Since this doesn't seem available in DTFJ, let's fake it with 0 + // Lets fake it with 1 ... byte [] inData = cpckt.getByteData(); long thread = createLongFromBytes(inData, 0, 8); logr.log(JDILogger.LEVEL_VERBOSE, "ThreadGroup("+thread+")"); //$NON-NLS-1$ //$NON-NLS-2$ ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); Vector vctr = new Vector(); - addLongToVector(vctr, 0); + addLongToVector(vctr, 1); rpckt.setData(vectorToByte(vctr)); return rpckt; }else if (cpckt.getCommand() == 6){ @@ -2509,7 +2824,7 @@ //Location is 8 bytes (2 ints) //We pad with 4 bytes of zeros try{ - addLongToVector(vctr, jLoc.getLineNumber()); + addLongToVector(vctr, jLoc.getAddress().getAddress()); } catch(Exception exxy){ addLongToVector(vctr, -1); @@ -2591,6 +2906,57 @@ logr.log(JDILogger.LEVEL_VERBOSE, "0 frames and no thread found"); //$NON-NLS-1$ ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT); return rpckt; + }else if(cpckt.getCommand() == 8){ + // Monitor information + byte[] inData = cpckt.getByteData(); + long threadID = createLongFromBytes(inData, 0, 8); + logr.log(JDILogger.LEVEL_VERBOSE, "Thread.OwnedMonitors(" + threadID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + List ownedMonitors = new ArrayList(); + for (JavaMonitor jm : monitorMap.values()){ + JavaThread thr; + if ((thr = jm.getOwner())!= null){ + if (thr.getJNIEnv().getAddress() == threadID){ + ownedMonitors.add(jm.getObject()); + } + } + } + Vector vctr = new Vector(); + addIntToVector(vctr, ownedMonitors.size()); + for (JavaObject obj: ownedMonitors){ + vctr.add((byte)TAG_OBJECT); + addLongToVector(vctr, obj.getID().getAddress()); + logr.log(JDILogger.LEVEL_VERYVERBOSE, " Owns "+obj.getID().getAddress()); //$NON-NLS-1$ //$NON-NLS-2$ + } + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + }else if(cpckt.getCommand() == 9){ + // Monitor information + byte[] inData = cpckt.getByteData(); + long threadID = createLongFromBytes(inData, 0, 8); + logr.log(JDILogger.LEVEL_VERBOSE, "Thread.CurrentContendedMonitors(" + threadID + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + JavaMonitor contended = null; + for (JavaMonitor jm : monitorMap.values()){ + for (JavaThread thr: jm.getEnterWaiters()){ + if (thr.getJNIEnv().getAddress() == threadID){ + contended = jm; + } + } + } + + + Vector vctr = new Vector(); + if (contended == null){ + addLongToVector(vctr, 0); + }else{ + addIntToVector(vctr, (byte)TAG_OBJECT); + addLongToVector(vctr, contended.getObject().getID().getAddress()); + logr.log(JDILogger.LEVEL_VERYVERBOSE, " Contended on "+contended.getObject().getID().getAddress()); //$NON-NLS-1$ //$NON-NLS-2$ + } + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + }else if(cpckt.getCommand() == 12){ logr.log(JDILogger.LEVEL_VERBOSE, "SuspendCount()"); //$NON-NLS-1$ Vector vctr = new Vector(); @@ -2599,6 +2965,7 @@ 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; @@ -2638,7 +3005,7 @@ return rpckt; } logr.log(JDILogger.LEVEL_VERYVERBOSE, " array type: " + jObject.getJavaClass().getName()); //$NON-NLS-1$ - if (jObject.getJavaClass().getName().equals("[int")){ //$NON-NLS-1$ + if (jObject.getJavaClass().getName().equals("[I")){ //$NON-NLS-1$ int []jObjs = new int[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); if (jObjs != null){ @@ -2657,7 +3024,7 @@ rpckt.setData(vectorToByte(vctr)); return rpckt; } - }else if (jObject.getJavaClass().getName().equals("[float")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[F")){ //$NON-NLS-1$ float []jObjs = new float[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); if (jObjs != null){ @@ -2674,7 +3041,7 @@ return rpckt; } - }else if (jObject.getJavaClass().getName().equals("[short")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[S")){ //$NON-NLS-1$ short []jObjs = new short[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); if (jObjs != null){ @@ -2692,7 +3059,7 @@ return rpckt; } - }else if (jObject.getJavaClass().getName().equals("[long")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[J")){ //$NON-NLS-1$ long []jObjs = new long[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); if (jObjs != null){ @@ -2709,7 +3076,7 @@ return rpckt; } - }else if (jObject.getJavaClass().getName().equals("[byte")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[B")){ //$NON-NLS-1$ byte []jObjs = new byte[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); @@ -2726,7 +3093,7 @@ return rpckt; - }else if (jObject.getJavaClass().getName().equals("[boolean")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[Z")){ //$NON-NLS-1$ byte []jObjs = new byte[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); @@ -2743,7 +3110,7 @@ return rpckt; - }else if (jObject.getJavaClass().getName().equals("[double")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[D")){ //$NON-NLS-1$ double []jObjs = new double[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); @@ -2760,7 +3127,7 @@ return rpckt; - }else if (jObject.getJavaClass().getName().equals("[char")){ //$NON-NLS-1$ + }else if (jObject.getJavaClass().getName().equals("[C")){ //$NON-NLS-1$ char []jObjs = new char[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); @@ -2778,17 +3145,30 @@ return rpckt; - }else{ + } else{ JavaObject []jObjs = new JavaObject[length]; jObject.arraycopy(firstIndex, jObjs, 0, length); logr.log(JDILogger.LEVEL_VERYVERBOSE, " got " + jObjs.length + "objects"); //$NON-NLS-1$ //$NON-NLS-2$ Vector vctr = new Vector(); - vctr.add((byte)'L'); + + vctr.add((byte)TAG_ARRAY); + addIntToVector(vctr, jObjs.length); + + byte arrayTagType = (byte)TAG_OBJECT; + + String arrayName = jObject.getJavaClass().getName(); + if (arrayName.equals("[Ljava/lang/String;")){ + arrayTagType = (byte)TAG_STRING; + }else if ( arrayName.charAt(1) == '['){ + arrayTagType = (byte)TAG_ARRAY; + } + for(int i = 0; i < jObjs.length; i++){ + // Also check if it is an array of interfaces if (jObjs[i] != null){ - vctr.add((byte)'L'); + vctr.add(arrayTagType); addLongToVector(vctr, jObjs[i].getID().getAddress()); logr.log(JDILogger.LEVEL_VERYVERBOSE, " jObjs["+i+"] address " + jObjs[i].getID().getAddress()); //$NON-NLS-1$ //$NON-NLS-2$ logr.log(JDILogger.LEVEL_VERYVERBOSE, " jObjs["+i+"] type " + jObjs[i].getJavaClass().getName()); //$NON-NLS-1$ //$NON-NLS-2$ @@ -2798,6 +3178,9 @@ if (!classes.containsKey(jObjs[i].getJavaClass().getID().getAddress())){ logr.log(JDILogger.LEVEL_VERYVERBOSE, " Class is not of registered type"); //$NON-NLS-1$ } + }else{ + vctr.add((byte)TAG_OBJECT); + addLongToVector(vctr, 0); } } ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); @@ -2813,6 +3196,7 @@ 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; @@ -2841,7 +3225,12 @@ addIntToVector(vctr, LAST_ID++); rpckt.setData(vectorToByte(vctr)); return rpckt; + }else if (cpckt.getCommand() == 2){ + logr.log(JDILogger.LEVEL_VERBOSE, "Ignoring event request"); + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + 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; @@ -2889,13 +3278,14 @@ // Get slot number and type of each requested variable. GETVALUESLOTS: for (int i=0; i < slots; i++) { int slot = createIntFromBytes(inData, 20+5*i, 4); - byte type = inData[20+5*i+1]; + byte type = inData[20+5*i+4]; Object value = jFrame.getVariable(slot); - + logr.log(JDILogger.LEVEL_VERYVERBOSE, "OBJECT("+value+")"); switch(type) { case TAG_ARRAY: - long arrayAddress = -1L; + long arrayAddress = 0L; + vctr.add((byte)TAG_ARRAY); if (value instanceof JavaObject) { JavaObject obj = (JavaObject) value; if (obj.isArray()) { @@ -2907,7 +3297,7 @@ break; case TAG_BYTE: byte byteVal = -1; - + vctr.add((byte)TAG_BYTE); if (value instanceof Number) { Number num = (Number) value; byteVal = num.byteValue(); @@ -2917,7 +3307,7 @@ break; case TAG_CHAR: char charVal = (char) -1; - + vctr.add((byte)TAG_CHAR); if (value instanceof Character) { charVal = (Character) value; } @@ -2926,16 +3316,24 @@ break; case TAG_OBJECT: long objectAddress = -1L; + byte typeTag = (byte)TAG_OBJECT; + if (value instanceof JavaObject) { JavaObject obj = (JavaObject) value; - objectAddress = obj.getID().getAddress(); + objectAddress = obj.getID().getAddress(); + if (obj != null){ + if (obj.getJavaClass().getName().equals("java/lang/String")){ + typeTag = (byte)TAG_STRING; + } + } } + vctr.add(typeTag); logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " Object in slot=" + slot + " value="+objectAddress); addLongToVector(vctr, objectAddress ); break; case TAG_FLOAT: float floatVal = -1; - + vctr.add((byte)TAG_FLOAT); if (value instanceof Number) { Number num = (Number) value; floatVal = num.floatValue(); @@ -2945,7 +3343,7 @@ break; case TAG_DOUBLE: double doubleVal = -1; - + vctr.add((byte)TAG_DOUBLE); if (value instanceof Number) { Number num = (Number) value; doubleVal = num.doubleValue(); @@ -2956,7 +3354,7 @@ break; case TAG_INT: int intVal = -1; - + vctr.add((byte)TAG_INT); if (value instanceof Number) { Number num = (Number) value; intVal = num.intValue(); @@ -2966,7 +3364,7 @@ break; case TAG_LONG: long longVal = -1; - + vctr.add((byte)TAG_LONG); if (value instanceof Number) { Number num = (Number) value; longVal = num.longValue(); @@ -2977,7 +3375,7 @@ break; case TAG_SHORT: short shortVal = -1; - + vctr.add((byte)TAG_SHORT); if (value instanceof Number) { Number num = (Number) value; shortVal = num.shortValue(); @@ -2988,17 +3386,18 @@ break; case TAG_BOOLEAN: boolean booleanVal = false; - + vctr.add((byte)TAG_BOOLEAN); if (value instanceof Boolean) { booleanVal = ((Boolean) value); } logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " boolean in slot=" + slot + " value="+booleanVal); + vctr.add(booleanVal ? (byte) 1 : (byte) 0); break; case TAG_STRING: String stringVal= ""; - + vctr.add((byte)TAG_STRING); if (value instanceof JavaObject) { stringVal = javaObjectToString( (JavaObject) value); } @@ -3071,8 +3470,8 @@ JavaObject obj = (JavaObject) value; objectAddress = obj.getID().getAddress(); } - - logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " return this object value="+objectAddress); + vctr.add((byte)TAG_OBJECT); + logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " return this object value="+objectAddress+" "+value); addLongToVector(vctr, objectAddress ); } rpckt.setData(vectorToByte(vctr)); @@ -3090,11 +3489,74 @@ ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT); 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; } + private ReplyPacket threadGroupReference(CommandPacket cpckt) throws Exception{ + + if (cpckt.getCommand() == 1){ + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + Vector vctr = new Vector(); + addStringToVector(vctr, "All threads"); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + } else if (cpckt.getCommand() == 2){ + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + Vector vctr = new Vector(); + addLongToVector(vctr, 0); + rpckt.setData(vectorToByte(vctr)); + return rpckt; + } else if (cpckt.getCommand() == 3){ + logr.log(JDILogger.LEVEL_VERBOSE, "Returning all threads as single group"); //$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 vctr = new Vector(); + 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 + " id is "+thd.getObject().getID()) ; //$NON-NLS-1$ //$NON-NLS-2$ + addLongToVector(vctr, hash); + } + + } + addIntToVectorFront(vctr, count); + addIntToVector(vctr, 0); + ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE); + byte []barray2 = vectorToByte(vctr); + rpckt.setData(barray2); + 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; + } public boolean isOk(){ return (errorCode == 0);