Search in sources :

Example 1 with J9DDRImageProcess

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess in project openj9 by eclipse.

the class NativeLibrariesCommand method getExeFromDDR.

// we can use the hint mechanism in DTFJ to work out the exe location for elf cores with very long path names
private void getExeFromDDR(Context ctx, PrintStream out) {
    try {
        ICore core = ctx.process.getAddressSpace().getCore();
        if (ILibraryDependentCore.class.isAssignableFrom(core.getClass())) {
            ILibraryDependentCore ldcore = (ILibraryDependentCore) core;
            J9DDRImageProcess proc = new J9DDRImageProcess(ctx.process);
            ImageModule exe = proc.getExecutable();
            out.println("exe = " + exe.getName());
            ldcore.executablePathHint(exe.getName());
        }
    } catch (Exception e) {
        out.println("Could not determine EXE name using DDR : " + e.getMessage());
    }
}
Also used : ILibraryDependentCore(com.ibm.j9ddr.corereaders.ILibraryDependentCore) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) ICore(com.ibm.j9ddr.corereaders.ICore) ImageModule(com.ibm.dtfj.image.ImageModule) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) IOException(java.io.IOException) CorruptDataException(com.ibm.j9ddr.CorruptDataException)

Example 2 with J9DDRImageProcess

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess 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 3 with J9DDRImageProcess

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess in project openj9 by eclipse.

the class RuntimeSettingsCommand method run.

/**
 * Run method for !runtimesettings extension.
 *
 * @param command  !runtimesettings
 * @param args	args passed by !runtimesettings 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("!runtimesettings expects no args. Usage :");
        printUsage(out);
        return;
    }
    try {
        Long currentSoftmx;
        String qualifiedCurrentSoftmx = "";
        String initialSoftmx = "not set";
        J9RASPointer ras = DataType.getJ9RASPointer();
        J9JavaVMPointer vm = J9RASHelper.getVM(ras);
        IProcess process = vm.getProcess();
        J9DDRImageProcess ddrProcess = new J9DDRImageProcess(process);
        String cmdline;
        /* Parse the command line of a running program that generated core
			 * file to get the original -Xsoftmx setting
			 */
        cmdline = ddrProcess.getCommandLine();
        int start = cmdline.indexOf("-Xsoftmx");
        int length = "-Xsoftmx".length();
        int end = cmdline.indexOf(" ", start);
        if (-1 != start) {
            /* extract the value from the end of the option */
            initialSoftmx = cmdline.substring(start + length, end);
            initialSoftmx = initialSoftmx.toUpperCase();
        }
        currentSoftmx = new Long(GCExtensions.softMx().longValue());
        qualifiedCurrentSoftmx = currentSoftmx.toString();
        Matcher m = p.matcher(initialSoftmx);
        /* if initial softmx value is set on the command line as qualified
			 * value, print current softmx value in qualified form, otherwise
			 * print current in byte value
			 */
        if (m.matches()) {
            /* User may add multiple letters after the number on the command
				 * line, currently GC parser accepts this and simply ignores
				 * extra letters, so we need to do the same, set initialSoftmx
				 * to the first match of the pattern
				 */
            initialSoftmx = m.group(1);
            /* convert size in bytes held in currentSoftmx to canonical form */
            qualifiedCurrentSoftmx = qualifiedSize(currentSoftmx);
            /* If qualifiedSize() returns size in bytes, it could not
				 * convert the value, so print the initialSoftmx variable in
				 * bytes
				 */
            m = p.matcher(qualifiedCurrentSoftmx);
            if (!m.matches()) {
                initialSoftmx = sizeInBytes(initialSoftmx);
            }
        } else {
            /* InitialSoftmx value has either not been set or is in byte
				 * form, so print current value as byte form
				 */
            qualifiedCurrentSoftmx = currentSoftmx.toString();
        }
        printTableOfEqualSpacedColumns(out, new String[] { "name", "initial value", "current value" }, new String[][] { { "-Xsoftmx", initialSoftmx, qualifiedCurrentSoftmx } });
    } catch (DataUnavailable e) {
        /* For Z/OS core files, command line 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");
    } catch (CorruptDataException e) {
        throw new DDRInteractiveCommandException(e);
    }
}
Also used : Matcher(java.util.regex.Matcher) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess) DDRInteractiveCommandException(com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException) CorruptDataException(com.ibm.j9ddr.CorruptDataException) 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 4 with J9DDRImageProcess

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess in project openj9 by eclipse.

the class DTFJBootstrapShim method run.

public void run(IVMData vmData, Object[] userData) {
    Object[] passbackArray = (Object[]) userData[0];
    J9DDRImageProcess process = (J9DDRImageProcess) userData[1];
    DTFJJavaRuntime runtime = new DTFJJavaRuntime();
    passbackArray[0] = runtime;
    DTFJContext.setRuntime(runtime);
    DTFJContext.setImageProcess(process);
}
Also used : DTFJJavaRuntime(com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaRuntime) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess)

Example 5 with J9DDRImageProcess

use of com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess in project openj9 by eclipse.

the class DTFJJavaThread method getImageThread.

/* (non-Javadoc)
	 * @see com.ibm.dtfj.java.JavaThread#getImageThread()
	 */
public ImageThread getImageThread() throws CorruptDataException, DataUnavailable {
    if (imageThread == null) {
        J9DDRImageProcess imageProcess = DTFJContext.getImageProcess();
        try {
            long tid = thread.osThread().tid().longValue();
            imageThread = imageProcess.getThread(tid);
            // We could't match one of the "proper" ImageThreads - so we'll return a stub image thread instead.
            if (null == imageThread) {
                imageThread = new J9DDRStubImageThread(DTFJContext.getProcess(), tid);
            }
        } catch (Throwable t) {
            throw J9DDRDTFJUtils.handleAsCorruptDataException(DTFJContext.getProcess(), t);
        }
    }
    return imageThread;
}
Also used : J9DDRStubImageThread(com.ibm.j9ddr.view.dtfj.image.J9DDRStubImageThread) J9DDRImageProcess(com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess)

Aggregations

J9DDRImageProcess (com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess)6 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)3 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)3 ICore (com.ibm.j9ddr.corereaders.ICore)2 IProcess (com.ibm.j9ddr.corereaders.memory.IProcess)2 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)2 J9RASPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RASPointer)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)1 ImageModule (com.ibm.dtfj.image.ImageModule)1 JavaClass (com.ibm.dtfj.java.JavaClass)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 JavaReference (com.ibm.dtfj.java.JavaReference)1 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)1 ILibraryDependentCore (com.ibm.j9ddr.corereaders.ILibraryDependentCore)1 Platform (com.ibm.j9ddr.corereaders.Platform)1 IteratorFilter (com.ibm.j9ddr.util.IteratorHelpers.IteratorFilter)1 J9DDRStubImageThread (com.ibm.j9ddr.view.dtfj.image.J9DDRStubImageThread)1 DTFJJavaRuntime (com.ibm.j9ddr.vm29.view.dtfj.java.DTFJJavaRuntime)1 IOException (java.io.IOException)1