equal
deleted
inserted
replaced
25 #include <string.h> |
25 #include <string.h> |
26 #include "jvmti.h" |
26 #include "jvmti.h" |
27 #include "agent_common.h" |
27 #include "agent_common.h" |
28 #include "JVMTITools.h" |
28 #include "JVMTITools.h" |
29 |
29 |
30 #ifdef __cplusplus |
|
31 extern "C" { |
30 extern "C" { |
32 #endif |
31 |
33 |
|
34 #ifndef JNI_ENV_ARG |
|
35 |
|
36 #ifdef __cplusplus |
|
37 #define JNI_ENV_ARG(x, y) y |
|
38 #define JNI_ENV_PTR(x) x |
|
39 #else |
|
40 #define JNI_ENV_ARG(x,y) x, y |
|
41 #define JNI_ENV_PTR(x) (*x) |
|
42 #endif |
|
43 |
|
44 #endif |
|
45 |
32 |
46 #define PASSED 0 |
33 #define PASSED 0 |
47 #define STATUS_FAILED 2 |
34 #define STATUS_FAILED 2 |
48 #define WAIT_START 100 |
35 #define WAIT_START 100 |
49 |
36 |
100 printf("(GetThreadInfo) unexpected error: %s (%d)\n", |
87 printf("(GetThreadInfo) unexpected error: %s (%d)\n", |
101 TranslateError(err), err); |
88 TranslateError(err), err); |
102 result = STATUS_FAILED; |
89 result = STATUS_FAILED; |
103 } |
90 } |
104 if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) { |
91 if (thrInfo.name != NULL && strcmp(thrInfo.name, "thr1") == 0) { |
105 thr_ptr = JNI_ENV_PTR(env)->NewGlobalRef(JNI_ENV_ARG((JNIEnv *)env, thread)); |
92 thr_ptr = env->NewGlobalRef(thread); |
106 if (printdump == JNI_TRUE) { |
93 if (printdump == JNI_TRUE) { |
107 printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr); |
94 printf(">>> ThreadStart: \"%s\", 0x%p\n", thrInfo.name, thr_ptr); |
108 } |
95 } |
109 } |
96 } |
110 |
97 |
133 |
120 |
134 if (options != NULL && strcmp(options, "printdump") == 0) { |
121 if (options != NULL && strcmp(options, "printdump") == 0) { |
135 printdump = JNI_TRUE; |
122 printdump = JNI_TRUE; |
136 } |
123 } |
137 |
124 |
138 res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
125 res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
139 JVMTI_VERSION_1_1); |
|
140 if (res != JNI_OK || jvmti == NULL) { |
126 if (res != JNI_OK || jvmti == NULL) { |
141 printf("Wrong result of a valid call to GetEnv !\n"); |
127 printf("Wrong result of a valid call to GetEnv !\n"); |
142 return JNI_ERR; |
128 return JNI_ERR; |
143 } |
129 } |
144 |
130 |
374 JNIEXPORT jint JNICALL |
360 JNIEXPORT jint JNICALL |
375 Java_nsk_jvmti_GetThreadState_thrstat002_getRes(JNIEnv *env, jclass cls) { |
361 Java_nsk_jvmti_GetThreadState_thrstat002_getRes(JNIEnv *env, jclass cls) { |
376 return result; |
362 return result; |
377 } |
363 } |
378 |
364 |
379 #ifdef __cplusplus |
365 } |
380 } |
|
381 #endif |
|