Search in sources :

Example 6 with IModule

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

the class NativeLibrariesCommand method showLibList.

// list the libraries from the core file and report whether or not they have been collected
private void showLibList(Context ctx, PrintStream out) {
    LibReader reader = new LibReader();
    out.println("Showing library list for " + DDRInteractive.getPath());
    Collection<? extends IModule> libs = null;
    try {
        libs = ctx.process.getModules();
    } catch (CorruptDataException e) {
        out.println("Corrupt data exception when retrieving list of libraries : " + e.getMessage());
        return;
    }
    getExeFromDDR(ctx, out);
    for (IModule lib : libs) {
        try {
            out.println("Lib : " + lib.getName());
            FooterLibraryEntry entry = reader.getEntry(lib.getName());
            if (entry == null) {
                out.println("\tLibrary is not appended to the core file, it may be present on the local disk");
            } else {
                out.println("\tLibrary has been collected");
                out.println("\tPath : " + entry.getPath());
                out.println("\tName : " + entry.getName());
                out.println("\tSize : " + entry.getSize());
            }
        } catch (CorruptDataException e) {
            out.println("Library name is corrupt");
        }
    }
}
Also used : FooterLibraryEntry(com.ibm.j9ddr.libraries.FooterLibraryEntry) IModule(com.ibm.j9ddr.corereaders.memory.IModule) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with IModule

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

the class DDRSymbolFinder method addVoidPointersAsSymbols.

private static void addVoidPointersAsSymbols(String structureName, long structureAddress, StructureReader structureReader, IProcess process) throws DataUnavailableException, CorruptDataException {
    if (structureAddress == 0) {
        return;
    }
    List<String> voidFields = getVoidPointerFieldsFromStructure(structureReader, structureName);
    if (voidFields == null) {
        return;
    }
    // Format the hex and structure name the same as the rest of DDR.
    int paddingSize = process.bytesPerPointer() * 2;
    String formatString = "[!%s 0x%0" + paddingSize + "X->%s]";
    for (String field : voidFields) {
        if (ignoredSymbols.contains(structureName + "." + field)) {
            // Ignore this field, it's not a function.
            continue;
        }
        long functionAddress = followPointerFromStructure(structureName, structureAddress, field, structureReader, process);
        if (functionAddress == 0) {
            // Skip null pointers.
            continue;
        }
        // Lower case the structure name to match the rest of the DDR !<struct> commands.
        String symName = String.format(formatString, structureName.toLowerCase(), structureAddress, field);
        if (functionAddress == 0) {
            // Null pointer, possibly unset or no longer used.
            continue;
        }
        if (addSymbols) {
            IModule module = getModuleForInstructionAddress(process, functionAddress);
            if (module == null) {
                continue;
            }
            boolean found = false;
            // Don't override/duplicate symbols we've already seen.
            for (ISymbol sym : module.getSymbols()) {
                if (sym.getAddress() == functionAddress) {
                    Logger logger = Logger.getLogger(LoggerNames.LOGGER_STRUCTURE_READER);
                    logger.log(FINER, "DDRSymbolFinder: Found exact match with " + sym.toString() + " not adding.");
                    found = true;
                    break;
                }
            }
            if (!found) {
                Logger logger = Logger.getLogger(LoggerNames.LOGGER_STRUCTURE_READER);
                logger.log(FINER, "DDRSymbolFinder: Adding new DDR symbol " + symName);
                SymbolUtil.addDDRSymbolToModule(module, "[" + field + "]", symName, functionAddress);
            }
        }
    }
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol) Logger(java.util.logging.Logger)

Example 8 with IModule

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

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

the class ELFDumpReader method close.

public void close() throws IOException {
    // close the handle to the dump
    _reader.close();
    // now close any open module handles
    if ((_executable != null) && (_executable instanceof ELFFileReader)) {
        ((ELFFileReader) _executable).is.close();
    }
    for (IModule module : _modules) {
        if (module instanceof ELFFileReader) {
            ((ELFFileReader) module).is.close();
        }
    }
    // close any tracked open files
    for (ELFFileReader reader : openFileTracker) {
        if (reader != null) {
            reader.close();
        }
    }
    // release any resources acquired for library resolution
    _resolver.dispose();
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule)

