Search in sources :

Example 56 with J9ClassPointer

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

the class J9ClassHelper method getArrayName.

public static String getArrayName(J9ClassPointer clazz) throws CorruptDataException {
    J9ArrayClassPointer arrayClass = J9ArrayClassPointer.cast(clazz);
    StringBuilder name = new StringBuilder();
    int arity = 0;
    try {
        arity = arrayClass.arity().intValue();
    } catch (InvalidDataTypeException e) {
        throw new AddressedCorruptDataException(arrayClass.getAddress(), "Array arity larger than MAXINT");
    }
    if (arity > MAXIMUM_ARRAY_ARITY) {
        // Doubtful
        throw new AddressedCorruptDataException(arrayClass.getAddress(), "Very high arity " + arity + " from array class 0x" + Long.toHexString(arrayClass.getAddress()));
    }
    for (int i = 0; i < arity; i++) {
        name.append('[');
    }
    String elementClassName = J9ClassHelper.getName(arrayClass.leafComponentType());
    Character type = TYPE_MAP.get(elementClassName);
    if (type != null) {
        name.append(type);
    } else {
        name.append('L');
        name.append(elementClassName);
        name.append(";");
    }
    return name.toString();
}
Also used : J9ArrayClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ArrayClassPointer) AddressedCorruptDataException(com.ibm.j9ddr.AddressedCorruptDataException) InvalidDataTypeException(com.ibm.j9ddr.InvalidDataTypeException)

Example 57 with J9ClassPointer

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

the class AbstractPointer method getObjectClassAtOffset.

protected J9ClassPointer getObjectClassAtOffset(long offset) throws CorruptDataException {
    long location = address + offset;
    long classPointer;
    if (J9BuildFlags.interp_compressedObjectHeader) {
        classPointer = (long) getAddressSpace().getIntAt(location) & 0xFFFFFFFFL;
    } else {
        classPointer = getAddressSpace().getPointerAt(location);
    }
    if (classPointer == 0L) {
        throw new MemoryFault(location, "Invalid class address found in object");
    }
    J9ClassPointer cp = checkClassCache(classPointer);
    if (cp == null) {
        cp = J9ClassPointer.cast(classPointer);
        setClassCache(classPointer, cp);
    }
    return cp;
}
Also used : MemoryFault(com.ibm.j9ddr.corereaders.memory.MemoryFault) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)

Example 58 with J9ClassPointer

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

the class J9MethodHelper method getName.

public static String getName(J9MethodPointer methodPointer) throws CorruptDataException {
    J9ClassPointer className;
    J9ConstantPoolPointer constantPool;
    if (methodPointer.isNull())
        return "bad ramMethod";
    constantPool = ConstantPoolHelpers.J9_CP_FROM_METHOD(methodPointer);
    if (constantPool.isNull()) {
        return "error reading constant pool from ramMethod";
    }
    className = ConstantPoolHelpers.J9_CLASS_FROM_CP(constantPool);
    if (className.isNull()) {
        return "error reading class name from constant pool";
    }
    J9ROMNameAndSignaturePointer nameAndSignature = ROMHelp.J9_ROM_METHOD_FROM_RAM_METHOD(methodPointer).nameAndSignature();
    String name = J9UTF8Helper.stringValue(nameAndSignature.name());
    String signature = J9UTF8Helper.stringValue(nameAndSignature.signature());
    return J9ClassHelper.getName(className) + "." + name + signature;
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ConstantPoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer)

Example 59 with J9ClassPointer

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

the class J9ObjectHelper method readFieldOffset.

// FIXME: Probably want to cache the entire class hierarchy the 1st time through for any field
private static J9ObjectFieldOffset readFieldOffset(J9ObjectPointer objPointer, String name, String signature) throws CorruptDataException {
    J9ClassPointer currentClass = J9ObjectHelper.clazz(objPointer);
    while (currentClass.notNull()) {
        Iterator<J9ObjectFieldOffset> fields = J9ClassHelper.getFieldOffsets(currentClass);
        while (fields.hasNext()) {
            J9ObjectFieldOffset field = (J9ObjectFieldOffset) fields.next();
            if (field.getName().equals(name) && field.getSignature().equals(signature)) {
                return field;
            }
        }
        currentClass = J9ClassHelper.superclass(currentClass);
    }
    throw new NoSuchElementException(String.format("No field named %s with signature %s in %s", name, signature, J9ObjectHelper.getClassName(objPointer)));
}
Also used : J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset) NoSuchElementException(java.util.NoSuchElementException)

