Search in sources :

Example 6 with J9ROMClassPointer

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

the class LinearDumper method addSlot.

public void addSlot(StructurePointer clazz, SlotType type, AbstractPointer slotPtr, String slotName, String additionalInfo) throws CorruptDataException {
    try {
        J9ROMNameAndSignaturePointer nas;
        long offset;
        /* The slots of the type J9_ROM_UTF8 are changed to have 2 slots:
			 * -J9_SRP_TO_STRING
			 * -J9_ROM_UTF8
			 * This is done because we want to print the SRP field and also print
			 * the UTF8 it is pointing to */
        switch(type) {
            case J9_ROM_UTF8:
                offset = slotPtr.getAddress() - clazz.getAddress();
                classRegions.add(new J9ClassRegion(slotPtr, SlotType.J9_SRP_TO_STRING, slotName, additionalInfo, type.getSize(), offset, true));
                VoidPointer srp = SelfRelativePointer.cast(slotPtr).get();
                addUTF8Region(clazz, slotName, additionalInfo, srp);
                break;
            case J9_UTF8:
                addUTF8Region(clazz, slotName, additionalInfo, slotPtr);
                break;
            /* The fields of the type J9_SRPNAS or J9_SRP are changed to have 2 J9_ROM_UTF8
				 * fields for their name and signature separated. */
            case J9_SRPNAS:
                nas = J9ROMNameAndSignaturePointer.cast(SelfRelativePointer.cast(slotPtr).get());
                if (nas.notNull()) {
                    addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
                    addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
                }
                /* Since it is a SRP to a NAS, also print the SRP field. */
                addSlot(clazz, SlotType.J9_SRP, slotPtr, "cpFieldNAS");
                break;
            case J9_NAS:
                nas = J9ROMNameAndSignaturePointer.cast(slotPtr);
                addSlot(clazz, SlotType.J9_ROM_UTF8, nas.nameEA(), "name");
                addSlot(clazz, SlotType.J9_ROM_UTF8, nas.signatureEA(), "signature");
                break;
            case J9_IntermediateClassData:
                offset = slotPtr.getAddress() - clazz.getAddress();
                classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, ((J9ROMClassPointer) clazz).intermediateClassDataLength().longValue(), offset, true));
                break;
            default:
                offset = slotPtr.getAddress() - clazz.getAddress();
                classRegions.add(new J9ClassRegion(slotPtr, type, slotName, additionalInfo, type.getSize(), offset, true));
                break;
        }
    } catch (Exception e) {
    }
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 7 with J9ROMClassPointer

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

the class LinearDumper method getAllRegions.

/**
 * Returns a tree of regions and slots. Each slot is under a region. The
 * root element is always null.
 * @param classWalker
 *
 * @return J9ClassRegionNode tree of J9ClassRegion
 * @throws CorruptDataException
 */
public J9ClassRegionNode getAllRegions(ClassWalker classWalker) throws CorruptDataException {
    classWalker.allSlotsInObjectDo(this);
    final StructurePointer clazz = classWalker.getClazz();
    /* Add the UTF8 region */
    if (firstJ9_ROM_UTF8 != Long.MAX_VALUE) {
        addSection(clazz, PointerPointer.cast(firstJ9_ROM_UTF8), lastJ9_ROM_UTF8 - firstJ9_ROM_UTF8, "UTF8", true);
    }
    groupSectionByName(clazz, "methodDebugInfo", false);
    groupSectionByName(clazz, "variableInfo", false);
    /*
		 * the offset is a pointer which points at the end of the current
		 * region, in the case of a region which have no real size, it points at
		 * the beginning of the region
		 */
    AbstractPointer offset = PointerPointer.NULL;
    J9ClassRegionNode currentNode = new J9ClassRegionNode(null);
    Stack<J9ClassRegionNode> parentStack = new Stack<J9ClassRegionNode>();
    J9ClassRegion previousRegion = null;
    Collections.sort(classRegions);
    for (J9ClassRegion region : classRegions) {
        if (isSameRegion(previousRegion, region)) {
            previousRegion = region;
            continue;
        }
        previousRegion = region;
        if (SlotType.J9_SECTION_START == region.getType()) {
            if (region.getComputePadding() && offset.notNull() && !offset.eq(region.getSlotPtr())) {
                currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", region.getSlotPtr().getAddress() - offset.getAddress(), 0, true)));
            }
            if (region.getComputePadding()) {
                offset = region.getSlotPtr();
            }
            parentStack.push(currentNode);
            J9ClassRegionNode newChild = new J9ClassRegionNode(region);
            currentNode.addChild(newChild);
            currentNode = newChild;
        } else if (SlotType.J9_SECTION_END == region.getType()) {
            if (region.getComputePadding()) {
                long paddingSize = (region.getSlotPtr().getAddress() - offset.getAddress());
                if (paddingSize != 0) {
                    currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", paddingSize, 0, true)));
                }
                offset = region.getSlotPtr();
            }
            currentNode = parentStack.pop();
        } else {
            boolean computePadding = false;
            if (currentNode.getNodeValue() != null) {
                computePadding = currentNode.getNodeValue().getComputePadding();
            }
            if (computePadding && offset.notNull() && !offset.eq(region.getSlotPtr())) {
                currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", region.getSlotPtr().getAddress() - offset.getAddress(), 0, true)));
            }
            if (computePadding) {
                offset = region.getSlotPtr().addOffset(region.length);
            }
            currentNode.addChild(new J9ClassRegionNode(region));
        }
    }
    // Padding after the class and inside the romSize.
    if (clazz instanceof J9ROMClassPointer) {
        long size = J9ROMClassPointer.cast(clazz).romSize().longValue();
        long paddingSize = (clazz.longValue() + size) - offset.longValue();
        if (paddingSize != 0) {
            currentNode.addChild(new J9ClassRegionNode(new J9ClassRegion(offset, SlotType.J9_Padding, "Padding", "", paddingSize, 0, true)));
            // The class padding might be inserted out of order
            Collections.sort(currentNode.getChildren());
        }
    }
    return currentNode;
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) StructurePointer(com.ibm.j9ddr.vm29.pointer.StructurePointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) Stack(java.util.Stack)

