Search in sources :

Example 1 with IProcess

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

the class AIXDumpReader method loadUserInfo.

private void loadUserInfo() throws IOException, MemoryFault {
    if (!_userInfoLoaded) {
        seek(userInfoOffset());
        _pid = readInt();
        // Get the process command line. For AIX dumps we find the registers in
        // the initial (top - this is to be consistent with AIX headers)
        // stack frame. Register 3 has the number of command line arguments
        // (argc), register 4 has
        // a pointer to a list of pointers to the command line arguments (argv),
        // and register 5 contains the pointer to the environment vars
        IProcess memory = getProcess();
        long workingAddress = _structTopOfStackVirtualAddress;
        int pointerSize = pointerSize() / 8;
        // Ignore GPR0-2
        workingAddress += (2 * pointerSize);
        // argc
        long reg3 = memory.getPointerAt(workingAddress += pointerSize);
        // argv
        _argv = memory.getPointerAt(workingAddress += pointerSize);
        // env
        _environmentHandle = memory.getPointerAt(workingAddress += pointerSize);
        // truncate to integer
        _argc = (int) reg3;
        _userInfoLoaded = true;
    }
}
Also used : IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 2 with IProcess

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

the class AIXDumpReader method getCommandLine.

String getCommandLine() throws CorruptDataException {
    try {
        loadUserInfo();
    } catch (IOException e1) {
        throw new CorruptDataException(e1);
    }
    IProcess memory = getProcess();
    int pointerSize = pointerSize() / 8;
    if (_argc > 100) {
        throw new CorruptDataException("Argc too high. Likely corrupt data. Argc=" + _argc + " structTopOfStackVirtualAddress = 0x" + Long.toHexString(_structTopOfStackVirtualAddress));
    }
    long[] addresses = new long[_argc];
    for (int i = 0; i < _argc; i++) {
        addresses[i] = memory.getPointerAt(_argv + (i * pointerSize));
    }
    StringBuffer commandLine = new StringBuffer();
    for (int i = 0; i < _argc; i++) {
        try {
            long startingAddress = addresses[i];
            long workingAddress = startingAddress;
            while (memory.getByteAt(workingAddress) != 0) {
                workingAddress++;
            }
            int stringLength = (int) (workingAddress - startingAddress);
            byte[] buffer = new byte[stringLength];
            memory.getBytesAt(startingAddress, buffer);
            commandLine.append(new String(buffer, "ASCII"));
            commandLine.append(" ");
        } catch (MemoryFault e) {
            commandLine.append(" <Fault reading argv[" + i + "] at 0x" + Long.toHexString(addresses[i]) + ">");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
    }
    return commandLine.toString();
}
Also used : MemoryFault(com.ibm.j9ddr.corereaders.memory.MemoryFault) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 3 with IProcess

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

the class AIXDumpReader method executablePathHint.

// Passback of executable path. If we couldn't load the executable the first time, try again now.
public void executablePathHint(String path) {
    if (_executable instanceof MissingFileModule) {
        // Check the hint points at the same file name
        try {
            if (!getFileName(_executable.getName()).equals(getFileName(path))) {
                return;
            }
        } catch (CorruptDataException e1) {
            return;
        }
        // Remove placeholder memory source
        _process.removeMemorySource(_executableTextSection);
        // Remember the current placeholder in case this one fails too
        IModule currentExecutable = _executable;
        IMemorySource currentExecutableTextSection = _executableTextSection;
        ILibraryResolver resolver = LibraryResolverFactory.getResolverForCoreFile(this.coreFile);
        IProcess proc = getProcess();
        try {
            seek(_loaderOffset);
            readInt();
            // Ignore flags
            readLoaderInfoFlags();
            // Ignore dataOffset
            readAddress();
            long textVirtualAddress = readAddress();
            long textSize = readAddress();
            long dataVirtualAddress = readAddress();
            long dataSize = readAddress();
            // Disregard fileName from core
            readString();
            String fileName = path;
            String objectName = readString();
            String moduleName = fileName;
            if (0 < objectName.length()) {
                moduleName += "(" + objectName + ")";
            }
            loadModule(resolver, proc, textVirtualAddress, textSize, dataVirtualAddress, dataSize, fileName, objectName, moduleName, true);
        } catch (IOException e) {
        // TODO handle
        }
        // If the executable is still a MissingFileModule, the hint didn't work
        if (_executable instanceof MissingFileModule) {
            _process.removeMemorySource(_executableTextSection);
            _executableTextSection = currentExecutableTextSection;
            _process.addMemorySource(_executableTextSection);
            _executable = currentExecutable;
        }
    }
}
Also used : IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource) IModule(com.ibm.j9ddr.corereaders.memory.IModule) ILibraryResolver(com.ibm.j9ddr.corereaders.ILibraryResolver) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IOException(java.io.IOException) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess) MissingFileModule(com.ibm.j9ddr.corereaders.memory.MissingFileModule)

