Search in sources :

Example 21 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException 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 22 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class FindPatternCommand method run.

/**
 * Run method for !findpattern extension.
 *
 * @param command  !findpattern
 * @param args	args passed by !findpattern extension.
 * @param context Context
 * @param out PrintStream
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        byte[] pattern = null;
        BigInteger bytesToSearch = CommandUtils.longToBigInteger(UDATA.MAX.longValue());
        int length = 0;
        if (args.length != 1) {
            printUsage(out);
            return;
        }
        String[] realArgs = args[0].split(",");
        if (realArgs.length == 1) {
            CommandUtils.dbgError(out, "Error: must specify alignment\n");
            printUsage(out);
            return;
        }
        String hexstring = realArgs[0];
        int patternAlignment = Integer.parseInt(realArgs[1]);
        long startSearchFrom = 0;
        if (realArgs.length == 3) {
            startSearchFrom = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
            bytesToSearch = bytesToSearch.subtract(CommandUtils.longToBigInteger(startSearchFrom));
        } else if (realArgs.length == 4) {
            startSearchFrom = CommandUtils.parsePointer(realArgs[2], J9BuildFlags.env_data64);
            bytesToSearch = CommandUtils.parseNumber(realArgs[3]);
            if (bytesToSearch.add(CommandUtils.longToBigInteger(startSearchFrom)).toString(CommandUtils.RADIX_HEXADECIMAL).length() > UDATA.SIZEOF) {
                out.println("Warning: bytesToSearch value (" + realArgs[3] + ") is larger than the max available memory after the search start address (" + realArgs[2] + ").\n Pattern will be searched in all the remaining memory after the search start address");
                bytesToSearch = CommandUtils.longToBigInteger(UDATA.MAX.longValue()).subtract(CommandUtils.longToBigInteger(startSearchFrom));
            }
        } else if (realArgs.length > 4) {
            CommandUtils.dbgError(out, "Error: too many arguments\n");
        }
        length = hexstring.length() / 2;
        if (length > PATTERN_LENGHT) {
            CommandUtils.dbgPrint(out, String.format("Pattern is too long. Truncating to %d bytes\n", PATTERN_LENGHT));
            length = PATTERN_LENGHT;
        }
        pattern = new byte[length];
        for (int i = 0; i < length; i++) {
            int hex1 = hexValue(hexstring.charAt(i * 2));
            int hex2 = hexValue(hexstring.charAt(i * 2 + 1));
            if ((hex1 < 0) || (hex2 < 0)) {
                CommandUtils.dbgError(out, "Error: non-hex value found in hex string\n");
                return;
            }
            pattern[i] = (byte) ((hex1 << 4) + hex2);
        }
        /* ensure that alignment is > 0 */
        if (patternAlignment == 0) {
            patternAlignment = 1;
        }
        CommandUtils.dbgPrint(out, String.format("Searching for %d bytes. Alignment = %d, start = %s, bytesToSearch = %s ...\n", length, patternAlignment, U8Pointer.cast(startSearchFrom).getHexAddress(), bytesToSearch.toString()));
        long result = dbgFindPatternInRange(context, pattern, patternAlignment, startSearchFrom, bytesToSearch);
        if (0 != result) {
            CommandUtils.dbgPrint(out, String.format("Result = %s\n", U8Pointer.cast(result).getHexAddress()));
        } else {
            CommandUtils.dbgPrint(out, String.format("Result = No Match Found.\n"));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) BigInteger(java.math.BigInteger) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 23 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class FindOverlappingSegmentsCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    int segmentType = MemorySegmentIterator.MEMORY_ALL_TYPES & ~((int) J9MemorySegment.MEMORY_TYPE_SHARED_META);
    if (args.length == 0) {
    /* use default */
    } else {
        String argument = args[0];
        if (argument.equalsIgnoreCase("help")) {
            printHelp(out);
            return;
        } else if (argument.equalsIgnoreCase("all")) {
            segmentType = MemorySegmentIterator.MEMORY_ALL_TYPES;
        } else if (argument.equalsIgnoreCase("virtual")) {
            segmentType = (int) J9MemorySegment.MEMORY_TYPE_VIRTUAL;
        }
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        SegmentsUtil.checkSegmentsForOverlap(out, vm, segmentType);
        out.append(nl);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 24 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class FindVMCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9RASHelper.setCachedVM(null);
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        CommandUtils.dbgPrint(out, "!j9javavm %s\n", vm.getHexAddress());
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 25 with DDRInteractiveCommandException

use of com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException in project openj9 by eclipse.

the class GCCheckCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        GCCheckRunner.run(vm, args, out);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Aggregations

DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)86 CorruptDataException (com.ibm.j9ddr.CorruptDataException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)38 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)16 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)16 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)16 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)11 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 UDATAPointer (com.ibm.j9ddr.vm29.pointer.UDATAPointer)6 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)6 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)6 UDATA (com.ibm.j9ddr.vm29.types.UDATA)6 PatternString (com.ibm.j9ddr.util.PatternString)5 ROMClassesIterator (com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator)5 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)5 RomClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker)5 MonitorTable (com.ibm.j9ddr.vm29.j9.MonitorTable)4 MonitorTableListIterator (com.ibm.j9ddr.vm29.j9.MonitorTableListIterator)4