JavaThread thd = (JavaThread) tmpobj;
if (thd.getObject().getID().getAddress() == threadID){
Iterator frames = thd.getStackFrames().iterator();
while(frames.hasNext()){
JavaStackFrame jFrame = (JavaStackFrame)frames.next();
if (jFrame.getBasePointer().getAddress() == frameID){
// vctr.add((byte)'L');
// addLongToVector(vctr,jFrame.getLocation().getMethod().getDeclaringClass().getID().getAddress());
// logr.log(JDILogger.LEVEL_VERBOSE, " " + jFrame.getLocation().getMethod().getDeclaringClass().getID().getAddress()); //$NON-NLS-1$
// 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+4];
Object value = jFrame.getVariable(slot);
logr.log(JDILogger.LEVEL_VERYVERBOSE, "OBJECT("+value+")");
switch(type) {
case TAG_ARRAY:
long arrayAddress = 0L;
vctr.add((byte)TAG_ARRAY);
if (value instanceof JavaObject) {
JavaObject obj = (JavaObject) value;
if (obj.isArray()) {
arrayAddress = obj.getID().getAddress();
}
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " Array in slot=" + slot + " value="+arrayAddress);
addLongToVector(vctr, arrayAddress );
break;
case TAG_BYTE:
byte byteVal = -1;
vctr.add((byte)TAG_BYTE);
if (value instanceof Number) {
Number num = (Number) value;
byteVal = num.byteValue();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " byte in slot=" + slot + " value="+byteVal);
vctr.add(byteVal);
break;
case TAG_CHAR:
char charVal = (char) -1;
vctr.add((byte)TAG_CHAR);
if (value instanceof Character) {
charVal = (Character) value;
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " byte in slot=" + slot + " value="+charVal);
addCharToVector(vctr, charVal);
break;
case TAG_OBJECT:
long objectAddress = 0L;
byte typeTag = (byte)TAG_OBJECT;
if (value instanceof JavaObject) {
JavaObject obj = (JavaObject) value;
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();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " float in slot=" + slot + " value="+floatVal);
addIntToVector(vctr, Float.floatToIntBits(floatVal));
break;
case TAG_DOUBLE:
double doubleVal = -1;
vctr.add((byte)TAG_DOUBLE);
if (value instanceof Number) {
Number num = (Number) value;
doubleVal = num.doubleValue();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " double in slot=" + slot + " value="+doubleVal);
addLongToVector(vctr, Double.doubleToLongBits(doubleVal));
break;
case TAG_INT:
int intVal = -1;
vctr.add((byte)TAG_INT);
if (value instanceof Number) {
Number num = (Number) value;
intVal = num.intValue();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " int in slot=" + slot + " value="+intVal);
addIntToVector(vctr, intVal);
break;
case TAG_LONG:
long longVal = -1;
vctr.add((byte)TAG_LONG);
if (value instanceof Number) {
Number num = (Number) value;
longVal = num.longValue();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " long in slot=" + slot + " value="+longVal);
addLongToVector(vctr, longVal);
break;
case TAG_SHORT:
short shortVal = -1;
vctr.add((byte)TAG_SHORT);
if (value instanceof Number) {
Number num = (Number) value;
shortVal = num.shortValue();
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " short in slot=" + slot + " value="+shortVal);
addShortToVector(vctr, shortVal);
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);
}
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " string in slot=" + slot + " value=\""+stringVal+"\"");
addStringToVector(vctr, stringVal);
break;
default:
logr.log(JDILogger.LEVEL_VERBOSE, " " +jFrame.getLocation() + " unable to handle type "+type+" in "+jFrame.getLocation());
rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
vctr = new Vector<Byte>();
break GETVALUESLOTS;
}
}
}
}
}
}
}
}
}
}
rpckt.setData(vectorToByte(vctr));
return rpckt;
}else if (cpckt.getCommand() == 3){
byte []inData = cpckt.getByteData();
long threadID = createLongFromBytes(inData, 0, 8);
long frameID = createLongFromBytes(inData, 8, 8);
//TODO - Get this to work
logr.log(JDILogger.LEVEL_VERBOSE, "ThisObject(" + threadID + "," + frameID + ")"); //$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;
if (thd.getObject().getID().getAddress() == threadID){
Iterator frames = thd.getStackFrames().iterator();
while(frames.hasNext()){
JavaStackFrame jFrame = (JavaStackFrame)frames.next();
if (jFrame.getBasePointer().getAddress() == frameID){
Vector<Byte> vctr = new Vector<Byte>();
ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
if ((jFrame.getLocation().getMethod().getModifiers() & Modifier.STATIC) !=0) {
addLongToVector(vctr, 0); // Return null as static method.
} else {
Object value = jFrame.getVariable(0);
long objectAddress = 0;
if (value != null && value instanceof JavaObject) {
JavaObject obj = (JavaObject) value;
objectAddress = obj.getID().getAddress();
}
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));
return rpckt;
}