use of com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod in project openj9 by eclipse.
the class DumpRomMethodCommand method romMethodIteratorFromRamMethod.
private Iterable<J9ROMClassAndMethod> romMethodIteratorFromRamMethod(J9MethodPointer ramMethod) throws CorruptDataException {
Iterable<J9ROMClassAndMethod> methodIterator;
J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
J9ROMClassPointer romClass = ramClass.romClass();
Vector<J9ROMClassAndMethod> methodInfoVector = new Vector<J9ROMClassAndMethod>(1);
methodInfoVector.add(new J9ROMClassAndMethod(romMethod, romClass));
methodIterator = methodInfoVector;
return methodIterator;
}
use of com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod 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;
}
}
use of com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod in project openj9 by eclipse.
the class FilteredROMMethodsIterator method next.
public J9ROMClassAndMethod next() {
J9ROMClassAndMethod result = nextMethod;
/* hasNext may have already go the next method */
nextMethod = null;
/* destructive read */
if (null == result) {
do {
try {
if ((null != currentRomMethod) && (remainingMethods > 0)) {
J9ROMMethodPointer romMethod = currentRomMethod;
J9ROMNameAndSignaturePointer nameAndSignature = romMethod.nameAndSignature();
J9UTF8Pointer methNameUTF = nameAndSignature.name();
String methName = J9UTF8Helper.stringValue(methNameUTF);
if (methodPattern.isMatch(methName)) {
String methSig = J9UTF8Helper.stringValue(nameAndSignature.signature());
if (signaturePattern.isMatch(methSig)) {
result = new J9ROMClassAndMethod(romMethod, currentRomClass);
}
}
currentRomMethod = ROMHelp.nextROMMethod(currentRomMethod);
--remainingMethods;
} else {
if (!goToNextClass()) {
break;
/* ran out of classes */
}
}
} catch (CorruptDataException e) {
throw new NoSuchElementException();
}
} while (null == result);
}
return result;
}
Aggregations