Search in sources :

Example 1 with ImageSection

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

the class DTFJTest method writeObject.

@SuppressWarnings("unchecked")
protected void writeObject(JavaObject obj, long index) throws Exception {
    startTag("<object");
    write(" index=\"" + index + "\"");
    write(" address=\"0x" + Long.toHexString(obj.getID().getAddress()) + "\"");
    write(" size=\"0x" + Long.toHexString(obj.getSize()) + "\"");
    write(">\n");
    writeClass(obj.getJavaClass());
    tag("<toString>" + obj.toString() + "</toString>\n");
    tag("<persistentHashCode>" + obj.getPersistentHashcode() + "</persistentHashCode>\n");
    if (obj.isArray()) {
        tag("<array elementCount=\"0x" + Long.toHexString(obj.getArraySize()) + "\" />\n");
    }
    for (Iterator sections = obj.getSections(); sections.hasNext(); ) {
        ImageSection section = (ImageSection) sections.next();
        writeSection(section);
    }
    endTag("</object>\n");
}
Also used : Iterator(java.util.Iterator) ImageSection(com.ibm.dtfj.image.ImageSection)

Example 2 with ImageSection

use of com.ibm.dtfj.image.ImageSection 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 3 with ImageSection

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

the class J9DDRImageAddressSpace method getImageSections.

public Iterator<?> getImageSections() {
    Collection<? extends IMemoryRange> ranges = as.getMemoryRanges();
    List<ImageSection> sections = new ArrayList<ImageSection>(ranges.size());
    IProcess proc = getPointerProcess();
    // it may be the case that we can't determine the pointer size if there are no processes found in the address space
    if (null == proc) {
        return J9DDRDTFJUtils.emptyIterator();
    }
    for (IMemoryRange thisRange : ranges) {
        J9DDRImageSection section = new J9DDRImageSection(proc, thisRange.getBaseAddress(), thisRange.getSize(), thisRange.getName());
        sections.add(section);
    }
    return sections.iterator();
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) ArrayList(java.util.ArrayList) ImageSection(com.ibm.dtfj.image.ImageSection) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 4 with ImageSection

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

the class J9DDRImageThread method getStackSections.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.image.ImageThread#getStackSections()
	 */
public Iterator<?> getStackSections() {
    Collection<? extends IMemoryRange> ranges = thread.getMemoryRanges();
    List<ImageSection> sections = new ArrayList<ImageSection>(ranges.size());
    for (IMemoryRange range : ranges) {
        sections.add(new J9DDRImageSection(process, range.getBaseAddress(), range.getSize(), "stack section at " + Long.toHexString(range.getBaseAddress())));
    }
    return sections.iterator();
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) ArrayList(java.util.ArrayList) ImageSection(com.ibm.dtfj.image.ImageSection)

Example 5 with ImageSection

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

the class J9DDRImageModule method getSections.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.image.ImageModule#getSections()
	 */
@SuppressWarnings("unchecked")
public Iterator getSections() {
    Collection<? extends IMemoryRange> ranges = delegate.getMemoryRanges();
    List<ImageSection> sections = new ArrayList<ImageSection>(ranges.size());
    for (IMemoryRange range : ranges) {
        sections.add(new J9DDRImageSection(process, range.getBaseAddress(), range.getSize(), range.getName()));
    }
    return sections.iterator();
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) ArrayList(java.util.ArrayList) ImageSection(com.ibm.dtfj.image.ImageSection)

Aggregations

ImageSection (com.ibm.dtfj.image.ImageSection)30 Iterator (java.util.Iterator)18 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)11 ArrayList (java.util.ArrayList)7 CorruptData (com.ibm.dtfj.image.CorruptData)6 LinkedList (java.util.LinkedList)5 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)4 J9DDRImageSection (com.ibm.j9ddr.view.dtfj.image.J9DDRImageSection)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 JavaMethod (com.ibm.dtfj.java.JavaMethod)3 JavaObject (com.ibm.dtfj.java.JavaObject)3 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)3 ImageProcess (com.ibm.dtfj.image.ImageProcess)2 ImageSymbol (com.ibm.dtfj.image.ImageSymbol)2 ImageThread (com.ibm.dtfj.image.ImageThread)2 JavaClass (com.ibm.dtfj.java.JavaClass)2 JavaHeap (com.ibm.dtfj.java.JavaHeap)2 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)2 J9DDRDTFJUtils.corruptIterator (com.ibm.j9ddr.view.dtfj.J9DDRDTFJUtils.corruptIterator)2 GCClassLoaderIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassLoaderIterator)2