Search in sources :

Example 1 with Image

use of com.ibm.dtfj.image.Image in project openj9 by eclipse.

the class JCImageFactory method getImage.

/**
 */
public Image getImage(File arg0) throws IOException {
    InputStream stream = new FileInputStream(arg0);
    try {
        Image image = new JavaCoreReader(new ImageBuilderFactory()).generateImage(stream);
        // following cast is safe since examining the code path from generateImage
        // shows that what comes back can only be the JCImage from
        // com.ibm.dtfj.javacore.builder.javacore.ImageBuilder, instance variable _fImage
        ((JCImage) image).setSource(arg0.toURI());
        return image;
    } finally {
        stream.close();
    }
}
Also used : JavaCoreReader(com.ibm.dtfj.javacore.parser.j9.JavaCoreReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) ImageBuilderFactory(com.ibm.dtfj.javacore.builder.javacore.ImageBuilderFactory) Image(com.ibm.dtfj.image.Image) FileInputStream(java.io.FileInputStream)

Example 2 with Image

use of com.ibm.dtfj.image.Image in project openj9 by eclipse.

the class JCImageFactory method getImage.

public Image getImage(final ImageInputStream in, URI sourceID) throws IOException {
    InputStream stream = new InputStream() {

        public int read() throws IOException {
            return in.read();
        }
    };
    try {
        Image image = new JavaCoreReader(new ImageBuilderFactory()).generateImage(stream);
        ((JCImage) image).setSource(sourceID);
        return image;
    } finally {
        in.close();
    }
}
Also used : JavaCoreReader(com.ibm.dtfj.javacore.parser.j9.JavaCoreReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) ImageBuilderFactory(com.ibm.dtfj.javacore.builder.javacore.ImageBuilderFactory) Image(com.ibm.dtfj.image.Image)

Example 3 with Image

use of com.ibm.dtfj.image.Image in project openj9 by eclipse.

the class DTFJWalker method walkCoreFile.

public void walkCoreFile(File file) {
    // the factory will have to be on the classpath as it is in the same jar as this class
    J9DDRImageFactory factory = new J9DDRImageFactory();
    Image image = null;
    try {
        image = factory.getImage(file);
    } catch (IOException e) {
        System.err.println("Failed to create an Image from the core file : " + e.getMessage());
        logger.log(Level.WARNING, "Failed to create Image from core file", e);
        return;
    }
    try {
        Method iterator = image.getClass().getDeclaredMethod("getAddressSpaces", (Class[]) null);
        iterate(image, iterator, 100);
    } catch (Exception e) {
        System.err.println("Failed to get address space iterator method : " + e.getMessage());
        logger.log(Level.WARNING, "Failed to get address space iterator method", e);
        return;
    }
    System.out.println("Walk complete");
    showResults();
}
Also used : IOException(java.io.IOException) Method(java.lang.reflect.Method) Image(com.ibm.dtfj.image.Image) IOException(java.io.IOException) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)

Example 4 with Image

use of com.ibm.dtfj.image.Image in project openj9 by eclipse.

the class PHDImageFactory method getImage.

public Image getImage(ImageInputStream in, ImageInputStream meta, URI sourceID) throws IOException {
    ImageFactory metaFactory = getMetaFactory();
    Image metaImage = metaFactory.getImage(meta, sourceID);
    return new PHDImage(sourceID, in, metaImage);
}
Also used : ImageFactory(com.ibm.dtfj.image.ImageFactory) Image(com.ibm.dtfj.image.Image)

Example 5 with Image

use of com.ibm.dtfj.image.Image in project openj9 by eclipse.

the class ImageTest method getSystemTypeTest.

@Test
public void getSystemTypeTest() {
    for (int i = 0; i != ddrTestObjects.size(); i++) {
        Image ddrImg = (Image) ddrTestObjects.get(i);
        Image jextractImg = (Image) jextractTestObjects.get(i);
        imageComparator.testEquals(ddrImg, jextractImg, ImageComparator.SYSTEM_TYPE);
    }
}
Also used : Image(com.ibm.dtfj.image.Image) Test(org.junit.Test)

Aggregations

Image (com.ibm.dtfj.image.Image)27 Test (org.junit.Test)10 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)7 ImageFactory (com.ibm.dtfj.image.ImageFactory)7 File (java.io.File)7 ImageProcess (com.ibm.dtfj.image.ImageProcess)6 J9DDRImageFactory (com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)6 IOException (java.io.IOException)6 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)5 Iterator (java.util.Iterator)4 ImageInputStream (javax.imageio.stream.ImageInputStream)4 CorruptData (com.ibm.dtfj.image.CorruptData)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 ImageModule (com.ibm.dtfj.image.ImageModule)2 ImageBuilderFactory (com.ibm.dtfj.javacore.builder.javacore.ImageBuilderFactory)2 JavaCoreReader (com.ibm.dtfj.javacore.parser.j9.JavaCoreReader)2 FileNotFoundException (java.io.FileNotFoundException)2 ICoreFileReader (com.ibm.dtfj.corereaders.ICoreFileReader)1