< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP07/sp07t001/sp07t001.cpp

Print this page
rev 52100 : 8212082: Remove the NSK_CPP_STUB macros for remaining vmTestbase/jvmti/[sS]*
Summary:
Reviewed-by:


  45 static jrawMonitorID waitLock = NULL;
  46 static jrawMonitorID frameLock = NULL;
  47 static int sampleCount = 0;
  48 static volatile int depth = 0;
  49 static jvmtiFrameInfo sampleStack[MAX_DEPTH];
  50 static jint frameCount = 0;
  51 static jvmtiFrameInfo frameBuffer[MAX_DEPTH];
  52 
  53 /* ========================================================================== */
  54 
  55 static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
  56     const char* THREAD_NAME = "Debuggee Thread";
  57     jvmtiThreadInfo info;
  58     jthread *threads = NULL;
  59     jint threads_count = 0;
  60     int i;
  61 
  62     NSK_DISPLAY0("Prepare: find tested thread\n");
  63 
  64     /* get all live threads */
  65     if (!NSK_JVMTI_VERIFY(
  66            NSK_CPP_STUB3(GetAllThreads, jvmti, &threads_count, &threads)))
  67         return NSK_FALSE;
  68 
  69     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
  70         return NSK_FALSE;
  71 
  72     /* find tested thread */
  73     for (i = 0; i < threads_count; i++) {
  74         if (!NSK_VERIFY(threads[i] != NULL))
  75             return NSK_FALSE;
  76 
  77         /* get thread information */
  78         if (!NSK_JVMTI_VERIFY(
  79                 NSK_CPP_STUB3(GetThreadInfo, jvmti, threads[i], &info)))
  80             return NSK_FALSE;
  81 
  82         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
  83 
  84         /* find by name */
  85         if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) {
  86             thread = threads[i];
  87         }
  88 
  89         if (info.name != NULL) {
  90             if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(
  91                     Deallocate, jvmti, (unsigned char*)info.name)))
  92                 return NSK_FALSE;
  93         }
  94     }
  95 
  96     /* deallocate threads list */
  97     if (!NSK_JVMTI_VERIFY(
  98             NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)threads)))
  99         return NSK_FALSE;
 100 
 101     if (thread == NULL) {
 102         NSK_COMPLAIN0("Debuggee thread not found");
 103         return NSK_FALSE;
 104     }
 105 
 106     if (!NSK_JVMTI_VERIFY(
 107             NSK_CPP_STUB3(CreateRawMonitor, jvmti, "waitLock", &waitLock)))
 108         return NSK_FALSE;
 109 
 110     return NSK_TRUE;
 111 }
 112 
 113 /* ============================================================================= */
 114 
 115 static int wait_for(jvmtiEnv* jvmti, jlong millis) {
 116 
 117     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, waitLock)))
 118         return NSK_FALSE;
 119 
 120     if (!NSK_JVMTI_VERIFY(
 121             NSK_CPP_STUB3(RawMonitorWait, jvmti, waitLock, millis)))
 122         nsk_jvmti_setFailStatus();
 123 
 124     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, waitLock)))
 125         return NSK_FALSE;
 126 
 127     return NSK_TRUE;
 128 }
 129 
 130 static int displayFrameInfo(jvmtiEnv* jvmti, jint i) {
 131     char buffer[32];
 132     char *name = NULL;
 133     char *signature = NULL;
 134 
 135     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
 136             frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
 137         return NSK_FALSE;
 138 
 139     NSK_DISPLAY4("    got[%d] method: %s%s, location: %s\n", i, name,
 140         signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
 141     if (name != NULL)
 142         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
 143     if (signature != NULL)
 144         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
 145 
 146     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
 147             sampleStack[i].method, &name, &signature, NULL)))
 148         return NSK_FALSE;
 149 
 150     NSK_DISPLAY4("    exp[%d] method: %s%s, location: %s\n", i, name,
 151         signature, jlong_to_string(sampleStack[i].location, buffer));
 152     if (name != NULL)
 153         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
 154     if (signature != NULL)
 155         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
 156 
 157     return NSK_TRUE;
 158 }
 159 
 160 static int complainFrameInfo(jvmtiEnv* jvmti, jint i) {
 161     char buffer[32];
 162     char *name = NULL;
 163     char *signature = NULL;
 164 
 165     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
 166             frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))
 167         return NSK_FALSE;
 168 
 169     NSK_COMPLAIN3("    got: method=%s%s, location=%s\n", name, signature,
 170         jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
 171     if (name != NULL)
 172         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
 173     if (signature != NULL)
 174         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
 175 
 176     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetMethodName, jvmti,
 177             sampleStack[i].method, &name, &signature, NULL)))
 178         return NSK_FALSE;
 179 
 180     NSK_COMPLAIN3("    expected: method=%s%s, location=%s\n", name, signature,
 181         jlong_to_string(sampleStack[i].location, buffer));
 182     if (name != NULL)
 183         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)name);
 184     if (signature != NULL)
 185         NSK_CPP_STUB2(Deallocate, jvmti, (unsigned char*)signature);
 186 
 187     return NSK_TRUE;
 188 }
 189 
 190 static int checkStackTrace(jvmtiEnv* jvmti, JNIEnv* jni) {
 191     jint i;
 192     int res = NSK_TRUE;
 193     int displayFlag =
 194         (nsk_getVerboseMode() && (sampleCount % DISPLAYING_FREQUENCY) == 0);
 195 
 196     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
 197         return NSK_FALSE;
 198 
 199     /* get stack trace */
 200     if (!NSK_JVMTI_VERIFY(
 201             NSK_CPP_STUB6(GetStackTrace, jvmti, thread,
 202                 0, MAX_DEPTH, frameBuffer, &frameCount))) {
 203         res = NSK_FALSE;
 204     } else {
 205         if (displayFlag) {
 206             NSK_DISPLAY3("Sample #%d, frameCount: %d, depth: %d\n",
 207                 sampleCount, frameCount, depth);
 208         }
 209         if (!NSK_VERIFY(frameCount >= depth)) {
 210             NSK_COMPLAIN3("Sample #%d, wrong frameCount: %d, expected >= %d\n",
 211                 sampleCount, frameCount, depth);
 212             res = NSK_FALSE;
 213         } else {
 214             for (i = 0; i < depth; i++) {
 215                 if (displayFlag && !displayFrameInfo(jvmti, i))
 216                     res = NSK_FALSE;
 217                 if (!NSK_VERIFY(sampleStack[i].method ==
 218                         frameBuffer[frameCount-1-i].method) ||
 219                     !NSK_VERIFY(sampleStack[i].location ==
 220                         frameBuffer[frameCount-1-i].location)) {
 221 
 222                     NSK_COMPLAIN3("Sample #%d, depth=%d, wrong frame [%d]:\n",
 223                         sampleCount, depth, i);
 224                     complainFrameInfo(jvmti, i);
 225                     res = NSK_FALSE;
 226                 }
 227             }
 228         }
 229     }
 230 
 231     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
 232         return NSK_FALSE;
 233 
 234     return res;
 235 }
 236 
 237 /* ========================================================================== */
 238 
 239 /* agent algorithm */
 240 static void JNICALL
 241 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 242 
 243     /* wait for initial sync */
 244     if (!nsk_jvmti_waitForSync(timeout))
 245         return;
 246 
 247     if (!prepare(jvmti, jni)) {
 248         nsk_jvmti_setFailStatus();
 249         return;
 250     }
 251 


 261     /* resume debugee after last sync */
 262     if (!nsk_jvmti_resumeSync())
 263         return;
 264 }
 265 
 266 /* ========================================================================== */
 267 
 268 JNIEXPORT jint JNICALL
 269 Java_nsk_jvmti_scenarios_sampling_SP07_sp07t001Thread_wrapper(JNIEnv* jni,
 270         jobject obj, jint i) {
 271     jint result = 0;
 272     jclass klass = NULL;
 273     jmethodID method = NULL;
 274     jvmtiEnv* jvmti = nsk_jvmti_getAgentJVMTIEnv();
 275 
 276     if (!NSK_VERIFY(depth < MAX_DEPTH)) {
 277         nsk_jvmti_setFailStatus();
 278         return 0;
 279     }
 280 
 281     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
 282         return NSK_FALSE;
 283 
 284     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetFrameLocation, jvmti, NULL, 1,
 285             &sampleStack[depth].method, &sampleStack[depth].location))) {
 286         nsk_jvmti_setFailStatus();
 287         return 0;
 288     }
 289 
 290     depth++;
 291 
 292     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB5(GetFrameLocation, jvmti, NULL, 0,
 293             &sampleStack[depth].method, &sampleStack[depth].location))) {
 294         nsk_jvmti_setFailStatus();
 295         return 0;
 296     }
 297 
 298     depth++;
 299 
 300     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
 301         return NSK_FALSE;
 302 
 303     if (!NSK_JNI_VERIFY(jni, (klass = NSK_CPP_STUB2(GetObjectClass,
 304             jni, obj)) != NULL)) {
 305         nsk_jvmti_setFailStatus();
 306         return 0;
 307     }
 308 
 309     if (!NSK_JNI_VERIFY(jni, (method = NSK_CPP_STUB4(GetMethodID,
 310             jni, klass, "fibonacci", "(I)I")) != NULL)) {
 311         nsk_jvmti_setFailStatus();
 312         return 0;
 313     }
 314 
 315     result = NSK_CPP_STUB4(CallIntMethod, jni, obj, method, i);
 316 
 317     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorEnter, jvmti, frameLock)))
 318         return NSK_FALSE;
 319 
 320     depth--;
 321     depth--;
 322 
 323     if (!NSK_JVMTI_VERIFY(NSK_CPP_STUB2(RawMonitorExit, jvmti, frameLock)))
 324         return NSK_FALSE;
 325 
 326     return result;
 327 }
 328 
 329 /* ========================================================================== */
 330 
 331 /* agent library initialization */
 332 #ifdef STATIC_BUILD
 333 JNIEXPORT jint JNICALL Agent_OnLoad_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 334     return Agent_Initialize(jvm, options, reserved);
 335 }
 336 JNIEXPORT jint JNICALL Agent_OnAttach_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 337     return Agent_Initialize(jvm, options, reserved);
 338 }
 339 JNIEXPORT jint JNI_OnLoad_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 340     return JNI_VERSION_1_8;
 341 }
 342 #endif
 343 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 344     jvmtiEnv* jvmti = NULL;
 345 
 346     /* init framework and parse options */
 347     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 348         return JNI_ERR;
 349 
 350     timeout = nsk_jvmti_getWaitTime() * 60000;
 351     NSK_DISPLAY1("Timeout: %d msc\n", (int)timeout);
 352 
 353     /* create JVMTI environment */
 354     if (!NSK_VERIFY((jvmti =
 355             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 356         return JNI_ERR;
 357 
 358     if (!NSK_JVMTI_VERIFY(
 359             NSK_CPP_STUB3(CreateRawMonitor, jvmti, "frameLock", &frameLock)))
 360         return NSK_FALSE;
 361 
 362     /* register agent proc and arg */
 363     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 364         return JNI_ERR;
 365 
 366     return JNI_OK;
 367 }
 368 
 369 /* ========================================================================== */
 370 
 371 }


  45 static jrawMonitorID waitLock = NULL;
  46 static jrawMonitorID frameLock = NULL;
  47 static int sampleCount = 0;
  48 static volatile int depth = 0;
  49 static jvmtiFrameInfo sampleStack[MAX_DEPTH];
  50 static jint frameCount = 0;
  51 static jvmtiFrameInfo frameBuffer[MAX_DEPTH];
  52 
  53 /* ========================================================================== */
  54 
  55 static int prepare(jvmtiEnv* jvmti, JNIEnv* jni) {
  56     const char* THREAD_NAME = "Debuggee Thread";
  57     jvmtiThreadInfo info;
  58     jthread *threads = NULL;
  59     jint threads_count = 0;
  60     int i;
  61 
  62     NSK_DISPLAY0("Prepare: find tested thread\n");
  63 
  64     /* get all live threads */
  65     if (!NSK_JVMTI_VERIFY(jvmti->GetAllThreads(&threads_count, &threads)))

  66         return NSK_FALSE;
  67 
  68     if (!NSK_VERIFY(threads_count > 0 && threads != NULL))
  69         return NSK_FALSE;
  70 
  71     /* find tested thread */
  72     for (i = 0; i < threads_count; i++) {
  73         if (!NSK_VERIFY(threads[i] != NULL))
  74             return NSK_FALSE;
  75 
  76         /* get thread information */
  77         if (!NSK_JVMTI_VERIFY(jvmti->GetThreadInfo(threads[i], &info)))

  78             return NSK_FALSE;
  79 
  80         NSK_DISPLAY3("    thread #%d (%s): %p\n", i, info.name, threads[i]);
  81 
  82         /* find by name */
  83         if (info.name != NULL && (strcmp(info.name, THREAD_NAME) == 0)) {
  84             thread = threads[i];
  85         }
  86 
  87         if (info.name != NULL) {
  88             if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)info.name)))

  89                 return NSK_FALSE;
  90         }
  91     }
  92 
  93     /* deallocate threads list */
  94     if (!NSK_JVMTI_VERIFY(jvmti->Deallocate((unsigned char*)threads)))

  95         return NSK_FALSE;
  96 
  97     if (thread == NULL) {
  98         NSK_COMPLAIN0("Debuggee thread not found");
  99         return NSK_FALSE;
 100     }
 101 
 102     if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("waitLock", &waitLock)))

 103         return NSK_FALSE;
 104 
 105     return NSK_TRUE;
 106 }
 107 
 108 /* ============================================================================= */
 109 
 110 static int wait_for(jvmtiEnv* jvmti, jlong millis) {
 111 
 112     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(waitLock)))
 113         return NSK_FALSE;
 114 
 115     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorWait(waitLock, millis)))

 116         nsk_jvmti_setFailStatus();
 117 
 118     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(waitLock)))
 119         return NSK_FALSE;
 120 
 121     return NSK_TRUE;
 122 }
 123 
 124 static int displayFrameInfo(jvmtiEnv* jvmti, jint i) {
 125     char buffer[32];
 126     char *name = NULL;
 127     char *signature = NULL;
 128 
 129     if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))

 130         return NSK_FALSE;
 131 
 132     NSK_DISPLAY4("    got[%d] method: %s%s, location: %s\n", i, name,
 133         signature, jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
 134     if (name != NULL)
 135         jvmti->Deallocate((unsigned char*)name);
 136     if (signature != NULL)
 137         jvmti->Deallocate((unsigned char*)signature);
 138 
 139     if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL)))

 140         return NSK_FALSE;
 141 
 142     NSK_DISPLAY4("    exp[%d] method: %s%s, location: %s\n", i, name,
 143         signature, jlong_to_string(sampleStack[i].location, buffer));
 144     if (name != NULL)
 145         jvmti->Deallocate((unsigned char*)name);
 146     if (signature != NULL)
 147         jvmti->Deallocate((unsigned char*)signature);
 148 
 149     return NSK_TRUE;
 150 }
 151 
 152 static int complainFrameInfo(jvmtiEnv* jvmti, jint i) {
 153     char buffer[32];
 154     char *name = NULL;
 155     char *signature = NULL;
 156 
 157     if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(frameBuffer[frameCount-1-i].method, &name, &signature, NULL)))

 158         return NSK_FALSE;
 159 
 160     NSK_COMPLAIN3("    got: method=%s%s, location=%s\n", name, signature,
 161         jlong_to_string(frameBuffer[frameCount-1-i].location, buffer));
 162     if (name != NULL)
 163         jvmti->Deallocate((unsigned char*)name);
 164     if (signature != NULL)
 165         jvmti->Deallocate((unsigned char*)signature);
 166 
 167     if (!NSK_JVMTI_VERIFY(jvmti->GetMethodName(sampleStack[i].method, &name, &signature, NULL)))

 168         return NSK_FALSE;
 169 
 170     NSK_COMPLAIN3("    expected: method=%s%s, location=%s\n", name, signature,
 171         jlong_to_string(sampleStack[i].location, buffer));
 172     if (name != NULL)
 173         jvmti->Deallocate((unsigned char*)name);
 174     if (signature != NULL)
 175         jvmti->Deallocate((unsigned char*)signature);
 176 
 177     return NSK_TRUE;
 178 }
 179 
 180 static int checkStackTrace(jvmtiEnv* jvmti, JNIEnv* jni) {
 181     jint i;
 182     int res = NSK_TRUE;
 183     int displayFlag =
 184         (nsk_getVerboseMode() && (sampleCount % DISPLAYING_FREQUENCY) == 0);
 185 
 186     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
 187         return NSK_FALSE;
 188 
 189     /* get stack trace */
 190     if (!NSK_JVMTI_VERIFY(jvmti->GetStackTrace(thread, 0, MAX_DEPTH, frameBuffer, &frameCount))) {


 191         res = NSK_FALSE;
 192     } else {
 193         if (displayFlag) {
 194             NSK_DISPLAY3("Sample #%d, frameCount: %d, depth: %d\n",
 195                 sampleCount, frameCount, depth);
 196         }
 197         if (!NSK_VERIFY(frameCount >= depth)) {
 198             NSK_COMPLAIN3("Sample #%d, wrong frameCount: %d, expected >= %d\n",
 199                 sampleCount, frameCount, depth);
 200             res = NSK_FALSE;
 201         } else {
 202             for (i = 0; i < depth; i++) {
 203                 if (displayFlag && !displayFrameInfo(jvmti, i))
 204                     res = NSK_FALSE;
 205                 if (!NSK_VERIFY(sampleStack[i].method ==
 206                         frameBuffer[frameCount-1-i].method) ||
 207                     !NSK_VERIFY(sampleStack[i].location ==
 208                         frameBuffer[frameCount-1-i].location)) {
 209 
 210                     NSK_COMPLAIN3("Sample #%d, depth=%d, wrong frame [%d]:\n",
 211                         sampleCount, depth, i);
 212                     complainFrameInfo(jvmti, i);
 213                     res = NSK_FALSE;
 214                 }
 215             }
 216         }
 217     }
 218 
 219     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
 220         return NSK_FALSE;
 221 
 222     return res;
 223 }
 224 
 225 /* ========================================================================== */
 226 
 227 /* agent algorithm */
 228 static void JNICALL
 229 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
 230 
 231     /* wait for initial sync */
 232     if (!nsk_jvmti_waitForSync(timeout))
 233         return;
 234 
 235     if (!prepare(jvmti, jni)) {
 236         nsk_jvmti_setFailStatus();
 237         return;
 238     }
 239 


 249     /* resume debugee after last sync */
 250     if (!nsk_jvmti_resumeSync())
 251         return;
 252 }
 253 
 254 /* ========================================================================== */
 255 
 256 JNIEXPORT jint JNICALL
 257 Java_nsk_jvmti_scenarios_sampling_SP07_sp07t001Thread_wrapper(JNIEnv* jni,
 258         jobject obj, jint i) {
 259     jint result = 0;
 260     jclass klass = NULL;
 261     jmethodID method = NULL;
 262     jvmtiEnv* jvmti = nsk_jvmti_getAgentJVMTIEnv();
 263 
 264     if (!NSK_VERIFY(depth < MAX_DEPTH)) {
 265         nsk_jvmti_setFailStatus();
 266         return 0;
 267     }
 268 
 269     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
 270         return NSK_FALSE;
 271 
 272     if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 1, &sampleStack[depth].method, &sampleStack[depth].location))) {

 273         nsk_jvmti_setFailStatus();
 274         return 0;
 275     }
 276 
 277     depth++;
 278 
 279     if (!NSK_JVMTI_VERIFY(jvmti->GetFrameLocation(NULL, 0, &sampleStack[depth].method, &sampleStack[depth].location))) {

 280         nsk_jvmti_setFailStatus();
 281         return 0;
 282     }
 283 
 284     depth++;
 285 
 286     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
 287         return NSK_FALSE;
 288 
 289     if (!NSK_JNI_VERIFY(jni, (klass = jni->GetObjectClass(obj)) != NULL)) {

 290         nsk_jvmti_setFailStatus();
 291         return 0;
 292     }
 293 
 294     if (!NSK_JNI_VERIFY(jni, (method = jni->GetMethodID(klass, "fibonacci", "(I)I")) != NULL)) {

 295         nsk_jvmti_setFailStatus();
 296         return 0;
 297     }
 298 
 299     result = jni->CallIntMethod(obj, method, i);
 300 
 301     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorEnter(frameLock)))
 302         return NSK_FALSE;
 303 
 304     depth--;
 305     depth--;
 306 
 307     if (!NSK_JVMTI_VERIFY(jvmti->RawMonitorExit(frameLock)))
 308         return NSK_FALSE;
 309 
 310     return result;
 311 }
 312 
 313 /* ========================================================================== */
 314 
 315 /* agent library initialization */
 316 #ifdef STATIC_BUILD
 317 JNIEXPORT jint JNICALL Agent_OnLoad_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 318     return Agent_Initialize(jvm, options, reserved);
 319 }
 320 JNIEXPORT jint JNICALL Agent_OnAttach_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 321     return Agent_Initialize(jvm, options, reserved);
 322 }
 323 JNIEXPORT jint JNI_OnLoad_sp07t001(JavaVM *jvm, char *options, void *reserved) {
 324     return JNI_VERSION_1_8;
 325 }
 326 #endif
 327 jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) {
 328     jvmtiEnv* jvmti = NULL;
 329 
 330     /* init framework and parse options */
 331     if (!NSK_VERIFY(nsk_jvmti_parseOptions(options)))
 332         return JNI_ERR;
 333 
 334     timeout = nsk_jvmti_getWaitTime() * 60000;
 335     NSK_DISPLAY1("Timeout: %d msc\n", (int)timeout);
 336 
 337     /* create JVMTI environment */
 338     if (!NSK_VERIFY((jvmti =
 339             nsk_jvmti_createJVMTIEnv(jvm, reserved)) != NULL))
 340         return JNI_ERR;
 341 
 342     if (!NSK_JVMTI_VERIFY(jvmti->CreateRawMonitor("frameLock", &frameLock)))

 343         return NSK_FALSE;
 344 
 345     /* register agent proc and arg */
 346     if (!NSK_VERIFY(nsk_jvmti_setAgentProc(agentProc, NULL)))
 347         return JNI_ERR;
 348 
 349     return JNI_OK;
 350 }
 351 
 352 /* ========================================================================== */
 353 
 354 }
< prev index next >