use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9ROMClassSanity.
/*
* Based on vmchk/checkromclasses.c r1.5
*
* J9ROMClass sanity:
* SRP check:
* Ensure J9ROMClass->interfaces SRP is in the same segment if J9ROMClass->interfaceCount != 0.
* Ensure J9ROMClass->romMethods SRP is in the same segment if J9ROMClass->romMethodCount != 0.
* Ensure J9ROMClass->romFields SRP is in the same segment if J9ROMClass->romFieldCount != 0.
* Ensure J9ROMClass->innerClasses SRP is in the same segment if J9ROMClass->innerClasseCount != 0.
* Ensure cpShapeDescription in the same segment.
* Ensure all SRPs are in range on 64 bit platforms (including className, superclassName, and outerClassName).
*
* ConstantPool count check:
* Ensure ramConstantPoolCount <= romConstantPoolCount
*/
private void checkJ9ROMClassSanity(J9JavaVMPointer vm, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking ROM classes");
// 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();
verifyJ9ROMClass(out, vm, clazz);
count++;
}
}
reportMessage(out, "Checking %d ROM classes done", count);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ClassSubclassHierarchy.
private boolean verifyJ9ClassSubclassHierarchy(J9JavaVMPointer javaVM, PrintStream out, J9ClassPointer classPointer) throws CorruptDataException {
int index = 0;
UDATA rootDepth = J9ClassHelper.classDepth(classPointer);
J9ClassPointer currentClass = classPointer;
boolean done = false;
while (!done) {
J9ClassPointer nextSubclass = currentClass.subclassTraversalLink();
if (nextSubclass.isNull()) {
reportError(out, "class=0x%s had NULL entry in subclassTraversalLink list at index=%d following class=0x%s", Long.toHexString(classPointer.getAddress()), index, Long.toHexString(currentClass.getAddress()));
return false;
}
/* Sanity check the nextSubclass. */
if (!verifyJ9ClassHeader(javaVM, out, nextSubclass)) {
return false;
}
if (J9ClassHelper.classDepth(nextSubclass).lte(rootDepth)) {
done = true;
} else {
currentClass = nextSubclass;
index++;
}
}
return true;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer 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.J9JavaVMPointer 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);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer in project openj9 by eclipse.
the class TraceConfigCommand method run.
public void run(String command, String[] args, Context context, final PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
// !RasGlobalStorage
RasGlobalStoragePointer rasGlobal = RasGlobalStoragePointer.cast(vm.j9rasGlobalStorage());
// !UtGlobalData
UtGlobalDataPointer utGlobal = UtGlobalDataPointer.cast(rasGlobal.utGlobalData());
// !UtComponentList componentList
UtComponentListPointer componentList = utGlobal.componentList();
// !UtComponentData head
UtComponentDataPointer head = componentList.head();
if (args.length == 0) {
walkTraceComponents(new ModuleVisitor() {
public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
out.println(moduleName(modInfo));
}
}, head, context, out);
} else if ("all".equals(args[0])) {
walkTraceComponents(new ModuleVisitor() {
public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
printActiveTracePoints(modInfo, out);
}
}, head, context, out);
} else {
for (int i = 0; i < args.length; i++) {
final String componentName = args[i];
walkTraceComponents(new ModuleVisitor() {
public void visit(UtModuleInfoPointer modInfo) throws CorruptDataException {
if (componentName.equals(moduleName(modInfo))) {
printActiveTracePoints(modInfo, out);
}
}
}, head, context, out);
}
}
} catch (CorruptDataException e) {
e.printStackTrace();
}
}
Aggregations