Search in sources :

Example 1 with UnbackedMemorySource

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

the class ProgramHeaderEntry method asMemorySource.

IMemorySource asMemorySource() {
    IMemorySource source = null;
    if (!isEmpty()) {
        boolean isExecutable = (_flags & PF_X) != 0;
        source = new ELFMemorySource(virtualAddress, memorySize, fileOffset, reader);
    } else {
        source = new UnbackedMemorySource(virtualAddress, memorySize, "ELF ProgramHeaderEntry storage declared but data not included");
    }
    Properties memoryProps = ((IDetailedMemoryRange) source).getProperties();
    memoryProps.setProperty("IN_CORE", "" + (!isEmpty()));
    if ((_flags & PF_W) != 0) {
        memoryProps.setProperty(IDetailedMemoryRange.WRITABLE, Boolean.TRUE.toString());
    }
    if ((_flags & PF_X) != 0) {
        memoryProps.setProperty(IDetailedMemoryRange.EXECUTABLE, Boolean.TRUE.toString());
    }
    if ((_flags & PF_R) != 0) {
        memoryProps.setProperty(IDetailedMemoryRange.READABLE, Boolean.TRUE.toString());
    }
    return source;
}
Also used : IMemorySource(com.ibm.j9ddr.corereaders.memory.IMemorySource) UnbackedMemorySource(com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource) IDetailedMemoryRange(com.ibm.j9ddr.corereaders.memory.IDetailedMemoryRange) Properties(java.util.Properties)

Example 2 with UnbackedMemorySource

use of com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource 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 3 with UnbackedMemorySource

use of com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource 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

IMemorySource (com.ibm.j9ddr.corereaders.memory.IMemorySource)3 UnbackedMemorySource (com.ibm.j9ddr.corereaders.memory.UnbackedMemorySource)3 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)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 DetailedDumpMemorySource (com.ibm.j9ddr.corereaders.memory.DetailedDumpMemorySource)1 DumpMemorySource (com.ibm.j9ddr.corereaders.memory.DumpMemorySource)1 IDetailedMemoryRange (com.ibm.j9ddr.corereaders.memory.IDetailedMemoryRange)1 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)1 IModule (com.ibm.j9ddr.corereaders.memory.IModule)1 MemoryRange (com.ibm.j9ddr.corereaders.memory.MemoryRange)1 MissingFileModule (com.ibm.j9ddr.corereaders.memory.MissingFileModule)1 Module (com.ibm.j9ddr.corereaders.memory.Module)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1