Search in sources :

Example 51 with VoidPointer

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

the class MonitorsCommand method j9vmthreadCommand.

/**
 * See {@link MonitorsCommand#helpCommand(String[], PrintStream)} for
 * function documentation
 *
 * @param args
 *            command args
 * @param out
 *            the output stream
 * @throws DDRInteractiveCommandException
 */
private void j9vmthreadCommand(String[] args, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length < 2) {
        out.println("This command takes one address argument: \"!monitors j9vmthread <address>\"");
        return;
    }
    try {
        long address = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
        VoidPointer ptr = VoidPointer.cast(address);
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        J9VMThreadPointer thread = null;
        GCVMThreadListIterator threadIterator = GCVMThreadListIterator.from();
        while (threadIterator.hasNext()) {
            if (ptr.equals(threadIterator.next())) {
                thread = J9VMThreadPointer.cast(ptr);
            }
        }
        if (null == thread) {
            throw new DDRInteractiveCommandException(String.format("Could not find any j9vmthread at address %s\n", ptr.getHexAddress()));
        }
        // Step 1: Print the general info for the VM and native threads:
        out.println(String.format("!j9vmthread 0x%08x\t!j9thread 0x%08x\t// %s", thread.getAddress(), thread.osThread().getAddress(), J9VMThreadHelper.getName(thread)));
        printMonitorsForJ9VMThread(out, vm, thread);
        printMonitorsForJ9Thread(out, vm, thread.osThread());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCVMThreadListIterator(com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9VMThreadPointer(com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 52 with VoidPointer

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

the class WalkJ9PoolCommand method walkJ9Pool.

/**
 * This method walks through each element in the pool and prints each elements' address.
 * Elements can be in the same puddle or different, and this method do not print puddle information.
 *
 * @param address address of the pool
 * @param out print stream
 * @throws DDRInteractiveCommandException
 */
private void walkJ9Pool(long address, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9PoolPointer j9pool = J9PoolPointer.cast(address);
        Pool pool = Pool.fromJ9Pool(j9pool, VoidPointer.class);
        SlotIterator<VoidPointer> poolIterator = pool.iterator();
        VoidPointer currentElement;
        int i = 0;
        while (poolIterator.hasNext()) {
            currentElement = poolIterator.next();
            out.println(String.format("\t[%d]\t=\t%s", i++, currentElement.getHexAddress()));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException("Either address is not a valid pool address or pool itself is corrupted.");
    }
}
Also used : J9PoolPointer(com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer) VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) Pool(com.ibm.j9ddr.vm29.j9.Pool) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 53 with VoidPointer

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

the class CheckEngine method checkObjectHeap.

public int checkObjectHeap(J9ObjectPointer object, GCHeapRegionDescriptor regionDesc) {
    int result = J9MODRON_SLOT_ITERATOR_OK;
    boolean isDead = false;
    boolean isIndexable = false;
    J9ClassPointer clazz = null;
    try {
        if (ObjectModel.isDeadObject(object)) {
            /* this is a hole */
            result = checkJ9LinkedFreeHeader(GCHeapLinkedFreeHeader.fromJ9Object(object), regionDesc, _cycle.getCheckFlags());
            if (J9MODRON_GCCHK_RC_OK != result) {
                CheckError error = new CheckError(object, _cycle, _currentCheck, "Object", result, _cycle.nextErrorCount());
                _reporter.report(error);
                /* There are some error cases would not prevent further iteration */
                if (!((J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_HOLE == result) || (J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_NOT_IN_REGION == result) || (J9MODRON_GCCHK_RC_DEAD_OBJECT_NEXT_IS_POINTED_INSIDE == result))) {
                    _reporter.reportHeapWalkError(error, _lastHeapObject1, _lastHeapObject2, _lastHeapObject3);
                    return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
                }
            }
            return J9MODRON_SLOT_ITERATOR_OK;
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
        return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
    }
    try {
        // Prefetch this data to make CDE handling easy
        isIndexable = ObjectModel.isIndexable(object);
        clazz = J9ObjectHelper.clazz(object);
        result = checkJ9Object(object, regionDesc, _cycle.getCheckFlags());
    } catch (CorruptDataException cde) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
        return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
    }
    if (J9MODRON_GCCHK_RC_OK != result) {
        String elementName = isIndexable ? "IObject " : "Object ";
        CheckError error = new CheckError(object, _cycle, _currentCheck, elementName, result, _cycle.nextErrorCount());
        _reporter.report(error);
        /* There are some error cases would not prevent further iteration */
        if (!(J9MODRON_GCCHK_RC_CLASS_IS_UNLOADED == result)) {
            _reporter.reportHeapWalkError(error, _lastHeapObject1, _lastHeapObject2, _lastHeapObject3);
            return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
        } else {
            return J9MODRON_SLOT_ITERATOR_OK;
        }
    }
    try {
        /* check Ownable Synchronizer Object consistency */
        if (needVerifyOwnableSynchronizerConsistency()) {
            if (J9Object.OBJECT_HEADER_SHAPE_MIXED == ObjectModel.getClassShape(clazz).intValue() && !J9ClassHelper.classFlags(clazz).bitAnd(J9AccClassOwnableSynchronizer).eq(0)) {
                if (ObjectAccessBarrier.isObjectInOwnableSynchronizerList(object).isNull()) {
                    CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_OWNABLE_SYNCHRONIZER_OBJECT_IS_NOT_ATTACHED_TO_THE_LIST, _cycle.nextErrorCount());
                    _reporter.report(error);
                } else {
                    _ownableSynchronizerObjectCountOnHeap += 1;
                }
            }
        }
    } catch (CorruptDataException cde) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
        _reporter.report(error);
        return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
    }
    if (J9MODRON_GCCHK_RC_OK == result) {
        GCObjectIterator fieldIterator;
        GCObjectIterator addressIterator;
        try {
            fieldIterator = GCObjectIterator.fromJ9Object(object, true);
            addressIterator = GCObjectIterator.fromJ9Object(object, true);
        } catch (CorruptDataException e) {
            // TODO : cde should be part of the error
            CheckError error = new CheckError(object, _cycle, _currentCheck, "Object ", J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount());
            _reporter.report(error);
            return J9MODRON_SLOT_ITERATOR_UNRECOVERABLE_ERROR;
        }
        while (fieldIterator.hasNext()) {
            J9ObjectPointer field = fieldIterator.next();
            VoidPointer address = addressIterator.nextAddress();
            result = checkSlotObjectHeap(field, ObjectReferencePointer.cast(address), regionDesc, object);
            if (J9MODRON_SLOT_ITERATOR_OK != result) {
                break;
            }
        }
    }
    if (J9MODRON_GCCHK_RC_OK == result) {
        /* this heap object is OK. Record it in the cache in case we find a pointer to it soon */
        int cacheIndex = (int) (object.getAddress() % OBJECT_CACHE_SIZE);
        _checkedObjectCache[cacheIndex] = object;
    }
    return result;
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) GCObjectIterator(com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Example 54 with VoidPointer

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

the class CheckMonitorTable method print.

@Override
public void print() {
    try {
        VoidPointer monitorTableList = VoidPointer.cast(getJavaVM().monitorTableList());
        GCMonitorReferenceIterator monitorReferenceIterator = GCMonitorReferenceIterator.from();
        MonitorTable previousMonitorTable = null;
        ScanFormatter formatter = new ScanFormatter(this, "MonitorTableList", monitorTableList);
        while (monitorReferenceIterator.hasNext()) {
            J9ObjectMonitorPointer objectMonitor = monitorReferenceIterator.next();
            MonitorTable currentMonitorTable = monitorReferenceIterator.currentMonitorTable();
            if (!currentMonitorTable.equals(previousMonitorTable)) {
                if (null != previousMonitorTable) {
                    formatter.endSection();
                }
                formatter.section("MonitorTable", currentMonitorTable.getMonitorTableListEntryPointer());
            }
            J9ThreadAbstractMonitorPointer monitor = J9ThreadAbstractMonitorPointer.cast(objectMonitor.monitor());
            formatter.entry(VoidPointer.cast(monitor.userData()));
            previousMonitorTable = currentMonitorTable;
        }
        if (null != previousMonitorTable) {
            formatter.endSection();
        }
        formatter.end("MonitorTableList", monitorTableList);
    } catch (CorruptDataException e) {
    // TODO: handle exception
    }
}
Also used : VoidPointer(com.ibm.j9ddr.vm29.pointer.VoidPointer) J9ObjectMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectMonitorPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) GCMonitorReferenceIterator(com.ibm.j9ddr.vm29.j9.gc.GCMonitorReferenceIterator) MonitorTable(com.ibm.j9ddr.vm29.j9.MonitorTable) J9ThreadAbstractMonitorPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ThreadAbstractMonitorPointer)

