37 static int userData = 0, allocationError = 0;
38
39 static jvmtiEnv* st_jvmti = NULL;
40 static const char* debugeeClassSignature = "Lnsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002;";
41 static const char* objectFieldName = "object";
42
43 typedef struct ObjectDescStruct {
44 jlong tag;
45 jlong size;
46 } ObjectDesc;
47
48 static ObjectDesc *objectDescBuf;
49
50 /* ============================================================================= */
51
52 /* ============================================================================= */
53
54
55 /** jvmtiObjectReferenceCallback for first iteration. */
56 jvmtiIterationControl JNICALL
57 objectReferenceCallback1( jvmtiObjectReferenceKind reference_kind,
58 jlong class_tag,
59 jlong size,
60 jlong* tag_ptr,
61 jlong referrer_tag,
62 jint referrer_index,
63 void* user_data) {
64
65 objectCount++;
66 /* Set tag */
67 *tag_ptr = objectCount;
68
69 if (!NSK_JVMTI_VERIFY(st_jvmti->Allocate((sizeof(ObjectDesc)),
70 (unsigned char**)&objectDescBuf))) {
71 nsk_jvmti_setFailStatus();
72 allocationError = 1;
73 }
74
75 (*objectDescBuf).tag = *tag_ptr;
76 (*objectDescBuf).size = size;
77
78 return JVMTI_ITERATION_ABORT;
79 }
80
81 /** jvmtiObjectReferenceCallback for second iteration. */
82 jvmtiIterationControl JNICALL
83 objectReferenceCallback2( jvmtiObjectReferenceKind reference_kind,
84 jlong class_tag,
85 jlong size,
86 jlong* tag_ptr,
87 jlong referrer_tag,
88 jint referrer_index,
89 void* user_data) {
90
91 objectCount--;
92
93 if (!NSK_JVMTI_VERIFY(st_jvmti->Deallocate((unsigned char*)objectDescBuf))) {
94 nsk_jvmti_setFailStatus();
95 }
96
97 return JVMTI_ITERATION_ABORT;
98 }
99
100 /* ============================================================================= */
101
102 /** Agent algorithm. */
103 static void JNICALL
104 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
105
106 NSK_DISPLAY0("Wait for debugee start\n");
107 if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
108 return;
109
|
37 static int userData = 0, allocationError = 0;
38
39 static jvmtiEnv* st_jvmti = NULL;
40 static const char* debugeeClassSignature = "Lnsk/jvmti/IterateOverObjectsReachableFromObject/iterobjreachobj002;";
41 static const char* objectFieldName = "object";
42
43 typedef struct ObjectDescStruct {
44 jlong tag;
45 jlong size;
46 } ObjectDesc;
47
48 static ObjectDesc *objectDescBuf;
49
50 /* ============================================================================= */
51
52 /* ============================================================================= */
53
54
55 /** jvmtiObjectReferenceCallback for first iteration. */
56 jvmtiIterationControl JNICALL
57 objectReferenceCallback1(jvmtiObjectReferenceKind reference_kind,
58 jlong class_tag,
59 jlong size,
60 jlong* tag_ptr,
61 jlong referrer_tag,
62 jint referrer_index,
63 void* user_data) {
64
65 objectCount++;
66 /* Set tag */
67 *tag_ptr = objectCount;
68
69 if (!NSK_JVMTI_VERIFY(st_jvmti->Allocate((sizeof(ObjectDesc)),
70 (unsigned char**)&objectDescBuf))) {
71 nsk_jvmti_setFailStatus();
72 allocationError = 1;
73 }
74
75 (*objectDescBuf).tag = *tag_ptr;
76 (*objectDescBuf).size = size;
77
78 return JVMTI_ITERATION_ABORT;
79 }
80
81 /** jvmtiObjectReferenceCallback for second iteration. */
82 jvmtiIterationControl JNICALL
83 objectReferenceCallback2(jvmtiObjectReferenceKind reference_kind,
84 jlong class_tag,
85 jlong size,
86 jlong* tag_ptr,
87 jlong referrer_tag,
88 jint referrer_index,
89 void* user_data) {
90
91 objectCount--;
92
93 if (!NSK_JVMTI_VERIFY(st_jvmti->Deallocate((unsigned char*)objectDescBuf))) {
94 nsk_jvmti_setFailStatus();
95 }
96
97 return JVMTI_ITERATION_ABORT;
98 }
99
100 /* ============================================================================= */
101
102 /** Agent algorithm. */
103 static void JNICALL
104 agentProc(jvmtiEnv* jvmti, JNIEnv* jni, void* arg) {
105
106 NSK_DISPLAY0("Wait for debugee start\n");
107 if (!NSK_VERIFY(nsk_jvmti_waitForSync(timeout)))
108 return;
109
|