Example 10 with IModule

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

the class MiniDumpReader method parseStreams.

private void parseStreams() throws IOException, CorruptCoreException {
    seek(_streamDirectoryRva);
    List<EarlyInitializedStream> earlyStreams = new LinkedList<EarlyInitializedStream>();
    for (int i = 0; i < _numberOfStreams; i++) {
        int streamType = readInt();
        int dataSize = readInt();
        // TODO: should location be a long?
        // long location = (readInt() << 32) + rva1;
        int location = readInt();
        switch(streamType) {
            case Stream.THREADLIST:
                threadStreams.add(new ThreadStream(dataSize, location));
                break;
            case Stream.MODULELIST:
                moduleStreams.add(new ModuleStream(dataSize, location));
                break;
            case Stream.SYSTEMINFO:
                // Needs to go at the front - we rely on it to tell us the
                // pointer size
                earlyStreams.add(0, new SystemInfoStream(dataSize, location));
                break;
            case Stream.MEMORY64LIST:
                earlyStreams.add(new Memory64Stream(dataSize, location));
                break;
            case Stream.MISCINFO:
                earlyStreams.add(new MiscInfoStream(dataSize, location));
                break;
            case Stream.THREADINFO:
                threadInfoStreams.add(new ThreadInfoStream(dataSize, location));
                break;
            case Stream.MEMORYINFO:
                memoryInfoStreams.add(new MemoryInfoStream(dataSize, location));
                break;
        }
    }
    for (EarlyInitializedStream entry : earlyStreams) {
        entry.readFrom(this);
        int ptrSize = entry.readPtrSize(this);
        if (0 != ptrSize) {
            _is64bit = ptrSize == 64 ? true : false;
        }
    }
    for (MemoryInfoStream entry : memoryInfoStreams) {
        entry.readFrom(this, is64Bit(), _memoryRanges);
    }
    // and user32, so any WOW64 process will have at least these 5 loaded.
    if (_is64bit) {
        int wowCount = 0;
        for (IModule module : getModules()) {
            try {
                String modName = module.getName().toLowerCase();
                if (modName.contains("syswow64")) {
                    wowCount++;
                }
            } catch (CorruptDataException e) {
            // Silently ignore for now, and report when the user actually wants to read the modules.
            }
        }
        if (wowCount > 5) {
            _is64bit = false;
            // A side effect of loading the modules above is that we must (later) reconstruct the address spaces.
            addressSpaces = null;
        }
    }
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) CorruptDataException(com.ibm.j9ddr.CorruptDataException) LinkedList(java.util.LinkedList)

Aggregations

IModule (com.ibm.j9ddr.corereaders.memory.IModule)14 CorruptDataException (com.ibm.j9ddr.CorruptDataException)6 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)5 LinkedList (java.util.LinkedList)5 MissingFileModule (com.ibm.j9ddr.corereaders.memory.MissingFileModule)4 IOException (java.io.IOException)4 IMemorySource (com.ibm.j9ddr.corereaders.memory.IMemorySource)3 ISymbol (com.ibm.j9ddr.corereaders.memory.ISymbol)3 Module (com.ibm.j9ddr.corereaders.memory.Module)3 ArrayList (java.util.ArrayList)3 InvalidDumpFormatException (com.ibm.j9ddr.corereaders.InvalidDumpFormatException)2 LibraryDataSource (com.ibm.j9ddr.corereaders.LibraryDataSource)2 MemoryFault (com.ibm.j9ddr.corereaders.memory.MemoryFault)2 UnwindModule (com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Properties (java.util.Properties)2 ImageModule (com.ibm.dtfj.image.ImageModule)1 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)1 CorruptCoreException (com.ibm.j9ddr.corereaders.CorruptCoreException)1 ILibraryResolver (com.ibm.j9ddr.corereaders.ILibraryResolver)1