Search in sources :

Example 6 with ImageSymbol

use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.

the class DTFJKickTyres method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    boolean useJExtract = false;
    if (args.length > 1) {
        if (args[1].toLowerCase().trim().equals("jextract")) {
            useJExtract = true;
        }
    }
    ImageFactory factory = null;
    if (useJExtract) {
        try {
            Class<?> jxfactoryclass = Class.forName("com.ibm.dtfj.image.j9.ImageFactory");
            factory = (ImageFactory) jxfactoryclass.newInstance();
        } catch (Exception e) {
            System.out.println("Could not create a jextract based implementation of ImageFactory");
            e.printStackTrace();
            System.exit(1);
        }
    } else {
        factory = new J9DDRImageFactory();
    }
    Image img = factory.getImage(new File(args[0]));
    Iterator<?> addressSpaceIt = img.getAddressSpaces();
    while (addressSpaceIt.hasNext()) {
        ImageAddressSpace as = (ImageAddressSpace) addressSpaceIt.next();
        Iterator<?> processIt = as.getProcesses();
        while (processIt.hasNext()) {
            ImageProcess process = (ImageProcess) processIt.next();
            System.err.println("Got process " + process);
            try {
                System.err.println("Command line was " + process.getCommandLine());
            } catch (Throwable t) {
                t.printStackTrace();
            }
            try {
                System.err.println("Executable was: " + process.getExecutable());
            } catch (Throwable t) {
                t.printStackTrace();
            }
            try {
                System.err.println("Modules were:");
                Iterator<?> it = process.getLibraries();
                if (!it.hasNext()) {
                    System.err.println("No modules!");
                }
                while (it.hasNext()) {
                    ImageModule module = (ImageModule) it.next();
                    System.err.println("* " + module.getName());
                    Iterator<?> symIt = module.getSymbols();
                    while (symIt.hasNext()) {
                        Object symObj = symIt.next();
                        if (symObj instanceof ImageSymbol) {
                            ImageSymbol sym = (ImageSymbol) symObj;
                            if (sym.getName().toLowerCase().contains("environ")) {
                                System.err.println("X sym " + sym.getName() + " = " + sym.getAddress());
                            }
                        }
                    }
                }
            } catch (Throwable t) {
                t.printStackTrace();
            }
            try {
                Properties env = process.getEnvironment();
                System.err.println("Environment");
                for (Object key : env.keySet()) {
                    System.err.println(key + " = " + env.getProperty((String) key));
                }
            } catch (Throwable t) {
                t.printStackTrace();
            }
            Iterator<?> runtimeIt = process.getRuntimes();
            while (runtimeIt.hasNext()) {
                JavaRuntime runtime = (JavaRuntime) runtimeIt.next();
                System.err.println("Got runtime: " + runtime);
                JavaVMInitArgs initArgs = runtime.getJavaVMInitArgs();
                Iterator<?> optionsIt = initArgs.getOptions();
                System.err.println("Options:");
                while (optionsIt.hasNext()) {
                    Object optionObj = optionsIt.next();
                    if (optionObj instanceof JavaVMOption) {
                        JavaVMOption option = (JavaVMOption) optionObj;
                        System.err.println("* " + option.getOptionString());
                    }
                }
            }
        }
    }
}
Also used : JavaRuntime(com.ibm.dtfj.java.JavaRuntime) ImageSymbol(com.ibm.dtfj.image.ImageSymbol) Image(com.ibm.dtfj.image.Image) Properties(java.util.Properties) ImageModule(com.ibm.dtfj.image.ImageModule) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) J9DDRImageFactory(com.ibm.j9ddr.view.dtfj.image.J9DDRImageFactory) ImageFactory(com.ibm.dtfj.image.ImageFactory) ImageAddressSpace(com.ibm.dtfj.image.ImageAddressSpace) JavaVMOption(com.ibm.dtfj.java.JavaVMOption) ImageProcess(com.ibm.dtfj.image.ImageProcess) JavaVMInitArgs(com.ibm.dtfj.java.JavaVMInitArgs) File(java.io.File)

Example 7 with ImageSymbol

use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.

the class ImageSymbolComparator method testEquals.

// getAddress()
// getName()
public void testEquals(Object ddrObject, Object jextractObject, int members) {
    ImageSymbol ddrImageSymbol = (ImageSymbol) ddrObject;
    ImageSymbol jextractImageSymbol = (ImageSymbol) jextractObject;
    // getAddress()
    if ((ADDRESS & members) != 0)
        new ImagePointerComparator().testComparatorEquals(ddrImageSymbol, jextractImageSymbol, "getAddress");
    // getName()
    if ((NAME & members) != 0)
        testJavaEquals(ddrImageSymbol, jextractImageSymbol, "getName");
}
Also used : ImageSymbol(com.ibm.dtfj.image.ImageSymbol)

