use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class J9ClassHelper method getArrayName.
public static String getArrayName(J9ClassPointer clazz) throws CorruptDataException {
J9ArrayClassPointer arrayClass = J9ArrayClassPointer.cast(clazz);
StringBuilder name = new StringBuilder();
int arity = 0;
try {
arity = arrayClass.arity().intValue();
} catch (InvalidDataTypeException e) {
throw new AddressedCorruptDataException(arrayClass.getAddress(), "Array arity larger than MAXINT");
}
if (arity > MAXIMUM_ARRAY_ARITY) {
// Doubtful
throw new AddressedCorruptDataException(arrayClass.getAddress(), "Very high arity " + arity + " from array class 0x" + Long.toHexString(arrayClass.getAddress()));
}
for (int i = 0; i < arity; i++) {
name.append('[');
}
String elementClassName = J9ClassHelper.getName(arrayClass.leafComponentType());
Character type = TYPE_MAP.get(elementClassName);
if (type != null) {
name.append(type);
} else {
name.append('L');
name.append(elementClassName);
name.append(";");
}
return name.toString();
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class AbstractPointer method getObjectClassAtOffset.
protected J9ClassPointer getObjectClassAtOffset(long offset) throws CorruptDataException {
long location = address + offset;
long classPointer;
if (J9BuildFlags.interp_compressedObjectHeader) {
classPointer = (long) getAddressSpace().getIntAt(location) & 0xFFFFFFFFL;
} else {
classPointer = getAddressSpace().getPointerAt(location);
}
if (classPointer == 0L) {
throw new MemoryFault(location, "Invalid class address found in object");
}
J9ClassPointer cp = checkClassCache(classPointer);
if (cp == null) {
cp = J9ClassPointer.cast(classPointer);
setClassCache(classPointer, cp);
}
return cp;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer 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.J9ClassPointer in project openj9 by eclipse.
the class J9ObjectHelper method readFieldOffset.
// FIXME: Probably want to cache the entire class hierarchy the 1st time through for any field
private static J9ObjectFieldOffset readFieldOffset(J9ObjectPointer objPointer, String name, String signature) throws CorruptDataException {
J9ClassPointer currentClass = J9ObjectHelper.clazz(objPointer);
while (currentClass.notNull()) {
Iterator<J9ObjectFieldOffset> fields = J9ClassHelper.getFieldOffsets(currentClass);
while (fields.hasNext()) {
J9ObjectFieldOffset field = (J9ObjectFieldOffset) fields.next();
if (field.getName().equals(name) && field.getSignature().equals(signature)) {
return field;
}
}
currentClass = J9ClassHelper.superclass(currentClass);
}
throw new NoSuchElementException(String.format("No field named %s with signature %s in %s", name, signature, J9ObjectHelper.getClassName(objPointer)));
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer in project openj9 by eclipse.
the class AllClassesCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
init();
if (args != null) {
if (!parseArgs(out, args)) {
return;
}
}
boolean useRange = (rangeStart != null && rangeEnd != null);
/* If none of "rom" or "ram" is specified, then list both type of classes */
if (!dumpROMClasses && !dumpRAMClasses) {
dumpROMClasses = dumpRAMClasses = true;
}
try {
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
if (dumpRAMClasses) {
out.append("RAM classes (ram size loader rom replacement name)" + nl);
out.append("Class addr\tsize\t\tClassLoader\tROM class addr\tArray\tClass name" + nl);
out.append(nl);
ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
while (classSegmentIterator.hasNext()) {
J9ClassPointer classPointer = J9ClassPointer.NULL;
try {
classPointer = (J9ClassPointer) classSegmentIterator.next();
if (useRange) {
if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
/* J9Class is outside of specified range; skip it. */
continue;
}
}
// 0x02713400 0x00000148 0x001210cc 0x02da2f20 0x00000000
// java/util/regex/Pattern$Begin
out.append(classPointer.getHexAddress());
out.append('\t');
out.append(J9ClassHelper.size(classPointer, vm).getHexValue());
out.append('\t');
out.append(classPointer.classLoader().getHexAddress());
out.append('\t');
out.append(classPointer.romClass().getHexAddress());
out.append('\t');
if (J9ClassHelper.isSwappedOut(classPointer)) {
out.append(classPointer.arrayClass().getHexAddress());
} else {
out.append('0');
}
out.append('\t');
out.append(J9ClassHelper.getJavaName(classPointer));
out.append(nl);
} catch (CorruptDataException e) {
if (useRange) {
if (classPointer.getAddress() < rangeStart.getAddress() || classPointer.getAddress() >= rangeEnd.getAddress()) {
/* J9Class that caused CorruptDataException is outside of specified range; skip it. */
continue;
}
}
}
}
}
if (dumpROMClasses) {
ROMClassesIterator iterator = null;
out.append(nl);
if (useRange) {
iterator = new ROMClassesRangeIterator(out, rangeStart, rangeEnd);
/* Classloader is not available when using ROMClassesRangeIterator */
out.append("ROM classes (rom size modifiers name)" + nl);
out.append("Class addr\tROM size\tModifiers\tExtra\t\tClass name" + nl);
} else {
iterator = new ROMClassesIterator(out, vm.classMemorySegments());
out.append("ROM classes (rom size loader modifiers name)" + nl);
out.append("Class addr\tROM size\tClassLoader\tModifiers\tExtra\t\tClass name" + nl);
}
out.append(nl);
while (iterator.hasNext()) {
J9ROMClassPointer classPointer = iterator.next();
out.append(classPointer.getHexAddress());
out.append('\t');
out.append(classPointer.romSize().getHexValue());
/* MemorySegment is not available when using ROMClassesRangeIterator */
if (iterator.getMemorySegmentPointer() != J9MemorySegmentPointer.NULL) {
out.append('\t');
out.append(iterator.getMemorySegmentPointer().classLoader().getHexAddress());
}
out.append('\t');
out.append(classPointer.modifiers().getHexValue());
out.append('\t');
out.append(classPointer.extraModifiers().getHexValue());
out.append('\t');
out.append(J9UTF8Helper.stringValue(classPointer.className()));
out.append(nl);
}
out.append(nl);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
Aggregations