Search in sources :

Example 1 with IMemory

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

the class MiniDumpReader method getCommandLine.

String getCommandLine() throws CorruptDataException, DataUnavailableException {
    // For dumps from Windows Vista, Server 2008 and later, we have no way to find the command line
    if (_windowsMajorVersion >= 6) {
        throw new DataUnavailableException("Command line not available from Windows core dump");
    }
    // For dumps from older Windows versions, we can get the command line from the known PEB location
    String commandLine = null;
    try {
        IMemory memory = getMemory();
        short length;
        long commandAddress;
        if (is64Bit()) {
            length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_64);
            commandAddress = memory.getLongAt(COMMAND_LINE_ADDRESS_ADDRESS_64);
        } else {
            length = memory.getShortAt(COMMAND_LINE_LENGTH_ADDRESS_32);
            commandAddress = 0xFFFFFFFF & memory.getIntAt(COMMAND_LINE_ADDRESS_ADDRESS_32);
        }
        if (commandAddress == 0) {
            throw new DataUnavailableException("Command line not in core file");
        }
        byte[] buf = new byte[length];
        memory.getBytesAt(commandAddress, buf);
        // FIXME: Should UTF-16LE be hard coded here? Is the encoding platform
        // specific?
        commandLine = new String(buf, "UTF-16LE");
        return commandLine;
    } catch (Exception e) {
        // throw a corrupt data exception as we expect the command line to be present so DataUnavailable is not appropriate
        throw new CorruptDataException("Failed to read command line from core file", e);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IMemory(com.ibm.j9ddr.corereaders.memory.IMemory) CorruptDataException(com.ibm.j9ddr.CorruptDataException) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) FileNotFoundException(java.io.FileNotFoundException) CorruptCoreException(com.ibm.j9ddr.corereaders.CorruptCoreException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)1 CorruptCoreException (com.ibm.j9ddr.corereaders.CorruptCoreException)1 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)1 IMemory (com.ibm.j9ddr.corereaders.memory.IMemory)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1