Search in sources :

Example 1 with MemoryRange

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

the class JniMemory method getMemoryRanges.

public Collection<? extends IMemoryRange> getMemoryRanges() {
    List<MemoryRange> ranges = new LinkedList<MemoryRange>();
    MemoryRange region = getValidRegionVirtual(0, searchSize);
    while (region != null) {
        ranges.add(region);
        region = getValidRegionVirtual(region.getBaseAddress() + region.getSize(), searchSize);
    }
    return ranges;
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) MemoryRange(com.ibm.j9ddr.corereaders.memory.MemoryRange) LinkedList(java.util.LinkedList)

Example 2 with MemoryRange

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

the class ModuleStream method loadModuleSections.

private void loadModuleSections(IAddressSpace as, long imageBaseAddress, long readingAddress, long e_lfanew, Collection<IMemoryRange> sections) throws MemoryFault {
    int pemagic = as.getIntAt(readingAddress);
    readingAddress += 4;
    if (0x4550 != pemagic) {
        logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "loadModuleSections", "PE Magic is: \"" + Integer.toHexString(pemagic));
    }
    // typedef struct _IMAGE_FILE_HEADER {
    // dump.readShort(); //machine
    readingAddress += 2;
    short numberOfSections = as.getShortAt(readingAddress);
    readingAddress += 2;
    // dump.readInt(); //date/time stamp
    readingAddress += 4;
    // dump.readInt(); //pointerToSymbolTable
    readingAddress += 4;
    // dump.readInt(); //numberOfSymbols
    readingAddress += 4;
    short sizeOfOptionalHeader = as.getShortAt(readingAddress);
    readingAddress += 2;
    // dump.readShort(); //characteristics
    readingAddress += 2;
    // now skip ahead to after the optional header since that is where section
    // headers can be found
    readingAddress = imageBaseAddress + e_lfanew + 24 + /* sizeof PE header */
    (0xFFFFL & sizeOfOptionalHeader);
    for (int j = 0; j < numberOfSections; j++) {
        // typedef struct _IMAGE_SECTION_HEADER
        byte[] rawName = new byte[8];
        as.getBytesAt(readingAddress, rawName);
        readingAddress += 8;
        long virtualSize = as.getIntAt(readingAddress);
        readingAddress += 4;
        long virtualAddress = as.getIntAt(readingAddress);
        readingAddress += 4;
        // dump.readInt(); //sizeOfRawData
        readingAddress += 4;
        // dump.readInt(); //pointerToRawData
        readingAddress += 4;
        // dump.readInt(); //pointerToRelocations
        readingAddress += 4;
        // dump.readInt(); //pointerToLineNumbers
        readingAddress += 4;
        // dump.readShort(); //numberOfRelocations
        readingAddress += 2;
        // dump.readShort(); //numberOfLineNumbers
        readingAddress += 2;
        // dump.readInt(); //section_characteristics
        readingAddress += 4;
        long relocatedAddress = virtualAddress + imageBaseAddress;
        String name;
        try {
            name = new String(rawName, "ASCII");
            // Trim off any trailing nulls.
            name = name.trim();
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        IMemoryRange section = new MemoryRange(as, relocatedAddress, virtualSize, name);
        sections.add(section);
    }
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) MemoryRange(com.ibm.j9ddr.corereaders.memory.MemoryRange) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 3 with MemoryRange

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

the class AIXDumpReader method loadModule.

private void loadModule(ILibraryResolver resolver, IProcess proc, long textVirtualAddress, long textSize, long dataVirtualAddress, long dataSize, String fileName, String objectName, String moduleName, boolean loadingExecutable) {
    // .data range will be loaded in core. .text range will be in the module itself.
    IMemoryRange data = new MemoryRange(proc.getAddressSpace(), dataVirtualAddress, dataSize, ".data");
    IModule module;
    IMemorySource text;
    try {
        LibraryDataSource library = null;
        if (loadingExecutable) {
            library = resolver.getLibrary(fileName, true);
        } else {
            library = resolver.getLibrary(fileName);
        }
        IModuleFile moduleFile = loadModuleFile(library, objectName);
        text = moduleFile.getTextSegment(textVirtualAddress, textSize);
        List<? extends ISymbol> symbols = moduleFile.getSymbols(textVirtualAddress);
        List<IMemoryRange> moduleMemoryRanges = new LinkedList<IMemoryRange>();
        moduleMemoryRanges.add(text);
        moduleMemoryRanges.add(data);
        module = new Module(proc, moduleName, symbols, moduleMemoryRanges, textVirtualAddress, moduleFile.getProperties());
    } catch (Exception e) {
        // Create a non-backed memory range for the text segment (so we know it exists)
        text = new UnbackedMemorySource(textVirtualAddress, textSize, "Native library " + moduleName + " couldn't be found", 0, ".text");
        List<IMemoryRange> moduleMemoryRanges = new LinkedList<IMemoryRange>();
        moduleMemoryRanges.add(text);
        moduleMemoryRanges.add(data);
        // Can't find the library - put a stub in with the information we have.
        module = new MissingFileModule(proc, moduleName, moduleMemoryRanges);
    }
    // Add .text to _memoryRanges so it becomes part of the native address space.
    addMemorySource(text);
    if (loadingExecutable) {
        _executable = module;
        _executableTextSection = text;
    } else {
        _modules.add(module);
    }
}
Also used : IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource) IModule(com.ibm.j9ddr.corereaders.memory.IModule) UnbackedMemorySource(com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) MemoryRange(com.ibm.j9ddr.corereaders.memory.MemoryRange) LibraryDataSource(com.ibm.j9ddr.corereaders.LibraryDataSource) LinkedList(java.util.LinkedList) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) InvalidDumpFormatException(com.ibm.j9ddr.corereaders.InvalidDumpFormatException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MissingFileModule(com.ibm.j9ddr.corereaders.memory.MissingFileModule) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) IModuleFile(com.ibm.j9ddr.corereaders.IModuleFile) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) MissingFileModule(com.ibm.j9ddr.corereaders.memory.MissingFileModule) IModule(com.ibm.j9ddr.corereaders.memory.IModule) Module(com.ibm.j9ddr.corereaders.memory.Module)

