use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class TraceConfigCommand method walkTraceComponents.
/**
* Walk the trace components and use the visitor pattern to save us writing this
* loop several times.
*
* @param visitor the visitor object to run on each UtModuleInfo.
* @param head the pointer to the first item in the list of UtComponentData
* @param context
* @param out
*/
private static void walkTraceComponents(final ModuleVisitor visitor, final UtComponentDataPointer head, Context context, PrintStream out) {
UtComponentDataPointer current = head;
try {
while (current != null && current.notNull()) {
UtModuleInfoPointer modInfo = current.moduleInfo();
visitor.visit(modInfo);
current = current.next();
}
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
use of com.ibm.j9ddr.CorruptDataException 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.CorruptDataException in project openj9 by eclipse.
the class WalkInternTableCommand method getRomClassBuilderPtr.
/**
* This method is used to get the pointer to the RomClassBuilder
* @param out PrintStream
* @return void
* @throws CorruptDataException
*/
private J9DbgStringInternTablePointer getRomClassBuilderPtr(PrintStream out) throws CorruptDataException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (vm.isNull()) {
out.append("VM can not be found " + nl);
return null;
}
J9TranslationBufferSetPointer translationBufferSetPtr = vm.dynamicLoadBuffers();
if (translationBufferSetPtr.isNull()) {
out.append("J9TranslationBufferSet can not be found " + nl);
return null;
}
J9DbgROMClassBuilderPointer romClassBuilderPtr = J9DbgROMClassBuilderPointer.cast(translationBufferSetPtr.romClassBuilder());
if (romClassBuilderPtr.isNull()) {
out.append("romClassBuilderPtr can not be found " + nl);
return null;
}
return romClassBuilderPtr.stringInternTable();
} catch (CorruptDataException e) {
throw e;
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class CheckEngine method checkJ9ObjectPointer.
private int checkJ9ObjectPointer(J9ObjectPointer object, J9ObjectPointer[] newObject, GCHeapRegionDescriptor[] regionDesc) throws CorruptDataException {
newObject[0] = object;
if (object.isNull()) {
return J9MODRON_GCCHK_RC_OK;
}
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
/* Is the object on the stack? */
GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
while (threadListIterator.hasNext()) {
J9VMThreadPointer vmThread = threadListIterator.next();
if (isObjectOnStack(object, vmThread.stackObject())) {
return J9MODRON_GCCHK_RC_STACK_OBJECT;
}
}
UDATA classSlot = UDATA.cast(object.clazz());
if (classSlot.eq(J9MODRON_GCCHK_J9CLASS_EYECATCHER)) {
return J9MODRON_GCCHK_RC_OBJECT_SLOT_POINTS_TO_J9CLASS;
}
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
// if (0 == regionDesc->objectAlignment) {
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
/* Now we know object is not on stack we can check that it's correctly aligned
* for a J9Object.
*/
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
if (isMidscavengeFlagSet()) {
if (GCExtensions.isVLHGC() || (regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW))) {
// TODO: ideally, we should only check this in the evacuate segment
// TODO: do some safety checks first -- is there enough room in the segment?
GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
if (scavengerForwardedHeader.isForwardedPointer()) {
newObject[0] = scavengerForwardedHeader.getForwardedObject();
reportForwardedObject(object, newObject[0]);
// Replace the object and resume
object = newObject[0];
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
/* Is the object on the stack? */
GCVMThreadListIterator threadListIterator = GCVMThreadListIterator.from();
while (threadListIterator.hasNext()) {
J9VMThreadPointer vmThread = threadListIterator.next();
if (isObjectOnStack(object, vmThread.stackObject())) {
return J9MODRON_GCCHK_RC_STACK_OBJECT;
}
}
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
// if (0 == regionDesc->objectAlignment) {
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
/* make sure the forwarded pointer is also aligned */
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
}
}
}
if (isScavengerBackoutFlagSet()) {
GCScavengerForwardedHeader scavengerForwardedHeader = GCScavengerForwardedHeader.fromJ9Object(object);
if (scavengerForwardedHeader.isReverseForwardedPointer()) {
newObject[0] = scavengerForwardedHeader.getReverseForwardedPointer();
reportForwardedObject(object, newObject[0]);
// Replace the object and resume
object = newObject[0];
regionDesc[0] = findRegionForPointer(object, regionDesc[0]);
if (regionDesc[0] == null) {
return J9MODRON_GCCHK_RC_NOT_FOUND;
}
if (!regionDesc[0].containsObjects()) {
/* this is a heap region, but it's not intended for objects (could be free or an arraylet leaf) */
return J9MODRON_GCCHK_RC_NOT_IN_OBJECT_REGION;
}
if (!regionDesc[0].getTypeFlags().allBitsIn(MEMORY_TYPE_NEW)) {
/* reversed forwarded should point to Evacuate */
return J9MODRON_GCCHK_RC_REVERSED_FORWARDED_OUTSIDE_EVACUATE;
}
/* make sure the forwarded pointer is also aligned */
if (object.anyBitsIn(J9MODRON_GCCHK_J9OBJECT_ALIGNMENT_MASK)) {
return J9MODRON_GCCHK_RC_UNALIGNED;
}
}
}
/* Check that elements of a double array are aligned on an 8-byte boundary. For continuous
* arrays, verifying that the J9Indexable object is aligned on an 8-byte boundary is sufficient.
* For arraylets, depending on the layout, elements of the array may be stored on arraylet leafs
* or on the spine. Arraylet leafs should always be aligned on 8-byte boundaries. Checking both
* the first and last element will ensure that we are always checking that elements are aligned
* on the spine.
* */
long classShape = -1;
try {
classShape = ObjectModel.getClassShape(J9ObjectHelper.clazz(object)).longValue();
} catch (CorruptDataException cde) {
/* don't bother to report an error yet -- a later step will catch this. */
}
if (classShape == OBJECT_HEADER_SHAPE_DOUBLES) {
J9IndexableObjectPointer array = J9IndexableObjectPointer.cast(object);
int size = 0;
VoidPointer elementPtr = VoidPointer.NULL;
try {
size = ObjectModel.getSizeInElements(object).intValue();
} catch (InvalidDataTypeException ex) {
// size in elements can not be larger then 2G but it is...
// We could report an error at this point, but the C version
// doesn't -- we'll catch it later
} catch (IllegalArgumentException ex) {
// We could report an error at this point, but the C version
// doesn't -- we'll catch it later
}
if (0 != size) {
elementPtr = ObjectModel.getElementAddress(array, 0, U64.SIZEOF);
if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
}
elementPtr = ObjectModel.getElementAddress(array, size - 1, U64.SIZEOF);
if (elementPtr.anyBitsIn(U64.SIZEOF - 1)) {
return J9MODRON_GCCHK_RC_DOUBLE_ARRAY_UNALIGNED;
}
}
}
return J9MODRON_GCCHK_RC_OK;
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class CheckFinalizableList method print.
@Override
public void print() {
try {
ScanFormatter formatter = new ScanFormatter(this, "finalizableList");
GCFinalizableObjectIterator finalizableObjectIterator = GCFinalizableObjectIterator.from();
int state = finalizableObjectIterator.getState();
while (finalizableObjectIterator.hasNext()) {
if (finalizableObjectIterator.getState() != state) {
formatter.endSection();
state = finalizableObjectIterator.getState();
switch(state) {
case GCFinalizableObjectIterator.state_system:
formatter.section("finalizable objects created by the system classloader");
break;
case GCFinalizableObjectIterator.state_default:
formatter.section("finalizable objects created by application class loaders");
break;
case GCFinalizableObjectIterator.state_reference:
formatter.section("reference objects");
break;
}
}
formatter.entry(finalizableObjectIterator.next());
}
formatter.end("finalizableList");
} catch (CorruptDataException e) {
// TODO: handle exception
}
}
Aggregations