Search in sources :

Example 61 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class DumpAllRegionsCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    boolean statsRequested = false;
    boolean skipReport = false;
    if (0 != args.length) {
        String argument = args[0];
        if (argument.equalsIgnoreCase("help")) {
            help(out);
            return;
        }
        statsRequested = argument.equalsIgnoreCase("stats");
        skipReport = statsRequested;
    }
    try {
        GCHeapRegionIterator gcHeapRegionIterator = GCHeapRegionIterator.from();
        int[] stats = new int[regionTypesString.length];
        int total = 0;
        String header1, header2, header3;
        String footer;
        String formatString;
        String regionType;
        initializeStats(stats);
        if (J9BuildFlags.env_data64) {
            header1 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
            header2 = "|    region      |     start      |      end       |    subspace    | flags  |      size      |      region type     \n";
            header3 = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
            formatString = " %016x %016x %016x %016x %08x %16x %s\n";
            footer = "+----------------+----------------+----------------+----------------+--------+----------------+----------------------\n";
        } else {
            header1 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
            header2 = "| region | start  |  end   |subspace| flags  |  size  |      region type     \n";
            header3 = "+--------+--------+--------+--------+--------+--------+----------------------\n";
            formatString = " %08x %08x %08x %08x %08x %8x %s\n";
            footer = "+--------+--------+--------+--------+--------+--------+----------------------\n";
        }
        if (!skipReport) {
            out.append(header1);
            out.append(header2);
            out.append(header3);
        }
        while (gcHeapRegionIterator.hasNext()) {
            GCHeapRegionDescriptor heapRegionDescriptor = gcHeapRegionIterator.next();
            int index = (int) heapRegionDescriptor.getRegionType();
            total += 1;
            if (index < regionTypesString.length) {
                regionType = regionTypesString[index];
                stats[index] += 1;
            } else {
                regionType = "Unknown";
            }
            if (!skipReport) {
                out.append(String.format(formatString, heapRegionDescriptor.getHeapRegionDescriptorPointer().getAddress(), heapRegionDescriptor.getLowAddress().getAddress(), heapRegionDescriptor.getHighAddress().getAddress(), heapRegionDescriptor.getSubSpace().getAddress(), heapRegionDescriptor.getTypeFlags().longValue(), heapRegionDescriptor.getSize().longValue(), regionType));
            }
        }
        if (!skipReport) {
            out.append(footer);
        }
        if (statsRequested) {
            String formatStringStats = " \t%s: %d\n";
            for (int i = 0; i < regionTypesString.length; i++) {
                if (0 != stats[i]) {
                    out.append(String.format(formatStringStats, regionTypesString[i], stats[i]));
                }
            }
            out.append(String.format(formatStringStats, "++++ TOTAL", total));
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : GCHeapRegionDescriptor(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionDescriptor) GCHeapRegionIterator(com.ibm.j9ddr.vm29.j9.gc.GCHeapRegionIterator) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 62 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.

the class DumpAllRomClassLinearCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    long nestingThreashold;
    if (args.length > 1) {
        throw new DDRInteractiveCommandException("This debug extension accepts none or one argument!");
    } else if (args.length == 1) {
        nestingThreashold = Long.valueOf(args[0]);
    } else {
        nestingThreashold = 1;
    }
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (null != vm) {
            out.println();
            out.println("!j9javavm " + vm.getHexAddress());
        } else {
            throw new DDRInteractiveCommandException("Unable to find the VM in core dump!");
        }
        out.println();
        ROMClassesIterator iterator = new ROMClassesIterator(out, vm.classMemorySegments());
        while (iterator.hasNext()) {
            J9ROMClassPointer classPointer = iterator.next();
            out.println("!dumpromclasslinear " + classPointer.getHexAddress());
            // ROM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
            out.println(String.format("ROM Class '%s' at %s", J9UTF8Helper.stringValue(classPointer.className()), classPointer.getHexAddress()));
            out.println();
            ClassWalker classWalker = new RomClassWalker(classPointer, context);
            new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
            out.println();
        }
    } catch (CorruptDataException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
Also used : ROMClassesIterator(com.ibm.j9ddr.vm29.j9.walkers.ROMClassesIterator) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) LinearDumper(com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) ClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) RomClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RomClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 63 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException 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 64 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException 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 65 with CorruptDataException

use of com.ibm.j9ddr.CorruptDataException 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)

Aggregations

CorruptDataException (com.ibm.j9ddr.CorruptDataException)221 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)81 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)46 J9ObjectPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)41 J9ClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer)33 VoidPointer (com.ibm.j9ddr.vm29.pointer.VoidPointer)30 NoSuchElementException (java.util.NoSuchElementException)28 J9VMThreadPointer (com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer)25 UDATA (com.ibm.j9ddr.vm29.types.UDATA)20 PointerPointer (com.ibm.j9ddr.vm29.pointer.PointerPointer)17 J9ROMClassPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer)15 U8Pointer (com.ibm.j9ddr.vm29.pointer.U8Pointer)11 J9MethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer)9 J9ROMMethodPointer (com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer)9 ClassWalker (com.ibm.j9ddr.vm29.tools.ddrinteractive.ClassWalker)8 LinearDumper (com.ibm.j9ddr.vm29.tools.ddrinteractive.LinearDumper)8 PatternString (com.ibm.j9ddr.util.PatternString)7 GCVMThreadListIterator (com.ibm.j9ddr.vm29.j9.gc.GCVMThreadListIterator)7 ClassSegmentIterator (com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator)7 J9PoolPointer (com.ibm.j9ddr.vm29.pointer.generated.J9PoolPointer)7