Package javax.tools.diagnostics.image

Examples of javax.tools.diagnostics.image.ImageAddressSpace


    return factory.getImage(getPopulatedHProfFile());
   
  }
  protected ImageAddressSpace getFirstAddressSpace() throws IOException {
    Image minimal=getMinimalImage();
    ImageAddressSpace space=(ImageAddressSpace)minimal.getAddressSpaces().get(0);
    return space;
  }
View Full Code Here


    return space;
  }

  protected ImageProcess getCurrentProcess() throws IOException {
   
    ImageAddressSpace space=getFirstAddressSpace();
    return space.getCurrentProcess();
   
  }
View Full Code Here

    return (JavaRuntime) getCurrentProcess().getRuntimes().get(0);
  }

protected JavaHeap getPopulatedJavaHeap() throws IOException {
  Image populated=getPopulatedImage();
  ImageAddressSpace space=(ImageAddressSpace)populated.getAddressSpaces().get(0);
  ImageProcess process=space.getCurrentProcess();
  JavaRuntime rt=(JavaRuntime) process.getRuntimes().get(0);
  return (JavaHeap) rt.getHeaps().get(0);
  
}
View Full Code Here

   */
  public void testGetObjectAtAddress()
  {
    JavaHeap heap = defaultJavaHeap();
    JavaRuntime runtime = defaultJavaRuntime();
    ImageAddressSpace addressSpace = defaultAddressSpace();
    ImagePointer address=null;
    ImagePointer unalignedAddress=null;
    Iterator heapSections = heap.getSections().iterator();


    //determine the heap start and end address
    long heapStartAddress = Long.MAX_VALUE;
    long heapEndAddress = 0;

    Object nextElement = null;

    ImageSection currentSection = null;
    long sectionStart = 0;

    while (heapSections.hasNext()) {
      nextElement = heapSections.next();
      if (nextElement instanceof ImageSection) {
        currentSection = (ImageSection) nextElement;
        sectionStart = currentSection.getBaseAddress().getAddress();
        if (sectionStart < heapStartAddress) {
          heapStartAddress = sectionStart;
        }
        if (sectionStart + currentSection.getSize() > heapEndAddress) {
          heapEndAddress = sectionStart + currentSection.getSize();
        }

      }

    }

    //check that every object in the heap can be retrieved by address
    boolean exception=false;
    for (Iterator objects = heap.getObjects().iterator();objects.hasNext();) {
      Object potentialObject = objects.next();
      JavaObject object = null;
      if (potentialObject instanceof JavaObject) {
        object = (JavaObject)potentialObject;
      } else {
        continue;
      }
      address=(ImagePointer)object.getID();
      try {
        runtime.getObjectAtAddress(address).getJavaClass();
        if (unalignedAddress == null) {
          unalignedAddress = address.add(1);
        }
      } catch (Exception e) {
        e.printStackTrace();
        exception=true;
        break;
      }

    }
    assertFalse(exception);


    // Check an address BEFORE the start of the heap. For some JVMs, off-heap objects are supported
    exception=false;
    try {
      long addr1 = ((heapStartAddress-1000) & (Long.MAX_VALUE-7L));
      runtime.getObjectAtAddress(addressSpace.getPointer(addr1));
    } catch (IllegalArgumentException e) {
            e.printStackTrace();
      exception=true;
    } catch (Exception e) {
    }
View Full Code Here

  }
  private ImageProcess getProcess() {
   
    Image image=getImage();
    Iterator addressIterator=image.getAddressSpaces().iterator();
    ImageAddressSpace addressSpace=(ImageAddressSpace) addressIterator.next();
    ImageProcess process=addressSpace.getCurrentProcess();
    return process;
  }
