Search in sources :

Example 1 with DTFJCorruptDataException

use of com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException 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 2 with DTFJCorruptDataException

use of com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException in project openj9 by eclipse.

the class J9DDRImage method getProcessorType.

public String getProcessorType() throws DataUnavailable, CorruptDataException {
    checkJ9RASMachineData();
    if (j9MachineData != null) {
        try {
            return j9MachineData.osArch();
        } catch (com.ibm.j9ddr.CorruptDataException e) {
            throw new DTFJCorruptDataException(j9MachineData.getProcess(), e);
        }
    } else {
        Properties prop = coreFile.getProperties();
        String result = prop.getProperty(ICore.PROCESSOR_TYPE_PROPERTY);
        if (result != null) {
            return result;
        } else {
            throw new DataUnavailable();
        }
    }
}
Also used : DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) Properties(java.util.Properties)

Example 3 with DTFJCorruptDataException

use of com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException in project openj9 by eclipse.

the class J9DDRImageProcess method getLibraries.

public Iterator<?> getLibraries() throws DataUnavailable, CorruptDataException {
    try {
        Collection<? extends IModule> modules = process.getModules();
        List<ImageModule> libraries = new ArrayList<ImageModule>();
        for (IModule module : modules) {
            libraries.add(new J9DDRImageModule(process, module));
        }
        return libraries.iterator();
    } catch (com.ibm.j9ddr.CorruptDataException e) {
        throw new DTFJCorruptDataException(new J9DDRCorruptData(process, e));
    }
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) ArrayList(java.util.ArrayList) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 4 with DTFJCorruptDataException

use of com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException in project openj9 by eclipse.

the class J9DDRImageProcess method getEnvironment.

/**
 * This method gets the environment variables.
 * First it tries to extract it from RAS structure.
 * If not, it tries to get it from loaded modules.
 * @return Properties instance of environment variables.
 * @throws DataUnavailable
 * @throws CorruptDataException
 */
public Properties getEnvironment() throws DataUnavailable, CorruptDataException {
    try {
        checkFailureInfo();
        if (j9rasProcessData != null) {
            try {
                Properties properties;
                long environ = j9rasProcessData.getEnvironment();
                if (process.getPlatform() == Platform.WINDOWS && j9rasProcessData.version() > 4) {
                    // Get the env vars from an environment strings block instead of the environ global
                    properties = EnvironmentUtils.readEnvironmentStrings(process, environ);
                } else {
                    long stringPointer = process.getPointerAt(environ);
                    properties = EnvironmentUtils.readEnvironment(process, stringPointer);
                }
                if ((null == properties) || (0 == properties.size())) {
                    /* In the case of env vars is null or empty, 
						 * throw exception so that it tries to get env vars from modules 
						 */
                    throw new com.ibm.j9ddr.CorruptDataException("");
                }
                return properties;
            } catch (com.ibm.j9ddr.CorruptDataException e1) {
                /* Seems like RAS structure is corrupted. Try to get it from modules. */
                return process.getEnvironmentVariables();
            }
        } else {
            /* We don't have a J9RAS structure to work with. Try to get it from modules. */
            return process.getEnvironmentVariables();
        }
    } 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) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) Properties(java.util.Properties)

Example 5 with DTFJCorruptDataException

use of com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException in project openj9 by eclipse.

the class J9DDRImageProcess method getCurrentThread.

/**
 * This method returns the ImageThread that matches the TID stored in the J9RAS data structure,
 *  or
 *  case 1: if no J9RAS structure available return null
 *  case 2: if J9RAS structure available but no TID field (old JVMs, old jextract behaviour)
 *  		- return the first thread, or null if no threads
 *  case 3: if J9RAS structure available with TID field but TID is zero (eg dump triggered outside JVM)
 *  		- platform specific code if core readers have identified a current thread, else...
 *  case 4: if J9RAS structure available with TID field but no match (eg Linux), return a stub ImageThread
 *
 * @return ImageThread
 * @throws {@link CorruptDataException}
 */
public ImageThread getCurrentThread() throws CorruptDataException {
    try {
        checkFailureInfo();
        if (j9rasProcessData != null) {
            long currentThreadId;
            try {
                currentThreadId = j9rasProcessData.tid();
            } catch (DataUnavailable e) {
                // JExtract currently just takes first thread as we do here
                for (IOSThread thread : process.getThreads()) {
                    return new J9DDRImageThread(process, thread);
                }
                return null;
            }
            for (IOSThread thread : process.getThreads()) {
                if (thread.getThreadId() == currentThreadId) {
                    return new J9DDRImageThread(process, thread);
                }
            }
            if (currentThreadId == 0) {
                // for a thread with a non-zero Task Completion Code. There may be more we can do here for Win/Linux/AIX
                if (process.getPlatform() == Platform.ZOS) {
                    for (IOSThread thread : process.getThreads()) {
                        Properties threadProps = thread.getProperties();
                        String tcc = threadProps.getProperty("Task Completion Code");
                        if (tcc != null && !tcc.equals("0x0")) {
                            return new J9DDRImageThread(process, thread);
                        }
                    }
                }
            }
            // We cannot match the native thread at this point, so provide a stub based on the information in the RAS structure.
            return new J9DDRStubImageThread(process, currentThreadId);
        } else {
            return null;
        }
    } catch (com.ibm.j9ddr.CorruptDataException e) {
        throw new DTFJCorruptDataException(process, e);
    }
}
Also used : DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) IOSThread(com.ibm.j9ddr.corereaders.osthread.IOSThread) Properties(java.util.Properties)

Aggregations

DTFJCorruptDataException (com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException)5 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)4 Properties (java.util.Properties)4 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 ImageModule (com.ibm.dtfj.image.ImageModule)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 IOSThread (com.ibm.j9ddr.corereaders.osthread.IOSThread)1 ArrayList (java.util.ArrayList)1