Search in sources :

Example 6 with AbstractPointer

use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.

the class CheckEngine method findRegionForPointer.

private GCHeapRegionDescriptor findRegionForPointer(AbstractPointer pointer, GCHeapRegionDescriptor region) {
    GCHeapRegionDescriptor regionDesc = null;
    if (region != null && region.isAddressInRegion(pointer)) {
        return region;
    }
    regionDesc = regionForAddress(pointer);
    if (null != regionDesc) {
        return regionDesc;
    }
    // TODO kmt : this is tragically slow
    try {
        GCHeapRegionIterator iterator = GCHeapRegionIterator.from();
        while (iterator.hasNext()) {
            regionDesc = GCHeapRegionDescriptor.fromHeapRegionDescriptor(iterator.next());
            if (isPointerInRegion(pointer, regionDesc)) {
                return regionDesc;
            }
        }
    } catch (CorruptDataException e) {
    }
    return null;
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with AbstractPointer

use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.

the class J9ObjectStructureFormatter method printObjectField.

public void printObjectField(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ClassPointer fromClass, J9ObjectFieldOffset objectFieldOffset) throws CorruptDataException {
    J9ROMFieldShapePointer fieldShape = objectFieldOffset.getField();
    UDATA fieldOffset = objectFieldOffset.getOffsetOrAddress();
    boolean isHiddenField = objectFieldOffset.isHidden();
    String className = J9UTF8Helper.stringValue(fromClass.romClass().className());
    String fieldName = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().name());
    String fieldSignature = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().signature());
    U8Pointer valuePtr = dataStart;
    valuePtr = valuePtr.add(fieldOffset);
    padding(out, tabLevel);
    out.print(String.format("%s %s = ", fieldSignature, fieldName));
    if (fieldShape.modifiers().anyBitsIn(J9FieldSizeDouble)) {
        out.print(U64Pointer.cast(valuePtr).at(0).getHexValue());
    } else if (fieldShape.modifiers().anyBitsIn(J9FieldFlagObject)) {
        AbstractPointer ptr = J9BuildFlags.gc_compressedPointers ? U32Pointer.cast(valuePtr) : UDATAPointer.cast(valuePtr);
        out.print(String.format("!fj9object 0x%x", ptr.at(0).longValue()));
    } else {
        out.print(I32Pointer.cast(valuePtr).at(0).getHexValue());
    }
    out.print(String.format(" (offset=%d) (%s)", fieldOffset.longValue(), className));
    if (isHiddenField) {
        out.print(" <hidden>");
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA) J9ROMFieldShapePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldShapePointer) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer)

Example 8 with AbstractPointer

use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.

the class MMSublistSlotIterator method next.