Example 60 with J9ClassPointer

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

the class AllClassesCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    init();
    if (args != null) {
        if (!parseArgs(out, args)) {
            return;
        }
    }
    boolean useRange = (rangeStart != null && rangeEnd != null);
    /* If none of "rom" or "ram" is specified, then list both type of classes */
    if (!dumpROMClasses && !dumpRAMClasses) {
        dumpROMClasses = dumpRAMClasses = true;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (dumpRAMClasses) {
            out.append("RAM classes (ram size loader rom replacement name)" + nl);
            out.append("Class addr\tsize\t\tClassLoader\tROM class addr\tArray\tClass name" + nl);
            out.append(nl);
            ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
            while (classSegmentIterator.hasNext()) {
                J9ClassPointer classPointer = J9ClassPointer.NULL;
                try {
                    classPointer = (J9ClassPointer) classSegmentIterator.next();
                    if (useRange) {
                        if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
                            /* J9Class is outside of specified range; skip it. */
                            continue;
                        }
                    }
                    // 0x02713400 0x00000148 0x001210cc 0x02da2f20 0x00000000
                    // java/util/regex/Pattern$Begin
                    out.append(classPointer.getHexAddress());
                    out.append('\t');
                    out.append(J9ClassHelper.size(classPointer, vm).getHexValue());
                    out.append('\t');
                    out.append(classPointer.classLoader().getHexAddress());
                    out.append('\t');
                    out.append(classPointer.romClass().getHexAddress());
                    out.append('\t');
                    if (J9ClassHelper.isSwappedOut(classPointer)) {
                        out.append(classPointer.arrayClass().getHexAddress());
                    } else {
                        out.append('0');
                    }
                    out.append('\t');
                    out.append(J9ClassHelper.getJavaName(classPointer));
                    out.append(nl);
                } catch (CorruptDataException e) {
                    if (useRange) {
                        if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
                            /* J9Class that caused CorruptDataException is outside of specified range; skip it. */
                            continue;
                        }
                    }
                }
            }
        }
        if (dumpROMClasses) {
            ROMClassesIterator iterator = null;
            out.append(nl);
            if (useRange) {
                iterator = new ROMClassesRangeIterator(out, rangeStart, rangeEnd);
                /* Classloader is not available when using ROMClassesRangeIterator */
                out.append("ROM classes (rom size modifiers name)" + nl);
                out.append("Class addr\tROM size\tModifiers\tExtra\t\tClass name" + nl);
            } else {
                iterator = new ROMClassesIterator(out, vm.classMemorySegments());
                out.append("ROM classes (rom size loader modifiers name)" + nl);
                out.append("Class addr\tROM size\tClassLoader\tModifiers\tExtra\t\tClass name" + nl);
            }
            out.append(nl);
            while (iterator.hasNext()) {
                J9ROMClassPointer classPointer = iterator.next();
                out.append(classPointer.getHexAddress());
                out.append('\t');
                out.append(classPointer.romSize().getHexValue());
                /* MemorySegment is not available when using ROMClassesRangeIterator */
                if (iterator.getMemorySegmentPointer() != J9MemorySegmentPointer.NULL) {
                    out.append('\t');
                    out.append(iterator.getMemorySegmentPointer().classLoader().getHexAddress());
                }
                out.append('\t');
                out.append(classPointer.modifiers().getHexValue());
                out.append('\t');
                out.append(classPointer.extraModifiers().getHexValue());
                out.append('\t');
                out.append(J9UTF8Helper.stringValue(classPointer.className()));
                out.append(nl);
            }
            out.append(nl);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) ROMClassesRangeIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesRangeIterator) 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) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)67 CorruptDataException (com.ibm.j9ddr.CorruptDataException)34 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)13 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)13 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)12 UDATA (com.ibm.j9ddr.vm29.types.UDATA)12 U32 (com.ibm.j9ddr.vm29.types.U32)11 J9MemorySegmentPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MemorySegmentPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)8 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)8 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)7 NoSuchElementException (java.util.NoSuchElementException)7 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)6 J9ClassLoaderPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassLoaderPointer)6 GCClassHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCClassHeapIterator)5 GCSegmentIterator (com.ibm.j9ddr.vm29.j9.gc.GCSegmentIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 J9ITablePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ITablePointer)5