View Full Code Here

  private HashMap<Long, JavaMonitor> buildMonitors(){
    HashMap<Long, JavaMonitor> monitors = new HashMap<Long, JavaMonitor>();
    Iterator asIt = image.getAddressSpaces( ).iterator();
    while ( asIt.hasNext( ) )
    {
      ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
      Iterator prIt = as.getProcesses( ).iterator();
      while ( prIt.hasNext( ) ){
        ImageProcess process = (ImageProcess) prIt.next( );

        Iterator runTimesIt = process.getRuntimes( ).iterator();
        while ( runTimesIt.hasNext( ) )
View Full Code Here

    logr.log(JDILogger.LEVEL_VERYVERBOSE, "Building class list"); //$NON-NLS-1$
    HashMap<Long, JavaClass> classes = new HashMap<Long, JavaClass>();
    Iterator asIt = image.getAddressSpaces( ).iterator();
    while ( asIt.hasNext( ) )
    {
      ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
      Iterator prIt = as.getProcesses( ).iterator();
      while ( prIt.hasNext( ) ){
        ImageProcess process = (ImageProcess) prIt.next( );

        Iterator runTimesIt = process.getRuntimes( ).iterator();
        while ( runTimesIt.hasNext( ) )
View Full Code Here

  private int findLowestLineRef(long refType, long methodID) throws Exception{
    int lowest = 1999999999;
    Iterator asIt = image.getAddressSpaces( ).iterator();
    while ( asIt.hasNext( ) )
    {
      ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
      Iterator prIt = as.getProcesses( ).iterator();

      while ( prIt.hasNext( ) )
      {
        ImageProcess process = (ImageProcess) prIt.next( );
        Iterator runTimesIt = process.getRuntimes( ).iterator();
View Full Code Here

  private int findHighestLineRef(long refType, long methodID) throws Exception{
    int highest = 0;
    Iterator asIt = image.getAddressSpaces( ).iterator();
    while ( asIt.hasNext( ) )
    {
      ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
      Iterator prIt = as.getProcesses( ).iterator();

      while ( prIt.hasNext( ) )
      {
        ImageProcess process = (ImageProcess) prIt.next( );
        Iterator runTimesIt = process.getRuntimes( ).iterator();
View Full Code Here

    if (cpckt.getCommand() == VIRTUAL_MACHINE_VERSION){
      logr.log(JDILogger.LEVEL_VERBOSE, "Version()"); //$NON-NLS-1$
      Iterator asIt = image.getAddressSpaces( ).iterator();
      while ( asIt.hasNext( ) )
      {
        ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
        Iterator prIt = as.getProcesses( ).iterator();
        while ( prIt.hasNext( ) ){
          ImageProcess process = (ImageProcess) prIt.next( );

          Iterator runTimesIt = process.getRuntimes( ).iterator();
          while ( runTimesIt.hasNext( ) )
          {
            JavaRuntime javaRT = (JavaRuntime) runTimesIt.next( );
            //Since there doesn't seem to be a matching Kato call to get
            //the information for JDWP, lets call NOT_IMPLEMENTED, but really
            //attach some information back
            ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
            String description = "JDI Post Mortem Debugger"; //$NON-NLS-1$
            String vmVersion = javaRT.getVersion();
            String vmName = "JDI PMD"; //$NON-NLS-1$

            int jdwpMajor = 1;
            int jdwpMinor = 4;

            //We now have all the information for the reply.  Put it all together
            Vector<Byte> vctr = new Vector<Byte>();
            addStringToVector(vctr, description);
            addIntToVector(vctr, jdwpMajor);
            addIntToVector(vctr, jdwpMinor);
            addStringToVector(vctr, vmVersion);
            addStringToVector(vctr, vmName);
            rpckt.setData(vectorToByte(vctr));
            return rpckt;

          }
        }
      }

    }else if (cpckt.getCommand() == VIRTUAL_MACHINE_CLASS_PATHS){
     
      logr.log(JDILogger.LEVEL_VERYVERBOSE, "This does not return the actual class path, simply allows JDB to work.");
      Vector<Byte> vctr = new Vector<Byte>();
      addStringToVector(vctr, "");
      addIntToVector(vctr, 0);
      addIntToVector(vctr, 0);
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    } else if (cpckt.getCommand() == VIRTUAL_MACHINE_CLASSES_BY_SIGNATURE){
      Vector<Byte> vctr = new Vector<Byte>();
      byte []inData = cpckt.getByteData();
      String signature = getStringFromBytes(inData, 0);
      if (signature.charAt(0) == 'L'){
        signature = signature.substring(1, signature.length() - 1);
      }
      logr.log(JDILogger.LEVEL_VERBOSE, "ClassesBySignature(" + signature + ")"); //$NON-NLS-1$ //$NON-NLS-2$
      int count = 0;
      Iterator <JavaClass> javaClasses = classes.values().iterator();
      while (javaClasses.hasNext()){
        JavaClass javaClass = javaClasses.next();
        String searched = javaClass.getName();

        if (searched.equals(signature)){
          count++;
          if (javaClass.isArray()){
            vctr.add((byte)3);
          }else if (isInterface(javaClass.getID().getAddress())){
            vctr.add((byte)2);
          }else{
            vctr.add((byte)1);
          }
          //vctr.add((byte)1);
          addLongToVector(vctr, javaClass.getID().getAddress());
          //Verified Prepared and Initialized
          addIntToVector(vctr, 1 | 2 | 4);
          logr.log(JDILogger.LEVEL_VERYVERBOSE, "Match: " + javaClass.getName() +" " + Long.toHexString(javaClass.getID().getAddress())); //$NON-NLS-1$
        }else{
          String mangledName = "" + searched + ""; //$NON-NLS-1$ //$NON-NLS-2$
          if (mangledName.equals(signature)){
            count++;
            if (javaClass.isArray()){
              vctr.add((byte)3);
            }else if (isInterface(javaClass.getID().getAddress())){
              vctr.add((byte)2);
            }else{
              vctr.add((byte)1);
            }
            //vctr.add((byte)1);
            addLongToVector(vctr, javaClass.getID().getAddress());
            //Verified Prepared and Initialized
            addIntToVector(vctr, 1 | 2 | 4);
            logr.log(JDILogger.LEVEL_VERYVERBOSE, "Mangled Match: " + javaClass.getName()); //$NON-NLS-1$
          }else{
            String secondMangle = "[" + searched + ";"; //$NON-NLS-1$ //$NON-NLS-2$
            if (secondMangle.equals(signature)){
              count++;
              if (javaClass.isArray()){
                vctr.add((byte)3);
              }else if (isInterface(javaClass.getID().getAddress())){
                vctr.add((byte)2);
              }else{
                vctr.add((byte)1);
              }
              //vctr.add((byte)1);
              addLongToVector(vctr, javaClass.getID().getAddress());
              //Verified Prepared and Initialized
              addIntToVector(vctr, 1 | 2 | 4);
              logr.log(JDILogger.LEVEL_VERYVERBOSE, "Really mangled match: " + javaClass.getName()); //$NON-NLS-1$
            }
          }
        }

      }
      //Add the count to the front of the vector
      addIntToVectorFront(vctr, count);
      logr.log(JDILogger.LEVEL_VERYVERBOSE, count+" matches"); //$NON-NLS-1$
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    }else if (cpckt.getCommand() == VIRTUAL_MACHINE_ALL_CLASSES){
      logr.log(JDILogger.LEVEL_VERBOSE, "AllClasses()"); //$NON-NLS-1$
      Vector<Byte> vctr = new Vector<Byte>();
      int count = 0;
      Iterator <JavaClass> classList = classes.values().iterator();
      while(classList.hasNext()){
        JavaClass javaClass = (JavaClass)classList.next();
        long typeID = javaClass.getID().getAddress();
        String signature;

        if (javaClass.isArray()){
          vctr.add((byte)3);
          signature = "" + javaClass.getName() + ""; //$NON-NLS-1$ //$NON-NLS-2$
        }else if (isInterface(typeID)){
          vctr.add((byte)2);
          signature = "L" + javaClass.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$
        }else{
          vctr.add((byte)1);
          signature = "L" + javaClass.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$
        }
       
        int status = 7;
        addLongToVector(vctr, typeID);
        addStringToVector(vctr, signature);
        addIntToVector(vctr, status);
        count++;
       

      }

      logr.log(JDILogger.LEVEL_VERYVERBOSE, "  " + count +" class(es) found"); //$NON-NLS-1$ //$NON-NLS-2$
      addIntToVectorFront(vctr, count);
      ReplyPacket rpckt = new ReplyPacket(cpckt.getSequence(), FLAG_REPLY_PACKET, ERROR_NONE);
      rpckt.setData(vectorToByte(vctr));
      return rpckt;
    }else if (cpckt.getCommand() == VIRTUAL_MACHINE_ALL_THREADS){
      logr.log(JDILogger.LEVEL_VERBOSE, "AllThreads()"); //$NON-NLS-1$
      Iterator asIt = image.getAddressSpaces( ).iterator();
      while ( asIt.hasNext( ) )
      {
        ImageAddressSpace as = (ImageAddressSpace) asIt.next( );
        Iterator prIt = as.getProcesses( ).iterator();

        while ( prIt.hasNext( ) )
        {
          ImageProcess process = (ImageProcess) prIt.next( );
          Iterator runTimesIt = process.getRuntimes( ).iterator();
View Full Code Here

TOP

Related Classes of javax.tools.diagnostics.image.ImageAddressSpace

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.