Search in sources :

Example 46 with DDRInteractiveCommandException

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

the class SnapFormatWrapperCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    if ((args.length > 0) && (args[0].equals("-help") || args[0].equals("-h") || args[0].equals("-?"))) {
        out.println("Format selected trace buffers.");
        out.println();
        out.println("   -f <filename>            Write output to the specified file (default is stdout)");
        out.println();
        out.println("   -d <datfile_directory>   Set the directory to search for the trace format database");
        out.println();
        out.println("   -t <thread_id>           Only output trace information for the specified J9VMThread");
        out.println();
        out.println("   -s <filter>              Only output tracepoints that match the filter expression.");
        out.println("                            A filter expression consists of one or more tracepoint IDs");
        out.println("                            combined with AND, OR, and NOT operators (&, |, !).");
        out.println("      Examples:");
        out.println("         -s j9vm                            Print all tracepoints in component 'j9vm'");
        out.println("         -s j9vm|j9mm                       Print all tracepoints in components 'j9vm' and 'j9mm'");
        out.println("         -s {entry}                         Only print 'Entry' tracepoints");
        out.println("         -s j9vm.0-99                       Only print 'j9vm' tracepoints with IDs below 100");
        out.println("         -s j9scar&!(j9scar.59|j9scar.60)   Print j9scar tracepoints except for 59 and 60");
        return;
    }
    try {
        Class snapFormatCommandCls = Class.forName("com.ibm.j9ddr.tools.ddrinteractive.commands.SnapFormatCommand");
        Object snapFormatCommandInstance = snapFormatCommandCls.newInstance();
        if (snapFormatCommandInstance instanceof Command) {
            Command c = (Command) snapFormatCommandInstance;
            c.run(command, args, context, out);
        } else {
            throw new DDRInteractiveCommandException("Unable to format trace. Could not create formatter.");
        }
    } catch (ClassNotFoundException e) {
        // e.printStackTrace(out);
        throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
        // e.printStackTrace(out);
        throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
    } catch (InstantiationException e) {
        // e.printStackTrace(out);
        throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
    } catch (SecurityException e) {
        // e.printStackTrace(out);
        throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
    } catch (IllegalArgumentException e) {
        // e.printStackTrace(out);
        throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
    }
// catch (java.lang.Error e) {
// /* Naughty catching this but good for catching unresolved com.ibm.jvm.trace.* problems. */
// //e.printStackTrace(out);
// throw new DDRInteractiveCommandException("Unable to format trace. " + e.getMessage(), e);
// }
}
Also used : Command(com.ibm.j9ddr.tools.ddrinteractive.Command) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)

Example 47 with DDRInteractiveCommandException

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

the class LookupSymbolCommand method run.

