Search in sources :

Example 11 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class J9JavaStackIterator method next.

public J9JavaStackPointer next() {
    try {
        if (hasNext()) {
            J9JavaStackPointer next;
            next = currentStack;
            currentStack = currentStack.previous();
            return next;
        } else {
            throw new NoSuchElementException("There are no more items available through this iterator");
        }
    } catch (CorruptDataException cde) {
        // broken link to previous stack section, terminate the walk
        currentStack = J9JavaStackPointer.NULL;
        raiseCorruptDataEvent("Error getting next stack section", cde, false);
        return null;
    }
}
Also used : J9JavaStackPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaStackPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException)

Example 12 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class GCVMThreadStackSlotIterator method scanSlots.

static void scanSlots(J9VMThreadPointer walkThread, IStackWalkerCallbacks stackWalkerCallbacks, boolean includeStackFrameClassReferences, boolean trackVisibleFrameDepth) {
    WalkState walkState = new WalkState();
    walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK;
    walkState.walkThread = walkThread;
    walkState.callBacks = stackWalkerCallbacks;
    if (trackVisibleFrameDepth) {
        walkState.skipCount = 0;
        walkState.flags |= J9_STACKWALK_VISIBLE_ONLY;
    } else {
        walkState.flags |= J9_STACKWALK_SKIP_INLINES;
    }
    if (includeStackFrameClassReferences) {
        walkState.flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS;
    }
    StackWalkResult result = StackWalkResult.STACK_CORRUPT;
    result = StackWalker.walkStackFrames(walkState);
    if (StackWalkResult.NONE != result) {
        /* Explicitly raising a corrupt data event here since returning StackWalkResult.STACK_CORRUPT is fairly common if a core is not taken at a safe gc point */
        CorruptDataException corruptDataException = new CorruptDataException("Stack walk returned: " + result + " for vmThread: " + walkThread.getHexAddress());
        EventManager.raiseCorruptDataEvent("", corruptDataException, false);
    }
}
Also used : WalkState(com.ibm.j9ddr.vm29.j9.stackwalker.WalkState) CorruptDataException(com.ibm.j9ddr.CorruptDataException) StackWalkResult(com.ibm.j9ddr.vm29.j9.stackwalker.StackWalkResult)

Example 13 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class MonitorTable method initializedCachedMonitorTable.

private void initializedCachedMonitorTable() {
    cachedMonitorTable = new HashMap<J9ObjectPointer, J9ObjectMonitorPointer>();
    try {
        Iterator<J9ObjectMonitorPointer> iterator = iterator();
        while (iterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitor = iterator.next();
            J9ObjectPointer object = J9ObjectPointer.cast(objectMonitor.monitor().userData());
            cachedMonitorTable.put(object, objectMonitor);
        }
    } catch (CorruptDataException e) {
        raiseCorruptDataEvent("Error building cached monitor table", e, false);
    }
}
Also used : J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 14 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class VMConstantPool method getFieldOffset.

/**
 * Get a field offset from the constant pool.
 * @param index A J9VmconstantpoolConstants index into the constant pool.  Must be for a static or instance field reference.
 * @return Either the offset to the object, or null if the field's class is not resolved in the constant pool.
 * @throws CorruptDataException If the field cannot be found in the related class or the CP index is not a field reference.
 */