Example 8 with ImageSymbol

use of com.ibm.dtfj.image.ImageSymbol in project openj9 by eclipse.

the class InfoSymCommand method printModule.

private void printModule(ImageModule imageModule, boolean printSymbols) {
    try {
        out.print("\t  " + imageModule.getName());
    } catch (CorruptDataException cde) {
        out.print("\t  " + Exceptions.getCorruptDataExceptionString());
    }
    try {
        String addressInHex = String.format("0x%x", imageModule.getLoadAddress());
        out.print(" @ " + addressInHex);
    } catch (DataUnavailable e) {
    // if we do not have the load address, simply omit it
    } catch (CorruptDataException e) {
    // if we do not have the load address, simply omit it
    }
    Iterator itSection = imageModule.getSections();
    if (itSection.hasNext()) {
        out.print(", sections:\n");
    } else {
        out.print(", <no section information>\n");
    }
    // iterate through the library sections
    while (itSection.hasNext()) {
        Object next = itSection.next();
        if (next instanceof ImageSection) {
            ImageSection is = (ImageSection) next;
            out.print("\t   0x" + Long.toHexString(is.getBaseAddress().getAddress()) + " - 0x" + Long.toHexString(is.getBaseAddress().getAddress() + is.getSize()));
            out.print(", name: \"");
            out.print(is.getName());
            out.print("\", size: 0x");
            out.print(Long.toHexString(is.getSize()));
            out.print("\n");
        } else if (next instanceof CorruptData) {
            // warn the user that this image section is corrupt
            out.print("\t   <corrupt section encountered>\n");
        } else {
            // unexpected type in iterator
            out.print("\t   <corrupt section encountered>\n");
        }
    }
    if (printSymbols) {
        out.print("\t  " + "symbols:\n");
        Iterator itSymbols = imageModule.getSymbols();
        while (itSymbols.hasNext()) {
            Object next = itSymbols.next();
            if (next instanceof ImageSymbol) {
                ImageSymbol is = (ImageSymbol) next;
                out.print("\t   0x" + Long.toHexString(is.getAddress().getAddress()));
                out.print(", name: \"");
                out.print(is.getName());
                out.print("\"\n");
            } else if (next instanceof CorruptData) {
                // warn the user that this image section is corrupt
                out.print("\t   <corrupt symbol encountered>\n");
            } else {
                // unexpected type in iterator
                out.print("\t   <corrupt symbol encountered>\n");
            }
        }
    }
    out.print("\n");
}
Also used : ImageSymbol(com.ibm.dtfj.image.ImageSymbol) Iterator(java.util.Iterator) DataUnavailable(com.ibm.dtfj.image.DataUnavailable) ImageSection(com.ibm.dtfj.image.ImageSection) CorruptData(com.ibm.dtfj.image.CorruptData) CorruptDataException(com.ibm.dtfj.image.CorruptDataException)

Aggregations

ImageSymbol (com.ibm.dtfj.image.ImageSymbol)8 ImageModule (com.ibm.dtfj.image.ImageModule)3 CorruptData (com.ibm.dtfj.image.CorruptData)2 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)2 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)2 ImageProcess (com.ibm.dtfj.image.ImageProcess)2 ImageSection (com.ibm.dtfj.image.ImageSection)2 Iterator (java.util.Iterator)2 Image (com.ibm.dtfj.image.Image)1 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)1 ImageFactory (com.ibm.dtfj.image.ImageFactory)1 ImagePointer (com.ibm.dtfj.image.ImagePointer)1 JCImageModule (com.ibm.dtfj.image.javacore.JCImageModule)1 JCImageSymbol (com.ibm.dtfj.image.javacore.JCImageSymbol)1 JavaRuntime (com.ibm.dtfj.java.JavaRuntime)1 JavaVMInitArgs (com.ibm.dtfj.java.JavaVMInitArgs)1 JavaVMOption (com.ibm.dtfj.java.JavaVMOption)1 DataUnavailableException (com.ibm.j9ddr.DataUnavailableException)1 IMemoryRange (com.ibm.j9ddr.corereaders.memory.IMemoryRange)1 ISymbol (com.ibm.j9ddr.corereaders.memory.ISymbol)1