Search in sources :

Example 46 with CorruptDataException

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

the class CoreInfoCommand method run.

/**
 * Run method for !coreinfo extension.
 *
 * @param command  !coreinfo
 * @param args	args passed by !coreinfo extension.
 * @param context Context of current core file.
 * @param out PrintStream to print the output to the console.
 * @throws DDRInteractiveCommandException
 */
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if (0 < args.length) {
        out.println("!coreinfo expects no args. Usage :");
        printUsage(out);
        return;
    }
    J9JavaVMPointer vm;
    try {
        J9RASPointer ras = DataType.getJ9RASPointer();
        vm = J9RASHelper.getVM(ras);
        IProcess process = vm.getProcess();
        J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
        try {
            /* Print the command line of a running program that generated core file */
            out.println("COMMANDLINE\n" + ddrProcess.getCommandLine() + "\n");
        } catch (DataUnavailable e) {
            /*For Zos core files, commandline is not available */
            out.println("COMMANDLINE is not available\n");
        } catch (com.ibm.dtfj.image.CorruptDataException e) {
            throw new DDRInteractiveCommandException("CorruptDataException occured while getting the commandline from process");
        }
        Properties properties = J9JavaVMHelper.getSystemProperties(vm);
        /* Print VM service level info */
        out.println("JAVA SERVICE LEVEL INFO\n" + ras.serviceLevel().getCStringAtOffset(0));
        /* Print Java Version Info */
        out.println("JAVA VERSION INFO\n" + properties.get("java.fullversion"));
        /* Print Java VM Version Info */
        out.println("JAVA VM VERSION\t- " + properties.get("java.vm.version") + "\n");
        /* Print Platform Info */
        boolean is64BitPlatform = (process.bytesPerPointer() == 8) ? true : false;
        ICore core = vm.getProcess().getAddressSpace().getCore();
        Platform platform = core.getPlatform();
        out.println("PLATFORM INFO");
        out.print("Platform Name :\t" + platform.name());
        if (is64BitPlatform) {
            out.println(" 64Bit");
        } else {
            out.println(" 32Bit");
        }
        out.println("OS Level\t: " + ras.osnameEA().getCStringAtOffset(0) + " " + ras.osversionEA().getCStringAtOffset(0));
        out.println("Processors -");
        out.println("  Architecture\t: " + ras.osarchEA().getCStringAtOffset(0));
        out.println("  How Many\t: " + ras.cpus().longValue());
        try {
            properties = ddrProcess.getEnvironment();
            Enumeration processPropEnum = properties.keys();
            out.println("\nENVIRONMENT VARIABLES");
            while (processPropEnum.hasMoreElements()) {
                String key = (String) processPropEnum.nextElement();
                out.println(key + "=" + properties.get(key));
            }
        } catch (com.ibm.dtfj.image.CorruptDataException e) {
            throw new DDRInteractiveCommandException("CorruptDataException occured while getting the environment variables from process");
        } catch (DataUnavailable e) {
            out.println("Environment variables are not available\n");
        }
    } catch (CorruptDataException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Enumeration(java.util.Enumeration) Platform(com.ibm.j9ddr.corereaders.Platform) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) Properties(java.util.Properties) ICore(com.ibm.j9ddr.corereaders.ICore) J9RASPointer(com.ibm.j9ddr.vm29.pointer.generated.J9RASPointer) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess)

Example 47 with CorruptDataException

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

the class DumpAllRamClassLinearCommand 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();
        ClassSegmentIterator classSegmentIterator = new ClassSegmentIterator(vm.classMemorySegments());
        while (classSegmentIterator.hasNext()) {
            J9ClassPointer classPointer = (J9ClassPointer) classSegmentIterator.next();
            out.println("!dumpramclasslinear " + classPointer.getHexAddress());
            // RAM Class 'org/apache/tomcat/util/buf/MessageBytes' at 0x0DCF9008:
            out.println(String.format("RAM Class '%s' at %s", J9ClassHelper.getJavaName(classPointer), classPointer.getHexAddress()));
            out.println();
            ClassWalker classWalker = new RamClassWalker(classPointer, context);
            new LinearDumper().gatherLayoutInfo(out, classWalker, nestingThreashold);
            out.println();
        }
    } catch (CorruptDataException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}
Also used : ClassSegmentIterator(com.ibm.j9ddr.vm29.j9.walkers.ClassSegmentIterator) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) 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) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) RamClassWalker(com.ibm.j9ddr.vm29.tools.ddrinteractive.RamClassWalker) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 48 with CorruptDataException

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

