Lines Matching full:thread

52  * This is a per-thread structure that is allocated on the
53 * first event that occurs in a thread. It is freed after the
54 * thread's thread end event has completed processing. The
55 * structure contains state information on its thread including
57 * per-thread state such as the current method invocation or
65 jthread thread; member
77 jint resumeFrameDepth; /* !=0 => This thread is in a call to Thread.resume() */
86 struct ThreadList *list; /* Tells us what list this thread is in */
101 * popFrameProceedLock is used to assure that the event thread is
112 static jvmtiError threadControl_removeDebugThread(jthread thread);
115 * Threads which have issued thread start events and not yet issued thread
129 jthread thread; member
141 getStackDepth(jthread thread) in getStackDepth() argument
147 (gdata->jvmti, thread, &count); in getStackDepth()
154 /* Get the state of the thread direct from JVMTI */
156 threadState(jthread thread, jint *pstate) in threadState() argument
160 (gdata->jvmti, thread, pstate); in threadState()
165 setThreadLocalStorage(jthread thread, ThreadNode *node) in setThreadLocalStorage() argument
170 (gdata->jvmti, thread, (void*)node); in setThreadLocalStorage()
172 /* Just return, thread hasn't started yet */ in setThreadLocalStorage()
176 EXIT_ERROR(error, "cannot set thread local storage"); in setThreadLocalStorage()
182 getThreadLocalStorage(jthread thread) in getThreadLocalStorage() argument
189 (gdata->jvmti, thread, (void**)&node); in getThreadLocalStorage()
191 /* Just return NULL, thread hasn't started yet */ in getThreadLocalStorage()
195 EXIT_ERROR(error, "cannot get thread local storage"); in getThreadLocalStorage()
200 /* Search list for nodes that don't have TLS set and match this thread.
208 nonTlsSearch(JNIEnv *env, ThreadList *list, jthread thread) in nonTlsSearch() argument
213 if (isSameObject(env, node->thread, thread)) { in nonTlsSearch()
226 findThread(ThreadList *list, jthread thread) in findThread() argument
230 /* Get thread local storage for quick thread -> node access */ in findThread()
231 node = getThreadLocalStorage(thread); in findThread()
241 node = nonTlsSearch(env, list, thread); in findThread()
243 node = nonTlsSearch(env, &runningThreads, thread); in findThread()
245 node = nonTlsSearch(env, &otherThreads, thread); in findThread()
250 setThreadLocalStorage(thread, (void*)node); in findThread()
302 insertThread(JNIEnv *env, ThreadList *list, jthread thread) in insertThread() argument
307 node = findThread(list, thread); in insertThread()
311 EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"thread table entry"); in insertThread()
318 EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"thread table entry"); in insertThread()
326 saveGlobalRef(env, thread, &(node->thread)); in insertThread()
327 if (node->thread == NULL) { in insertThread()
330 EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"thread table entry"); in insertThread()
334 * Remember if it is a debug thread in insertThread()
336 if (threadControl_isDebugThread(node->thread)) { in insertThread()
342 * and the thread will need to be suspended when it starts. in insertThread()
352 /* Set thread local storage for quick thread -> node access. in insertThread()
356 setThreadLocalStorage(node->thread, (void*)node); in insertThread()
368 stepControl_clearRequest(node->thread, &node->currentStep); in clearThread()
370 (void)threadControl_removeDebugThread(node->thread); in clearThread()
372 /* Clear out TLS on this thread (just a cleanup action) */ in clearThread()
373 setThreadLocalStorage(node->thread, NULL); in clearThread()
374 tossGlobalRef(env, &(node->thread)); in clearThread()
380 removeThread(JNIEnv *env, ThreadList *list, jthread thread) in removeThread() argument
384 node = findThread(list, thread); in removeThread()
400 removeThread(env, list, node->thread); in removeResumed()
410 JDI_ASSERT(findThread(dest, node->thread) == NULL); in moveNode()
457 addDeferredEventMode(JNIEnv *env, jvmtiEventMode mode, EventIndex ei, jthread thread) in addDeferredEventMode() argument
466 eventMode->thread = NULL; in addDeferredEventMode()
467 saveGlobalRef(env, thread, &(eventMode->thread)); in addDeferredEventMode()
483 tossGlobalRef(env, &(eventMode->thread)); in freeDeferredEventModes()
493 jvmtiEventMode mode, EventIndex ei, jthread thread) in threadSetEventNotificationMode() argument
502 (gdata->jvmti, mode, eventIndex2jvmti(ei), thread); in threadSetEventNotificationMode()
507 processDeferredEventModes(JNIEnv *env, jthread thread, ThreadNode *node) in processDeferredEventModes() argument
517 if (isSameObject(env, thread, eventMode->thread)) { in processDeferredEventModes()
519 eventMode->mode, eventMode->ei, eventMode->thread); in processDeferredEventModes()
521 … EXIT_ERROR(error, "cannot process deferred thread event notifications at thread start"); in processDeferredEventModes()
524 tossGlobalRef(env, &(eventMode->thread)); in processDeferredEventModes()
539 * thread) needs to be grabbed here. This allows thread control in getLocks()
574 threadLock = debugMonitorCreate("JDWP Thread Lock"); in threadControl_initialize()
576 EXIT_ERROR(AGENT_ERROR_NULL_POINTER, "no java.lang.thread class"); in threadControl_initialize()
579 EXIT_ERROR(AGENT_ERROR_NULL_POINTER, "cannot resume thread"); in threadControl_initialize()
581 /* Get the java.lang.Thread.resume() method beginning location */ in threadControl_initialize()
623 error = threadState(node->thread, &state); in pendingAppResume()
625 EXIT_ERROR(error, "getting thread state"); in pendingAppResume()
659 jthread thread; in handleAppResumeCompletion() local
661 thread = evinfo->thread; in handleAppResumeCompletion()
665 node = findThread(&runningThreads, thread); in handleAppResumeCompletion()
668 jint compareDepth = getStackDepth(thread); in handleAppResumeCompletion()
683 blockOnDebuggerSuspend(jthread thread) in blockOnDebuggerSuspend() argument
687 node = findThread(NULL, thread); in blockOnDebuggerSuspend()
691 node = findThread(NULL, thread); in blockOnDebuggerSuspend()
697 trackAppResume(jthread thread) in trackAppResume() argument
704 node = findThread(&runningThreads, thread); in trackAppResume()
708 (gdata->jvmti, thread, fnum); in trackAppResume()
710 jint frameDepth = getStackDepth(thread); in trackAppResume()
715 thread); in trackAppResume()
719 thread); in trackAppResume()
742 jthread resumer = evinfo->thread; in handleAppResumeBreakpoint()
756 * Track the resuming thread by marking it as being within in handleAppResumeBreakpoint()
759 * to suspend threads while any thread is within a in handleAppResumeBreakpoint()
762 * suspends a thread it will remain suspended. in handleAppResumeBreakpoint()
800 * the thread list with already-existing threads. The threadLock in threadControl_onHook()
820 EXIT_ERROR(AGENT_ERROR_OUT_OF_MEMORY,"thread table"); in threadControl_onHook()
827 jthread thread = threads[i]; in threadControl_onHook() local
828 node = insertThread(env, &runningThreads, thread); in threadControl_onHook()
833 * can't rely on a thread start event for them. The chances in threadControl_onHook()
837 * the threads that already exist (e.g. the finalizer thread). in threadControl_onHook()
853 LOG_MISC(("thread=%p suspended", node->thread)); in commonSuspendByNode()
855 (gdata->jvmti, node->thread); in commonSuspendByNode()
865 * If the thread was suspended by another app thread, in commonSuspendByNode()
876 * Deferred suspends happen when the suspend is attempted on a thread
878 * is handled by the original request, and once the thread actually
941 * This error means that the thread is either a zombie or not yet in suspendThreadByNode()
942 * started. In either case, we ignore the error. If the thread in suspendThreadByNode()
943 * is a zombie, suspend/resume are no-ops. If the thread is not in suspendThreadByNode()
945 * of its thread start event. in suspendThreadByNode()
975 LOG_MISC(("thread=%p resumed", node->thread)); in resumeThreadByNode()
977 (gdata->jvmti, node->thread); in resumeThreadByNode()
982 * We successfully "suspended" this thread, but in resumeThreadByNode()
984 * Since the thread never ran, we can ignore our in resumeThreadByNode()
985 * failure to resume the thread. in resumeThreadByNode()
999 * The thread is only suspended when the count goes from 0 to 1 and
1005 * They must not be called from an application thread because
1006 * that thread may be suspended somewhere in the middle of things.
1014 * Delay any suspend while a call to java.lang.Thread.resume is in in preSuspend()
1017 * java.lang.Thread.suspend won't result in a notify even though in preSuspend()
1050 commonSuspend(JNIEnv *env, jthread thread, jboolean deferred) in commonSuspend() argument
1055 * If the thread is not between its start and end events, we should in commonSuspend()
1056 * still suspend it. To keep track of things, add the thread in commonSuspend()
1059 node = findThread(&runningThreads, thread); in commonSuspend()
1061 node = insertThread(env, &otherThreads, thread); in commonSuspend()
1087 * This thread was marked for suspension since its THREAD_START in resumeCopyHelper()
1090 * won't suspend this thread after we are done with the resumeAll. in resumeCopyHelper()
1092 * the thread while the app has it suspended. In this case, in resumeCopyHelper()
1094 * the thread should not be resumed when the debugger does a resume. in resumeCopyHelper()
1096 * If we don't then when the app resumes the thread and our Thread.resume in resumeCopyHelper()
1098 * the thread because suspendCount will be 1 meaning that the in resumeCopyHelper()
1099 * debugger has the thread suspended. See bug 6224859. in resumeCopyHelper()
1114 * on this thread. The check for !suspendOnStart is paranoia that in resumeCopyHelper()
1120 **listPtr = node->thread; in resumeCopyHelper()
1138 * on this thread. The check for !suspendOnStart is paranoia that in resumeCountHelper()
1173 * entire thread list from JVMTI so we use the runningThreads
1186 * toBeResumed) and would not be able to distinguish between a thread
1187 * that needs a hard resume versus a thread that is already running.
1234 EXIT_ERROR(AGENT_ERROR_INVALID_THREAD,"missing entry in running thread table"); in commonResumeList()
1236 LOG_MISC(("thread=%p resumed as part of list", node->thread)); in commonResumeList()
1281 * If the thread is not between its start and end events, we should in commonSuspendList()
1282 * still suspend it. To keep track of things, add the thread in commonSuspendList()
1305 /* thread is not suspended yet so put it on the request list */ in commonSuspendList()
1327 EXIT_ERROR(AGENT_ERROR_INVALID_THREAD,"missing entry in thread tables"); in commonSuspendList()
1329 LOG_MISC(("thread=%p suspended as part of list", node->thread)); in commonSuspendList()
1332 /* thread was suspended as requested */ in commonSuspendList()
1336 * If the thread was suspended by another app thread, in commonSuspendList()
1343 * because the thread is either a zombie or not yet in commonSuspendList()
1345 * thread is a zombie, suspend/resume are no-ops. If the in commonSuspendList()
1346 * thread is not started, it will be suspended for real in commonSuspendList()
1347 * during the processing of its thread start event. in commonSuspendList()
1369 commonResume(jthread thread) in commonResume() argument
1375 * The thread is normally between its start and end events, but if in commonResume()
1378 node = findThread(NULL, thread); in commonResume()
1382 * this thread, so do nothing. in commonResume()
1393 threadControl_suspendThread(jthread thread, jboolean deferred) in threadControl_suspendThread() argument
1400 log_debugee_location("threadControl_suspendThread()", thread, NULL, 0); in threadControl_suspendThread()
1403 error = commonSuspend(env, thread, deferred); in threadControl_suspendThread()
1410 threadControl_resumeThread(jthread thread, jboolean do_unblock) in threadControl_resumeThread() argument
1417 log_debugee_location("threadControl_resumeThread()", thread, NULL, 0); in threadControl_resumeThread()
1421 error = commonResume(thread); in threadControl_resumeThread()
1427 /* let eventHelper.c: commandLoop() know we resumed one thread */ in threadControl_resumeThread()
1435 threadControl_suspendCount(jthread thread, jint *count) in threadControl_suspendCount() argument
1442 node = findThread(&runningThreads, thread); in threadControl_suspendCount()
1444 node = findThread(&otherThreads, thread); in threadControl_suspendCount()
1453 * this thread, so the suspend count is 0. in threadControl_suspendCount()
1489 if (!contains(env, list, count, node->thread)) { in suspendAllHelper()
1490 error = commonSuspend(env, node->thread, JNI_FALSE); in suspendAllHelper()
1540 * in the thread list above. in threadControl_suspendAll()
1569 * of the two thread lists. in resumeHelper()
1589 * such threads must have a node in one of the thread lists, so there's in threadControl_resumeAll()
1590 * no need to get the whole thread list from JVMTI (unlike in threadControl_resumeAll()
1619 threadControl_getStepRequest(jthread thread) in threadControl_getStepRequest() argument
1628 node = findThread(&runningThreads, thread); in threadControl_getStepRequest()
1639 threadControl_getInvokeRequest(jthread thread) in threadControl_getInvokeRequest() argument
1648 node = findThread(&runningThreads, thread); in threadControl_getInvokeRequest()
1659 threadControl_addDebugThread(jthread thread) in threadControl_addDebugThread() argument
1671 saveGlobalRef(env, thread, &(debugThreads[debugThreadCount])); in threadControl_addDebugThread()
1684 threadControl_removeDebugThread(jthread thread) in threadControl_removeDebugThread() argument
1695 if (isSameObject(env, thread, debugThreads[i])) { in threadControl_removeDebugThread()
1712 threadControl_isDebugThread(jthread thread) in threadControl_isDebugThread() argument
1723 if (isSameObject(env, thread, debugThreads[i])) { in threadControl_isDebugThread()
1742 getPopFrameThread(jthread thread) in getPopFrameThread() argument
1750 node = findThread(NULL, thread); in getPopFrameThread()
1763 setPopFrameThread(jthread thread, jboolean value) in setPopFrameThread() argument
1769 node = findThread(NULL, thread); in setPopFrameThread()
1771 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"entry in thread table"); in setPopFrameThread()
1780 getPopFrameEvent(jthread thread) in getPopFrameEvent() argument
1788 node = findThread(NULL, thread); in getPopFrameEvent()
1791 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"entry in thread table"); in getPopFrameEvent()
1802 setPopFrameEvent(jthread thread, jboolean value) in setPopFrameEvent() argument
1808 node = findThread(NULL, thread); in setPopFrameEvent()
1810 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"entry in thread table"); in setPopFrameEvent()
1820 getPopFrameProceed(jthread thread) in getPopFrameProceed() argument
1828 node = findThread(NULL, thread); in getPopFrameProceed()
1831 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"entry in thread table"); in getPopFrameProceed()
1842 setPopFrameProceed(jthread thread, jboolean value) in setPopFrameProceed() argument
1848 node = findThread(NULL, thread); in setPopFrameProceed()
1850 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"entry in thread table"); in setPopFrameProceed()
1859 * Special event handler for events on the popped thread
1863 popFrameCompleteEvent(jthread thread) in popFrameCompleteEvent() argument
1870 setPopFrameEvent(thread, JNI_TRUE); in popFrameCompleteEvent()
1876 setPopFrameProceed(thread, JNI_FALSE); in popFrameCompleteEvent()
1877 while (getPopFrameProceed(thread) == JNI_FALSE) { in popFrameCompleteEvent()
1885 * Pop one frame off the stack of thread.
1889 popOneFrame(jthread thread) in popOneFrame() argument
1893 error = JVMTI_FUNC_PTR(gdata->jvmti,PopFrame)(gdata->jvmti, thread); in popOneFrame()
1898 /* resume the popped thread so that the pop occurs and so we */ in popOneFrame()
1900 LOG_MISC(("thread=%p resumed in popOneFrame", thread)); in popOneFrame()
1901 error = JVMTI_FUNC_PTR(gdata->jvmti,ResumeThread)(gdata->jvmti, thread); in popOneFrame()
1907 setPopFrameEvent(thread, JNI_FALSE); in popOneFrame()
1908 while (getPopFrameEvent(thread) == JNI_FALSE) { in popOneFrame()
1912 /* make sure not to suspend until the popped thread is on the wait */ in popOneFrame()
1915 /* return popped thread to suspended state */ in popOneFrame()
1916 LOG_MISC(("thread=%p suspended in popOneFrame", thread)); in popOneFrame()
1917 error = JVMTI_FUNC_PTR(gdata->jvmti,SuspendThread)(gdata->jvmti, thread); in popOneFrame()
1919 /* notify popped thread so it can proceed when resumed */ in popOneFrame()
1920 setPopFrameProceed(thread, JNI_TRUE); in popOneFrame()
1929 * pop frames of the stack of 'thread' until 'frame' is popped.
1932 threadControl_popFrames(jthread thread, FrameNumber fnum) in threadControl_popFrames() argument
1940 log_debugee_location("threadControl_popFrames()", thread, NULL, 0); in threadControl_popFrames()
1951 prevStepMode = threadControl_getInstructionStepMode(thread); in threadControl_popFrames()
1958 prevInvokeRequestMode = invoker_isEnabled(thread); in threadControl_popFrames()
1961 EI_SINGLE_STEP, thread); in threadControl_popFrames()
1966 /* Inform eventHandler logic we are in a popFrame for this thread */ in threadControl_popFrames()
1969 setPopFrameThread(thread, JNI_TRUE); in threadControl_popFrames()
1972 error = popOneFrame(thread); in threadControl_popFrames()
1977 setPopFrameThread(thread, JNI_FALSE); in threadControl_popFrames()
1985 stepControl_resetRequest(thread); in threadControl_popFrames()
1989 invoker_enableInvokeRequests(thread); in threadControl_popFrames()
1994 EI_SINGLE_STEP, thread); in threadControl_popFrames()
2001 checkForPopFrameEvents(JNIEnv *env, EventIndex ei, jthread thread) in checkForPopFrameEvents() argument
2003 if ( getPopFrameThread(thread) ) { in checkForPopFrameEvents()
2007 EXIT_ERROR(AGENT_ERROR_INTERNAL, "thread start during pop frame"); in checkForPopFrameEvents()
2010 /* Thread wants to end? let it. */ in checkForPopFrameEvents()
2011 setPopFrameThread(thread, JNI_FALSE); in checkForPopFrameEvents()
2012 popFrameCompleteEvent(thread); in checkForPopFrameEvents()
2017 popFrameCompleteEvent(thread); in checkForPopFrameEvents()
2036 threadControl_onEventHandlerEntry(jbyte sessionID, EventIndex ei, jthread thread, jobject currentEx… in threadControl_onEventHandlerEntry() argument
2047 log_debugee_location("threadControl_onEventHandlerEntry()", thread, NULL, 0); in threadControl_onEventHandlerEntry()
2050 consumed = checkForPopFrameEvents(env, ei, thread); in threadControl_onEventHandlerEntry()
2065 * and resume. If this thread is currently present in the in threadControl_onEventHandlerEntry()
2068 * well-known thread now. in threadControl_onEventHandlerEntry()
2070 node = findThread(&otherThreads, thread); in threadControl_onEventHandlerEntry()
2075 * Get a thread node for the reporting thread. For thread start in threadControl_onEventHandlerEntry()
2076 * events, or if this event precedes a thread start event, in threadControl_onEventHandlerEntry()
2077 * the thread node may need to be created. in threadControl_onEventHandlerEntry()
2080 * to precede thread start for some VM implementations. in threadControl_onEventHandlerEntry()
2082 node = insertThread(env, &runningThreads, thread); in threadControl_onEventHandlerEntry()
2087 processDeferredEventModes(env, thread, node); in threadControl_onEventHandlerEntry()
2093 threadToSuspend = node->thread; in threadControl_onEventHandlerEntry()
2099 * An attempt was made to suspend this thread before it started. in threadControl_onEventHandlerEntry()
2118 (gdata->jvmti, node->thread); in doPendingTasks()
2127 (gdata->jvmti, node->thread, node->pendingStop); in doPendingTasks()
2136 threadControl_onEventHandlerExit(EventIndex ei, jthread thread, in threadControl_onEventHandlerExit() argument
2141 log_debugee_location("threadControl_onEventHandlerExit()", thread, NULL, 0); in threadControl_onEventHandlerExit()
2148 node = findThread(&runningThreads, thread); in threadControl_onEventHandlerExit()
2150 EXIT_ERROR(AGENT_ERROR_NULL_POINTER,"thread list corrupted"); in threadControl_onEventHandlerExit()
2157 removeThread(env, &runningThreads, thread); in threadControl_onEventHandlerExit()
2168 /* No point in doing this if the thread is about to die.*/ in threadControl_onEventHandlerExit()
2183 threadControl_applicationThreadStatus(jthread thread, in threadControl_applicationThreadStatus() argument
2190 log_debugee_location("threadControl_applicationThreadStatus()", thread, NULL, 0); in threadControl_applicationThreadStatus()
2194 error = threadState(thread, &state); in threadControl_applicationThreadStatus()
2199 node = findThread(&runningThreads, thread); in threadControl_applicationThreadStatus()
2202 * While processing an event, an application thread is always in threadControl_applicationThreadStatus()
2219 threadControl_interrupt(jthread thread) in threadControl_interrupt() argument
2226 log_debugee_location("threadControl_interrupt()", thread, NULL, 0); in threadControl_interrupt()
2230 node = findThread(&runningThreads, thread); in threadControl_interrupt()
2233 (gdata->jvmti, thread); in threadControl_interrupt()
2247 threadControl_clearCLEInfo(JNIEnv *env, jthread thread) in threadControl_clearCLEInfo() argument
2253 node = findThread(&runningThreads, thread); in threadControl_clearCLEInfo()
2265 threadControl_cmpCLEInfo(JNIEnv *env, jthread thread, jclass clazz, in threadControl_cmpCLEInfo() argument
2275 node = findThread(&runningThreads, thread); in threadControl_cmpCLEInfo()
2289 threadControl_saveCLEInfo(JNIEnv *env, jthread thread, EventIndex ei, in threadControl_saveCLEInfo() argument
2296 node = findThread(&runningThreads, thread); in threadControl_saveCLEInfo()
2311 threadControl_setPendingInterrupt(jthread thread) in threadControl_setPendingInterrupt() argument
2317 node = findThread(&runningThreads, thread); in threadControl_setPendingInterrupt()
2326 threadControl_stop(jthread thread, jobject throwable) in threadControl_stop() argument
2333 log_debugee_location("threadControl_stop()", thread, NULL, 0); in threadControl_stop()
2337 node = findThread(&runningThreads, thread); in threadControl_stop()
2340 (gdata->jvmti, thread, throwable); in threadControl_stop()
2380 LOG_MISC(("thread=%p resumed", node->thread)); in resetHelper()
2381 (void)JVMTI_FUNC_PTR(gdata->jvmti,ResumeThread)(gdata->jvmti, node->thread); in resetHelper()
2384 stepControl_clearRequest(node->thread, &node->currentStep); in resetHelper()
2417 threadControl_getInstructionStepMode(jthread thread) in threadControl_getInstructionStepMode() argument
2425 node = findThread(&runningThreads, thread); in threadControl_getInstructionStepMode()
2434 threadControl_setEventMode(jvmtiEventMode mode, EventIndex ei, jthread thread) in threadControl_setEventMode() argument
2439 if ( thread == NULL ) { in threadControl_setEventMode()
2441 (gdata->jvmti, mode, eventIndex2jvmti(ei), thread); in threadControl_setEventMode()
2443 /* Thread event */ in threadControl_setEventMode()
2448 node = findThread(&runningThreads, thread); in threadControl_setEventMode()
2453 error = addDeferredEventMode(env, mode, ei, thread); in threadControl_setEventMode()
2456 mode, ei, thread); in threadControl_setEventMode()
2466 * Returns the current thread, if the thread has generated at least
2467 * one event, and has not generated a thread end event.
2471 jthread thread; in threadControl_currentThread() local
2478 thread = (node == NULL) ? NULL : node->thread; in threadControl_currentThread()
2482 return thread; in threadControl_currentThread()
2486 threadControl_getFrameGeneration(jthread thread) in threadControl_getFrameGeneration() argument
2494 node = findThread(NULL, thread); in threadControl_getFrameGeneration()