public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
    if (args.length != 1) {
        out.println("Please supply a function pointer to lookup.");
        return;
    }
    boolean is64BitPlatform = (ctx.process.bytesPerPointer() == 8) ? true : false;
    long address = CommandUtils.parsePointer(args[0], is64BitPlatform);
    try {
        String symbol = ctx.process.getProcedureNameForAddress(address);
        out.println("Closest match:");
        out.println(symbol);
    } catch (DataUnavailableException e) {
        throw new DDRInteractiveCommandException(e);
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 48 with DDRInteractiveCommandException

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

the class LimitCommand method run.

@SuppressWarnings("deprecation")
public void run(String command, final String[] args, final Context context, final PrintStream out) throws DDRInteractiveCommandException {
    final String[] newArgs;
    if (args.length < 2) {
        out.println("The limit command requires a timeout and another command to run as an argument.");
        return;
    }
    long timeout = Integer.parseInt(args[0]) * 1000;
    if (args.length > 2) {
        newArgs = new String[args.length - 2];
        System.arraycopy(args, 2, newArgs, 0, newArgs.length);
    } else {
        newArgs = new String[0];
    }
    Thread runner = new Thread("LimitCommand: " + args[1]) {

        public void run() {
            try {
                CommandParser commandParser = new CommandParser(args[1], newArgs);
                context.execute(commandParser, out);
            } catch (ParseException e) {
                e.printStackTrace(out);
            }
        }
    };
    runner.start();
    try {
        runner.join(timeout);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if (runner.isAlive()) {
        runner.stop(new DDRInteractiveCommandException("Timeout exceeded!"));
    }
}
Also used : DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) ParseException(java.text.ParseException) CommandParser(com.ibm.j9ddr.command.CommandParser)

Example 49 with DDRInteractiveCommandException

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

the class NativeStacksCommand method run.

public void run(String cmd, String[] args, Context ctx, PrintStream out) throws DDRInteractiveCommandException {
    Set<Long> threadIds = null;
    for (String arg : args) {
        if (threadIds == null) {
            threadIds = new HashSet<Long>();
        }
        Long tid = CommandUtils.parseNumber(arg).longValue();
        threadIds.add(tid);
    }
    try {
        Collection<? extends IOSThread> threads = ctx.process.getThreads();
        for (IOSThread t : threads) {
            if (threadIds == null || threadIds.contains(t.getThreadId())) {
                try {
                    out.printf("Thread id: %d (0x%X)\n", t.getThreadId(), t.getThreadId());
                    int frameId = 0;
                    if (threadIds != null) {
                        threadIds.remove(t.getThreadId());
                    }
                    for (IOSStackFrame f : t.getStackFrames()) {
                        String symbol = ctx.process.getProcedureNameForAddress(f.getInstructionPointer());
                        if (ctx.process.bytesPerPointer() == 8) {
                            out.printf("#%d bp:0x%016X ip:0x%016X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
                        } else {
                            out.printf("#%d bp:0x%08X ip:0x%08X %s\n", frameId++, f.getBasePointer(), f.getInstructionPointer(), symbol);
                        }
                    }
                } catch (DataUnavailableException e) {
                    out.printf("DataUnavailableException reading stack for thread %d\n", t.getThreadId());
                } catch (CorruptDataException e) {
                    out.printf("CorruptDataException reading stack for thread %d\n", t.getThreadId());
                }
                out.println("----------");
            }
        }
        if (threadIds != null && !threadIds.isEmpty()) {
            out.print("Unable to find native thread for id(s): ");
            for (long tid : threadIds) {
                out.print(tid);
            }
            out.println();
        }
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : DataUnavailableException(com.ibm.j9ddr.DataUnavailableException) IOSStackFrame(com.ibm.j9ddr.corereaders.osthread.IOSStackFrame) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) IOSThread(com.ibm.j9ddr.corereaders.osthread.IOSThread)

Example 50 with DDRInteractiveCommandException

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

the class ACCommand method run.

public void run(String command, String[] args, Context context, PrintStream out) throws DDRInteractiveCommandException {
    try {
        J9JavaVMPointer vm = J9RASHelper.getVM(DataType.getJ9RASPointer());
        if (command.equalsIgnoreCase("!acforobject")) {
            if (null == heapRegionManager) {
                MM_HeapRegionManagerPointer hrmPointer;
                hrmPointer = MM_GCExtensionsPointer.cast(vm.gcExtensions()).heapRegionManager();
                heapRegionManager = GCHeapRegionManager.fromHeapRegionManager(hrmPointer);
            }
            if (args.length < 1) {
                throw new DDRInteractiveCommandException("Invalid number of arguments specified.");
            }
            long addr = Long.decode(args[0]);
            J9ObjectPointer objectPointer = J9ObjectPointer.cast(addr);
            dumpACForObject(vm, objectPointer, out);
        } else {
            MM_GCExtensionsPointer gcExtensions = MM_GCExtensionsPointer.cast(vm.gcExtensions());
            if (args.length < 1) {
                throw new DDRInteractiveCommandException("Invalid number of arguments specified.");
            }
            boolean dumpACExternalReferences = false;
            boolean dumpOwnedRegions = false;
            for (int i = 1; i < args.length; i++) {
                String arg = args[i];
                if (arg.equalsIgnoreCase("xrefs")) {
                    dumpACExternalReferences = true;
                } else if (arg.equalsIgnoreCase("ownedRegions")) {
                    dumpOwnedRegions = true;
                } else {
                    throw new DDRInteractiveCommandException("Unrecognized acforobject subcommand -->" + arg);
                }
            }
            long addr = Long.decode(args[0]);
            MM_AllocationContextPointer ac = MM_AllocationContextPointer.cast(addr);
            if (dumpACExternalReferences) {
                // TODO: handle other AC types
                if (GCExtensions.isVLHGC()) {
                    context.execute("!mm_allocationcontexttarok", new String[] { args[0] }, out);
                }
                dumpLiveReferences(vm, ac, out);
            }
            if (dumpOwnedRegions) {
                dumpOwnedRegions(vm, ac, out);
            }
        }
    } catch (DDRInteractiveCommandException e) {
        throw e;
    } catch (Throwable e) {
        e.printStackTrace(out);
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : MM_AllocationContextPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_AllocationContextPointer) MM_HeapRegionManagerPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_HeapRegionManagerPointer) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) J9JavaVMPointer(com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer) MM_GCExtensionsPointer(com.ibm.j9ddr.vm29.pointer.generated.MM_GCExtensionsPointer) J9ObjectPointer(com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer)

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