Search in sources :

Example 1 with DumpMemorySource

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

the class AIXDumpReader method readCore.

protected void readCore() throws IOException {
    // Note that this structure is core_dumpx defined in
    // "/usr/include/sys/core.h"
    seek(0);
    // Ignore signalNumber
    readByte();
    // CORE_TRUNC == 0x80
    byte flags = readByte();
    if ((flags & 0x80) != 0) {
        _isTruncated = true;
    }
    // Ignore entryCount
    readShort();
    // Ignore version (core file format number)
    readInt();
    // Ignore fdsinfox
    readLong();
    _loaderOffset = readLong();
    _loaderSize = readLong();
    _threadCount = readInt();
    // Ignore padding
    readInt();
    _threadOffset = readLong();
    long segmentCount = readLong();
    long segmentOffset = readLong();
    // Stack - this appears to be special handling for the main thread first
    // attached to the address space
    // (this is helpful for us since that is how we can find command line
    // and env vars)
    long stackOffset = readLong();
    long stackVirtualAddress = readLong();
    long stackSize = readLong();
    _structTopOfStackVirtualAddress = stackVirtualAddress + stackSize - sizeofTopOfStack();
    IMemorySource memoryRange1 = new DumpMemorySource(stackVirtualAddress, stackSize, stackOffset, 0, this, "stack", false, false, false);
    addMemorySource(memoryRange1);
    // User data
    long dataOffset = readLong();
    long dataVirtualAddress = readLong();
    long dataSize = readLong();
    IMemorySource memoryRange = new DumpMemorySource(dataVirtualAddress, dataSize, dataOffset, this);
    addMemorySource(memoryRange);
    // Ignore sdataVirtualAddress
    readLong();
    // Ignore sdataSize
    readLong();
    long vmRegionCount = readLong();
    long vmRegionOffset = readLong();
    _implementation = readInt();
    // Ignore padding
    readInt();
    // Ignore checkpointRestartOffset
    readLong();
    // Ignore unsigned long long c_extctx; (Extended Context
    readLong();
    // Table offset)
    // Ignore padding (6 longs)
    readBytes(6 * 8);
    // ignore struct thrdctx c_flt; (faulting thread's context) //this is
    // resolved later via that constant "FAULTING_THREAD_OFFSET"
    // ignore struct userx c_u; (copy of the user structure)
    // >> end of core_dumpx structure
    readVMRegions(vmRegionOffset, vmRegionCount);
    readSegments(segmentOffset, segmentCount);
    readLoaderInfoAsMemoryRanges();
    readModules();
    _isTruncated |= checkHighestOffset();
    createProperties();
}
Also used : DumpMemorySource(com.ibm.j9ddr.corereaders.memory.DumpMemorySource) IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource)

Example 2 with DumpMemorySource

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

the class AIXDumpReader method readLoaderInfoAsMemoryRanges.

private void readLoaderInfoAsMemoryRanges() throws IOException {
    int next = 0;
    long current = _loaderOffset;
    do {
        current += next;
        seek(current);
        next = readInt();
        // Ignore flags
        readLoaderInfoFlags();
        long dataOffset = readAddress();
        // Ignore textOrigin
        readAddress();
        // Ignore textSize
        readAddress();
        long dataVirtualAddress = readAddress();
        long dataSize = readAddress();
        if (0 != dataOffset) {
            IMemorySource memoryRange = new DumpMemorySource(dataVirtualAddress, dataSize, dataOffset, this);
            // memoryRange.setDescription(name + " " +
            // Long.toHexString(textOrigin) + "-" +
            // Long.toHexString(textOrigin + textSize));
            addMemorySource(memoryRange);
        }
    } while (0 != next && current + next < _loaderOffset + _loaderSize);
}
Also used : DumpMemorySource(com.ibm.j9ddr.corereaders.memory.DumpMemorySource) IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource)

Example 3 with DumpMemorySource

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

the class AIXDumpReader method readSegments.

private void readSegments(long offset, long count) throws IOException {
    seek(offset);
    for (int i = 0; i < count; i++) {
        long address = readLong();
        long size = readLong();
        long off = readLong();
        // Ignore segmentFlags
        readInt();
        // Ignore padding
        readInt();
        // Anonymously mapped area
        IMemorySource memoryRange = new DumpMemorySource(address, size, off, 0, this, "anon segment");
        addMemorySource(memoryRange);
    }
}
Also used : DumpMemorySource(com.ibm.j9ddr.corereaders.memory.DumpMemorySource) IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource)

Example 4 with DumpMemorySource

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

the class AIXDumpReader method readVMRegions.

private void readVMRegions(long offset, long count) throws IOException {
    seek(offset);
    for (int i = 0; i < count; i++) {
        long address = readLong();
        long size = readLong();
        long off = readLong();
        // Anonymously mapped area
        IMemorySource memoryRange = new DumpMemorySource(address, size, off, 0, this, "anon vm region");
        // memoryRange.setDescription("anon vm region");
        addMemorySource(memoryRange);
    }
}
Also used : DumpMemorySource(com.ibm.j9ddr.corereaders.memory.DumpMemorySource) IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource)

Example 5 with DumpMemorySource

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

the class MemoryInfoStream method readFrom.

