Search in sources :

Example 11 with ImagePointer

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

the class JavaRuntimeBuilder method addJavaStackFrame.

/**
 */
public JavaStackFrame addJavaStackFrame(JavaThread javaThread, String className, String classFileName, String methodName, String methodType, String compilationLevel, int lineNumber) throws BuilderFailureException {
    try {
        JCJavaThread jThread = (JCJavaThread) javaThread;
        JCJavaClass jclass = getJavaRuntime().findJavaClass(className);
        if (jclass == null) {
            jclass = new JCJavaClass(getJavaRuntime(), className);
        }
        JCJavaMethod method = new JCJavaMethod(methodName, jclass);
        JCJavaLocation location = new JCJavaLocation(method);
        location.setFilename(classFileName);
        location.setCompilation(compilationLevel);
        location.setLineNumber(lineNumber);
        JCJavaStackFrame stackFrame = new JCJavaStackFrame(jThread, location);
        if ("run".equals(methodName)) {
            /*
				 * Perhaps the type of the thread is the type of the last run() method.
				 * Not strictly accurate if the class was extended without overriding run(). 
				 * Add the object only if the object ID is valid.
				 */
            try {
                JavaObject jo = jThread.getObject();
                if (jo != null) {
                    ImagePointer tid = jo.getID();
                    if (fAddressSpace.isValidAddressID(tid.getAddress())) {
                        JCJavaObject jobject = new JCJavaObject(tid, jclass);
                        jThread.setObject(jobject);
                    }
                }
            } catch (CorruptDataException e) {
            // Ignore
            }
        }
        return stackFrame;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : JCJavaObject(com.ibm.dtfj.java.javacore.JCJavaObject) ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaMethod(com.ibm.dtfj.java.javacore.JCJavaMethod) JavaObject(com.ibm.dtfj.java.JavaObject) JCJavaObject(com.ibm.dtfj.java.javacore.JCJavaObject) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCJavaStackFrame(com.ibm.dtfj.java.javacore.JCJavaStackFrame) JCJavaLocation(com.ibm.dtfj.java.javacore.JCJavaLocation) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass) CorruptDataException(com.ibm.dtfj.image.CorruptDataException) JCJavaThread(com.ibm.dtfj.java.javacore.JCJavaThread)

Example 12 with ImagePointer

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

the class JavaRuntimeBuilder method addClassLoader.

/**
 * Must pass a valid class loader ID in order to generate a class loader object. Else exception
 * is thrown.
 *
 * @param classLoaderName optional
 * @param clID required, or else exception is throw and class loader is not created.
 * @param objectID optional (although generally this is the same as the clID for most javacores)
 * @return successfully created JavaClassLoader
 * @throws BuilderFailureException if class loader ID is invalid.
 */
public JavaClassLoader addClassLoader(String classLoaderName, long clID, long objectID) throws BuilderFailureException {
    try {
        JCJavaClassLoader classLoader = getJavaRuntime().findJavaClassLoader(clID);
        if (classLoader == null) {
            classLoader = new JCJavaClassLoader(getJavaRuntime(), clID);
        }
        JCJavaObject javaObject = classLoader.getInternalObject();
        if (javaObject == null) {
            JCJavaClass javaClass = getJavaRuntime().findJavaClass(classLoaderName);
            if (javaClass == null) {
                javaClass = new JCJavaClass(getJavaRuntime(), classLoaderName);
            }
            ImagePointer objectPointer = fAddressSpace.getPointer(objectID);
            javaObject = new JCJavaObject(objectPointer, javaClass);
            classLoader.setObject(javaObject);
        }
        return classLoader;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : JCJavaObject(com.ibm.dtfj.java.javacore.JCJavaObject) ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaClassLoader(com.ibm.dtfj.java.javacore.JCJavaClassLoader) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass)

Example 13 with ImagePointer

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

the class ImageProcessBuilder method addImageThread.

/**
 * @param Properties with String key and String value
 */
public ImageThread addImageThread(long nativeThreadID, long systemThreadID, Properties properties) throws BuilderFailureException {
    try {
        ImagePointer pointer = fImageAddressSpace.getPointer(nativeThreadID);
        JCImageThread thread = fImageProcess.getImageThread(pointer);
        if (thread == null) {
            thread = new JCImageThread(pointer);
            if (registers != null) {
                // Add the registers to the first thread
                for (Iterator it = registers.entrySet().iterator(); it.hasNext(); ) {
                    Map.Entry me = (Map.Entry) it.next();
                    ImageRegister ir = new JCImageRegister((String) me.getKey(), (Number) me.getValue());
                    thread.addRegister(ir);
                }
                registers = null;
            }
            fImageProcess.addImageThread(thread);
        }
        for (Iterator it = properties.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry me = (Map.Entry) it.next();
            thread.addProperty(me.getKey(), me.getValue());
        }
        if (systemThreadID != IBuilderData.NOT_AVAILABLE) {
            pointer = fImageAddressSpace.getPointer(systemThreadID);
            thread.setSystemThreadID(pointer);
        }
        return thread;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : JCImageThread(com.ibm.dtfj.image.javacore.JCImageThread) ImagePointer(com.ibm.dtfj.image.ImagePointer) ImageRegister(com.ibm.dtfj.image.ImageRegister) JCImageRegister(com.ibm.dtfj.image.javacore.JCImageRegister) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCImageRegister(com.ibm.dtfj.image.javacore.JCImageRegister) Iterator(java.util.Iterator) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) Map(java.util.Map)

Example 14 with ImagePointer

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

the class ImageProcessBuilder method addRoutine.

public ImageSymbol addRoutine(ImageModule library, String name, long address) {
    ImagePointer addr = fImageAddressSpace.getPointer(address);
    ImageSymbol symbol = new JCImageSymbol(name, addr);
    JCImageModule mod = (JCImageModule) library;
    mod.addSymbol(symbol);
    return symbol;
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JCImageSymbol(com.ibm.dtfj.image.javacore.JCImageSymbol) ImageSymbol(com.ibm.dtfj.image.ImageSymbol) JCImageModule(com.ibm.dtfj.image.javacore.JCImageModule) JCImageSymbol(com.ibm.dtfj.image.javacore.JCImageSymbol)

Example 15 with ImagePointer

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

the class JavaRuntimeBuilder method addClass.

/**
 * Note that even if a class was already registered with a class loader previously, it may contain incomplete data,
 * so this case has to be considered.
 */
public JavaClass addClass(JavaClassLoader jClassLoader, String name, long classID, long superClassID, String fileName) throws BuilderFailureException {
    try {
        JCJavaClassLoader classLoader = (JCJavaClassLoader) jClassLoader;
        JCJavaClass jClass = generateJavaClass(getJavaRuntime(), name, classID);
        jClass.setJavaSuperClass(superClassID);
        jClass.setClassLoader(classLoader);
        ImagePointer ip = jClass.getID();
        if (ip != null) {
            classLoader.addClass(name, ip);
        } else {
            if (classLoader.internalGetClass(name) == null) {
                classLoader.addClass(name);
            }
        }
        return jClass;
    } catch (JCInvalidArgumentsException e) {
        throw new BuilderFailureException(e);
    }
}
Also used : ImagePointer(com.ibm.dtfj.image.ImagePointer) JCJavaClassLoader(com.ibm.dtfj.java.javacore.JCJavaClassLoader) BuilderFailureException(com.ibm.dtfj.javacore.builder.BuilderFailureException) JCInvalidArgumentsException(com.ibm.dtfj.java.javacore.JCInvalidArgumentsException) JCJavaClass(com.ibm.dtfj.java.javacore.JCJavaClass)

Aggregations

ImagePointer (com.ibm.dtfj.image.ImagePointer)45 CorruptDataException (com.ibm.dtfj.image.CorruptDataException)19 MemoryAccessException (com.ibm.dtfj.image.MemoryAccessException)12 JavaClass (com.ibm.dtfj.java.JavaClass)9 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)8 CorruptData (com.ibm.dtfj.image.j9.CorruptData)7 JavaObject (com.ibm.dtfj.java.JavaObject)7 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)7 Iterator (java.util.Iterator)7 JCJavaClass (com.ibm.dtfj.java.javacore.JCJavaClass)6 ImageAddressSpace (com.ibm.dtfj.image.ImageAddressSpace)5 JCJavaObject (com.ibm.dtfj.java.javacore.JCJavaObject)4 ArrayList (java.util.ArrayList)4 Vector (java.util.Vector)4 DataUnavailable (com.ibm.dtfj.image.DataUnavailable)3 ImageSection (com.ibm.dtfj.image.ImageSection)3 JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)3 JCJavaMonitor (com.ibm.dtfj.java.javacore.JCJavaMonitor)3 IOException (java.io.IOException)3 CorruptData (com.ibm.dtfj.image.CorruptData)2