Search in sources :

Example 1 with ClosingFileReader

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

the class AIXDumpReader method getReaderForFile.

public static ICore getReaderForFile(File file) throws IOException, InvalidDumpFormatException {
    ClosingFileReader reader = new ClosingFileReader(file, ByteOrder.BIG_ENDIAN);
    // Read first few bytes to check this is an AIX dump
    byte[] buffer = new byte[128];
    reader.readFully(buffer);
    if (!isAIXDump(buffer, file.length())) {
        reader.close();
        throw new InvalidDumpFormatException("File " + file.getAbsolutePath() + " is not an AIX dump");
    }
    reader.seek(CORE_FILE_VERSION_OFFSET);
    int version = reader.readInt();
    boolean is64Bit = false;
    if (version == CORE_DUMP_X_VERSION) {
        // Could be a 64 bit if generated on a pre-AIX5 machine
        reader.seek(CORE_DUMP_X_PI_FLAGS_2_OFFSET);
        int flags = reader.readInt();
        is64Bit = (S64BIT & flags) != 0;
    } else if (version == CORE_DUMP_XX_VERSION) {
        // All core_dump_xx are 64 bit processes
        is64Bit = true;
    } else {
        throw new InvalidDumpFormatException("Unrecognised core file version: " + Long.toHexString(version));
    }
    if (is64Bit) {
        return new AIX64DumpReader(file, reader);
    } else {
        return new AIX32DumpReader(file, reader);
    }
}
Also used : InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) ClosingFileReader(com.ibm.j9ddr.corereaders.ClosingFileReader)

Example 2 with ClosingFileReader

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

the class MiniDumpReader method processDump.

public ICore processDump(String path) throws FileNotFoundException, InvalidDumpFormatException, IOException {
    File file = new File(path);
    // 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) File(java.io.File)

Example 3 with ClosingFileReader

use of com.ibm.j9ddr.corereaders.ClosingFileReader 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)

Aggregations

ClosingFileReader (com.ibm.j9ddr.corereaders.ClosingFileReader)3 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)3 File (java.io.File)1