Example 4 with IProcess

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

the class JniReader method getAddressSpaces.

/**
 * This method creates JNI address space and puts it into collection instance.
 *
 * @return Collection of address spaces
 */
public Collection<? extends IAddressSpace> getAddressSpaces() {
    if (null == addressSpaces) {
        addressSpaces = new ArrayList<IAddressSpace>(1);
        JniAddressSpace addressSpace = new JniAddressSpace(0, this);
        Iterator<? extends IProcess> ite = addressSpace.getProcesses().iterator();
        if (ite.hasNext()) {
            IProcess process = ite.next();
            /* This is sanity check. It should always be the JniProcess instance */
            if (process instanceof JniProcess) {
                JniProcess jniProcess = (JniProcess) process;
                /* Set ICore.PROCESSOR_TYPE_PROPERTY in the properties by checking the target architecture */
                int targetArchitecture = jniProcess.getTargetArchitecture();
                switch(targetArchitecture) {
                    case JniProcess.TARGET_TYPE_X86_32:
                        properties.setProperty(ICore.PROCESSOR_TYPE_PROPERTY, "x86");
                        break;
                    case JniProcess.TARGET_TYPE_X86_64:
                        properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "amd64");
                        break;
                    case JniProcess.TARGET_TYPE_S390_31:
                    case JniProcess.TARGET_TYPE_S390_64:
                        properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "s390");
                        break;
                    case JniProcess.TARGET_TYPE_PPC_32:
                    case JniProcess.TARGET_TYPE_PPC_64:
                        properties.put(ICore.PROCESSOR_TYPE_PROPERTY, "ppc");
                        break;
                    default:
                }
            }
        }
        addressSpaces.add(addressSpace);
    }
    return addressSpaces;
}
Also used : IAddressSpace(com.ibm.j9ddr.corereaders.memory.IAddressSpace) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 5 with IProcess

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

the class ThreadStream method readFrom.

@Override
public void readFrom(MiniDumpReader dump, IAddressSpace addressSpace, boolean is64Bit) throws CorruptDataException, IOException {
    dump.seek(getLocation());
    int numberOfThreads = dump.readInt();
    if (numberOfThreads > 100000) {
        throw new CorruptDataException("Unlikely number of threads found in dump: " + numberOfThreads + ". Suspect data corruption");
    }
    for (int i = 0; i < numberOfThreads; i++) {
        dump.seek(getLocation() + 4 + i * 48);
        int threadId = dump.readInt();
        // Ignore suspendCount
        dump.readInt();
        int priorityClass = dump.readInt();
        int priority = dump.readInt();
        // Ignore teb
        dump.readLong();
        long stackStart = dump.readLong();
        long stackSize = 0xFFFFFFFFL & dump.readInt();
        long stackRva = 0xFFFFFFFFL & dump.readInt();
        // contextDataSize
        dump.readInt();
        long contextRva = 0xFFFFFFFFL & dump.readInt();
        Properties properties = new Properties();
        properties.setProperty("priorityClass", String.valueOf(priorityClass));
        properties.setProperty("priority", String.valueOf(priority));
        dump.addThread(new WindowsOSThread(threadId, stackStart, stackSize, stackRva, contextRva, properties, dump, (IProcess) addressSpace));
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Aggregations

IProcess (com.ibm.j9ddr.corereaders.memory.IProcess)18 IOException (java.io.IOException)6 CorruptDataException (com.ibm.j9ddr.CorruptDataException)5 IAddressSpace (com.ibm.j9ddr.corereaders.memory.IAddressSpace)4 ICore (com.ibm.j9ddr.corereaders.ICore)3 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 IVMData (com.ibm.j9ddr.IVMData)2 Platform (com.ibm.j9ddr.corereaders.Platform)2 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 J9DDRImageProcess (com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9RASPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RASPointer)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 ImageSection (com.ibm.dtfj.image.ImageSection)1 ILibraryResolver (com.ibm.j9ddr.corereaders.ILibraryResolver)1 IMemorySource (com.ibm.j9ddr.corereaders.memory.IMemorySource)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1