Search in sources :

Example 1 with J9ROMClassAndMethod

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;
}
Also used : J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) Vector(java.util.Vector) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Example 2 with J9ROMClassAndMethod

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;
    }
}
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)

Example 3 with J9ROMClassAndMethod

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;
}
Also used : J9ROMNameAndSignaturePointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) J9UTF8Pointer(com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException) NoSuchElementException(java.util.NoSuchElementException) J9ROMClassAndMethod(com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)

Aggregations

J9ROMClassAndMethod (com.ibm.j9ddr.vm29.j9.walkers.J9ROMClassAndMethod)3 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)1 PatternString (com.ibm.j9ddr.util.PatternString)1 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)1 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)1 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)1 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)1 J9ROMNameAndSignaturePointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMNameAndSignaturePointer)1 J9UTF8Pointer (com.ibm.j9ddr.vm29.pointer.generated.J9UTF8Pointer)1 FilteredROMMethodsIterator (com.ibm.j9ddr.vm29.tools.ddrinteractive.FilteredROMMethodsIterator)1 NoSuchElementException (java.util.NoSuchElementException)1 Vector (java.util.Vector)1