Search in sources :

Example 1 with FilteredROMMethodsIterator

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;
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) FilteredROMMethodsIterator(com.ibm.j9ddr.vm29.tools.ddrinteractive.FilteredROMMethodsIterator) U8Pointer(com.ibm.j9ddr.vm29.pointer.U8Pointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)1 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 J9ROMClassAndMethod (com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)1 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)1 FilteredROMMethodsIterator (com.ibm.j9ddr.vm29.tools.ddrinteractive.FilteredROMMethodsIterator)1