use of com.ibm.j9ddr.vm29.tools.ddrinteractive.FilteredROMMethodsIterator in project openj9 by eclipse.
the class DumpRomMethodCommand method run.
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
try {
Iterable<J9ROMClassAndMethod> methodIterator = null;
if (args.length < 1) {
printUsage(out);
return;
}
String selector = args[0];
if (selector.equals("-a")) {
if (args.length != 2) {
printUsage(out);
return;
}
/* decimal or hexadecimal */
long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9MethodPointer ramMethod = J9MethodPointer.cast(methodAddress);
if (ramMethod.isNull()) {
CommandUtils.dbgPrint(out, "bad ram method addr\n");
return;
}
methodIterator = romMethodIteratorFromRamMethod(ramMethod);
} else if (selector.equals("-o")) {
if (args.length != 2) {
printUsage(out);
return;
}
long methodAddress = CommandUtils.parsePointer(args[1], J9BuildFlags.env_data64);
J9ROMMethodPointer romMethod = J9ROMMethodPointer.cast(methodAddress);
if (romMethod.isNull()) {
CommandUtils.dbgPrint(out, "bad rom method addr\n");
return;
}
J9ROMMethodPointer bytecodesStart = romMethod.add(1);
/* bytecodes immediately follow the J9ROMMethod struct */
U8Pointer pc = U8Pointer.cast(bytecodesStart.getAddress());
J9MethodPointer ramMethod = J9JavaVMHelper.getMethodFromPC(J9RASHelper.getVM(DataType.getJ9RASPointer()), pc);
methodIterator = romMethodIteratorFromRamMethod(ramMethod);
} else {
try {
methodIterator = new FilteredROMMethodsIterator(out, context, selector);
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
}
}
for (J9ROMClassAndMethod mi : methodIterator) {
out.println(String.format("Class: %s", J9UTF8Helper.stringValue(mi.romClass.className())));
J9BCUtil.j9bcutil_dumpRomMethod(out, mi.romMethod, mi.romClass, dumpFlags, J9BCUtil.BCUtil_DumpAnnotations);
}
} catch (CorruptDataException e) {
throw new DDRInteractiveCommandException(e);
} catch (NullPointerException e) {
e.printStackTrace();
throw e;
}
}
Aggregations