Example 4 with MemoryRange

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

the class AIXDumpReader method readThread.

// private J9DDRImageThread readThread(J9DDRImageAddressSpace addressSpace,
// long offset) throws IOException
private IOSThread readThread(long offset) throws IOException {
    // Note that we appear to be parsing a "struct thrdsinfo" here which is
    // described in "/usr/include/procinfo.h"
    // however, the shape for 64-bit is somewhat guessed since the structs
    // thrdentry64 and thrdsinfo64 (for 64 and 32 bit dumps, respectively),
    // which are listed in the documentation, don't appear to be the actual
    // structures at work here
    seek(offset);
    // tid is 64-bits one 64-bit platforms but 32-bits on 32-bit platforms
    // unsigned long ti_tid; /* thread identifier */
    long tid = readAddress();
    // unsigned long ti_pid; /* process identifier */
    readInt();
    /* scheduler information */
    // unsigned long ti_policy; /* scheduling policy */
    int ti_policy = readInt();
    // unsigned long ti_pri; /* current effective priority */
    int ti_pri = readInt();
    // unsigned long ti_state; /* thread state -- from thread.h */
    int ti_state = readInt();
    // unsigned long ti_flag; /* thread flags -- from thread.h */
    int ti_flag = readInt();
    // unsigned long ti_scount; /* suspend count */
    int ti_scount = readInt();
    // unsigned long ti_wtype; /* type of thread wait */
    int ti_wtype = readInt();
    // unsigned long ti_wchan; /* wait channel */
    int ti_wchan = readInt();
    // unsigned long ti_cpu; /* processor usage */
    int ti_cpu = readInt();
    // cpu_t ti_cpuid; /* processor on which I'm bound */
    int ti_cpuid = readInt();
    // sigset_t ti_sigmask /* sigs to be blocked */
    readSigset();
    // sigset_t ti_sig; /* pending sigs */
    readSigset();
    // unsigned long ti_code; /* iar of exception */
    readInt();
    // struct sigcontext *ti_scp; /* sigctx location in userspace */
    readAddress();
    // char ti_cursig; /* current/last signal taken */
    int signalNumber = 0xFF & readByte();
    Map<String, Number> registers = readRegisters(offset);
    Properties properties = new Properties();
    properties.put("scheduling policy", Integer.toHexString(ti_policy));
    properties.put("current effective priority", Integer.toHexString(ti_pri));
    properties.put("thread state", Integer.toHexString(ti_state));
    properties.put("thread flags", Integer.toHexString(ti_flag));
    properties.put("suspend count", Integer.toHexString(ti_scount));
    properties.put("type of thread wait", Integer.toHexString(ti_wtype));
    properties.put("wait channel", Integer.toHexString(ti_wchan));
    properties.put("processor usage", Integer.toHexString(ti_cpu));
    properties.put("processor on which I'm bound", Integer.toHexString(ti_cpuid));
    // the signal number should probably be exposed through a real API for,
    // for now, it is interesting info so just return it
    properties.put("current/last signal taken", Integer.toHexString(signalNumber));
    long stackPointer = getStackPointerFrom(registers);
    IMemoryRange range = getProcess().getMemoryRangeForAddress(stackPointer);
    if (null == range) {
        throw new IOException("Cannot find memory range for stackPointer " + Long.toHexString(stackPointer));
    }
    IMemoryRange stackRange = new MemoryRange(getProcess().getAddressSpace(), range, "stack");
    return new AIXOSThread(getProcess(), tid, Collections.singletonList(stackRange), properties, registers);
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) MemoryRange(com.ibm.j9ddr.corereaders.memory.MemoryRange) IOException(java.io.IOException) Properties(java.util.Properties)

Aggregations

IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)4 MemoryRange (com.ibm.j9ddr.corereaders.memory.MemoryRange)4 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 LinkedList (java.util.LinkedList)2 CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 IModuleFile (com.ibm.j9ddr.corereaders.IModuleFile)1 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)1 LibraryDataSource (com.ibm.j9ddr.corereaders.LibraryDataSource)1 IMemorySource (com.ibm.j9ddr.corereaders.memory.IMemorySource)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 MissingFileModule (com.ibm.j9ddr.corereaders.memory.MissingFileModule)1 Module (com.ibm.j9ddr.corereaders.memory.Module)1 UnbackedMemorySource (com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Properties (java.util.Properties)1