Search in sources :

Example 1 with DataUnavailableException

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

Example 2 with DataUnavailableException

use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.

the class J9DDRImageProcess method getCommandLine.

/**
 * This method tries to get command line of the program that generated core file.
 *
 * We can't get the command line from the core dump on zOS, or on recent Windows versions. On Linux
 * it may be truncated. The java launcher stores the command line in an environment variable, so for
 * all platforms we now try that first, with the core reader as a fallback.
 *
 * @return String instance of the commandline
 * @throws DataUnavailable
 * @throws {@link CorruptDataException}
 */
public String getCommandLine() throws DataUnavailable, CorruptDataException {
    try {
        Properties environment = getEnvironment();
        String javaCommandLine = environment.getProperty(JAVA_COMMAND_LINE_ENVIRONMENT_VARIABLE);
        if (javaCommandLine != null) {
            return javaCommandLine;
        }
        return process.getCommandLine();
    } catch (com.ibm.j9ddr.CorruptDataException e) {
        throw new DTFJCorruptDataException(process, e);
    } catch (DataUnavailableException e) {
        throw new DataUnavailable(e.getMessage());
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) Properties(java.util.Properties)

Example 3 with DataUnavailableException

use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.

the class WindowsProcessAddressSpace method getEnvironmentSymbols.

/**
 *  This method returns a list of symbols with the name "_environ"
 *
 *  @return LinkedList instance of symbols with the name "_environ"
 *  @throws CorruptDataException
 */
private LinkedList<ISymbol> getEnvironmentSymbols() throws CorruptDataException {
    List<IModule> modules = getModules();
    LinkedList<ISymbol> symbols = new LinkedList<ISymbol>();
    for (IModule thisModule : modules) {
        try {
            for (ISymbol thisSymbol : thisModule.getSymbols()) {
                if (thisSymbol.getName().equals("_environ")) {
                    symbols.add(thisSymbol);
                }
            }
        } catch (DataUnavailableException e) {
            continue;
        }
    }
    return symbols;
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol) LinkedList(java.util.LinkedList)

Example 4 with DataUnavailableException

use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.

the class WindowsProcessAddressSpace method getEnvironmentVariables.

/**
 * This method tries to get environment variables by iterating through modules.
 * It returns the one with environment var "IBM_JAVA_COMMAND_LINE"
 * If there is no module with IBM_JAVA_COMMAND_LINE, then it returns the last one.
 *
 * @return Properties instance of environment variables.
 * @throws DataUnavailableException
 * @throws CorruptDataException
 */
public Properties getEnvironmentVariables() throws DataUnavailableException, CorruptDataException {
    if (null == environment) {
        LinkedList<ISymbol> environSymbols = getEnvironmentSymbols();
        ISymbol environ = null;
        if (0 == environSymbols.size()) {
            throw new DataUnavailableException("Couldn't find environment symbol");
        }
        /* There might be more than one module with environment variables. Use the one that has IBM_JAVA_COMMAND_LINE */
        for (int i = 0; i < environSymbols.size(); i++) {
            environ = environSymbols.get(i);
            long environPointer = getPointerAt(environ.getAddress());
            environment = EnvironmentUtils.readEnvironment(this, environPointer);
            if (environment.containsKey("IBM_JAVA_COMMAND_LINE")) {
                break;
            }
        }
    }
    return environment;
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol)

Example 5 with DataUnavailableException

use of com.ibm.j9ddr.DataUnavailableException in project openj9 by eclipse.

the class LookupSymbolCommand method run.

public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        out.println("Please supply a function pointer to lookup.");
        return;
    }
    boolean is64BitPlatform = (ctx.process.bytesPerPointer() == 8) ? true : false;
    long address = CommandUtils.parsePointer(args[0], is64BitPlatform);
    try {
        String symbol = ctx.process.getProcedureNameForAddress(address);
        out.println("Closest match:");
        out.println(symbol);
    } catch (DataUnavailableException e) {
        throw new DDRInteractiveCommandException(e);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 ISymbol (com.ibm.j9ddr.corereaders.memory.ISymbol)3 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)2 Properties (java.util.Properties)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)1 CorruptCoreException (com.ibm.j9ddr.corereaders.CorruptCoreException)1 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)1 IMemory (com.ibm.j9ddr.corereaders.memory.IMemory)1 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 IOSStackFrame (com.ibm.j9ddr.corereaders.osthread.IOSStackFrame)1 IOSThread (com.ibm.j9ddr.corereaders.osthread.IOSThread)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1