use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class RamClassSummaryCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ClassSummaryHelper classSummaryHelper = new ClassSummaryHelper(preferredOrder);
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
numberOfClasses++;
ClassWalker classWalker = new RamClassWalker(classPointer, context);
LinearDumper linearDumper = new LinearDumper();
J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
classSummaryHelper.addRegionsForClass(allRegionsNode);
}
classSummaryHelper.printStatistics(out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method findMethodInVTable.
private boolean findMethodInVTable(J9MethodPointer method, J9ClassPointer classPointer) throws CorruptDataException {
UDATAPointer vTable = J9ClassHelper.vTable(classPointer);
long vTableSize = vTable.at(0).longValue();
/* skip magic first entry */
for (long vTableIndex = 2; vTableIndex <= vTableSize + 1; vTableIndex++) {
// System.out.printf("%d COMP 0x%s vs. 0x%s\n", (int)vTableIndex, Long.toHexString(method.getAddress()), Long.toHexString(vTable.at(vTableIndex).longValue()));
if (method.eq(J9MethodPointer.cast(vTable.at(vTableIndex)))) {
return true;
}
}
return false;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method checkJ9ClassSanity.
/*
* Based on vmchk/checkclasses.c r1.7
*
* J9Class sanity:
* Eyecatcher check:
* Ensure J9Class->eyecatcher == 0x99669966.
*
* Superclasses check:
* Ensure J9Class->superclasses != null unless J9Class is Object.
*
* ClassObject null check:
* Ensure J9Class->classObject != null if (J9Class->initializeStatus == J9ClassInitSucceeded)
*
* ClassLoader segment check:
* Ensure J9Class->classLoader->classSegments contains J9Class.
*
* ConstantPool check:
* Ensure J9Class->ramConstantPool->ramClass is equal to the J9Class.
*
* Subclass hierarchy check:
* Ensure subclasses can be traversed per the J9Class classDepth.
*
* Obsolete class check:
* Ensure obsolete classes are found in the replacedClass linked list on the currentClass.
*/
private void checkJ9ClassSanity(J9JavaVMPointer javaVM, PrintStream out) throws CorruptDataException {
reportMessage(out, "Checking classes");
// Stolen from RootScaner.scanClasses()
// GCClassLoaderIterator gcClassLoaderIterator =
// GCClassLoaderIterator.from();
GCSegmentIterator segmentIterator = GCSegmentIterator.fromJ9MemorySegmentList(javaVM.classMemorySegments(), J9MemorySegment.MEMORY_TYPE_RAM_CLASS);
int count = 0;
int obsoleteCount = 0;
while (segmentIterator.hasNext()) {
J9MemorySegmentPointer segment = segmentIterator.next();
GCClassHeapIterator classHeapIterator = GCClassHeapIterator.fromJ9MemorySegment(segment);
while (classHeapIterator.hasNext()) {
J9ClassPointer clazz = classHeapIterator.next();
if (!J9ClassHelper.isObsolete(clazz)) {
verifyJ9Class(javaVM, out, clazz);
} else {
verifyObsoleteJ9Class(javaVM, out, clazz);
obsoleteCount++;
}
count++;
}
}
reportMessage(out, "Checking %d classes (%d obsolete) done", count, obsoleteCount);
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class VmCheckCommand method verifyJ9ROMClass.
private void verifyJ9ROMClass(PrintStream out, J9JavaVMPointer vm, J9ClassPointer clazz) throws CorruptDataException {
J9ROMClassPointer romClass = clazz.romClass();
J9ClassLoaderPointer classLoader = clazz.classLoader();
J9MemorySegmentPointer segment = findSegmentInClassLoaderForAddress(classLoader, romClass);
if (!segment.isNull()) {
long address;
if (romClass.interfaceCount().longValue() != 0) {
address = romClass.interfaces().getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->interfaces");
}
if (romClass.romMethodCount().longValue() != 0) {
address = romClass.romMethods().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romMethods");
}
if (romClass.romFieldCount().longValue() != 0) {
address = romClass.romFields().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->romFields");
}
if (romClass.innerClassCount().longValue() != 0) {
address = romClass.innerClasses().longValue();
verifyAddressInSegment(out, vm, segment, address, "romClass->innerClasses");
}
U32Pointer cpShapeDescription = romClass.cpShapeDescription();
/* TODO: is !isNull() check required or not? */
if (!cpShapeDescription.isNull()) {
address = cpShapeDescription.getAddress();
verifyAddressInSegment(out, vm, segment, address, "romClass->cpShapeDescription");
}
}
{
J9UTF8Pointer className = romClass.className();
J9UTF8Pointer superclassName = romClass.superclassName();
J9UTF8Pointer outerClassName = romClass.outerClassName();
if (className.isNull() || !verifyUTF8(className)) {
reportError(out, "invalid className=0x%s utf8 for romClass=0x%s", Long.toHexString(className.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!superclassName.isNull() && !verifyUTF8(superclassName)) {
reportError(out, "invalid superclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(superclassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
if (!outerClassName.isNull() && !verifyUTF8(outerClassName)) {
reportError(out, "invalid outerclassName=0x%s utf8 for romClass=0x%s", Long.toHexString(outerClassName.getAddress()), Long.toHexString(romClass.getAddress()));
}
}
U32 ramConstantPoolCount = romClass.ramConstantPoolCount();
U32 romConstantPoolCount = romClass.romConstantPoolCount();
if (ramConstantPoolCount.gt(romConstantPoolCount)) {
reportError(out, "ramConstantPoolCount=%d > romConstantPoolCount=%d for romClass=0x%s", ramConstantPoolCount.longValue(), romConstantPoolCount.longValue(), Long.toHexString(romClass.getAddress()));
}
}
Aggregations