use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printObjectField.
public void printObjectField(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, J9ClassPointer fromClass, J9ObjectFieldOffset objectFieldOffset) throws CorruptDataException {
J9ROMFieldShapePointer fieldShape = objectFieldOffset.getField();
UDATA fieldOffset = objectFieldOffset.getOffsetOrAddress();
boolean isHiddenField = objectFieldOffset.isHidden();
String className = J9UTF8Helper.stringValue(fromClass.romClass().className());
String fieldName = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().name());
String fieldSignature = J9UTF8Helper.stringValue(fieldShape.nameAndSignature().signature());
U8Pointer valuePtr = dataStart;
valuePtr = valuePtr.add(fieldOffset);
padding(out, tabLevel);
out.print(String.format("%s %s = ", fieldSignature, fieldName));
if (fieldShape.modifiers().anyBitsIn(J9FieldSizeDouble)) {
out.print(U64Pointer.cast(valuePtr).at(0).getHexValue());
} else if (fieldShape.modifiers().anyBitsIn(J9FieldFlagObject)) {
AbstractPointer ptr = J9BuildFlags.gc_compressedPointers ? U32Pointer.cast(valuePtr) : UDATAPointer.cast(valuePtr);
out.print(String.format("!fj9object 0x%x", ptr.at(0).longValue()));
} else {
out.print(I32Pointer.cast(valuePtr).at(0).getHexValue());
}
out.print(String.format(" (offset=%d) (%s)", fieldOffset.longValue(), className));
if (isHiddenField) {
out.print(" <hidden>");
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method printSubArrayType.
void printSubArrayType(PrintStream out, int tabLevel, J9ClassPointer localClazz, U8Pointer dataStart, int begin, int end, J9IndexableObjectPointer array) throws CorruptDataException {
U32 arraySize = J9IndexableObjectHelper.size(array);
if (arraySize.anyBitsIn(0x80000000)) {
arraySize = new U32(Integer.MAX_VALUE);
}
int finish = Math.min(arraySize.intValue(), end);
if (begin < finish) {
String className = J9IndexableObjectHelper.getClassName(array);
char signature = className.charAt(1);
switch(signature) {
case 'B':
case 'Z':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 1);
out.println(String.format("[%d] = %3d, 0x%02x", index, U8Pointer.cast(slot).at(0).longValue(), U8Pointer.cast(slot).at(0).longValue()));
}
break;
case 'C':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
long value = U16Pointer.cast(slot).at(0).longValue();
out.println(String.format("[%d] = %5d, 0x%2$04x, '%c'", index, value, (char) value));
}
break;
case 'S':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 2);
out.println(String.format("[%d] = %6d, 0x%04x", index, I16Pointer.cast(slot).at(0).longValue(), U16Pointer.cast(slot).at(0).longValue()));
}
break;
case 'I':
case 'F':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 4);
out.println(String.format("[%d] = %10d, 0x%08x, %8.8fF", index, I32Pointer.cast(slot).at(0).longValue(), U32Pointer.cast(slot).at(0).longValue(), FloatPointer.cast(slot).floatAt(0)));
}
break;
case 'J':
case 'D':
for (int index = begin; index < finish; index++) {
padding(out, tabLevel);
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, 8);
out.println(String.format("[%d] = %2d, 0x%016x, %8.8fF", index, I64Pointer.cast(slot).at(0).longValue(), I64Pointer.cast(slot).at(0).longValue(), DoublePointer.cast(slot).doubleAt(0)));
}
break;
case 'L':
case '[':
for (int index = begin; index < finish; index++) {
VoidPointer slot = J9IndexableObjectHelper.getElementEA(array, index, (int) ObjectReferencePointer.SIZEOF);
if (slot.notNull()) {
long compressedPtrValue;
if (J9BuildFlags.gc_compressedPointers) {
compressedPtrValue = I32Pointer.cast(slot).at(0).longValue();
} else {
compressedPtrValue = DataType.getProcess().getPointerAt(slot.getAddress());
}
padding(out, tabLevel);
out.println(String.format("[%d] = !fj9object 0x%x = !j9object 0x%x", index, compressedPtrValue, ObjectReferencePointer.cast(slot).at(0).longValue()));
} else {
padding(out, tabLevel);
out.println(String.format("[%d] = null", slot));
}
}
break;
}
}
/* check if it just printed a range; if so, give cmd to see all data */
arraySize = J9IndexableObjectHelper.size(array);
if (begin > 0 || arraySize.longValue() > finish) {
out.println(String.format("To print entire range: !j9indexableobject %s %d %d\n", array.getHexAddress(), 0, arraySize.longValue()));
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class J9ObjectStructureFormatter method formatArrayObject.
private void formatArrayObject(PrintStream out, J9ClassPointer localClazz, U8Pointer dataStart, J9IndexableObjectPointer localObject, int begin, int end) throws CorruptDataException {
String className = J9IndexableObjectHelper.getClassName(localObject);
out.print(String.format("!J9IndexableObject %s {", localObject.getHexAddress()));
out.println();
/* print individual fields */
out.println(String.format(" struct J9Class* clazz = !j9arrayclass 0x%X // %s", localClazz.getAddress(), className));
out.println(String.format(" Object flags = %s;", J9IndexableObjectHelper.flags(localObject).getHexValue()));
U32 size = J9IndexableObjectHelper.size(localObject);
if (!J9BuildFlags.thr_lockNursery) {
out.println(String.format(" j9objectmonitor_t monitor = %s;", J9IndexableObjectHelper.monitor(localObject).getHexValue()));
}
if (size.anyBitsIn(0x80000000)) {
out.println(String.format(" U_32 size = %s; // Size exceeds Integer.MAX_VALUE!", size.getHexValue()));
} else {
out.println(String.format(" U_32 size = %s;", size.getHexValue()));
}
printSubArrayType(out, 1, localClazz, dataStart, begin, end, localObject);
out.println("}");
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class JavaLangClassLoaderHelper method getParent.
public static J9ObjectPointer getParent(J9ObjectPointer loader) throws CorruptDataException {
if (loader.isNull()) {
return J9ObjectPointer.NULL;
}
if (parentOffset == null) {
// Iterate through all the fields of Ljava/lang/ClassLoader; until you find "parent"
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
J9ClassPointer javaLangClassLoader = J9ClassLoaderHelper.findClass(vm.systemClassLoader(), "Ljava/lang/ClassLoader;");
Iterator<J9ObjectFieldOffset> fieldIterator = J9ClassHelper.getFieldOffsets(javaLangClassLoader);
while (fieldIterator.hasNext()) {
Object nextField = fieldIterator.next();
if (nextField instanceof J9ObjectFieldOffset) {
J9ObjectFieldOffset offset = (J9ObjectFieldOffset) nextField;
if ("parent".equals(offset.getName())) {
parentOffset = offset;
break;
}
}
}
}
if (parentOffset != null) {
return J9ObjectHelper.getObjectField(loader, parentOffset);
} else {
throw new CorruptDataException("Unable to find field offset for the 'parent' field");
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class LiveSetWalker method scanObject.
private static void scanObject(HashSet<J9ObjectPointer> visitedObjects, ObjectVisitor visitor, J9ObjectPointer object, VoidPointer address) {
if (visitedObjects.contains(object)) {
return;
}
if (!visitor.visit(object, address)) {
return;
}
visitedObjects.add(object);
try {
GCObjectIterator objectIterator = GCObjectIterator.fromJ9Object(object, true);
GCObjectIterator addressIterator = GCObjectIterator.fromJ9Object(object, true);
while (objectIterator.hasNext()) {
J9ObjectPointer slot = objectIterator.next();
VoidPointer addr = addressIterator.nextAddress();
if (slot.notNull()) {
scanObject(visitedObjects, visitor, slot, addr);
}
}
if (J9ObjectHelper.getClassName(object).equals("java/lang/Class")) {
J9ClassPointer clazz = ConstantPoolHelpers.J9VM_J9CLASS_FROM_HEAPCLASS(object);
// Iterate the Object slots
GCClassIterator classIterator = GCClassIterator.fromJ9Class(clazz);
GCClassIterator classAddressIterator = GCClassIterator.fromJ9Class(clazz);
while (classIterator.hasNext()) {
J9ObjectPointer slot = classIterator.next();
VoidPointer addr = classAddressIterator.nextAddress();
if (slot.notNull()) {
scanObject(visitedObjects, visitor, slot, addr);
}
}
// Iterate the Class slots
GCClassIteratorClassSlots classSlotIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
GCClassIteratorClassSlots classSlotAddressIterator = GCClassIteratorClassSlots.fromJ9Class(clazz);
while (classSlotIterator.hasNext()) {
J9ClassPointer slot = classSlotIterator.next();
VoidPointer addr = classSlotAddressIterator.nextAddress();
J9ObjectPointer classObject = ConstantPoolHelpers.J9VM_J9CLASS_TO_HEAPCLASS(slot);
if (classObject.notNull()) {
scanObject(visitedObjects, visitor, classObject, addr);
}
}
}
} catch (CorruptDataException e) {
EventManager.raiseCorruptDataEvent("Corruption found while walking the live set, object: " + object.getHexAddress(), e, false);
}
visitor.finishVisit(object, address);
}
Aggregations