Search in sources :

Example 26 with Image

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

the class PHDImageFactory method getMetaImage.

private Image getMetaImage(File file, File metaFile) throws IOException, FileNotFoundException {
    ImageFactory metaFactory = getMetaFactory();
    Image i2;
    try {
        i2 = metaFactory.getImage(metaFile);
    } catch (RuntimeException e) {
        // javacore reader isn't that robust
        FileNotFoundException ex = new FileNotFoundException(MessageFormat.format("Problem opening dump {0} metafile {1}", file, metaFile));
        ex.initCause(e);
        throw ex;
    }
    return i2;
}
Also used : ImageFactory(com.ibm.dtfj.image.ImageFactory) FileNotFoundException(java.io.FileNotFoundException) Image(com.ibm.dtfj.image.Image)

Example 27 with Image

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

the class OpenCommand method imagesFromCommandLine.

/**
 * Creates a DTFJ image from the supplied core or zip file
 */
private void imagesFromCommandLine(String[] args) {
    apiLevelMajor = factory.getDTFJMajorVersion();
    apiLevelMinor = factory.getDTFJMinorVersion();
    out.println(Version.getAllVersionInfo(factory));
    out.println("Loading image from DTFJ...\n");
    try {
        // default to a single image
        Image[] images = new Image[1];
        if (ctx.hasPropertyBeenSet(VERBOSE_MODE_PROPERTY)) {
            // If we are using DDR this will enable warnings.
            // (If not it's irrelevant.)
            Logger.getLogger("j9ddr.view.dtfj").setLevel(Level.WARNING);
        }
        // at this point the existence of either -core or -zip has been checked
        long current = System.currentTimeMillis();
        File file1 = new File(args[0]);
        if (args.length == 1) {
            if (FileManager.isArchive(file1) && !ctx.hasPropertyBeenSet(LEGACY_ZIP_MODE_PROPERTY)) {
                images = factory.getImagesFromArchive(file1, ctx.hasPropertyBeenSet(EXTRACT_PROPERTY));
            } else {
                images[0] = factory.getImage(file1);
            }
        } else {
            File file2 = new File(args[1]);
            images[0] = factory.getImage(file1, file2);
        }
        logger.fine(String.format("Time taken to load image %d ms", System.currentTimeMillis() - current));
        for (Image image : images) {
            createContexts(image, args[0]);
        }
    } catch (IOException e) {
        out.println("Could not load dump file and/or could not load XML file: " + e.getMessage());
        if (ctx.hasPropertyBeenSet(VERBOSE_MODE_PROPERTY)) {
            e.printStackTrace();
        }
    }
}
Also used : IOException(java.io.IOException) Image(com.ibm.dtfj.image.Image) File(java.io.File)

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