public void readFrom(MiniDumpReader dump, boolean is64Bit, Collection<? extends IMemorySource> ranges) throws IOException {
    dump.seek(getLocation());
    int sizeOfHeader = 0;
    int sizeOfEntry = 0;
    long numberOfEntries = 0;
    HashMap<Long, Properties> memoryInfo = new HashMap<Long, Properties>();
    // The header is 2 ULONGs, which are 32 bit and a ULONG64
    sizeOfHeader = dump.readInt();
    sizeOfEntry = dump.readInt();
    numberOfEntries = dump.readLong();
    // The thread info structures follow the header.
    /* Each structure is:
			ULONG64 BaseAddress;
			ULONG64 AllocationBase;
			ULONG32 AllocationProtect;
			ULONG32 __alignment1;
			ULONG64 RegionSize;
			ULONG32 State;
			ULONG32 Protect;
			ULONG32 Type;
			ULONG32 __alignment2;
		 */
    // We should be exactly here already but to be safe.
    dump.seek(getLocation() + sizeOfHeader);
    for (int i = 0; i < numberOfEntries; i++) {
        Properties props = new Properties();
        long baseAddress = dump.readLong();
        long allocationBase = dump.readLong();
        int allocationProtect = dump.readInt();
        // alignment1
        dump.readInt();
        long regionSize = dump.readLong();
        int state = dump.readInt();
        int protect = dump.readInt();
        int type = dump.readInt();
        // alignment2
        dump.readInt();
        props.put("state", decodeStateFlags(state));
        props.put("state_flags", String.format("0x%X", state));
        props.put("size", String.format(is64Bit ? "0x%016X" : "0x%08X", regionSize));
        if (state != STATE_MEM_FREE) {
            // For free memory allocation base, allocation protect, protect and type are undefined.
            props.put("allocationBase", String.format(is64Bit ? "0x%016X" : "0x%08X", allocationBase));
            props.put("allocationProtect", decodeProtectFlags(allocationProtect));
            props.put("allocationProtect_flags", String.format("0x%X", allocationProtect));
            props.put("protect", decodeProtectFlags(protect));
            setReadWriteExecProperties(protect, props);
            props.put("protect_flags", String.format("0x%X", protect));
            props.put("type", decodeTypeFlags(type));
            props.put("type_flags", String.format("0x%X", allocationProtect));
        } else {
            // Free memory is not accessible.
            props.setProperty(READABLE, FALSE);
            props.setProperty(WRITABLE, FALSE);
            props.setProperty(EXECUTABLE, FALSE);
        }
        memoryInfo.put(new Long(baseAddress), props);
    }
    /* Merge the extra properties into the memory info. */
    Iterator<? extends IMemorySource> memoryIterator = ranges.iterator();
    List<IMemorySource> newRanges = new ArrayList<IMemorySource>(memoryInfo.size());
    while (memoryIterator.hasNext()) {
        IMemorySource m = memoryIterator.next();
        Properties p = memoryInfo.remove(m.getBaseAddress());
        if (p != null && m instanceof DumpMemorySource) {
            DetailedDumpMemorySource newSource = new DetailedDumpMemorySource((DumpMemorySource) m, p);
            newSource.getProperties().putAll(p);
            newRanges.add(newSource);
        } else {
            newRanges.add(m);
        }
    }
    // Add sections we didn't find as unbacked memory!
    // (There should be at least one huge one in the middle if this is 64 bit.)
    Iterator<Entry<Long, Properties>> propsIterator = memoryInfo.entrySet().iterator();
    while (propsIterator.hasNext()) {
        Entry<Long, Properties> e = propsIterator.next();
        long size = Long.parseLong(((String) e.getValue().get("size")).substring(2), 16);
        String explanation = "Windows MINIDUMP_MEMORY_INFO entry included but data not included in dump";
        if ("MEM_FREE".equals(e.getValue().get("state"))) {
            explanation = "Free memory, unallocated";
        }
        UnbackedMemorySource m = new UnbackedMemorySource(e.getKey(), size, explanation);
        m.getProperties().putAll(e.getValue());
        newRanges.add(m);
    }
    Collections.sort(newRanges, new Comparator<IMemorySource>() {

        public int compare(IMemorySource o1, IMemorySource o2) {
            if (o1.getBaseAddress() > o2.getBaseAddress()) {
                return 1;
            } else if (o1.getBaseAddress() < o2.getBaseAddress()) {
                return -1;
            }
            return 0;
        }
    });
    dump.setMemorySources(newRanges);
}
Also used : DetailedDumpMemorySource(com.ibm.j9ddr.corereaders.memory.DetailedDumpMemorySource) DumpMemorySource(com.ibm.j9ddr.corereaders.memory.DumpMemorySource) IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource) DetailedDumpMemorySource(com.ibm.j9ddr.corereaders.memory.DetailedDumpMemorySource) HashMap(java.util.HashMap) UnbackedMemorySource(com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource) ArrayList(java.util.ArrayList) Properties(java.util.Properties) Entry(java.util.Map.Entry)

Aggregations

DumpMemorySource (com.ibm.j9ddr.corereaders.memory.DumpMemorySource)6 IMemorySource (com.ibm.j9ddr.corereaders.memory.IMemorySource)6 ArrayList (java.util.ArrayList)2 DetailedDumpMemorySource (com.ibm.j9ddr.corereaders.memory.DetailedDumpMemorySource)1 UnbackedMemorySource (com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Properties (java.util.Properties)1