use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9MethodSanity.
/*
* Based on vmchk/checkmethods.c r1.5
*
* J9Method sanity:
* Bytecode check:
* Ensure (bytecodes - sizeof(J9ROMMethod) is in the right "area" to be a ROM Method.
* Use ROMClass to determine where ROM methods for that class begin.
* Constant pool check:
* Ensure method's constant pool is the same as that of its J9Class.
* Useful to validate that HCR doesn't violate this invariant.
* VTable check:
* If method of a non-interface class has modifier J9AccMethodVTable,
* ensure it exists in the VTable of its J9Class.
* Useful to validate that HCR doesn't violate this invariant.
*/
private void checkJ9MethodSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking methods");
// Stolen from RootScaner.scanClasses()
// GCClassLoaderIterator gcClassLoaderIterator =
// GCClassLoaderIterator.from();
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(vm.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
int count = 0;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
if (!J9ClassHelper.isObsolete(clazz)) {
count += verifyClassMethods(vm, out, clazz);
}
}
}
reportMessage(out, "Checking %d methods done", count);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class CheckClassHeap method check.
@Override
public void check() {
try {
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(_javaVM.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
_engine.clearPreviousObjects();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
if (_engine.checkClassHeap(clazz, segment) != CheckBase.J9MODRON_SLOT_ITERATOR_OK) {
return;
}
_engine.pushPreviousClass(clazz);
}
}
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class StackmapCommand method run.
/**
* Java representation of j9dbgext.c#dbgext_stackmap function.
*
* @param command DDR extension command of stackmap.
* It is supposed to be "stackmap" if this method is being called.
* @param args Arguments passed to !stackmap DDR extension.
* Only one argument is expected since !stackmap expects only the address.
* @param context Current context that DDR is running on.
* @param out Print stream to write the output.
*
* @return void
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
if (args.length != 1) {
printUsage(out);
return;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (null == vm) {
out.println("vm can not be found.");
}
long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
U8Pointer pc = U8Pointer.cast(address);
CommandUtils.dbgPrint(out, "Searching for PC=%d in VM=%s...\n", pc.longValue(), vm.getHexAddress());
J9MethodPointer remoteMethod = J9JavaVMHelper.getMethodFromPC(vm, pc);
if (remoteMethod.notNull()) {
int[] stackMap = new int[MAX_STACKSLOTS_COUNT / INT_SIZE_IN_BITS];
int leftMostBitIntMask = 1 << (INT_SIZE_IN_BITS - 1);
CommandUtils.dbgPrint(out, "Found method %s !j9method %s\n", J9MethodHelper.getName(remoteMethod), remoteMethod.getHexAddress());
UDATA offsetPC = new UDATA(pc.sub(U8Pointer.cast(remoteMethod.bytecodes())));
CommandUtils.dbgPrint(out, "Relative PC = %d\n", offsetPC.longValue());
J9ClassPointer localClass = J9_CLASS_FROM_CP(remoteMethod.constantPool());
long methodIndex = new UDATA(remoteMethod.sub(localClass.ramMethods())).longValue();
CommandUtils.dbgPrint(out, "Method index is %d\n", methodIndex);
J9ROMMethodPointer localROMMethod = J9ROMCLASS_ROMMETHODS(localClass.romClass());
while (methodIndex != 0) {
localROMMethod = ROMHelp.nextROMMethod(localROMMethod);
--methodIndex;
}
CommandUtils.dbgPrint(out, "Using ROM method %s\n", localROMMethod.getHexAddress());
/*
* This call will return the depth of the stack or errorcode in case of a failure.
*/
int errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, null, 0);
if (0 > errorCode) {
CommandUtils.dbgPrint(out, "Stack map failed, error code = %d\n", errorCode);
} else {
int stackMapIndex = 0;
if (0 != errorCode) {
/* This call to j9stackmap_StackBitsForPC will fill the stackMap */
errorCode = StackMap.j9stackmap_StackBitsForPC(offsetPC, localClass.romClass(), localROMMethod, stackMap, errorCode);
int currentDescription = stackMap[stackMapIndex];
int descriptionInt = 0;
CommandUtils.dbgPrint(out, "Stack map (%d slots mapped): ", errorCode);
long bitsRemaining = errorCode % INT_SIZE_IN_BITS;
if (bitsRemaining != 0) {
descriptionInt = currentDescription << (INT_SIZE_IN_BITS - bitsRemaining);
currentDescription++;
}
while (errorCode != 0) {
if (bitsRemaining == 0) {
descriptionInt = currentDescription;
currentDescription = stackMap[++stackMapIndex];
bitsRemaining = INT_SIZE_IN_BITS;
}
CommandUtils.dbgPrint(out, "%d", (descriptionInt & (leftMostBitIntMask)) != 0 ? 1 : 0);
descriptionInt = descriptionInt << 1;
--bitsRemaining;
--errorCode;
}
CommandUtils.dbgPrint(out, "\n");
} else {
CommandUtils.dbgPrint(out, "Stack is empty\n");
}
}
} else {
CommandUtils.dbgPrint(out, "Not found\n");
}
} catch (CorruptDataException e) {
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyObsoleteJ9Class.
private boolean verifyObsoleteJ9Class(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
boolean passed = true;
J9ClassPointer replacedClass;
J9ClassPointer currentClass = J9ClassHelper.currentClass(classPointer);
verifyJ9ClassHeader(javaVM, out, currentClass);
replacedClass = currentClass.replacedClass();
while (!replacedClass.isNull()) {
if (replacedClass.eq(classPointer)) {
/* Expected case: found classPointer in the list. */
break;
}
replacedClass = replacedClass.replacedClass();
}
if (replacedClass.isNull()) {
reportError(out, "obsolete class=0x%s is not in replaced list on currentClass=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(currentClass.getAddress()));
passed = false;
}
return passed;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class CheckEngine method checkJ9Class.
private int checkJ9Class(J9ClassPointer clazz, J9MemorySegmentPointer segment, int checkFlags) throws CorruptDataException {
if (clazz.isNull()) {
return J9MODRON_GCCHK_RC_OK;
}
if (clazz.anyBitsIn(J9MODRON_GCCHK_J9CLASS_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_CLASS_POINTER_UNALIGNED;
}
/* Check that the class header containes the expected values */
int ret = checkJ9ClassHeader(clazz);
if (J9MODRON_GCCHK_RC_OK != ret) {
return ret;
}
/* Check that class is not unloaded */
ret = checkJ9ClassIsNotUnloaded(clazz);
if (J9MODRON_GCCHK_RC_OK != ret) {
return ret;
}
if ((checkFlags & J9MODRON_GCCHK_VERIFY_RANGE) != J9MODRON_GCCHK_VERIFY_RANGE) {
UDATA delta = UDATA.cast(segment.heapAlloc()).sub(UDATA.cast(clazz));
/* Basic check that there is enough room for the object header */
if (delta.lt(J9Class.SIZEOF)) {
return J9MODRON_GCCHK_RC_CLASS_INVALID_RANGE;
}
}
return J9MODRON_GCCHK_RC_OK;
}
Aggregations