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 |
35 |
49 typedef struct { |
36 typedef struct { |
210 |
197 |
211 if (options != NULL && strcmp(options, "printdump") == 0) { |
198 if (options != NULL && strcmp(options, "printdump") == 0) { |
212 printdump = JNI_TRUE; |
199 printdump = JNI_TRUE; |
213 } |
200 } |
214 |
201 |
215 res = JNI_ENV_PTR(jvm)->GetEnv(JNI_ENV_ARG(jvm, (void **) &jvmti), |
202 res = jvm->GetEnv((void **) &jvmti, JVMTI_VERSION_1_1); |
216 JVMTI_VERSION_1_1); |
|
217 if (res != JNI_OK || jvmti == NULL) { |
203 if (res != JNI_OK || jvmti == NULL) { |
218 printf("Wrong result of a valid call to GetEnv!\n"); |
204 printf("Wrong result of a valid call to GetEnv!\n"); |
219 return JNI_ERR; |
205 return JNI_ERR; |
220 } |
206 } |
221 |
207 |
277 !caps.can_generate_breakpoint_events || |
263 !caps.can_generate_breakpoint_events || |
278 !caps.can_generate_single_step_events) { |
264 !caps.can_generate_single_step_events) { |
279 return; |
265 return; |
280 } |
266 } |
281 |
267 |
282 clazz = JNI_ENV_PTR(env)->GetObjectClass(JNI_ENV_ARG(env, thr)); |
268 clazz = env->GetObjectClass(thr); |
283 if (clazz == NULL) { |
269 if (clazz == NULL) { |
284 printf("Cannot get class of the thread object\n"); |
270 printf("Cannot get class of the thread object\n"); |
285 result = STATUS_FAILED; |
271 result = STATUS_FAILED; |
286 return; |
272 return; |
287 } |
273 } |
288 |
274 |
289 midD = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), "D", "()V"); |
275 midD = env->GetMethodID(clazz, "D", "()V"); |
290 if (midD == NULL) { |
276 if (midD == NULL) { |
291 printf("Cannot get Method ID for method \"D\"\n"); |
277 printf("Cannot get Method ID for method \"D\"\n"); |
292 result = STATUS_FAILED; |
278 result = STATUS_FAILED; |
293 return; |
279 return; |
294 } |
280 } |
295 |
281 |
296 midRun = JNI_ENV_PTR(env)->GetMethodID(JNI_ENV_ARG(env, clazz), |
282 midRun = env->GetMethodID(clazz, "run", "()V"); |
297 "run", "()V"); |
|
298 if (midRun == NULL) { |
283 if (midRun == NULL) { |
299 printf("Cannot get Method ID for method \"run\"\n"); |
284 printf("Cannot get Method ID for method \"run\"\n"); |
300 result = STATUS_FAILED; |
285 result = STATUS_FAILED; |
301 return; |
286 return; |
302 } |
287 } |