Search in sources :

Example 6 with Image

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

the class ImageTest method getProcessorCountTest.

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

Example 7 with Image

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

the class ImageTest method getIPAddressesTest.

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

Example 8 with Image

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

the class ImageTest method getCreationTimeTest.

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

Example 9 with Image

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

the class ImageTest method getProcessorTypeTest.

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

Example 10 with Image

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

the class DDRLibraryAdapter method constructLibraryList.

/**
 * Constructs the list of libraries required using the DDR implementation of the DTFJ Image* API.
 * This ensures that the correct classloading is used for determining which libraries to collect.
 * @param coreFile core file to process
 */
@SuppressWarnings({ "unchecked" })
private void constructLibraryList(final File coreFile) {
    moduleNames = new ArrayList<String>();
    ImageFactory factory = new J9DDRImageFactory();
    final Image image;
    final boolean isAIX;
    try {
        image = factory.getImage(coreFile);
        isAIX = image.getSystemType().toLowerCase().startsWith("aix");
    } catch (IOException e) {
        logger.log(SEVERE, "Could not open core file", e);
        errorMessages.add(e.getMessage());
        return;
    } catch (CorruptDataException e) {
        logger.log(SEVERE, "Could not determine system type", e);
        errorMessages.add(e.getMessage());
        return;
    } catch (DataUnavailable e) {
        logger.log(SEVERE, "Could not determine system type", e);
        errorMessages.add(e.getMessage());
        return;
    }
    for (Iterator spaces = image.getAddressSpaces(); spaces.hasNext(); ) {
        ImageAddressSpace space = (ImageAddressSpace) spaces.next();
        for (Iterator procs = space.getProcesses(); procs.hasNext(); ) {
            ImageProcess proc = (ImageProcess) procs.next();
            try {
                // add the executable to the list of libraries to be collected
                ImageModule exe = proc.getExecutable();
                moduleNames.add(exe.getName());
                for (Iterator libraries = proc.getLibraries(); libraries.hasNext(); ) {
                    ImageModule module = (ImageModule) libraries.next();
                    String key = null;
                    try {
                        // handle CDE thrown by getName(), as this is required further on this call needs to succeed
                        if (isAIX) {
                            key = module.getName();
                            // check on AIX if module is the .a file or library
                            int pos = key.indexOf(".a(");
                            if ((pos != -1) && (key.lastIndexOf(')') == key.length() - 1)) {
                                key = key.substring(0, pos + 2);
                            }
                        } else {
                            key = module.getName();
                        }
                        logger.fine("Module : " + key);
                        if (!moduleNames.contains(key)) {
                            // don't store duplicate libraries
                            moduleNames.add(key);
                        }
                    } catch (Exception e) {
                        logger.log(WARNING, "Error getting module name", e);
                    }
                }
            } catch (DataUnavailable e) {
                logger.log(WARNING, "Error getting library list", e);
                errorMessages.add(e.getMessage());
            } catch (com.ibm.dtfj.image.CorruptDataException e) {
                logger.log(WARNING, "Error getting library list", e);
                errorMessages.add(e.getMessage());
            }
        }
    }
}
Also used : IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Image(com.ibm.dtfj.image.Image) ImageModule(com.ibm.dtfj.image.ImageModule) IOException(java.io.IOException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) ImageFactory(com.ibm.dtfj.image.ImageFactory) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) ImageProcess(com.ibm.dtfj.image.ImageProcess) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable)

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