Example 8 with J9ROMClassPointer

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

the class BytecodesCommand method run.

// dbgext_bytecodes
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        J9MethodPointer ramMethod = J9MethodPointer.cast(address);
        long maps = 0;
        if (ramMethod.isNull()) {
            CommandUtils.dbgPrint(out, "bad or missing ram method addr\n");
            return;
        }
        J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= BCT_LittleEndianOutput;
        } else {
            maps |= BCT_BigEndianOutput;
        }
        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
        J9ROMClassPointer romClass = ramClass.romClass();
        J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, maps, 0);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 9 with J9ROMClassPointer

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

the class DumpRomClassCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long maps = 0;
        if (args.length != 1 && args.length != 2) {
            printUsage(out);
            return;
        }
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= J9BCTranslationData.BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= J9BCTranslationData.BCT_LittleEndianOutput;
        } else {
            maps |= J9BCTranslationData.BCT_BigEndianOutput;
        }
        /* check for name:<name> */
        if (args[0].startsWith("name:")) {
            long hitCount = 0;
            String searchClassName = args[0].substring(args[0].indexOf(':') + 1);
            PatternString pattern = new PatternString(searchClassName);
            J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
            ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
            while (iterator.hasNext()) {
                J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
                String javaName = J9ClassHelper.getJavaName(classPointer);
                if (pattern.isMatch(javaName)) {
                    hitCount++;
                    J9ROMClassPointer clazz = classPointer.romClass();
                    String hexString = clazz.getHexAddress();
                    out.println(String.format("ROMClass %1$s named %2$s\n", hexString, javaName));
                    J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
                }
            }
            out.println(String.format("Found %1$d class(es) with name %2$s\n", hitCount, searchClassName));
        } else {
            /* treat argument as address */
            long addr = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
            J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 10 with J9ROMClassPointer

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

the class DumpRomClassLinearCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0)
        throw new DDRInteractiveCommandException("This debug extension needs an address argument !dumpromclasslinear <addr>[,n]");
    String[] arguments = args[0].split(",");
    long addr = Long.decode(arguments[0]);
    long nestingThreshold;
    if (arguments.length > 1) {
        nestingThreshold = Long.decode(arguments[1]);
    } else {
        nestingThreshold = 1;
    }
    J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
    try {
        // ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
        out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(clazz.className()), clazz.getHexAddress()));
        ClassWalker classWalker = new RomClassWalker(clazz, context);
        new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreshold);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)27 CorruptDataException (com.ibm.j9ddr.CorruptDataException)16 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)11 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)8 U32 (com.ibm.j9ddr.vm29.types.U32)8 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)7 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)7 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)6 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)6 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 J9ROMConstantPoolItemPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMConstantPoolItemPointer)5 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)5 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 PatternString (com.ibm.j9ddr.util.PatternString)4 SelfRelativePointer (com.ibm.j9ddr.vm29.pointer.SelfRelativePointer)4 U16Pointer (com.ibm.j9ddr.vm29.pointer.U16Pointer)4 J9ConstantPoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)4 J9ClassRegionNode (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper.J9ClassRegionNode)4