Search in sources :

Example 1 with CorruptStructuresException

use of com.ibm.j9ddr.exceptions.CorruptStructuresException in project openj9 by eclipse.

the class VMDataFactory method getAllVMData.

// TODO - fix this for z/OS which will require noting which RAS symbols have already been found in the core
/**
 * Finds all of the blobs in a given process and wraps them in a IVMData structure.
 *
 * @param process process to scan
 * @return all located blobs
 * @throws IOException re-throws IOExceptions
 */
public static synchronized List<IVMData> getAllVMData(IProcess process) throws IOException {
    List<IVMData> cachedVMData = vmDataCache.get(process);
    if (cachedVMData != null) {
        return cachedVMData;
    }
    // nothing in the cache for this process, so need to scan
    // Get an ImageInputStream on the Structure Offset Data.  This may or may not be in the core file itself.
    List<IVMData> data = new ArrayList<IVMData>();
    ImageInputStream in = null;
    // End Of Memory
    boolean EOM = false;
    long address = 0;
    j9RASAddress = 0;
    while (!EOM) {
        try {
            address = j9RASAddress + 1;
            in = getStructureDataFile(process, address);
            if (in != null) {
                EOM = !(in instanceof IMemoryImageInputStream);
                IVMData vmdata = getVMData(process, in);
                data.add(vmdata);
                if (vmdata.getClassLoader().getHeader().getCoreVersion() == 1) {
                    // version 1 does not support multiple blobs
                    EOM = true;
                    break;
                }
            } else {
                EOM = true;
            }
        } catch (JVMNotFoundException e) {
            // no more JVMs were found
            EOM = true;
        } catch (JVMNotDDREnabledException e) {
            // an older JVM was found, so ignore that and carry on looking
            // on z/OS a failure with the j9ras symbol resolution aborts the scan
            EOM = EOM | (process.getPlatform() == Platform.ZOS);
            continue;
        } catch (MissingDDRStructuresException e) {
            // cannot process as the structures are missing
            // on z/OS a failure with the j9ras symbol resolution aborts the scan
            EOM = EOM | (process.getPlatform() == Platform.ZOS);
            continue;
        } catch (CorruptStructuresException e) {
            // cannot process as the structures are corrupt and cannot be read
            // on z/OS a failure with the j9ras symbol resolution aborts the scan
            EOM = EOM | (process.getPlatform() == Platform.ZOS);
            continue;
        } catch (IOException e) {
            continue;
        }
    }
    // scan is switched off for Java-only applications (specifically jdmpview) via a system property.
    if ((System.getProperty(NOEXTRASEARCHFORNODE_PROPERTY) == null) && (data.size() == 0)) {
        StructureHeader header = null;
        try {
            header = findNodeVersion(process);
        } catch (Exception e) {
            if (e instanceof IOException) {
                throw (IOException) e;
            } else {
                IOException ioe = new IOException();
                // avoid use of IOException(throwable) to be compatible with J5
                ioe.initCause(e);
                throw ioe;
            }
        }
        if (header != null) {
            in = getBlobFromLibrary(process, header);
            if (in != null) {
                IVMData vmdata = getVMData(process, in);
                data.add(vmdata);
            }
        }
    }
    vmDataCache.put(process, data);
    return data;
}
Also used : MemoryCacheImageInputStream(javax.imageio.stream.MemoryCacheImageInputStream) IMemoryImageInputStream(com.ibm.j9ddr.corereaders.memory.IMemoryImageInputStream) FileImageInputStream(javax.imageio.stream.FileImageInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) ArrayList(java.util.ArrayList) IOException(java.io.IOException) JVMNotFoundException(com.ibm.j9ddr.exceptions.JVMNotFoundException) CorruptStructuresException(com.ibm.j9ddr.exceptions.CorruptStructuresException) UnknownArchitectureException(com.ibm.j9ddr.exceptions.UnknownArchitectureException) IOException(java.io.IOException) JVMNotDDREnabledException(com.ibm.j9ddr.exceptions.JVMNotDDREnabledException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) MissingDDRStructuresException(com.ibm.j9ddr.exceptions.MissingDDRStructuresException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) JVMNotDDREnabledException(com.ibm.j9ddr.exceptions.JVMNotDDREnabledException) JVMNotFoundException(com.ibm.j9ddr.exceptions.JVMNotFoundException) IMemoryImageInputStream(com.ibm.j9ddr.corereaders.memory.IMemoryImageInputStream) CorruptStructuresException(com.ibm.j9ddr.exceptions.CorruptStructuresException) MissingDDRStructuresException(com.ibm.j9ddr.exceptions.MissingDDRStructuresException)

Aggregations

IMemoryImageInputStream (com.ibm.j9ddr.corereaders.memory.IMemoryImageInputStream)1 CorruptStructuresException (com.ibm.j9ddr.exceptions.CorruptStructuresException)1 JVMNotDDREnabledException (com.ibm.j9ddr.exceptions.JVMNotDDREnabledException)1 JVMNotFoundException (com.ibm.j9ddr.exceptions.JVMNotFoundException)1 MissingDDRStructuresException (com.ibm.j9ddr.exceptions.MissingDDRStructuresException)1 UnknownArchitectureException (com.ibm.j9ddr.exceptions.UnknownArchitectureException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 FileImageInputStream (javax.imageio.stream.FileImageInputStream)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1 MemoryCacheImageInputStream (javax.imageio.stream.MemoryCacheImageInputStream)1