Search in sources :

Example 11 with IModule

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

the class BaseWindowsOSThread method getModuleForInstructionAddress.

public UnwindModule getModuleForInstructionAddress(long address) throws CorruptDataException {
    Collection<? extends IModule> modules = process.getModules();
    IModule matchingModule = null;
    OUTER_LOOP: for (IModule thisModule : modules) {
        for (IMemoryRange thisRange : thisModule.getMemoryRanges()) {
            if (thisRange.contains(address)) {
                matchingModule = thisModule;
                break OUTER_LOOP;
            }
        }
    }
    if (matchingModule == null || !(matchingModule instanceof UnwindModule)) {
        return null;
    }
    return (UnwindModule) matchingModule;
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) IModule(com.ibm.j9ddr.corereaders.memory.IModule) UnwindModule(com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule)

Example 12 with IModule

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

the class ModuleStream method readFrom.

@Override
public void readFrom(MiniDumpReader dump, IAddressSpace as, boolean is64Bit) throws IOException, CorruptDataException {
    dump.seek(getLocation());
    int numberOfModules = dump.readInt();
    if (numberOfModules > 1024) {
        throw new CorruptDataException("Improbably high number of modules found: " + numberOfModules + ", location = " + Long.toHexString(getLocation()));
    }
    class ModuleData {

        long imageBaseAddress;

        Properties properties;

        int nameAddress;
    }
    ModuleData[] moduleData = new ModuleData[numberOfModules];
    for (int i = 0; i < numberOfModules; i++) {
        moduleData[i] = new ModuleData();
        moduleData[i].imageBaseAddress = dump.readLong();
        int imageSize = dump.readInt();
        int checksum = dump.readInt();
        int timeDateStamp = dump.readInt();
        moduleData[i].nameAddress = dump.readInt();
        moduleData[i].properties = readProperties(dump, imageSize, checksum, timeDateStamp);
    }
    for (ModuleData thisModule : moduleData) {
        final long imageBaseAddress = thisModule.imageBaseAddress;
        final String moduleName = getModuleName(dump, thisModule.nameAddress);
        final Properties properties = thisModule.properties;
        short magic;
        try {
            magic = as.getShortAt(imageBaseAddress);
            if (0x5A4D != magic) {
                logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "Magic number was: " + Integer.toHexString(0xFFFF & magic) + " expected 0x5A4D");
            }
        } catch (MemoryFault e1) {
            logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "MemoryFault reading magic number", e1);
        }
        long e_lfanewAddress = imageBaseAddress + 0x3c;
        // load the e_lfanew since that is the load-address-relative location of
        // the PE Header
        Collection<IMemoryRange> sections = new LinkedList<IMemoryRange>();
        try {
            long e_lfanew = 0xFFFFFFFFL & as.getIntAt(e_lfanewAddress);
            // push us to the start of the PE header
            long readingAddress = e_lfanew + imageBaseAddress;
            List<ISymbol> symbols = null;
            if (0 != e_lfanew) {
                loadModuleSections(as, imageBaseAddress, readingAddress, e_lfanew, sections);
                symbols = buildSymbols(dump, as, imageBaseAddress);
            }
            if (symbols == null) {
                symbols = new LinkedList<ISymbol>();
            }
            // Load the list of RUNTIME_FUNCTION structures that map code
            // ranges to stack unwind information.
            List<RuntimeFunction> runtimeFunctionList = null;
            runtimeFunctionList = buildRuntimeFunctionList(dump, as, imageBaseAddress);
            IModule module;
            if (runtimeFunctionList != null) {
                module = new UnwindModule(as.getProcesses().iterator().next(), moduleName, symbols, sections, thisModule.imageBaseAddress, properties, runtimeFunctionList);
            // Uncommend to dump unwind info as we find it. This is very verbose.
            // ((UnwindModule)module).dumpUndwindInfo(System.err);
            } else {
                module = new Module(as.getProcesses().iterator().next(), moduleName, symbols, sections, thisModule.imageBaseAddress, properties);
            }
            if (moduleName.toLowerCase().endsWith(".exe")) {
                dump.setExecutable(module);
            } else {
                dump.addLibrary(module);
            }
        } catch (RuntimeException e) {
            // Don't want to prevent RTE's propogating
            throw e;
        } catch (Exception e) {
            // this needs to be here in order to not fail completely whenever we
            // encounter a strange record
            logger.logp(Level.WARNING, "com.ibm.j9ddr.corereaders.minidump.ModuleStream", "readFrom", "Problem reading symbols", e);
        }
    }
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol) CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties) LinkedList(java.util.LinkedList) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) CorruptCoreException(com.ibm.j9ddr.corereaders.CorruptCoreException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) MemoryFault(com.ibm.j9ddr.corereaders.memory.MemoryFault) UnwindModule(com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule) IModule(com.ibm.j9ddr.corereaders.memory.IModule) Module(com.ibm.j9ddr.corereaders.memory.Module) UnwindModule(com.ibm.j9ddr.corereaders.minidump.unwind.UnwindModule) RuntimeFunction(com.ibm.j9ddr.corereaders.minidump.unwind.RuntimeFunction)

Example 13 with IModule

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

the class WindowsProcessAddressSpace method getEnvironmentSymbols.

/**
 *  This method returns a list of symbols with the name "_environ"
 *
 *  @return LinkedList instance of symbols with the name "_environ"
 *  @throws CorruptDataException
 */
private LinkedList<ISymbol> getEnvironmentSymbols() throws CorruptDataException {
    List<IModule> modules = getModules();
    LinkedList<ISymbol> symbols = new LinkedList<ISymbol>();
    for (IModule thisModule : modules) {
        try {
            for (ISymbol thisSymbol : thisModule.getSymbols()) {
                if (thisSymbol.getName().equals("_environ")) {
                    symbols.add(thisSymbol);
                }
            }
        } catch (DataUnavailableException e) {
            continue;
        }
    }
    return symbols;
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) ISymbol(com.ibm.j9ddr.corereaders.memory.ISymbol) LinkedList(java.util.LinkedList)

Example 14 with IModule

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

the class J9DDRImageProcess method getLibraries.

public Iterator<?> getLibraries() throws DataUnavailable, CorruptDataException {
    try {
        Collection<? extends IModule> modules = process.getModules();
        List<ImageModule> libraries = new ArrayList<ImageModule>();
        for (IModule module : modules) {
            libraries.add(new J9DDRImageModule(process, module));
        }
        return libraries.iterator();
    } catch (com.ibm.j9ddr.CorruptDataException e) {
        throw new DTFJCorruptDataException(new J9DDRCorruptData(process, e));
    }
}
Also used : IModule(com.ibm.j9ddr.corereaders.memory.IModule) DTFJCorruptDataException(com.ibm.j9ddr.view.dtfj.DTFJCorruptDataException) ArrayList(java.util.ArrayList) ImageModule(com.ibm.dtfj.image.ImageModule)

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