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>();
JavaObject obj = javaClass.getClassLoader().getObject();
long address = 0L;
if (obj != null) {
address = obj.getID().getAddress();
}
addLongToVector(vctr, address);
logr.log(JDILogger.LEVEL_VERYVERBOSE, " 0x" + Long.toHexString(address) ); //$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++;