Search in sources :

Example 16 with Image

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

the class ImageCreator method createProcessImage.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.tck.api.IImageCreator#createProcessImage(com.ibm.dtfj.tck.api.TCKConfiguration)
	 */
public Image createProcessImage(TCKConfiguration conf) throws IOException {
    fixClassPath();
    String systemDump = System.getProperty("system.dump");
    if (systemDump == null) {
        throw new IllegalArgumentException("You need to specify a system dump with -Dsystem.dump=");
    }
    J9DDRImageFactory factory = new J9DDRImageFactory();
    Image image = factory.getImage(new File(systemDump));
    if (null == image) {
        throw new IOException("Cannot get DTFJ image from " + systemDump);
    }
    return image;
}
Also used : IOException(java.io.IOException) Image(com.ibm.dtfj.image.Image) File(java.io.File) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)

Example 17 with Image

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

the class JExtractXMLGenerator method getRuntime.

@SuppressWarnings("unchecked")
private JavaRuntime getRuntime() throws Exception {
    ImageFactory factory = new J9DDRImageFactory();
    File core = new File(opts.get(OPT_CORE_FILE));
    if (core.exists()) {
        Image image = factory.getImage(core);
        for (Iterator spaces = image.getAddressSpaces(); spaces.hasNext(); ) {
            Object space = spaces.next();
            if (!(space instanceof CorruptData)) {
                for (Iterator processes = ((ImageAddressSpace) space).getProcesses(); processes.hasNext(); ) {
                    Object process = processes.next();
                    if (!(process instanceof CorruptData)) {
                        for (Iterator runtimes = ((ImageProcess) process).getRuntimes(); runtimes.hasNext(); ) {
                            Object runtime = runtimes.next();
                            if (runtime instanceof JavaRuntime) {
                                return (JavaRuntime) runtime;
                            }
                        }
                    }
                }
            }
        }
        writeComment("Could not find Java runtime in core file");
        throw new IllegalArgumentException("Could not find Java runtime");
    } else {
        throw new IllegalArgumentException("The specified core file : " + core.getAbsolutePath() + " does not exist");
    }
}
Also used : J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) ImageFactory(com.ibm.dtfj.image.ImageFactory) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.CorruptData) Image(com.ibm.dtfj.image.Image) File(java.io.File) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)

Example 18 with Image

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

the class DTFJUnitTest method buildContext.

private static TestContext buildContext(ImageFactory imageFactory, File coreFile) throws IOException {
    TestContext ctx = new DTFJUnitTest.TestContext();
    Image image = imageFactory.getImage(coreFile);
    ctx.setImage(image);
    Iterator<?> addressSpaceIt = image.getAddressSpaces();
    while (addressSpaceIt.hasNext()) {
        Object asObj = addressSpaceIt.next();
        if (asObj instanceof CorruptData) {
            System.err.println("Corrupt AddressSpace returned: " + asObj);
        } else if (asObj instanceof ImageAddressSpace) {
            ImageAddressSpace as = (ImageAddressSpace) asObj;
            ctx.setSpace(as);
            Iterator<?> processIterator = as.getProcesses();
            while (processIterator.hasNext()) {
                Object processObj = processIterator.next();
                if (processObj instanceof CorruptData) {
                    System.err.println("Corrupt ImageProcess returned: " + asObj);
                } else if (processObj instanceof ImageProcess) {
                    ImageProcess process = (ImageProcess) processObj;
                    ctx.setProcess(process);
                    Iterator<?> runtimeIterator = process.getRuntimes();
                    while (runtimeIterator.hasNext()) {
                        Object runtimeObj = runtimeIterator.next();
                        if (runtimeObj instanceof CorruptData) {
                            System.err.println("Corrupt ImageProcess returned: " + asObj);
                        } else if (runtimeObj instanceof JavaRuntime) {
                            JavaRuntime runtime = (JavaRuntime) runtimeObj;
                            ctx.setRuntime(runtime);
                            return ctx;
                        } else {
                            throw new ClassCastException("Unexpected type from Runtime iterator: " + runtimeObj.getClass() + ": " + runtimeObj);
                        }
                    }
                } else {
                    throw new ClassCastException("Unexpected type from Process iterator: " + processObj.getClass() + ": " + processObj);
                }
            }
        } else {
            throw new ClassCastException("Unexpected type from AddressSpace iterator: " + asObj.getClass() + ": " + asObj);
        }
    }
    throw new RuntimeException("Could not find a Java Runtime");
}
Also used : ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) CorruptData(com.ibm.dtfj.image.CorruptData) Image(com.ibm.dtfj.image.Image)

Example 19 with Image

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

the class ImageTest method getProcessorSubTypeTest.

@Test
public void getProcessorSubTypeTest() {
    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.PROCESSOR_SUB_TYPE);
    }
}
Also used : Image(com.ibm.dtfj.image.Image) Test(org.junit.Test)

Example 20 with Image

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

the class ImageTest method getSystemSubTypeTest.

@Test
public void getSystemSubTypeTest() {
    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_SUB_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