Example 55 with VoidPointer

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

the class CheckEngine method checkSlot.

public int checkSlot(PointerPointer objectIndirect, VoidPointer objectIndirectBase, int objectType) {
    J9ObjectPointer object;
    try {
        object = J9ObjectPointer.cast(objectIndirect.at(0));
        int result = checkObjectIndirect(object);
        if (J9MODRON_GCCHK_RC_OK != result) {
            CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, result, _cycle.nextErrorCount(), objectType);
            _reporter.report(error);
        }
    } catch (CorruptDataException e) {
        // TODO : cde should be part of the error
        CheckError error = new CheckError(objectIndirectBase, objectIndirect, _cycle, _currentCheck, J9MODRON_GCCHK_RC_CORRUPT_DATA_EXCEPTION, _cycle.nextErrorCount(), objectType);
        _reporter.report(error);
    }
    return J9MODRON_SLOT_ITERATOR_OK;
}
Also used : CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

Aggregations

VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)48 CorruptDataException (com.ibm.j9ddr.CorruptDataException)37 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)15 NoSuchElementException (java.util.NoSuchElementException)13 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)9 UDATA (com.ibm.j9ddr.vm29.types.UDATA)9 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)5 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)5 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)5 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)4 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)3 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 JavaObject (com.ibm.dtfj.java.JavaObject)2 J9DDRCorruptData (com.ibm.j9ddr.view.dtfj.image.J9DDRCorruptData)2 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)2 GCJNIGlobalReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCJNIGlobalReferenceIterator)2 GCJNIWeakGlobalReferenceIterator (com.ibm.j9ddr.vm29.j9.gc.GCJNIWeakGlobalReferenceIterator)2 GCObjectIterator (com.ibm.j9ddr.vm29.j9.gc.GCObjectIterator)2 BaseStackWalkerCallbacks (com.ibm.j9ddr.vm29.j9.stackwalker.BaseStackWalkerCallbacks)2