Search in sources :

Example 1 with ICore

use of com.ibm.j9ddr.corereaders.ICore 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 ICore

use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.

the class DDRInteractive method locateRuntimes.

private void locateRuntimes(String path) throws Exception {
    ICore reader = CoreReader.readCoreFile(path);
    if (null == reader) {
        throw new RuntimeException("Cannot find Core Reader for file: " + path);
    }
    locateRuntimes(reader);
}
Also used : ICore(com.ibm.j9ddr.corereaders.ICore)

Example 3 with ICore

use of com.ibm.j9ddr.corereaders.ICore 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 4 with ICore

use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.

the class BootstrapJUnitTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    try {
        String coreFileName = System.getProperty("ddr.core.file.name");
        if (coreFileName == null) {
            fail("Did not specify core file name with -Dddr.core.file.name");
        }
        ICore core = CoreReader.readCoreFile(coreFileName);
        List<IAddressSpace> addressSpaces = new ArrayList<IAddressSpace>(core.getAddressSpaces());
        for (IAddressSpace thisAS : addressSpaces) {
            for (IProcess thisProc : thisAS.getProcesses()) {
                try {
                    vmData = VMDataFactory.getVMData(thisProc);
                    return;
                } catch (IOException ex) {
                // This happens if we can't find a JVM or a blob. Keep looking
                }
            }
        }
        fail("Couldn't initialize VMData");
    } catch (FileNotFoundException e) {
        fail("Could not initialize VMData: " + e.getMessage());
    } catch (IOException e) {
        fail("Could not initialize VMData: " + e.getMessage());
    }
}
Also used : IAddressSpace(com.ibm.j9ddr.corereaders.memory.IAddressSpace) ArrayList(java.util.ArrayList) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) ICore(com.ibm.j9ddr.corereaders.ICore) IProcess(com.ibm.j9ddr.corereaders.memory.IProcess) BeforeClass(org.junit.BeforeClass)

Example 5 with ICore

use of com.ibm.j9ddr.corereaders.ICore in project openj9 by eclipse.

the class DumpSegments method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.err.println("Expected 1 argument, got " + args.length);
    }
    String filename = args[0];
    ICore core = CoreReader.readCoreFile(filename);
    Collection<? extends IAddressSpace> addressSpaces = core.getAddressSpaces();
    for (IAddressSpace as : addressSpaces) {
        System.err.println("Address space: " + as.getAddressSpaceId());
        List<? extends IMemoryRange> ranges = new ArrayList<IMemoryRange>(as.getMemoryRanges());
        Collections.sort(ranges);
        // System.err.println("Raw mappings");
        // for(IMemoryRange thisRange : ranges) {
        // System.err.println("Base: " +
        // Long.toHexString(thisRange.getBaseAddress()) + " - size: " +
        // Long.toHexString(thisRange.getSize()));
        // if (thisRange.getBaseAddress() == 0xf95f000) {
        // System.err.println("Found!");
        // }
        // }
        List<Range> localRanges = new LinkedList<Range>();
        for (IMemoryRange range : ranges) {
            Range newRange = new Range();
            newRange.base = range.getBaseAddress();
            newRange.size = range.getSize();
            localRanges.add(newRange);
        }
        localRanges = mergeRanges(localRanges);
        for (Range range : localRanges) {
            System.err.println("Base: " + Long.toHexString(range.base) + " - size: " + Long.toHexString(range.size));
            try {
                if (range.size > 7) {
                    /*
						 * Pick three addresses and read integers from them -
						 * proves that endian conversion is working
						 */
                    long address1 = range.base;
                    long address2 = range.base + range.size - 5;
                    long address3 = (address1 + address2) / 2;
                    System.err.print(Long.toHexString(address1) + " - ");
                    System.err.println(Integer.toHexString(as.getIntAt(address1)));
                    System.err.print(Long.toHexString(address2) + " - ");
                    System.err.println(Integer.toHexString(as.getIntAt(address2)));
                    System.err.print(Long.toHexString(address3) + " - ");
                    if (0xf971ffd == address3) {
                        System.err.println("Found!");
                    }
                    System.err.println(Integer.toHexString(as.getIntAt(address3)));
                }
            } catch (MemoryFault ex) {
                ex.printStackTrace();
            }
        }
    }
}
Also used : IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) IAddressSpace(com.ibm.j9ddr.corereaders.memory.IAddressSpace) ArrayList(java.util.ArrayList) ICore(com.ibm.j9ddr.corereaders.ICore) IMemoryRange(com.ibm.j9ddr.corereaders.memory.IMemoryRange) LinkedList(java.util.LinkedList)

Aggregations

ICore (com.ibm.j9ddr.corereaders.ICore)10 Platform (com.ibm.j9ddr.corereaders.Platform)3 IAddressSpace (com.ibm.j9ddr.corereaders.memory.IAddressSpace)3 IProcess (com.ibm.j9ddr.corereaders.memory.IProcess)3 ArrayList (java.util.ArrayList)3 CorruptDataException (com.ibm.j9ddr.CorruptDataException)2 UnknownArchitectureException (com.ibm.j9ddr.exceptions.UnknownArchitectureException)2 DDRInteractiveCommandException (com.ibm.j9ddr.tools.ddrinteractive.DDRInteractiveCommandException)2 J9DDRImageProcess (com.ibm.j9ddr.view.dtfj.image.J9DDRImageProcess)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 Logger (java.util.logging.Logger)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)1 ImageModule (com.ibm.dtfj.image.ImageModule)1 IVMData (com.ibm.j9ddr.IVMData)1 ILibraryDependentCore (com.ibm.j9ddr.corereaders.ILibraryDependentCore)1 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)1 J9JavaVMPointer (com.ibm.j9ddr.vm29.pointer.generated.J9JavaVMPointer)1 J9RASPointer (com.ibm.j9ddr.vm29.pointer.generated.J9RASPointer)1 FileNotFoundException (java.io.FileNotFoundException)1