Search in sources :

Example 56 with J9ObjectPointer

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

the class GCVMThreadMonitorRecordSlotIterator method next.

public J9ObjectPointer next() {
    if (hasNext()) {
        try {
            J9ObjectPointer next;
            if (monitorRecord.notNull()) {
                next = monitorRecord.object();
                monitorRecord = monitorRecord.next();
            } else {
                next = jniMonitorRecord.object();
                jniMonitorRecord = jniMonitorRecord.next();
            }
            return next;
        } catch (CorruptDataException e) {
            // can try to recover from this
            raiseCorruptDataEvent("Error getting next item", e, false);
            return null;
        }
    } else {
        throw new NoSuchElementException("There are no more items available through this iterator");
    }
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) NoSuchElementException(java.util.NoSuchElementException)

Example 57 with J9ObjectPointer

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

the class MonitorIterator method threadPoolHasNext.

private boolean threadPoolHasNext() throws CorruptDataException {
    while ((current == null) && pool.notNull()) {
        while (index < poolSize) {
            J9ThreadMonitorPointer monitor = J9ThreadMonitorPointer.cast(poolEntries.add(index));
            index++;
            if (freeTag != monitor.count().longValue()) {
                J9ThreadAbstractMonitorPointer lock = J9ThreadAbstractMonitorPointer.cast(monitor);
                if (lock.flags().allBitsIn(J9ThreadAbstractMonitor.J9THREAD_MONITOR_OBJECT)) {
                    if (!lock.userData().eq(0)) {
                        // this is an object monitor in the system monitor table
                        J9ObjectPointer obj = J9ObjectPointer.cast(lock.userData());
                        ObjectMonitor objmon = ObjectAccessBarrier.getMonitor(obj);
                        // This check is to exclude flat object monitors. Flat object monitors are accounted for during the heap walk
                        if ((objmon == null) || !objmon.isInflated()) {
                            continue;
                        }
                        // return an object monitor
                        current = objmon;
                    }
                } else {
                    // return a system monitor
                    current = monitor;
                }
                if (log.isLoggable(Level.FINE)) {
                    log.fine(String.format("Found monitor @ 0x%016x : %s", monitor.getAddress(), monitor.name().getCStringAtOffset(0)));
                }
                return true;
            }
        }
        pool = pool.next();
        if (pool.notNull()) {
            index = 0;
            poolEntries = pool.entriesEA();
        }
    }
    return pool.notNull();
}
Also used : J9ThreadMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadMonitorPointer) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer) ObjectMonitor(com.ibm.j9ddr.vm29.j9.ObjectMonitor)

Example 58 with J9ObjectPointer

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

the class J9IndexableObjectHelper method getDataAsString.

public static String getDataAsString(J9IndexableObjectPointer array, int dumpLimit, int characterDumpLimit) throws CorruptDataException {
    StringWriter buf = new StringWriter();
    J9ClassPointer clazz = J9ObjectHelper.clazz(J9ObjectPointer.cast(array));
    char typeChar = J9ClassHelper.getName(clazz).charAt(1);
    int length = J9IndexableObjectHelper.size(array).intValue();
    int limit = 0;
    if (typeChar != 'C') {
        limit = dumpLimit;
    } else {
        limit = characterDumpLimit;
    }
    buf.write("{ ");
    int i;
    for (i = 0; i < Math.min(length, limit); i++) {
        Object data = J9IndexableObjectHelper.getData(array);
        switch(typeChar) {
            case 'B':
                buf.write("0x");
                buf.write(Integer.toHexString(((byte[]) data)[i]));
                break;
            case 'C':
                char ch = ((char[]) data)[i];
                if (ch > 31 && ch < 127) {
                    buf.write(ch);
                } else {
                    buf.write('?');
                }
                break;
            case 'D':
                buf.write(Double.toString(((double[]) data)[i]));
                break;
            case 'F':
                buf.write(Float.toString(((float[]) data)[i]));
                break;
            case 'I':
                buf.write("0x");
                buf.write(Integer.toHexString(((int[]) data)[i]));
                break;
            case 'J':
                buf.write("0x");
                buf.write(Long.toHexString(((long[]) data)[i]));
                break;
            case 'S':
                buf.write("0x");
                buf.write(Integer.toHexString(((short[]) data)[i]));
                break;
            case 'Z':
                buf.write(((boolean[]) data)[i] ? "true" : "false");
                break;
            case 'L':
            case '[':
                {
                    J9ObjectPointer item = ((J9ObjectPointer[]) data)[i];
                    if (null == item) {
                        buf.write("null");
                    } else {
                        buf.write("0x");
                        buf.write(Long.toHexString(item.longValue()));
                    }
                    break;
                }
            default:
                buf.write("?");
        }
        if (typeChar != 'C' && (i != length - 1)) {
            /* We aren't printing out a character and we aren't the last element */
            buf.write(", ");
        }
    }
    if (i != length) {
        /* We hit the limit */
        buf.write("... ");
    }
    buf.write(" }");
    return buf.toString();
}
Also used : StringWriter(java.io.StringWriter) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 59 with J9ObjectPointer

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

the class J9ObjectHelper method getFieldOffset.

private static J9ObjectFieldOffset getFieldOffset(J9ObjectPointer objPointer, String name, String signature) throws CorruptDataException {
    J9ObjectFieldOffset result = J9ClassHelper.checkFieldOffsetCache(J9ObjectHelper.clazz(objPointer), name, signature);
    if (result == null) {
        result = readFieldOffset(objPointer, name, signature);
        J9ClassHelper.setFieldOffsetCache(J9ObjectHelper.clazz(objPointer), result, name, signature);
    }
    return result;
}
Also used : J9ObjectFieldOffset(com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)

Example 60 with J9ObjectPointer

use of com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer 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)

Aggregations

J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)76 CorruptDataException (com.ibm.j9ddr.CorruptDataException)48 UDATA (com.ibm.j9ddr.vm29.types.UDATA)22 NoSuchElementException (java.util.NoSuchElementException)18 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)17 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)16 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)12 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)7 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)6 ObjectMonitor (com.ibm.j9ddr.vm29.j9.ObjectMonitor)5 MarkedObject (com.ibm.j9ddr.vm29.j9.gc.GCHeapMap.MarkedObject)5 GCHeapRegionDescriptor (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor)5 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)5 GCObjectHeapIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectHeapIterator)4 GCObjectIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)4 ArrayList (java.util.ArrayList)4 J9ObjectFieldOffset (com.ibm.j9ddr.vm29.j9.J9ObjectFieldOffset)3 GCHeapRegionIterator (com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator)3 U32Pointer (com.ibm.j9ddr.vm29.pointer.U32Pointer)3