use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class ROMClassesRangeIterator method getNextClass.
private J9ROMClassPointer getNextClass() {
long newHeapPtr = 0;
J9ROMClassPointer newNextClass = J9ROMClassPointer.NULL;
if (nextClass == J9ROMClassPointer.NULL) {
newHeapPtr = startAddr;
} else {
try {
newHeapPtr = nextClass.getAddress() + nextClass.romSize().longValue();
} catch (CorruptDataException e) {
/* This shouldn't happen, but if it does then it's likely an internal error */
out.append("Unabled to read size of ROMClass at " + nextClass.getHexAddress() + ".\n");
newNextClass = J9ROMClassPointer.NULL;
}
}
if ((newHeapPtr != 0) && (newHeapPtr < endAddr)) {
/* test if the next ROMClass is valid */
newNextClass = J9ROMClassPointer.cast(newHeapPtr);
try {
if (newNextClass.romSize().eq(0)) {
out.append("Size of ROMClass at " + newNextClass.getHexAddress() + "is invalid.\n");
newNextClass = J9ROMClassPointer.NULL;
}
} catch (CorruptDataException e) {
out.append("Unable to read size of ROMClass at " + newNextClass.getHexAddress() + ".\n");
newNextClass = J9ROMClassPointer.NULL;
}
}
return newNextClass;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class FilteredROMMethodsIterator method goToNextClass.
private boolean goToNextClass() throws CorruptDataException {
resetMethodIterationState();
boolean classAvailable = false;
while (null == currentRomMethod) {
if (classIterator.hasNext()) {
J9ROMClassPointer tempRomClass = classIterator.next();
String className = J9UTF8Helper.stringValue(tempRomClass.className());
if (classPattern.isMatch(className)) {
if (tempRomClass.romMethodCount().longValue() > 0) {
currentRomClass = tempRomClass;
currentRomMethod = currentRomClass.romMethods();
remainingMethods = currentRomClass.romMethodCount().intValue();
classAvailable = true;
}
}
} else {
break;
/* no more classes or classloaders */
}
}
return classAvailable;
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer 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);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class AnalyseRomClassUTF8Command method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
boolean printUTF8WeightList = false;
int maxDistributionPercent = 85;
if ((args.length >= 1) && (args[0].equals("UTF8WeightList"))) {
printUTF8WeightList = true;
}
for (int i = 0; i < args.length; i++) {
if (args[i].endsWith("%")) {
try {
// Parses the maxDistribution string such as 85%
maxDistributionPercent = DecimalFormat.getInstance().parse(args[i]).intValue();
} catch (ParseException e) {
out.println("Usage: !analyseromClassutf8 [UTF8WeightList] [maxDistribution%] maxDistribution defaults to 85%");
}
}
}
Statistics statistics = new Statistics();
J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
ROMClassesIterator classSegmentIterator = new ROMClassesIterator(out, vm.classMemorySegments());
J9ObjectPointer bootstraploader = vm.systemClassLoader().classLoaderObject();
while (classSegmentIterator.hasNext()) {
J9ROMClassPointer classPointer = (J9ROMClassPointer) classSegmentIterator.next();
ClassWalker classWalker = new RomClassWalker(classPointer, context);
LinearDumper linearDumper = new LinearDumper();
J9ClassRegionNode allRegionsNode = linearDumper.getAllRegions(classWalker);
statistics.add(allRegionsNode, classSegmentIterator, bootstraploader);
}
statistics.getResult(printUTF8WeightList, maxDistributionPercent, out);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
use of com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer in project openj9 by eclipse.
the class ByteCodeDumper method dumpBytecodes.
public static IDATA dumpBytecodes(PrintStream out, J9ROMClassPointer romClass, J9ROMMethodPointer romMethod, U32 flags) throws Exception {
U16 temp;
UDATA length;
out.append(String.format(" Argument Count: %d", romMethod.argCount().intValue()));
out.append(nl);
temp = romMethod.tempCount();
out.append(String.format(" Temp Count: %d", temp.intValue()));
out.append(nl);
out.append(nl);
length = ROMHelp.J9_BYTECODE_SIZE_FROM_ROM_METHOD(romMethod);
if (length.eq(0)) {
return new IDATA(BCT_ERR_NO_ERROR);
/* catch abstract methods */
}
return j9bcutil_dumpBytecodes(out, romClass, ROMHelp.J9_BYTECODE_START_FROM_ROM_METHOD(romMethod), new UDATA(0), length.sub(1), flags, "");
}
Aggregations