public AbstractPointer next() {
    if (hasNext()) {
        VoidPointer currentScanPtr = VoidPointer.cast(scanPtr);
        scanPtr = scanPtr.add(1);
        return currentScanPtr;
    } else {
        throw new NoSuchElementException("There are no more items available through this iterator");
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 9 with AbstractPointer

use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.

the class ClassWalker method addObjectsAsSlot.

/**
 * It walks through each field in this structure that is represented by methodClass and
 * registers each field as a slot into ClassWalkerCallBack
 *
 * It uses the StructureDescriptor of J9DDR to get the FieldDescriptor of a structure.
 * The name, type and address are found in the FieldDescriptor. The name, type and address
 * are guaranteed to match the current core file, since they are taken from it.
 *
 * @param methodClass pointer class that is generated for the VM structure
 * @param renameFields	list of names to rename the original field names in the structure
 * @throws CorruptDataException
 */
protected void addObjectsAsSlot(StructurePointer methodClass, HashMap<String, String> renameFields) throws CorruptDataException {
    /* Get the structure name by removing "Pointer" suffix from the DDR generated class name*/
    String structureName = methodClass.getClass().getSimpleName().substring(0, methodClass.getClass().getSimpleName().indexOf("Pointer"));
    /* Get structure descriptor by using structure name */
    StructureDescriptor sd = StructureCommandUtil.getStructureDescriptor(structureName, getContext());
    /* Structure descriptor can not be null in normal circumstances, 
		 * because StructurePointer "methodClass" is generated for an existing structure in the VM, 
		 * so it should exist. If not, throw an exception. 
		 */
    if (sd == null) {
        throw new CorruptDataException("Structure \"" + structureName + "\" can not be found.");
    }
    for (FieldDescriptor fd : sd.getFields()) {
        /* Get the name of the field from field descriptor */
        String outName = fd.getName();
        /* Get SlotType by using field type name */
        SlotType type = getTypeByFieldTypeName(fd.getType());
        /* Get the address of the field by adding the offset to the methodClass'address */
        AbstractPointer address = U8Pointer.cast(methodClass).addOffset(fd.getOffset());
        /* Rename fields if any defined. */
        if (null != renameFields) {
            if (renameFields.containsKey(outName)) {
                outName = renameFields.get(outName);
            }
        }
        /*add the field into classWalkerCallback by its name, type, address and debug extension method name */
        classWalkerCallback.addSlot(clazz, type, address, outName, getDebugExtForMethodName(outName));
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) StructureDescriptor(com.ibm.j9ddr.StructureReader.StructureDescriptor) FieldDescriptor(com.ibm.j9ddr.StructureReader.FieldDescriptor) SlotType(com.ibm.j9ddr.vm29.tools.ddrinteractive.IClassWalkCallbacks.SlotType)

Example 10 with AbstractPointer

use of com.ibm.j9ddr.vm29.pointer.AbstractPointer in project openj9 by eclipse.

the class LinearDumper method groupSectionByName.

/**
 * Find the first and the last section and group them in another section with the same name ending with a "s".
 * For example, it will group all of the methodDebugInfo in a section named methodDebugInfos
 * It is important to note that the function does not check if the sections grouped are contiguous, it will
 * group all sections between the first and the last section even if their names doesn't match.
 *
 * @param clazz
 * @param name name of sections to group
 * @param computePadding
 * @throws CorruptDataException
 */
private void groupSectionByName(final StructurePointer clazz, String name, boolean computePadding) throws CorruptDataException {
    AbstractPointer firstMethodDebugInfo = null;
    AbstractPointer lastMethodDebugInfo = null;
    for (J9ClassRegion region : classRegions) {
        if (SlotType.J9_SECTION_START == region.getType() && region.getName().equals(name)) {
            if (firstMethodDebugInfo == null || region.getSlotPtr().lt(firstMethodDebugInfo)) {
                firstMethodDebugInfo = region.getSlotPtr();
            }
            if (lastMethodDebugInfo == null || region.getSlotPtr().add(region.getLength()).gt(lastMethodDebugInfo)) {
                lastMethodDebugInfo = region.getSlotPtr().addOffset(region.getLength());
            }
        }
    }
    if (firstMethodDebugInfo != null && lastMethodDebugInfo != null) {
        UDATA length = UDATA.cast(lastMethodDebugInfo).sub(UDATA.cast(firstMethodDebugInfo));
        addSection(clazz, PointerPointer.cast(firstMethodDebugInfo), length.longValue(), name + "s", computePadding);
    }
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) UDATA(com.ibm.j9ddr.vm29.types.UDATA)

Aggregations

AbstractPointer (com.ibm.j9ddr.vm29.pointer.AbstractPointer)8 CorruptDataException (com.ibm.j9ddr.CorruptDataException)7 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)4 UDATA (com.ibm.j9ddr.vm29.types.UDATA)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)2 StructurePointer (com.ibm.j9ddr.vm29.pointer.StructurePointer)2 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)2 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 FieldDescriptor (com.ibm.j9ddr.StructureReader.FieldDescriptor)1 StructureDescriptor (com.ibm.j9ddr.StructureReader.StructureDescriptor)1 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)1 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)1 U64Pointer (com.ibm.j9ddr.vm29.pointer.U64Pointer)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)1