Package javax.tools.diagnostics.runtime.java

Examples of javax.tools.diagnostics.runtime.java.JavaThread


            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();
View Full Code Here


            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();
View Full Code Here

      long object = createLongFromBytes(inData, 0, 8);
      Vector<Byte> vctr = new Vector<Byte>();
      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());
View Full Code Here

              Object tmpobj = thds.next();
              if (tmpobj instanceof CorruptData){
                //ignore this thread
              }else{
                count++;
                JavaThread thd = (JavaThread)tmpobj;
                if (thread == thd.getObject().getID().getAddress()){
                  Vector<Byte> vctr = new Vector<Byte>();
                  addStringToVector(vctr, thd.getName());
                  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_THREAD);
      return rpckt;
    }else if (cpckt.getCommand() == 2){
      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() == 3){
      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() == 4){
      byte []inData = cpckt.getByteData();
      long thread = createLongFromBytes(inData, 0, 8);
      logr.log(JDILogger.LEVEL_VERBOSE, "Status("+thread+")"); //$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();
            Vector<Byte> vctr = new Vector<Byte>();
            while(thds.hasNext()){
              Object tmpobj = thds.next();
              if (tmpobj instanceof CorruptData){
                //ignore this thread
              }else{
                JavaThread thd = (JavaThread) tmpobj;
                if (thd.getObject().getID().getAddress() == thread){
                  int threadStatus = 1;

                  logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread Status: "+thd.getState()); //$NON-NLS-1$
                  logr.log(JDILogger.LEVEL_VERYVERBOSE, "  Thread Name: " + thd.getName()); //$NON-NLS-1$
                  if ((thd.getState() & JavaThread.STATE_TERMINATED) > 0){
                    threadStatus = 0;
                    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is terminated"); //$NON-NLS-1$
                  }else if ((thd.getState() & JavaThread.STATE_SLEEPING) > 0){
                    threadStatus = 2;
                    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is sleeping"); //$NON-NLS-1$
                  }else if ((thd.getState() & JavaThread.STATE_IN_OBJECT_WAIT) > 0 || (thd.getState() & JavaThread.STATE_WAITING) > 0 || (thd.getState() & JavaThread.STATE_WAITING_INDEFINITELY) > 0 || (thd.getState() & JavaThread.STATE_WAITING_WITH_TIMEOUT) > 0){
                    threadStatus = 4;
                    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is waiting"); //$NON-NLS-1$
                  }else if ((thd.getState() & JavaThread.STATE_BLOCKED_ON_MONITOR_ENTER) > 0){
                    threadStatus = 3;
                    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is monitor"); //$NON-NLS-1$
                  }else{
                    threadStatus = 1;
                    logr.log(JDILogger.LEVEL_VERBOSE, "Thread is other (running)"); //$NON-NLS-1$
                    if ((thd.getState() & JavaThread.STATE_ALIVE) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is alive"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_IN_NATIVE) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is in native"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_PARKED) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is parked"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_INTERRUPTED) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is interrupted"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_VENDOR_1) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is vendor 1"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_VENDOR_3) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is vendor 2"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_VENDOR_2) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is vendor 3"); //$NON-NLS-1$
                    }
                    if ((thd.getState() & JavaThread.STATE_RUNNABLE) > 0){
                      logr.log(JDILogger.LEVEL_VERYVERBOSE, "Thread is runnable"); //$NON-NLS-1$
                    }


                  }
                  //The thread always starts in Eclipse as running
                  //Even if it isn't (See bug #161781)
                  int suspendStatus = 1;
                  threadStatus = 2;
                  addIntToVector(vctr, threadStatus);
                  addIntToVector(vctr, suspendStatus);
                  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() == 5){

      //ThreadGroup
      //This call returns the group of the input thread.
      //TODO - Since this doesn't seem available in Kato, 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<Byte> vctr = new Vector<Byte>();
      addLongToVector(vctr, 1);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    }else if (cpckt.getCommand() == 6){
      //List all the frames from the thread

      byte []inData = cpckt.getByteData();
      long thread = createLongFromBytes(inData, 0, 8);
      int startFrame = createIntFromBytes(inData, 8, 4);
      int length = createIntFromBytes(inData, 12, 4);
      logr.log(JDILogger.LEVEL_VERBOSE, "Frames(" + thread + "," + startFrame + "," + length + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$

      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() == thread){
                  int currentFrame = 0;
                  int count = 0;
                  Iterator frames = thd.getStackFrames().iterator();
                  Vector<Byte> vctr = new Vector<Byte>();
                  int count2 = 0;
                  while(frames.hasNext()){
                    count2++;
                    if (length > 0){
                      if (currentFrame >= startFrame && currentFrame <= startFrame + length){
                        JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                        addLongToVector(vctr, jStackFrame.getBasePointer().getAddress());

                        JavaLocation jLoc = jStackFrame.getLocation();

                        JavaMethod jMethod = jLoc.getMethod();

                        JavaClass jClass = jMethod.getDeclaringClass();

                        if (jClass.isArray()){
                          vctr.add((byte)3);
                        }else if(isInterface(jClass.getID().getAddress())){
                          vctr.add((byte)2);
                        }else{
                          vctr.add((byte)1);
                        }

                        addLongToVector(vctr, jClass.getID().getAddress());
                        addLongToVector(vctr, getMethodId(jClass.getID().getAddress(), jMethod));

                        //This is the current memory address.
                        addLongToVector(vctr, jLoc.getAddress().getAddress());
                        try{
                          logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + jLoc.getFilename() + "@" + jLoc.getMethod().getDeclaringClass().getName() + "{"+jLoc.getMethod().getDeclaringClass().getID().getAddress()+"}." + jLoc.getMethod().getName() + "{"+getMethodId(jClass.getID().getAddress(), jLoc.getMethod())+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                          try{
                            logr.log(JDILogger.LEVEL_VERYVERBOSE, "    :" + jLoc.getLineNumber()); //$NON-NLS-1$
                          }catch(Exception exxy){
                          }

                        }catch (Exception exxy){}
                        count++;
                      }
                    }else{
                      if (currentFrame >= startFrame){
                        JavaStackFrame jStackFrame = (JavaStackFrame)frames.next();
                        addLongToVector(vctr, jStackFrame.getBasePointer().getAddress());

                        JavaLocation jLoc = jStackFrame.getLocation();

                        JavaMethod jMethod = jLoc.getMethod();

                        JavaClass jClass = jMethod.getDeclaringClass();
                        if (jClass.isArray()){
                          vctr.add((byte)3);
                        }else if(isInterface(jClass.getID().getAddress())){
                          vctr.add((byte)2);
                        }else{
                          vctr.add((byte)1);
                        }

                        addLongToVector(vctr, jClass.getID().getAddress());
                        addLongToVector(vctr, getMethodId(jClass.getID().getAddress(), jMethod));

                        //Location is 8 bytes (2 ints)
                        //We pad with 4 bytes of zeros
                        try{
                          addLongToVector(vctr, jLoc.getAddress().getAddress());
                        }
                        catch(Exception exxy){
                          addLongToVector(vctr, -1);
                        }
                        try{
                          logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + jLoc.getFilename() + "@" + jLoc.getMethod().getDeclaringClass().getName() + "{"+jLoc.getMethod().getDeclaringClass().getID().getAddress()+"}." + jLoc.getMethod().getName() + "{"+getMethodId(jClass.getID().getAddress(),jLoc.getMethod())+"}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
                          try{
                            logr.log(JDILogger.LEVEL_VERYVERBOSE, "    :" + jLoc.getLineNumber()); //$NON-NLS-1$
                          }catch(Exception exxy){
                          }

                        }catch (Exception exxy){}

                        count++;
                      }
                    }
                  }
                  logr.log(JDILogger.LEVEL_VERYVERBOSE, count + " frames found (of " +count2 + ")"); //$NON-NLS-1$ //$NON-NLS-2$
                  ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
                  addIntToVectorFront(vctr, count);
                  rpckt.setData(vectorToByte(vctr));
                  return rpckt;

                }
              }
            }
          }
        }
      }
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_INVALID_OBJECT);
      return rpckt;
    }else if (cpckt.getCommand() == 7){
      //List all the frames from the thread

      byte []inData = cpckt.getByteData();
      long thread = createLongFromBytes(inData, 0, 8);
      logr.log(JDILogger.LEVEL_VERBOSE, "FrameCount(" + thread + ")"); //$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;
                if (thd.getObject().getID().getAddress() == thread){
                  int count = 0;
                  Iterator frames = thd.getStackFrames().iterator();
                  Vector<Byte> vctr = new Vector<Byte>();
                  while(frames.hasNext()){
                    frames.next();
                    count++;
                  }
                  logr.log(JDILogger.LEVEL_VERYVERBOSE, count + " frames found"); //$NON-NLS-1$
                  ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
                  addIntToVector(vctr, count);
                  rpckt.setData(vectorToByte(vctr));
                  return rpckt;

                }
              }
            }
          }
        }
      }
      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<JavaObject> ownedMonitors = new ArrayList<JavaObject>();
      for (JavaMonitor jm : monitorMap.values()){
        JavaThread thr;
        if ((thr = jm.getOwner())!= null){
          if (thr.getJNIEnv().getAddress() == threadID){
            ownedMonitors.add(jm.getObject());
          }
        }
      }
      Vector<Byte> vctr = new Vector<Byte>();
      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;
          }
        }
      }
     
