61 nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) |
61 nsk_jvmti_threadByName(THREAD_NAME)) != NULL)) |
62 return; |
62 return; |
63 NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); |
63 NSK_DISPLAY1(" ... found thread: %p\n", (void*)testedThread); |
64 |
64 |
65 NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); |
65 NSK_DISPLAY1("Suspend thread: %p\n", (void*)testedThread); |
66 if (!NSK_JVMTI_VERIFY( |
66 if (!NSK_JVMTI_VERIFY(jvmti->SuspendThread(testedThread))) { |
67 NSK_CPP_STUB2(SuspendThread, jvmti, testedThread))) { |
|
68 nsk_jvmti_setFailStatus(); |
67 nsk_jvmti_setFailStatus(); |
69 return; |
68 return; |
70 } |
69 } |
71 |
70 |
72 NSK_DISPLAY0("Let thread to run and finish\n"); |
71 NSK_DISPLAY0("Let thread to run and finish\n"); |
76 |
75 |
77 NSK_DISPLAY1("Get state vector for thread: %p\n", (void*)testedThread); |
76 NSK_DISPLAY1("Get state vector for thread: %p\n", (void*)testedThread); |
78 { |
77 { |
79 jint state = 0; |
78 jint state = 0; |
80 |
79 |
81 if (!NSK_JVMTI_VERIFY( |
80 if (!NSK_JVMTI_VERIFY(jvmti->GetThreadState(testedThread, &state))) { |
82 NSK_CPP_STUB3(GetThreadState, jvmti, testedThread, &state))) { |
|
83 nsk_jvmti_setFailStatus(); |
81 nsk_jvmti_setFailStatus(); |
84 } |
82 } |
85 NSK_DISPLAY2(" ... got state vector: %s (%d)\n", |
83 NSK_DISPLAY2(" ... got state vector: %s (%d)\n", |
86 TranslateState(state), (int)state); |
84 TranslateState(state), (int)state); |
87 |
85 |
92 nsk_jvmti_setFailStatus(); |
90 nsk_jvmti_setFailStatus(); |
93 } |
91 } |
94 } |
92 } |
95 |
93 |
96 NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); |
94 NSK_DISPLAY1("Resume thread: %p\n", (void*)testedThread); |
97 if (!NSK_JVMTI_VERIFY( |
95 if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) { |
98 NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) { |
|
99 nsk_jvmti_setFailStatus(); |
96 nsk_jvmti_setFailStatus(); |
100 } |
97 } |
101 /* Original agentProc test block ends here. */ |
98 /* Original agentProc test block ends here. */ |
102 |
99 |
103 /* |
100 /* |
105 * in order to slow down the rate of SuspendThread() calls. |
102 * in order to slow down the rate of SuspendThread() calls. |
106 */ |
103 */ |
107 for (late_count = 0; late_count < N_LATE_CALLS; late_count++) { |
104 for (late_count = 0; late_count < N_LATE_CALLS; late_count++) { |
108 jvmtiError l_err; |
105 jvmtiError l_err; |
109 printf("INFO: Late suspend thread: %p\n", (void*)testedThread); |
106 printf("INFO: Late suspend thread: %p\n", (void*)testedThread); |
110 l_err = NSK_CPP_STUB2(SuspendThread, jvmti, testedThread); |
107 l_err = jvmti->SuspendThread(testedThread); |
111 if (l_err != JVMTI_ERROR_NONE) { |
108 if (l_err != JVMTI_ERROR_NONE) { |
112 printf("INFO: Late suspend thread err: %d\n", l_err); |
109 printf("INFO: Late suspend thread err: %d\n", l_err); |
113 // testedThread has exited so we're done with late calls |
110 // testedThread has exited so we're done with late calls |
114 break; |
111 break; |
115 } |
112 } |
116 |
113 |
117 // Only resume a thread if suspend worked. Using NSK_DISPLAY1() |
114 // Only resume a thread if suspend worked. Using NSK_DISPLAY1() |
118 // here because we want ResumeThread() to be faster. |
115 // here because we want ResumeThread() to be faster. |
119 NSK_DISPLAY1("INFO: Late resume thread: %p\n", (void*)testedThread); |
116 NSK_DISPLAY1("INFO: Late resume thread: %p\n", (void*)testedThread); |
120 if (!NSK_JVMTI_VERIFY( |
117 if (!NSK_JVMTI_VERIFY(jvmti->ResumeThread(testedThread))) { |
121 NSK_CPP_STUB2(ResumeThread, jvmti, testedThread))) { |
|
122 nsk_jvmti_setFailStatus(); |
118 nsk_jvmti_setFailStatus(); |
123 } |
119 } |
124 } |
120 } |
125 |
121 |
126 printf("INFO: made %d late calls to JVM/TI SuspendThread()\n", |
122 printf("INFO: made %d late calls to JVM/TI SuspendThread()\n", |
135 // SP6.1-w - wait to end test |
131 // SP6.1-w - wait to end test |
136 if (!nsk_jvmti_waitForSync(timeout)) |
132 if (!nsk_jvmti_waitForSync(timeout)) |
137 return; |
133 return; |
138 |
134 |
139 NSK_DISPLAY0("Delete thread reference\n"); |
135 NSK_DISPLAY0("Delete thread reference\n"); |
140 NSK_TRACE(NSK_CPP_STUB2(DeleteGlobalRef, jni, testedThread)); |
136 NSK_TRACE(jni->DeleteGlobalRef(testedThread)); |
141 } |
137 } |
142 |
138 |
143 NSK_DISPLAY0("Let debugee to finish\n"); |
139 NSK_DISPLAY0("Let debugee to finish\n"); |
144 // SP7.1-n - notify agent end |
140 // SP7.1-n - notify agent end |
145 if (!nsk_jvmti_resumeSync()) |
141 if (!nsk_jvmti_resumeSync()) |
178 /* add specific capabilities for suspending thread */ |
174 /* add specific capabilities for suspending thread */ |
179 { |
175 { |
180 jvmtiCapabilities suspendCaps; |
176 jvmtiCapabilities suspendCaps; |
181 memset(&suspendCaps, 0, sizeof(suspendCaps)); |
177 memset(&suspendCaps, 0, sizeof(suspendCaps)); |
182 suspendCaps.can_suspend = 1; |
178 suspendCaps.can_suspend = 1; |
183 if (!NSK_JVMTI_VERIFY( |
179 if (!NSK_JVMTI_VERIFY(jvmti->AddCapabilities(&suspendCaps))) |
184 NSK_CPP_STUB2(AddCapabilities, jvmti, &suspendCaps))) |
|
185 return JNI_ERR; |
180 return JNI_ERR; |
186 } |
181 } |
187 |
182 |
188 /* register agent proc and arg */ |
183 /* register agent proc and arg */ |
189 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) |
184 if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL))) |