use of com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer in project openj9 by eclipse.
the class RamClassWalker method allSlotsInConstantPoolDo.
private void allSlotsInConstantPoolDo() throws CorruptDataException {
final J9ROMClassPointer romClass = ramClass.romClass();
final int constPoolCount = romClass.ramConstantPoolCount().intValue();
final J9ConstantPoolPointer cpp = J9ConstantPoolPointer.cast(ramClass.ramConstantPool());
U32Pointer cpDescriptionSlots = romClass.cpShapeDescription();
PointerPointer cpEntry = PointerPointer.cast(ramClass.ramConstantPool());
long cpDescription = 0;
long cpEntryCount = ramClass.romClass().ramConstantPoolCount().longValue();
long cpDescriptionIndex = 0;
while (cpEntryCount > 0) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpDescriptionSlots.at(0).longValue();
cpDescriptionSlots = cpDescriptionSlots.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
/*
* A switch statement can't be used on long type, it might be
* erroneous to cast it to an int as it might change in the future.
*/
long slotType = cpDescription & J9_CP_DESCRIPTION_MASK;
if ((slotType == J9CPTYPE_STRING) || (slotType == J9CPTYPE_ANNOTATION_UTF8)) {
J9RAMStringRefPointer ref = J9RAMStringRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_RAM_UTF8, ref.stringObjectEA(), "stringObject");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
if (slotType == J9CPTYPE_STRING) {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_STRING", false);
} else {
classWalkerCallback.addSection(clazz, ref, J9RAMStringRef.SIZEOF, "J9CPTYPE_ANNOTATION_UTF8", false);
}
} else if (slotType == J9CPTYPE_METHOD_TYPE) {
J9RAMMethodTypeRefPointer ref = J9RAMMethodTypeRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.type();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.typeEA(), "type");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slotCountEA(), "slotCount");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodTypeRef.SIZEOF, "J9CPTYPE_METHOD_TYPE", false);
} else if (slotType == J9CPTYPE_METHODHANDLE) {
J9RAMMethodHandleRefPointer ref = J9RAMMethodHandleRefPointer.cast(cpEntry);
J9ObjectPointer slot = ref.methodHandle();
if (slot.notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle", "!j9object");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodHandleEA(), "methodHandle");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.unusedEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodHandleRef.SIZEOF, "J9CPTYPE_METHODHANDLE", false);
} else if (slotType == J9CPTYPE_CLASS) {
J9RAMClassRefPointer ref = J9RAMClassRefPointer.cast(cpEntry);
if (ref.value().notNull()) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value", "!j9class");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueEA(), "value");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.modifiersEA(), "modifiers");
classWalkerCallback.addSection(clazz, ref, J9RAMClassRef.SIZEOF, "J9CPTYPE_CLASS", false);
} else if (slotType == J9CPTYPE_INT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldInt");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_INT", false);
} else if (slotType == J9CPTYPE_FLOAT) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot1EA(), "cpFieldFloat");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.slot2EA(), "cpFieldIntUnused");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_FLOAT", false);
} else if (slotType == J9CPTYPE_LONG) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_LONG");
classWalkerCallback.addSection(clazz, ref, J9RAMConstantRef.SIZEOF, "J9CPTYPE_LONG", false);
} else if (slotType == J9CPTYPE_DOUBLE) {
J9RAMConstantRefPointer ref = J9RAMConstantRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_I64, I64Pointer.cast(cpEntry), "J9CPTYPE_DOUBLE");
classWalkerCallback.addSection(clazz, ref, I64.SIZEOF, "J9CPTYPE_DOUBLE", false);
} else if (slotType == J9CPTYPE_FIELD) {
J9RAMFieldRefPointer ref = J9RAMFieldRefPointer.cast(cpEntry);
J9RAMStaticFieldRefPointer staticRef = J9RAMStaticFieldRefPointer.cast(cpEntry);
/* if the field ref is resolved static, it has 'flagsAndClass', for other cases (unresolved and resolved instance) it has 'flags'. */
if ((staticRef.flagsAndClass().longValue() > 0) && (staticRef.valueOffset().longValue() != -1)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_IDATA, staticRef.flagsAndClassEA(), "flagsAndClass");
} else {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.flagsEA(), "flags");
}
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.valueOffsetEA(), "valueOffset");
classWalkerCallback.addSection(clazz, ref, J9RAMFieldRef.SIZEOF, "J9CPTYPE_FIELD", false);
} else if (slotType == J9CPTYPE_INTERFACE_METHOD) {
J9RAMInterfaceMethodRefPointer ref = J9RAMInterfaceMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.interfaceClassEA(), "interfaceClass", "!j9class");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSection(clazz, ref, J9RAMInterfaceMethodRef.SIZEOF, "J9CPTYPE_INTERFACE_METHOD", false);
} else if (slotType == J9CPTYPE_STATIC_METHOD) {
J9RAMStaticMethodRefPointer ref = J9RAMStaticMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMStaticMethodRef.SIZEOF, "J9CPTYPE_STATIC_METHOD", false);
} else if ((slotType == J9CPTYPE_UNUSED) || (slotType == J9CPTYPE_UNUSED8)) {
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry, "unused");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, cpEntry.add(1), "unused");
classWalkerCallback.addSection(clazz, cpEntry, 2 * UDATA.SIZEOF, "J9CPTYPE_UNUSED", false);
} else if (slotType == J9CPTYPE_INSTANCE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "method", "!j9method");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_INSTANCE_METHOD", false);
} else if (slotType == J9CPTYPE_HANDLE_METHOD) {
J9RAMMethodRefPointer ref = J9RAMMethodRefPointer.cast(cpEntry);
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodIndexAndArgCountEA(), "methodTypeIndexAndArgCount");
classWalkerCallback.addSlot(clazz, SlotType.J9_UDATA, ref.methodEA(), "unused");
classWalkerCallback.addSection(clazz, ref, J9RAMMethodRef.SIZEOF, "J9CPTYPE_HANDLE_METHOD", false);
}
cpEntry = cpEntry.addOffset(J9RAMConstantPoolItem.SIZEOF);
cpEntryCount -= 1;
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
// The spaces at the end of "Constant Pool" are important since the
// regions are sorted
// by address and size, but when they are equal they are sorted by
// longest name and "Constant Pool" has to come first
classWalkerCallback.addSection(clazz, cpp, constPoolCount * 2 * UDATA.SIZEOF, "Constant Pool ", false);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ClassHeader.
private boolean verifyJ9ClassHeader(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
boolean passed = true;
J9ROMClassPointer romClass = classPointer.romClass();
String rootClasses = "java.lang.Object";
if (false == J9ClassHelper.hasValidEyeCatcher(classPointer)) {
reportError(out, "0x99669966 != eyecatcher (0x%s) for class=0x%s", Long.toHexString(classPointer.eyecatcher().longValue()), Long.toHexString(classPointer.getAddress()));
passed = false;
}
if (romClass.isNull()) {
reportError(out, "NULL == romClass for class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
}
if (classPointer.classLoader().isNull()) {
reportError(out, "NULL == classLoader for class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
}
long classDepth = J9ClassHelper.classDepth(classPointer).longValue();
if (classDepth > 0) {
if (classPointer.superclasses().isNull()) {
reportError(out, "NULL == superclasses for non-" + rootClasses + " class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
} else {
// Verify that all entries of superclasses[] are non-null.
for (long i = 0; i < classDepth; i++) {
if (classPointer.superclasses().at(i).isNull()) {
reportError(out, "superclasses[%d] is NULL for class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
break;
}
}
}
} else {
if (classPointer.superclasses().at(-1).notNull()) {
reportError(out, "superclasses[-1] should be NULL for class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
}
}
if (classPointer.initializeStatus().eq(J9ClassInitFlags.J9ClassInitSucceeded)) {
if (classPointer.classObject().isNull()) {
reportError(out, "NULL == class->classObject for initialized class=0x%s", Long.toHexString(classPointer.getAddress()));
passed = false;
}
}
if (J9ClassHelper.isObsolete(classPointer)) {
reportError(out, "clazz=0x%s is obsolete", Long.toHexString(classPointer.getAddress()));
passed = false;
}
if (!romClass.isNull() && !romClass.romConstantPoolCount().eq(0)) {
J9ConstantPoolPointer constantPool = J9ConstantPoolPointer.cast(classPointer.ramConstantPool());
J9ClassPointer cpClass = constantPool.ramClass();
if (!classPointer.eq(cpClass)) {
reportError(out, "clazz=0x%s not equal clazz->ramConstantPool->ramClass=0x%s", Long.toHexString(classPointer.getAddress()), Long.toHexString(cpClass.getAddress()));
passed = false;
}
}
return passed;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer in project openj9 by eclipse.
the class J9MethodHelper method getName.
public static String getName(J9MethodPointer methodPointer) throws CorruptDataException {
J9ClassPointer className;
J9ConstantPoolPointer constantPool;
if (methodPointer.isNull())
return "bad ramMethod";
constantPool = ConstantPoolHelpers.J9_CP_FROM_METHOD(methodPointer);
if (constantPool.isNull()) {
return "error reading constant pool from ramMethod";
}
className = ConstantPoolHelpers.J9_CLASS_FROM_CP(constantPool);
if (className.isNull()) {
return "error reading class name from constant pool";
}
J9ROMNameAndSignaturePointer nameAndSignature = ROMHelp.J9_ROM_METHOD_FROM_RAM_METHOD(methodPointer).nameAndSignature();
String name = J9UTF8Helper.stringValue(nameAndSignature.name());
String signature = J9UTF8Helper.stringValue(nameAndSignature.signature());
return J9ClassHelper.getName(className) + "." + name + signature;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyClassMethods.
private int verifyClassMethods(J9JavaVMPointer vm, PrintStream out, J9ClassPointer clazz) throws CorruptDataException {
int count = 0;
J9ROMClassPointer romClass = clazz.romClass();
int methodCount = romClass.romMethodCount().intValue();
J9MethodPointer methods = clazz.ramMethods();
boolean isInterfaceClass = J9ROMClassHelper.isInterface(romClass);
J9ConstantPoolPointer ramConstantPool = J9ConstantPoolPointer.cast(clazz.ramConstantPool());
for (int i = 0; i < methodCount; i++) {
J9MethodPointer method = methods.add(i);
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(method);
boolean methodInVTable = J9ROMMethodHelper.hasVTable(romMethod);
if (!findROMMethodInClass(vm, romClass, romMethod, methodCount)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in romClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!isInterfaceClass && methodInVTable) {
if (!findMethodInVTable(method, clazz)) {
reportError(out, "romMethod=0x%s (ramMethod=0x%s) not found in vTable of ramClass=0x%s", Long.toHexString(romMethod.getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(clazz.getAddress()));
}
}
if (!ramConstantPool.eq(ConstantPoolHelpers.J9_CP_FROM_METHOD(method))) {
reportError(out, "ramConstantPool=0x%s on ramMethod=0x%s not equal to ramConstantPool=0x%s on ramClass=0x%s", Long.toHexString(ConstantPoolHelpers.J9_CP_FROM_METHOD(method).getAddress()), Long.toHexString(method.getAddress()), Long.toHexString(ramConstantPool.getAddress()), Long.toHexString(clazz.getAddress()));
}
count++;
}
return count;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ConstantPoolPointer in project openj9 by eclipse.
the class VMConstantPoolCommand method run.
/**
* Run method for !vmconstantpool extension.
*
* @param command !vmconstantpool
* @param args args passed by !vmconstantpool extension.
* @param context Context
* @param out PrintStream
* @throws DDRInteractiveCommandException
*/
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer javaVM;
javaVM = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (args.length == 1) {
long vmaddress = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
if (vmaddress != javaVM.getAddress()) {
out.println(args[0] + " is not a valid j9javavm address. Run !findvm to find out the j9javavm address of the current context");
return;
}
} else if (args.length > 1) {
printUsage(out);
}
J9ConstantPoolPointer jclConstantPool = J9ConstantPoolPointer.cast(javaVM.jclConstantPoolEA());
J9ROMClassPointer romClass = jclConstantPool.ramClass().romClass();
int index;
U32Pointer cpShapeDescription;
int constPoolCount;
cpShapeDescription = romClass.cpShapeDescription();
long cpDescription = cpShapeDescription.at(0).longValue();
constPoolCount = romClass.romConstantPoolCount().intValue();
PointerPointer cpEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass));
long cpDescriptionIndex = 0;
for (index = 0; index < constPoolCount; index++) {
if (0 == cpDescriptionIndex) {
// Load a new description word
cpDescription = cpShapeDescription.at(0).longValue();
cpShapeDescription = cpShapeDescription.add(1);
cpDescriptionIndex = J9_CP_DESCRIPTIONS_PER_U32;
}
long shapeDesc = cpDescription & J9_CP_DESCRIPTION_MASK;
AbstractPointer ref = PointerPointer.NULL;
if (shapeDesc == J9CPTYPE_CLASS) {
ref = J9ROMClassRefPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_STRING) {
ref = J9ROMStringRefPointer.cast(cpEntry);
} else if ((shapeDesc == J9CPTYPE_INT) || (shapeDesc == J9CPTYPE_FLOAT)) {
ref = J9ROMConstantPoolItemPointer.cast(cpEntry);
} else if (shapeDesc == J9CPTYPE_LONG) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Long at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.getHexValue() + "\n}");
} else if (shapeDesc == J9CPTYPE_DOUBLE) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Double at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if ((shapeDesc == J9CPTYPE_INSTANCE_METHOD) || (shapeDesc == J9CPTYPE_STATIC_METHOD) || (shapeDesc == J9CPTYPE_INTERFACE_METHOD) || (shapeDesc == J9CPTYPE_HANDLE_METHOD) || (shapeDesc == J9CPTYPE_FIELD)) {
long classRefCPIndex;
if (shapeDesc == J9CPTYPE_FIELD) {
ref = J9ROMFieldRefPointer.cast(cpEntry);
/* gets the classRefCPIndex to obtain a pointer to the j9romclassref */
classRefCPIndex = J9ROMFieldRefPointer.cast(ref).classRefCPIndex().longValue();
} else {
ref = J9ROMFieldRefPointer.cast(cpEntry);
classRefCPIndex = J9ROMMethodRefPointer.cast(ref).classRefCPIndex().longValue();
}
PointerPointer classRefCPEntry = PointerPointer.cast(J9ROMClassHelper.constantPool(romClass)).addOffset(J9ROMConstantPoolItem.SIZEOF * classRefCPIndex);
/* gets the DDR output of the item */
String outString = ref.formatFullInteractive();
String[] parts = outString.split(nl);
/* add a debug extension(!j9romclassref) on the second line of the output */
parts[1] += "(!j9romclassref " + classRefCPEntry.getHexAddress() + ")";
out.print(join(nl, parts));
} else if ((shapeDesc == J9CPTYPE_UNUSED) || (shapeDesc == J9CPTYPE_UNUSED8)) {
U64Pointer longPointer = U64Pointer.cast(cpEntry);
out.println("Unused at " + longPointer.getHexAddress() + " {\n\t0x0: U64:" + longPointer.at(0).longValue() + "\n}");
} else if (ref.notNull()) {
out.println(ref.formatFullInteractive());
}
cpEntry = cpEntry.addOffset(J9ROMConstantPoolItem.SIZEOF);
cpDescription >>= J9_CP_BITS_PER_DESCRIPTION;
cpDescriptionIndex -= 1;
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations