Search in sources :

Example 1 with ClosingFileReader

use of com.ibm.dtfj.corereaders.ClosingFileReader in project openj9 by eclipse.

the class DTFJLibraryAdapter method getLibraryList.

public ArrayList<String> getLibraryList(final File coreFile) {
    if (moduleNames == null) {
        moduleNames = new ArrayList<String>();
        try {
            _parentDir = coreFile.getParentFile();
            logger.fine("Creating DTFJ core file reader");
            ClosingFileReader closingFile = new ClosingFileReader(coreFile);
            ICoreFileReader reader = DumpFactory.createDumpForCore(closingFile);
            isAIX = (reader instanceof NewAixDump);
            logger.fine("Extracting modules");
            reader.extract(this);
        } catch (FileNotFoundException e) {
            logger.log(SEVERE, "Could not open core file " + coreFile.getAbsolutePath(), e);
            errorMessages.add(e.getMessage());
        } catch (IOException e) {
            logger.log(SEVERE, "Error processing core file " + coreFile.getAbsolutePath(), e);
            errorMessages.add(e.getMessage());
        }
    }
    return moduleNames;
}
Also used : FileNotFoundException(java.io.FileNotFoundException) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) IOException(java.io.IOException) NewAixDump(com.ibm.dtfj.corereaders.NewAixDump) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader)

Example 2 with ClosingFileReader

use of com.ibm.dtfj.corereaders.ClosingFileReader in project openj9 by eclipse.

the class DTFJLibraryAdapter method isLibraryCollectionRequired.

public boolean isLibraryCollectionRequired(File coreFile) {
    ICoreFileReader reader = null;
    try {
        ClosingFileReader closingFile = new ClosingFileReader(coreFile);
        reader = DumpFactory.createDumpForCore(closingFile);
    } catch (Exception e) {
        logger.log(SEVERE, "Could not determine if library collection is required for " + coreFile.getAbsolutePath(), e);
        errorMessages.add(e.getMessage());
        // if this fails, then so would any collection attempt as well
        return false;
    }
    if (reader instanceof NewElfDump) {
        return true;
    }
    if (reader instanceof NewAixDump) {
        return true;
    }
    return false;
}
Also used : NewElfDump(com.ibm.dtfj.corereaders.NewElfDump) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) NewAixDump(com.ibm.dtfj.corereaders.NewAixDump) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader)

Example 3 with ClosingFileReader

use of com.ibm.dtfj.corereaders.ClosingFileReader in project openj9 by eclipse.

the class DTFJLibraryAdapter method openFile.

public ClosingFileReader openFile(String filename) throws IOException {
    // given that we may be looking for a file which came from another system, look it up in our support file dir first (we need that to over-ride the absolute path since it may be looking for a file in the same location as one on the local machine - this happens often if moving a core file from one Unix system to another)
    ClosingFileReader candidate = null;
    File absolute = new File(filename);
    String fileName = absolute.getName();
    File supportFileCopy = new File(_parentDir, fileName);
    if (supportFileCopy.exists()) {
        candidate = new ClosingFileReader(supportFileCopy);
    } else {
        candidate = new ClosingFileReader(absolute);
    }
    return candidate;
}
Also used : ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) File(java.io.File)

Example 4 with ClosingFileReader

use of com.ibm.dtfj.corereaders.ClosingFileReader in project openj9 by eclipse.

the class LayeredAddressSpace method getBytesAt.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.addressspace.IAbstractAddressSpace#getBytesAt(int, long, byte[])
	 */
public int getBytesAt(int asid, long address, byte[] buffer) throws MemoryAccessException {
    if (null == _moduleRangesArray) {
        _moduleRangesArray = (MemoryRange[]) _moduleRanges.keySet().toArray(new MemoryRange[0]);
    }
    int retI = findWhichMemoryRange(asid, address, _moduleRangesArray, _lastModuleRange, false);
    if (retI > -1) {
        MemoryRange range = (MemoryRange) _moduleRangesArray[retI];
        if (range.contains(address)) {
            ClosingFileReader readable = (ClosingFileReader) _moduleRanges.get(range);
            try {
                long fileOffset = range.getFileOffset() + (address - range.getVirtualAddress());
                readable.seek(fileOffset);
                readable.readFully(buffer);
                return buffer.length;
            } catch (IOException ex) {
                System.out.println(">> Memory access exception in getBytesAt");
                throw new MemoryAccessException(asid, address);
            }
        }
    }
    // this must not be in one of the newer regions
    return _base.getBytesAt(asid, address, buffer);
}
Also used : MemoryRange(com.ibm.dtfj.corereaders.MemoryRange) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) IOException(java.io.IOException) MemoryAccessException(com.ibm.dtfj.corereaders.MemoryAccessException)

Example 5 with ClosingFileReader

use of com.ibm.dtfj.corereaders.ClosingFileReader in project openj9 by eclipse.

the class DTFJImageFactory method getImage.

private ReleasingImage getImage(File imageFile, InputStream metadata, IFileLocationResolver resolver) throws IOException {
    ClosingFileReader reader = new ClosingFileReader(imageFile);
    ICoreFileReader core = DumpFactory.createDumpForCore(reader);
    XMLIndexReader indexData = new XMLIndexReader();
    // CMVC 154851 : pass the metadata stream through the new XML cleanup class
    XMLInputStream in = new XMLInputStream(metadata);
    ReleasingImage image = indexData.parseIndexWithDump(in, core, reader, resolver);
    image.addReleasable(in);
    image.addReleasable(reader);
    image.addReleasable(core);
    if (resolver instanceof ResourceReleaser) {
        image.addReleasable((ResourceReleaser) resolver);
    }
    return image;
}
Also used : ResourceReleaser(com.ibm.dtfj.corereaders.ResourceReleaser) XMLInputStream(com.ibm.jvm.j9.dump.indexsupport.XMLInputStream) ClosingFileReader(com.ibm.dtfj.corereaders.ClosingFileReader) ICoreFileReader(com.ibm.dtfj.corereaders.ICoreFileReader) XMLIndexReader(com.ibm.jvm.j9.dump.indexsupport.XMLIndexReader)

Aggregations

ClosingFileReader (com.ibm.dtfj.corereaders.ClosingFileReader)7 IOException (java.io.IOException)4 ICoreFileReader (com.ibm.dtfj.corereaders.ICoreFileReader)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 NewAixDump (com.ibm.dtfj.corereaders.NewAixDump)2 MemoryAccessException (com.ibm.dtfj.corereaders.MemoryAccessException)1 MemoryRange (com.ibm.dtfj.corereaders.MemoryRange)1 NewElfDump (com.ibm.dtfj.corereaders.NewElfDump)1 ResourceReleaser (com.ibm.dtfj.corereaders.ResourceReleaser)1 XMLIndexReader (com.ibm.jvm.j9.dump.indexsupport.XMLIndexReader)1 XMLInputStream (com.ibm.jvm.j9.dump.indexsupport.XMLInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1