Search in sources :

Example 1 with ImageModule

use of com.ibm.dtfj.image.ImageModule in project openj9 by eclipse.

the class ImageModuleComparator method testEquals.

// getName()
// getProperties()
// getSections()
// getSymbols()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    ImageModule ddrImageModule = (ImageModule) ddrObject;
    ImageModule jextractImageModule = (ImageModule) jextractObject;
    // getName()
    if ((NAME & members) != 0) {
        testJavaEquals(ddrImageModule, jextractImageModule, "getName");
    }
    // getProperties
    if ((PROPERTIES & members) != 0) {
        testPropertiesEquals(ddrImageModule, jextractImageModule, "getProperties");
    }
    // getSections
    if ((SECTIONS & members) != 0) {
        new ImageSectionComparator().testComparatorIteratorEquals(ddrImageModule, jextractImageModule, "getSections", ImageSection.class);
    }
    // getSymbols
    if ((SYMBOLS & members) != 0) {
        new ImageSymbolComparator().testComparatorIteratorEquals(ddrImageModule, jextractImageModule, "getSymbols", ImageSymbol.class);
    }
}
Also used : ImageModule(com.ibm.dtfj.image.ImageModule)

Example 2 with ImageModule

use of com.ibm.dtfj.image.ImageModule in project openj9 by eclipse.

the class ImageStackFrame method getProcedureName.

public String getProcedureName() throws CorruptDataException {
    if (null == _procedureName) {
        ImageModule bestModule = null;
        ImageSymbol bestClosest = null;
        long bestDelta = Long.MAX_VALUE;
        for (Iterator i = this._space.getProcesses(); i.hasNext(); ) {
            Object nexti = i.next();
            if (nexti instanceof CorruptData)
                continue;
            ImageProcess process = (ImageProcess) nexti;
            if ((_procedureAddress.getAddress() != ((1L << process.getPointerSize()) - 1))) {
                try {
                    ImageModule module = process.getExecutable();
                    ImageSymbol closest = getClosestSymbolFrom(module);
                    long delta = getDelta(module, closest);
                    if (delta >= 0 && delta < bestDelta) {
                        bestModule = module;
                        bestClosest = closest;
                        bestDelta = delta;
                    }
                } catch (DataUnavailable e) {
                } catch (CorruptDataException e) {
                }
                try {
                    for (Iterator j = process.getLibraries(); j.hasNext(); ) {
                        Object next = j.next();
                        if (next instanceof CorruptData)
                            continue;
                        ImageModule module = (ImageModule) next;
                        ImageSymbol closest = getClosestSymbolFrom(module);
                        long delta = getDelta(module, closest);
                        if (delta >= 0 && delta < bestDelta) {
                            bestModule = module;
                            bestClosest = closest;
                            bestDelta = delta;
                        }
                    }
                } catch (DataUnavailable e) {
                } catch (CorruptDataException e) {
                }
            }
        }
        ImageSymbol closest = bestClosest;
        ImageModule module = bestModule;
        long delta = bestDelta;
        if (null != module) {
            String deltaString = "";
            if (delta == Long.MAX_VALUE) {
                deltaString = "<offset not available>";
            } else {
                if (delta >= 0) {
                    deltaString = "+0x" + Long.toHexString(delta);
                } else {
                    deltaString = "-0x" + Long.toHexString(delta);
                }
            }
            if (null != closest) {
                _procedureName = module.getName() + "::" + closest.getName() + deltaString;
            } else {
                _procedureName = module.getName() + deltaString;
            }
        }
    }
    // If we haven't found the symbol, we might as well record that fact.
    if (null == _procedureName) {
        _procedureName = "<unknown location>";
    }
    return _procedureName;
}
Also used : ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 3 with ImageModule

use of com.ibm.dtfj.image.ImageModule in project openj9 by eclipse.

the class XKCommand method printSymbol.

private boolean printSymbol(long pointer, long diff, int pointerSize) {
    ImageProcess ip = ctx.getProcess();
    Iterator itModule;
    try {
        itModule = ip.getLibraries();
    } catch (CorruptDataException e) {
        // FIXME
        itModule = null;
    } catch (DataUnavailable e) {
        // FIXME
        itModule = null;
    }
    while (null != itModule && itModule.hasNext()) {
        ImageModule im = (ImageModule) itModule.next();
        Iterator itImageSection = im.getSections();
        while (itImageSection.hasNext()) {
            ImageSection is = (ImageSection) itImageSection.next();
            long startAddr = is.getBaseAddress().getAddress();
            long endAddr = startAddr + is.getSize();
            if (pointer >= startAddr && pointer < endAddr) {
                /* can we find a matching symbol? */
                long maxDifference = pointer - startAddr;
                ImageSymbol bestSymbol = null;
                for (Iterator iter = im.getSymbols(); iter.hasNext(); ) {
                    Object next = iter.next();
                    if (next instanceof CorruptData)
                        continue;
                    ImageSymbol symbol = (ImageSymbol) next;
                    long symbolAddress = symbol.getAddress().getAddress();
                    if (symbolAddress <= pointer && pointer - symbolAddress < maxDifference) {
                        maxDifference = pointer - symbolAddress;
                        bestSymbol = symbol;
                    }
                }
                try {
                    out.print(im.getName());
                } catch (CorruptDataException e) {
                    out.print(Exceptions.getCorruptDataExceptionString());
                }
                out.print("::");
                if (bestSymbol == null) {
                    out.print(is.getName());
                } else {
                    out.print(bestSymbol.getName());
                }
                out.print("+");
                out.print(Long.toString(maxDifference));
                // trying to find it elsewhere in the address space
                return true;
            }
        }
    }
    return false;
}
Also used : ImageSymbol(com.ibm.dtfj.image.ImageSymbol) ImageProcess(com.ibm.dtfj.image.ImageProcess) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageModule(com.ibm.dtfj.image.ImageModule)