View Full Code Here

            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){
//                      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>();
View Full Code Here

              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);
View Full Code Here

      {
        JavaRuntime jr = (JavaRuntime)mr;
        Iterator itThread = jr.getThreads().iterator();
       
        while (itThread.hasNext()) {
          JavaThread jt = (JavaThread)itThread.next();
          String currID;

          try {
            ImageThread it = jt.getImageThread()
            currID = it.getID();
          } catch (DiagnosticException e) {
            currID = null;
          }
         
View Full Code Here

    Iterator itMonitor = jr.getMonitors().iterator();
    while (itMonitor.hasNext()) {
      JavaMonitor jm = (JavaMonitor)itMonitor.next();
      Iterator itEnterWaiter = jm.getEnterWaiters().iterator();
      while (itEnterWaiter.hasNext()) {
        JavaThread jt = (JavaThread)itEnterWaiter.next();
        monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_ENTER));
      }
      Iterator itNotifyWaiter = jm.getNotifyWaiters().iterator();
      while (itNotifyWaiter.hasNext()) {
        JavaThread jt = (JavaThread)itNotifyWaiter.next();
        monitors.put(jt, new MonitorState(jm, MonitorState.WAITING_TO_BE_NOTIFIED_ON));
      }
    }
   
    return monitors;
View Full Code Here

    for (Object nextThread : runtime.getThreads()) {
      if (nextThread instanceof CorruptData) {
        continue;
      }
     
      JavaThread thread = (JavaThread) nextThread;
     
      // Iterate over all frames. If method is in passed class, add it to the list.
  FRAMES:  for (Object nextFrame : thread.getStackFrames()) {
        if (nextFrame instanceof CorruptData) {
          continue;
        }
       
        JavaStackFrame frame = (JavaStackFrame) nextFrame;
View Full Code Here

   
    do {
      String name = "";
      String objAddr = "";
      JavaObject object = null;
      JavaThread owner = null;
     
      try {
        owner = currNode.getMonitor().getOwner();
      } catch (CorruptDataException e) {
        name = Exceptions.getCorruptDataExceptionString() + " in owner";
      }

      if (name.equals("")) {
        try {
          name = owner.getName();
        } catch (CorruptDataException e) {
          name = Exceptions.getCorruptDataExceptionString() + " in owner's ID";
        }
      }
     
View Full Code Here

TOP

Related Classes of javax.tools.diagnostics.runtime.java.JavaThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.