Search in sources :

Example 6 with InvalidDumpFormatException

use of com.ibm.j9ddr.corereaders.InvalidDumpFormatException in project openj9 by eclipse.

the class MiniDumpReader method processDump.

public ICore processDump(File file) throws FileNotFoundException, InvalidDumpFormatException, IOException {
    // MiniDump files can be Little Endian only.
    this.coreFile = file;
    ClosingFileReader fileReader = new ClosingFileReader(file, ByteOrder.LITTLE_ENDIAN);
    if (!isMiniDump(fileReader)) {
        throw new InvalidDumpFormatException("The file " + file.getAbsolutePath() + " is not a valid MiniDump file.");
    }
    setReader(fileReader);
    return this;
}
Also used : InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) ClosingFileReader(com.ibm.j9ddr.corereaders.ClosingFileReader)

Example 7 with InvalidDumpFormatException

use of com.ibm.j9ddr.corereaders.InvalidDumpFormatException in project openj9 by eclipse.

the class ELFFileReader method getELFFileReaderWithOffset.

public static ELFFileReader getELFFileReaderWithOffset(ImageInputStream in, long offset) throws IOException, InvalidDumpFormatException {
    // mark the stream as the validation and bitsize determinations move the underlying pointer
    in.mark();
    in.seek(offset);
    if (!isFormatValid(in)) {
        throw new InvalidDumpFormatException("The input stream is not an ELF file");
    }
    int bitness = in.read();
    ByteOrder byteOrder = getByteOrder(in);
    in.setByteOrder(byteOrder);
    // reset the stream so that the reader reads from the start
    in.reset();
    if (ELFCLASS64 == bitness) {
        return new ELF64FileReader(in, offset);
    } else {
        return new ELF32FileReader(in, offset);
    }
}
Also used : InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) ByteOrder(java.nio.ByteOrder)

Example 8 with InvalidDumpFormatException

use of com.ibm.j9ddr.corereaders.InvalidDumpFormatException in project openj9 by eclipse.

the class ELFFileReader method getELFFileReaderWithOffset.

// ELF files can be either Big Endian (for example on Linux/PPC) or Little
// Endian (Linux/IA).
// Let's check whether it's actually an ELF file. We'll sort out the byte
// order later.
public static ELFFileReader getELFFileReaderWithOffset(File f, long offset) throws IOException, InvalidDumpFormatException {
    // Figure out which combination of bitness and architecture we are
    ImageInputStream in = new FileImageInputStream(f);
    if (!isFormatValid(in)) {
        throw new InvalidDumpFormatException("File " + f.getAbsolutePath() + " is not an ELF file");
    }
    int bitness = in.read();
    ByteOrder byteOrder = getByteOrder(in);
    // no longer need the input stream as passing the File descriptor into the reader
    in.close();
    if (ELFCLASS64 == bitness) {
        return new ELF64FileReader(f, byteOrder, offset);
    } else {
        return new ELF32FileReader(f, byteOrder, offset);
    }
}
Also used : FileImageInputStream(javax.imageio.stream.FileImageInputStream) FileImageInputStream(javax.imageio.stream.FileImageInputStream) ImageInputStream(javax.imageio.stream.ImageInputStream) InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) ByteOrder(java.nio.ByteOrder)

Aggregations

InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)8 ClosingFileReader (com.ibm.j9ddr.corereaders.ClosingFileReader)3 ByteOrder (java.nio.ByteOrder)2 LibraryDataSource (com.ibm.j9ddr.corereaders.LibraryDataSource)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 MissingFileModule (com.ibm.j9ddr.corereaders.memory.MissingFileModule)1 File (java.io.File)1 Properties (java.util.Properties)1 FileImageInputStream (javax.imageio.stream.FileImageInputStream)1 ImageInputStream (javax.imageio.stream.ImageInputStream)1