public static J9ObjectFieldOffset getFieldOffset(long index) throws CorruptDataException {
    if (_constantPool.length <= index || 0 > index) {
        throw new IndexOutOfBoundsException("Index outside of constant pool bounds");
    }
    int cpIndex = (int) index;
    long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(_cpShapeDescription, cpIndex);
    if (J9CPTYPE_FIELD != shapeDesc) {
        throw new CorruptDataException("VMConstantPool[" + index + "] CP_TYPE is not J9CPTYPE_FIELD");
    }
    /* The offset of the field, to be returned */
    J9ObjectFieldOffset offset = null;
    if (null != _constantPool[cpIndex]) {
        offset = (J9ObjectFieldOffset) _constantPool[cpIndex];
    } else {
        J9ROMFieldRefPointer romRef = J9ROMFieldRefPointer.cast(_romCPStart.add(cpIndex));
        J9ClassPointer refClass = getClass(romRef.classRefCPIndex().longValue());
        J9ClassPointer currentClass = refClass;
        if (currentClass.notNull()) {
            /* If the current class is J9ClassPointer.NULL, return null as the field offset */
            /* Resolve the fieldname, starting from the current class,
				 * and working up the class hierarchy towards the super classes. This should
				 * properly handle shadowed fields.
				 */
            String fieldName = J9UTF8Helper.stringValue(romRef.nameAndSignature().name());
            String signature = J9UTF8Helper.stringValue(romRef.nameAndSignature().signature());
            while (currentClass.notNull() && (null == offset)) {
                Iterator<J9ObjectFieldOffset> fields = J9ClassHelper.getFieldOffsets(currentClass);
                while (fields.hasNext()) {
                    J9ObjectFieldOffset field = fields.next();
                    if (field.getName().equals(fieldName) && field.getSignature().equals(signature)) {
                        offset = field;
                        break;
                    }
                }
                currentClass = J9ClassHelper.superclass(currentClass);
            }
            if (null == offset) {
                /* The field should exist in the class it points to, unless the constant pool is corrupt or wrong */
                throw new CorruptDataException("VMConstantPool[" + index + "] field not found: " + J9ClassHelper.getName(refClass) + "." + fieldName + " " + signature);
            } else {
                _constantPool[cpIndex] = offset;
            }
        }
    }
    return offset;
}
Also used : J9ROMFieldRefPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMFieldRefPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 15 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class StringTable method iterator.

public SlotIterator<J9ObjectPointer> iterator() {
    return new SlotIterator<J9ObjectPointer>() {

        private SlotIterator<PointerPointer> hashTableIterator = null;

        private long currentIndex = 0;

        public boolean hasNext() {
            while (true) {
                // Is the current iterator good?
                if (hashTableIterator != null) {
                    // Are there still entries?
                    if (hashTableIterator.hasNext()) {
                        return true;
                    }
                    // Move to the next hash table
                    currentIndex++;
                }
                // Are there more hash tables?
                if (currentIndex >= _tableCount) {
                    hashTableIterator = null;
                    return false;
                }
                // Get the next hash table iterator
                try {
                    J9HashTablePointer hashTable = J9HashTablePointer.cast(_stringTable._table().at(currentIndex));
                    HashTable<PointerPointer> currentHashTable = HashTable.fromJ9HashTable(hashTable, false, PointerPointer.class, _hashFn, new StringComparatorFunction<PointerPointer>());
                    hashTableIterator = currentHashTable.iterator();
                } catch (CorruptDataException e) {
                    raiseCorruptDataEvent("Error getting next item", e, false);
                // Keep trying
                }
            }
        }

        public J9ObjectPointer next() {
            if (hasNext()) {
                PointerPointer next = hashTableIterator.next();
                return J9ObjectPointer.cast(next);
            } else {
                throw new NoSuchElementException("There are no more items available through this iterator");
            }
        }

        public VoidPointer nextAddress() {
            if (hasNext()) {
                return VoidPointer.cast(hashTableIterator.nextAddress());
            } else {
                throw new NoSuchElementException("There are no more items available through this iterator");
            }
        }

        public void remove() {
            throw new UnsupportedOperationException("The image is read only and cannot be modified.");
        }
    };
}
Also used : PointerPointer(com.ibm.j9ddr.vm29.pointer.PointerPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9HashTablePointer(com.ibm.j9ddr.vm29.pointer.generated.J9HashTablePointer) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)221 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)46 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)41 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)33 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)30 NoSuchElementException (java.util.NoSuchElementException)28 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)25 UDATA (com.ibm.j9ddr.vm29.types.UDATA)20 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)17 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)15 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 PatternString (com.ibm.j9ddr.util.PatternString)7 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)7 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)7