Example 4 with ImageModule

use of com.ibm.dtfj.image.ImageModule in project openj9 by eclipse.

the class NativeLibrariesCommand method getExeFromDDR.

// we can use the hint mechanism in DTFJ to work out the exe location for elf cores with very long path names
private void getExeFromDDR(Context ctx, PrintStream out) {
    try {
        ICore core = ctx.process.getAddressSpace().getCore();
        if (ILibraryDependentCore.class.isAssignableFrom(core.getClass())) {
            ILibraryDependentCore ldcore = (ILibraryDependentCore) core;
            J9DDRImageProcess proc = new J9DDRImageProcess(ctx.process);
            ImageModule exe = proc.getExecutable();
            out.println("exe = " + exe.getName());
            ldcore.executablePathHint(exe.getName());
        }
    } catch (Exception e) {
        out.println("Could not determine EXE name using DDR : " + e.getMessage());
    }
}
Also used : ILibraryDependentCore(com.ibm.j9ddr.corereaders.ILibraryDependentCore) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) ICore(com.ibm.j9ddr.corereaders.ICore) ImageModule(com.ibm.dtfj.image.ImageModule) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 5 with ImageModule

use of com.ibm.dtfj.image.ImageModule in project openj9 by eclipse.

the class PHDImageProcess method processData.

private void processData(ImageAddressSpace space) {
    // }
    if (metaImageProcess != null) {
        try {
            for (Iterator it = metaImageProcess.getLibraries(); it.hasNext(); ) {
                Object next = it.next();
                if (next instanceof CorruptData) {
                    modules.add(new PHDCorruptImageModule(space, (CorruptData) next));
                } else {
                    try {
                        ImageModule mod = (ImageModule) next;
                        modules.add(new PHDImageModule(mod.getName()));
                    } catch (CorruptDataException e) {
                        modules.add(new PHDCorruptImageModule(space, e));
                    }
                }
            }
        } catch (CorruptDataException e) {
            modules_cd = new PHDCorruptData(space, e);
        } catch (DataUnavailable e) {
        // Ignore
        }
        /*
			 * Set up the image threads
			 */
        ImageThread current;
        try {
            current = metaImageProcess.getCurrentThread();
        } catch (CorruptDataException e) {
            currentThread = new PHDCorruptImageThread(space, e.getCorruptData());
            current = null;
        }
        for (Iterator it = metaImageProcess.getThreads(); it.hasNext(); ) {
            Object next = it.next();
            if (next instanceof CorruptData) {
                threads.put(next, new PHDCorruptImageThread(space, (CorruptData) next));
            } else {
                ImageThread thrd = (ImageThread) next;
                ImageThread imageThread = getThread(space, thrd);
                if (thrd.equals(current)) {
                    currentThread = imageThread;
                }
            }
        }
    }
// pid = getPID(file);
// runtimes = new ArrayList<JavaRuntime>();
// runtimes.add(new PHDJavaRuntime(file, parentImage, space,this,metaRuntime));
}
Also used : Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) ImageThread(com.ibm.dtfj.image.ImageThread) ImageModule(com.ibm.dtfj.image.ImageModule)

Aggregations

ImageModule (com.ibm.dtfj.image.ImageModule)15 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)6 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)5 ImageProcess (com.ibm.dtfj.image.ImageProcess)5 Iterator (java.util.Iterator)5 CorruptData (com.ibm.dtfj.image.CorruptData)3 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)3 IAttributeValueMap (com.ibm.dtfj.javacore.parser.j9.IAttributeValueMap)3 IOException (java.io.IOException)3 Image (com.ibm.dtfj.image.Image)2 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)2 ImageFactory (com.ibm.dtfj.image.ImageFactory)2 J9DDRImageFactory (com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory)2 ImageSection (com.ibm.dtfj.image.ImageSection)1 ImageThread (com.ibm.dtfj.image.ImageThread)1 JCImageModule (com.ibm.dtfj.image.javacore.JCImageModule)1 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)1 JavaVMInitArgs (com.ibm.dtfj.java.JavaVMInitArgs)1 JavaVMOption (com.ibm.dtfj.java.JavaVMOption)1 ParserException (com.ibm.dtfj.javacore.parser.framework.parser.ParserException)1