Search in sources :

Example 1 with JCImageThread

use of com.ibm.dtfj.image.javacore.JCImageThread 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 2 with JCImageThread

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

the class ImageProcessBuilder method addImageStackSection.

/**
 * Add a stack section to an existing image thread
 * @param thread The native thread
 * @param section The section we want to add
 */
public ImageSection addImageStackSection(ImageThread thread, ImageSection section) {
    JCImageThread thread2 = (JCImageThread) thread;
    thread2.addImageStackSection(section);
    return section;
}
Also used : JCImageThread(com.ibm.dtfj.image.javacore.JCImageThread)

Example 3 with JCImageThread

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

the class JCJavaRuntime method findJavaThread.

/**
 * NON-DTFJ
 * <br>
 * <b>For internal building purposes only</b>. Do not call outside the DTFJ implementation.
 * <br><br>
 * In most cases, the threadID is the tid in a javacore, but in some other occasions, the id
 * passed could be the system_thread_id or even the native thread. If a java thread is not
 * found via tid, see if it can be found indirectly by an image thread that may be associated
 * with the java thread (the image thread has a system thread ID as well as a native thread ID).
 * @param threadID usually, tid in a javacore, may be id of some other internal vm datastructure.
 * @return found java thread or null.
 */
public JCJavaThread findJavaThread(long threadID) {
    Object javaThread = null;
    fIDLookupKey.setKey(threadID);
    if ((javaThread = fJavaThreads.get(fIDLookupKey)) == null) {
        Iterator it = fJavaThreads.values().iterator();
        while (javaThread == null && it.hasNext()) {
            JCJavaThread jThread = (JCJavaThread) it.next();
            JCImageThread imageThread = jThread.internalGetImageThread();
            if (imageThread != null) {
                // lookup via systemthreadID
                ImagePointer pointer = imageThread.getSystemThreadID();
                long address = (pointer != null) ? pointer.getAddress() : IBuilderData.NOT_AVAILABLE;
                if (address != IBuilderData.NOT_AVAILABLE && address == threadID) {
                    javaThread = jThread;
                } else // lookup via nativethreadID. This is always set for any valid image thread.
                {
                    pointer = imageThread.getInternalID();
                    if (pointer.getAddress() == threadID) {
                        javaThread = jThread;
                    }
                }
            }
        }
    }
    return (JCJavaThread) javaThread;
}
Also used : JCImageThread(com.ibm.dtfj.image.javacore.JCImageThread) ImagePointer(com.ibm.dtfj.image.ImagePointer) Iterator(java.util.Iterator) JavaObject(com.ibm.dtfj.java.JavaObject)

Example 4 with JCImageThread

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

the class ImageProcessBuilder method addImageStackFrame.

public ImageStackFrame addImageStackFrame(long nativeThreadID, String name, long baseAddress, long procAddress) {
    ImagePointer pointer = fImageAddressSpace.getPointer(nativeThreadID);
    JCImageThread thread = fImageProcess.getImageThread(pointer);
    ImagePointer ip = procAddress != IBuilderData.NOT_AVAILABLE ? fImageAddressSpace.getPointer(procAddress) : null;
    JCImageStackFrame stackFrame = new JCImageStackFrame(name, null, ip);
    if (thread != null) {
        JCImageThread thrd = (JCImageThread) thread;
        thrd.addImageStackFrame(stackFrame);
    }
    return stackFrame;
}
Also used : JCImageThread(com.ibm.dtfj.image.javacore.JCImageThread) ImagePointer(com.ibm.dtfj.image.ImagePointer) JCImageStackFrame(com.ibm.dtfj.image.javacore.JCImageStackFrame)

Aggregations

JCImageThread (com.ibm.dtfj.image.javacore.JCImageThread)4 ImagePointer (com.ibm.dtfj.image.ImagePointer)3 Iterator (java.util.Iterator)2 ImageRegister (com.ibm.dtfj.image.ImageRegister)1 JCImageRegister (com.ibm.dtfj.image.javacore.JCImageRegister)1 JCImageStackFrame (com.ibm.dtfj.image.javacore.JCImageStackFrame)1 JavaObject (com.ibm.dtfj.java.JavaObject)1 JCInvalidArgumentsException (com.ibm.dtfj.java.javacore.JCInvalidArgumentsException)1 BuilderFailureException (com.ibm.dtfj.javacore.builder.BuilderFailureException)1 Map (java.util.Map)1