Search in sources :

Example 1 with PatternString

use of com.ibm.j9ddr.util.PatternString in project openj9 by eclipse.

the class DumpRomClassCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long maps = 0;
        if (args.length != 1 && args.length != 2) {
            printUsage(out);
            return;
        }
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= J9BCTranslationData.BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= J9BCTranslationData.BCT_LittleEndianOutput;
        } else {
            maps |= J9BCTranslationData.BCT_BigEndianOutput;
        }
        /* check for name:<name> */
        if (args[0].startsWith("name:")) {
            long hitCount = 0;
            String searchClassName = args[0].substring(args[0].indexOf(':') + 1);
            PatternString pattern = new PatternString(searchClassName);
            J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
            ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
            while (iterator.hasNext()) {
                J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
                String javaName = J9ClassHelper.getJavaName(classPointer);
                if (pattern.isMatch(javaName)) {
                    hitCount++;
                    J9ROMClassPointer clazz = classPointer.romClass();
                    String hexString = clazz.getHexAddress();
                    out.println(String.format("ROMClass %1$s named %2$s\n", hexString, javaName));
                    J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
                }
            }
            out.println(String.format("Found %1$d class(es) with name %2$s\n", hitCount, searchClassName));
        } else {
            /* treat argument as address */
            long addr = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
            J9ROMClassPointer clazz = J9ROMClassPointer.cast(addr);
            J9BCUtil.j9bcutil_dumpRomClass(out, clazz, maps);
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with PatternString

use of com.ibm.j9ddr.util.PatternString in project openj9 by eclipse.

the class J9ClassShapeCommand method findClassByName.

public static J9ClassPointer[] findClassByName(J9JavaVMPointer vm, String searchClassName) throws DDRInteractiveCommandException {
    ArrayList<J9ClassPointer> result = new ArrayList<J9ClassPointer>();
    try {
        PatternString pattern = new PatternString(searchClassName);
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
            String javaName = J9ClassHelper.getJavaName(classPointer);
            if (pattern.isMatch(javaName)) {
                result.add(classPointer);
            }
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
    return result.toArray(new J9ClassPointer[result.size()]);
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) ArrayList(java.util.ArrayList) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 3 with PatternString

use of com.ibm.j9ddr.util.PatternString in project openj9 by eclipse.

the class RomClassForNameCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for ROMClasses named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ROMClassPointer romClassPointer = iterator.next();
            String javaName = J9UTF8Helper.stringValue(romClassPointer.className());
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = romClassPointer.getHexAddress();
                out.println(String.format("!j9romclass %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d ROMClass(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 4 with PatternString

use of com.ibm.j9ddr.util.PatternString in project openj9 by eclipse.

the class FilteredROMMethodsIterator method setPatterns.

private void setPatterns(String searchExpression) {
    String classNameString = "*";
    String methodNameString = "*";
    String signatureString = "*";
    int parenLocation = searchExpression.indexOf('(');
    final int periodLocation = searchExpression.indexOf('.');
    if (periodLocation != -1) {
        int endOfClassName = (parenLocation >= 0) ? parenLocation : searchExpression.length();
        classNameString = searchExpression.substring(0, periodLocation);
        methodNameString = searchExpression.substring(periodLocation + 1, endOfClassName);
    } else {
        methodNameString = searchExpression;
    }
    if (parenLocation != -1) {
        signatureString = searchExpression.substring(parenLocation);
    }
    classPattern = new PatternString(classNameString);
    methodPattern = new PatternString(methodNameString);
    signaturePattern = new PatternString(signatureString);
}
Also used : PatternString(com.ibm.j9ddr.util.PatternString) PatternString(com.ibm.j9ddr.util.PatternString)

Example 5 with PatternString

use of com.ibm.j9ddr.util.PatternString in project openj9 by eclipse.

the class ClassForNameCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length == 0) {
        printUsage(out);
        return;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        ClassSegmentIterator iterator = new ClassSegmentIterator(vm.classMemorySegments());
        int hitCount = 0;
        String searchClassName = args[0];
        PatternString pattern = new PatternString(searchClassName);
        out.println(String.format("Searching for classes named '%1$s' in VM=%2$s", searchClassName, Long.toHexString(vm.getAddress())));
        while (iterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) iterator.next();
            String javaName = J9ClassHelper.getJavaName(classPointer);
            if (pattern.isMatch(javaName)) {
                hitCount++;
                String hexString = classPointer.getHexAddress();
                out.println(String.format("!j9class %1$s named %2$s", hexString, javaName));
            }
        }
        out.println(String.format("Found %1$d class(es) named %2$s", hitCount, searchClassName));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) PatternString(com.ibm.j9ddr.util.PatternString) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) PatternString(com.ibm.j9ddr.util.PatternString) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

PatternString (com.ibm.j9ddr.util.PatternString)5 CorruptDataException (com.ibm.j9ddr.CorruptDataException)4 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)4 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)3 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)3 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)3 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)2 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)1 ArrayList (java.util.ArrayList)1