< prev index next >

test/hotspot/jtreg/vmTestbase/nsk/jvmti/IterateOverHeap/iterheap006/iterheap006.cpp

Print this page
rev 52200 : [mq]: spaces


  29 
  30 extern "C" {
  31 
  32 /* ============================================================================= */
  33 
  34 static jlong timeout = 0;
  35 static jvmtiEnv* st_jvmti = NULL;
  36 static const char *storage_data = "local_storage_data";
  37 static void *storage_ptr = NULL;
  38 
  39 
  40 /* ============================================================================= */
  41 
  42 jvmtiIterationControl JNICALL
  43 heapObjectCallback(jlong class_tag,
  44                    jlong size,
  45                    jlong* tag_ptr,
  46                    void* storage_data) {
  47 
  48     if (!NSK_JVMTI_VERIFY(
  49             st_jvmti->SetEnvironmentLocalStorage(storage_data ))) {
  50         nsk_jvmti_setFailStatus();
  51     }
  52 
  53     if (!NSK_JVMTI_VERIFY(
  54             st_jvmti->GetEnvironmentLocalStorage(&storage_ptr))) {
  55         nsk_jvmti_setFailStatus();
  56     }
  57 
  58     /*  Iterate over only first object */
  59     return JVMTI_ITERATION_ABORT;
  60 }
  61 
  62 /* ============================================================================= */
  63 
  64 /** Agent algorithm. */
  65 static void JNICALL
  66 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  67 
  68     NSK_DISPLAY0("Wait for debugee start\n");
  69     if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
  70         return;
  71 
  72     {
  73         NSK_DISPLAY0("Calling IterateOverHeap with filter JVMTI_HEAP_OBJECT_EITHER\n");
  74         {
  75             if (!NSK_JVMTI_VERIFY(
  76                     jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_EITHER, heapObjectCallback, (void *)storage_data))) {
  77                 nsk_jvmti_setFailStatus();
  78             }
  79         }
  80 
  81         if (storage_data != storage_ptr) {
  82             NSK_COMPLAIN2("Local storage address was corrupted: %p ,\n\texpected value: %p\n",
  83                              storage_ptr, storage_data);
  84             nsk_jvmti_setFailStatus();
  85         }
  86 
  87         if (strcmp(storage_data, (char *)storage_ptr) != 0) {
  88             NSK_COMPLAIN2("Local storage was corrupted: %s ,\n\texpected value: %s\n",
  89                              (char *)storage_ptr, storage_data );
  90             nsk_jvmti_setFailStatus();
  91         }
  92     }
  93 
  94     NSK_DISPLAY0("Let debugee to finish\n");
  95     if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
  96         return;
  97 }
  98 
  99 /* ============================================================================= */
 100 
 101 /** Agent library initialization. */
 102 #ifdef STATIC_BUILD
 103 JNIEXPORT jint JNICALL Agent_OnLoad_iterheap006(JavaVM *jvm, char *options, void *reserved) {
 104     return Agent_Initialize(jvm, options, reserved);
 105 }
 106 JNIEXPORT jint JNICALL Agent_OnAttach_iterheap006(JavaVM *jvm, char *options, void *reserved) {
 107     return Agent_Initialize(jvm, options, reserved);
 108 }
 109 JNIEXPORT jint JNI_OnLoad_iterheap006(JavaVM *jvm, char *options, void *reserved) {




  29 
  30 extern "C" {
  31 
  32 /* ============================================================================= */
  33 
  34 static jlong timeout = 0;
  35 static jvmtiEnv* st_jvmti = NULL;
  36 static const char *storage_data = "local_storage_data";
  37 static void *storage_ptr = NULL;
  38 
  39 
  40 /* ============================================================================= */
  41 
  42 jvmtiIterationControl JNICALL
  43 heapObjectCallback(jlong class_tag,
  44                    jlong size,
  45                    jlong* tag_ptr,
  46                    void* storage_data) {
  47 
  48     if (!NSK_JVMTI_VERIFY(
  49             st_jvmti->SetEnvironmentLocalStorage(storage_data))) {
  50         nsk_jvmti_setFailStatus();
  51     }
  52 
  53     if (!NSK_JVMTI_VERIFY(
  54             st_jvmti->GetEnvironmentLocalStorage(&storage_ptr))) {
  55         nsk_jvmti_setFailStatus();
  56     }
  57 
  58     /*  Iterate over only first object */
  59     return JVMTI_ITERATION_ABORT;
  60 }
  61 
  62 /* ============================================================================= */
  63 
  64 /** Agent algorithm. */
  65 static void JNICALL
  66 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
  67 
  68     NSK_DISPLAY0("Wait for debugee start\n");
  69     if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
  70         return;
  71 
  72     {
  73         NSK_DISPLAY0("Calling IterateOverHeap with filter JVMTI_HEAP_OBJECT_EITHER\n");
  74         {
  75             if (!NSK_JVMTI_VERIFY(
  76                     jvmti->IterateOverHeap(JVMTI_HEAP_OBJECT_EITHER, heapObjectCallback, (void *)storage_data))) {
  77                 nsk_jvmti_setFailStatus();
  78             }
  79         }
  80 
  81         if (storage_data != storage_ptr) {
  82             NSK_COMPLAIN2("Local storage address was corrupted: %p ,\n\texpected value: %p\n",
  83                              storage_ptr, storage_data);
  84             nsk_jvmti_setFailStatus();
  85         }
  86 
  87         if (strcmp(storage_data, (char *)storage_ptr) != 0) {
  88             NSK_COMPLAIN2("Local storage was corrupted: %s ,\n\texpected value: %s\n",
  89                              (char *)storage_ptr, storage_data);
  90             nsk_jvmti_setFailStatus();
  91         }
  92     }
  93 
  94     NSK_DISPLAY0("Let debugee to finish\n");
  95     if (!NSK_VERIFY(nsk_jvmti_resumeSync()))
  96         return;
  97 }
  98 
  99 /* ============================================================================= */
 100 
 101 /** Agent library initialization. */
 102 #ifdef STATIC_BUILD
 103 JNIEXPORT jint JNICALL Agent_OnLoad_iterheap006(JavaVM *jvm, char *options, void *reserved) {
 104     return Agent_Initialize(jvm, options, reserved);
 105 }
 106 JNIEXPORT jint JNICALL Agent_OnAttach_iterheap006(JavaVM *jvm, char *options, void *reserved) {
 107     return Agent_Initialize(jvm, options, reserved);
 108 }
 109 JNIEXPORT jint JNI_OnLoad_iterheap006(JavaVM *jvm, char *options, void *reserved) {


< prev index next >