the class ClassloadersSummaryCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        Collection<ClassloadersSummaryNode> stats = getStat();
        printStat(stats, out, args.length > 0 && args[0].equalsIgnoreCase("segs"));
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 49 with CorruptDataException

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

the class WhatIsCommand method walkStructuresFrom.

private boolean walkStructuresFrom(StructurePointer startPoint) throws DDRInteractiveCommandException {
    Set<AbstractPointer> walked = new HashSet<AbstractPointer>();
    SearchStack searchStack = new SearchStack(maxDepth);
    if (UDATA.cast(startPoint).eq(searchValue)) {
        out.println("Found " + searchValue.getHexValue() + " as " + startPoint.formatShortInteractive());
        return true;
    }
    /* Seed with startPoint */
    searchStack.push(new SearchFrame(startPoint));
    walked.add(startPoint);
    boolean found = false;
    while (!searchStack.isEmpty() && !found) {
        SearchFrame current = searchStack.peek();
        int fieldIndex = current.fieldIndex++;
        if (current.fieldAccessors.length <= fieldIndex) {
            // We've walked all the fields on this object
            searchStack.pop();
            continue;
        }
        try {
            current.fieldName = current.fieldAccessors[fieldIndex].getName();
            Object result = current.fieldAccessors[fieldIndex].invoke(current.ptr);
            if (result == null) {
                continue;
            }
            fieldCount++;
            if (result instanceof StructurePointer) {
                StructurePointer ptr = (StructurePointer) result;
                found = checkPointer(searchStack, ptr);
                if (!searchStack.isFull() && !walked.contains(ptr)) {
                    walked.add(ptr);
                    searchStack.push(new SearchFrame(ptr));
                }
            } else if (result instanceof AbstractPointer) {
                AbstractPointer ptr = (AbstractPointer) result;
                found = checkPointer(searchStack, ptr);
            } else if (result instanceof Scalar) {
                Scalar s = (Scalar) result;
                found = checkScalar(searchStack, s);
            } else {
                out.println("Unexpected type walked: " + result.getClass().getName());
                continue;
            }
        } catch (InvocationTargetException e) {
            Throwable cause = e.getCause();
            if (cause instanceof CorruptDataException || cause instanceof NoSuchFieldError || cause instanceof NoClassDefFoundError) {
                // Skip this field
                continue;
            } else {
                throw new DDRInteractiveCommandException("Unexpected exception during walk", cause);
            }
        } catch (Exception e) {
            throw new DDRInteractiveCommandException("Unexpected exception during !whatis walk", e);
        }
    }
    return found;
}
Also used : AbstractPointer(com.ibm.j9ddr.vm29.pointer.AbstractPointer) StructurePointer(com.ibm.j9ddr.vm29.pointer.StructurePointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) InvocationTargetException(java.lang.reflect.InvocationTargetException) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) InvocationTargetException(java.lang.reflect.InvocationTargetException) Scalar(com.ibm.j9ddr.vm29.types.Scalar) HashSet(java.util.HashSet)

Example 50 with CorruptDataException

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

the class BytecodesCommand method run.

// dbgext_bytecodes
public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        long address = CommandUtils.parsePointer(args[0], J9BuildFlags.env_data64);
        J9MethodPointer ramMethod = J9MethodPointer.cast(address);
        long maps = 0;
        if (ramMethod.isNull()) {
            CommandUtils.dbgPrint(out, "bad or missing ram method addr\n");
            return;
        }
        J9ClassPointer ramClass = ConstantPoolHelpers.J9_CLASS_FROM_METHOD(ramMethod);
        if (args.length == 2 && args[1].equals("maps")) {
            maps |= BCT_DumpMaps;
        }
        if (J9BuildFlags.env_littleEndian) {
            maps |= BCT_LittleEndianOutput;
        } else {
            maps |= BCT_BigEndianOutput;
        }
        J9ROMMethodPointer romMethod = J9MethodHelper.romMethod(ramMethod);
        J9ROMClassPointer romClass = ramClass.romClass();
        J9BCUtil.j9bcutil_dumpRomMethod(out, romMethod, romClass, maps, 0);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : J9MethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9MethodPointer) J9ClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ClassPointer) J9ROMClassPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMClassPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9ROMMethodPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ROMMethodPointer) 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