blob: ab4a48bcb205cd017f5aa4177693e64b6cf299e3 [file] [log] [blame]
Alex Light49948e92016-08-11 15:35:28 -07001/* Copyright (C) 2016 The Android Open Source Project
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This file implements interfaces from the file jvmti.h. This implementation
5 * is licensed under the same terms as the file jvmti.h. The
6 * copyright and license information for the file jvmti.h follows.
7 *
8 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Oracle designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Oracle in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 * or visit www.oracle.com if you need additional information or have any
29 * questions.
30 */
31
Alex Light9c20a142016-08-23 15:05:12 -070032#include <string>
Andreas Gampef37e3022017-01-13 17:54:46 -080033#include <type_traits>
Alex Light9c20a142016-08-23 15:05:12 -070034#include <vector>
35
Alex Light49948e92016-08-11 15:35:28 -070036#include <jni.h>
Alex Light9c20a142016-08-23 15:05:12 -070037
Alex Light49948e92016-08-11 15:35:28 -070038#include "openjdkjvmti/jvmti.h"
39
Andreas Gampedb6dcb62016-09-13 09:05:59 -070040#include "art_jvmti.h"
Andreas Gampef37e3022017-01-13 17:54:46 -080041#include "base/logging.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070042#include "base/mutex.h"
43#include "events-inl.h"
Alex Light49948e92016-08-11 15:35:28 -070044#include "jni_env_ext-inl.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070045#include "obj_ptr-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080046#include "object_tagging.h"
Alex Light9c20a142016-08-23 15:05:12 -070047#include "runtime.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070048#include "scoped_thread_state_change-inl.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070049#include "thread-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080050#include "thread_list.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070051#include "ti_class.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080052#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070053#include "ti_heap.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070054#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080055#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080056#include "ti_object.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080057#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080058#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080059#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070060#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080061#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000062#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080063#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070064#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070065
66// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
67// easier to create.
68#pragma GCC diagnostic ignored "-Wunused-parameter"
69
70namespace openjdkjvmti {
71
Andreas Gampe77708d92016-10-07 11:48:21 -070072EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070073ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070074
Alex Lighte6574242016-08-17 09:56:24 -070075#define ENSURE_NON_NULL(n) \
76 do { \
77 if ((n) == nullptr) { \
78 return ERR(NULL_POINTER); \
79 } \
80 } while (false)
81
Alex Light49948e92016-08-11 15:35:28 -070082class JvmtiFunctions {
83 private:
84 static bool IsValidEnv(jvmtiEnv* env) {
85 return env != nullptr;
86 }
87
Alex Lighte6574242016-08-17 09:56:24 -070088#define ENSURE_VALID_ENV(env) \
89 do { \
90 if (!IsValidEnv(env)) { \
91 return ERR(INVALID_ENVIRONMENT); \
92 } \
93 } while (false)
94
95#define ENSURE_HAS_CAP(env, cap) \
96 do { \
97 ENSURE_VALID_ENV(env); \
98 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
99 return ERR(MUST_POSSESS_CAPABILITY); \
100 } \
101 } while (false)
102
Alex Light49948e92016-08-11 15:35:28 -0700103 public:
104 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700105 ENSURE_VALID_ENV(env);
106 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700107 if (size < 0) {
108 return ERR(ILLEGAL_ARGUMENT);
109 } else if (size == 0) {
110 *mem_ptr = nullptr;
111 return OK;
112 }
113 *mem_ptr = static_cast<unsigned char*>(malloc(size));
114 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
115 }
116
117 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700118 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700119 if (mem != nullptr) {
120 free(mem);
121 }
122 return OK;
123 }
124
125 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800126 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700127 }
128
129 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800130 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700131 }
132
133 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800134 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700135 }
136
137 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
138 return ERR(NOT_IMPLEMENTED);
139 }
140
141 static jvmtiError SuspendThreadList(jvmtiEnv* env,
142 jint request_count,
143 const jthread* request_list,
144 jvmtiError* results) {
145 return ERR(NOT_IMPLEMENTED);
146 }
147
148 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
149 return ERR(NOT_IMPLEMENTED);
150 }
151
152 static jvmtiError ResumeThreadList(jvmtiEnv* env,
153 jint request_count,
154 const jthread* request_list,
155 jvmtiError* results) {
156 return ERR(NOT_IMPLEMENTED);
157 }
158
159 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
160 return ERR(NOT_IMPLEMENTED);
161 }
162
163 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
164 return ERR(NOT_IMPLEMENTED);
165 }
166
167 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800168 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700169 }
170
171 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
172 jthread thread,
173 jint* owned_monitor_count_ptr,
174 jobject** owned_monitors_ptr) {
175 return ERR(NOT_IMPLEMENTED);
176 }
177
178 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
179 jthread thread,
180 jint* monitor_info_count_ptr,
181 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
182 return ERR(NOT_IMPLEMENTED);
183 }
184
185 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
186 jthread thread,
187 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700188 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700189 }
190
191 static jvmtiError RunAgentThread(jvmtiEnv* env,
192 jthread thread,
193 jvmtiStartFunction proc,
194 const void* arg,
195 jint priority) {
196 return ERR(NOT_IMPLEMENTED);
197 }
198
199 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
200 return ERR(NOT_IMPLEMENTED);
201 }
202
203 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
204 return ERR(NOT_IMPLEMENTED);
205 }
206
207 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
208 jint* group_count_ptr,
209 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000210 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700211 }
212
213 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
214 jthreadGroup group,
215 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000216 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700217 }
218
219 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
220 jthreadGroup group,
221 jint* thread_count_ptr,
222 jthread** threads_ptr,
223 jint* group_count_ptr,
224 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000225 return ThreadGroupUtil::GetThreadGroupChildren(env,
226 group,
227 thread_count_ptr,
228 threads_ptr,
229 group_count_ptr,
230 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700231 }
232
233 static jvmtiError GetStackTrace(jvmtiEnv* env,
234 jthread thread,
235 jint start_depth,
236 jint max_frame_count,
237 jvmtiFrameInfo* frame_buffer,
238 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700239 return StackUtil::GetStackTrace(env,
240 thread,
241 start_depth,
242 max_frame_count,
243 frame_buffer,
244 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700245 }
246
247 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
248 jint max_frame_count,
249 jvmtiStackInfo** stack_info_ptr,
250 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800251 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700252 }
253
254 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
255 jint thread_count,
256 const jthread* thread_list,
257 jint max_frame_count,
258 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800259 return StackUtil::GetThreadListStackTraces(env,
260 thread_count,
261 thread_list,
262 max_frame_count,
263 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700264 }
265
266 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800267 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700268 }
269
270 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
271 return ERR(NOT_IMPLEMENTED);
272 }
273
274 static jvmtiError GetFrameLocation(jvmtiEnv* env,
275 jthread thread,
276 jint depth,
277 jmethodID* method_ptr,
278 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800279 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700280 }
281
282 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
283 return ERR(NOT_IMPLEMENTED);
284 }
285
286 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
287 return ERR(NOT_IMPLEMENTED);
288 }
289
290 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
291 return ERR(NOT_IMPLEMENTED);
292 }
293
294 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
295 return ERR(NOT_IMPLEMENTED);
296 }
297
298 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
299 return ERR(NOT_IMPLEMENTED);
300 }
301
302 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
303 return ERR(NOT_IMPLEMENTED);
304 }
305
306 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
307 return ERR(NOT_IMPLEMENTED);
308 }
309
310 static jvmtiError FollowReferences(jvmtiEnv* env,
311 jint heap_filter,
312 jclass klass,
313 jobject initial_object,
314 const jvmtiHeapCallbacks* callbacks,
315 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700316 HeapUtil heap_util(&gObjectTagTable);
317 return heap_util.FollowReferences(env,
318 heap_filter,
319 klass,
320 initial_object,
321 callbacks,
322 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700323 }
324
325 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
326 jint heap_filter,
327 jclass klass,
328 const jvmtiHeapCallbacks* callbacks,
329 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700330 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700331 HeapUtil heap_util(&gObjectTagTable);
332 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700333 }
334
335 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700336 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700337
338 JNIEnv* jni_env = GetJniEnv(env);
339 if (jni_env == nullptr) {
340 return ERR(INTERNAL);
341 }
342
343 art::ScopedObjectAccess soa(jni_env);
344 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
345 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
346 *tag_ptr = 0;
347 }
348
349 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700350 }
351
352 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700353 ENSURE_HAS_CAP(env, can_tag_objects);
354
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700355 if (object == nullptr) {
356 return ERR(NULL_POINTER);
357 }
358
359 JNIEnv* jni_env = GetJniEnv(env);
360 if (jni_env == nullptr) {
361 return ERR(INTERNAL);
362 }
363
364 art::ScopedObjectAccess soa(jni_env);
365 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700366 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700367
368 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700369 }
370
371 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
372 jint tag_count,
373 const jlong* tags,
374 jint* count_ptr,
375 jobject** object_result_ptr,
376 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700377 ENSURE_HAS_CAP(env, can_tag_objects);
378
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700379 JNIEnv* jni_env = GetJniEnv(env);
380 if (jni_env == nullptr) {
381 return ERR(INTERNAL);
382 }
383
384 art::ScopedObjectAccess soa(jni_env);
385 return gObjectTagTable.GetTaggedObjects(env,
386 tag_count,
387 tags,
388 count_ptr,
389 object_result_ptr,
390 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700391 }
392
393 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700394 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700395 }
396
397 static jvmtiError IterateOverObjectsReachableFromObject(
398 jvmtiEnv* env,
399 jobject object,
400 jvmtiObjectReferenceCallback object_reference_callback,
401 const void* user_data) {
402 return ERR(NOT_IMPLEMENTED);
403 }
404
405 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
406 jvmtiHeapRootCallback heap_root_callback,
407 jvmtiStackReferenceCallback stack_ref_callback,
408 jvmtiObjectReferenceCallback object_ref_callback,
409 const void* user_data) {
410 return ERR(NOT_IMPLEMENTED);
411 }
412
413 static jvmtiError IterateOverHeap(jvmtiEnv* env,
414 jvmtiHeapObjectFilter object_filter,
415 jvmtiHeapObjectCallback heap_object_callback,
416 const void* user_data) {
417 return ERR(NOT_IMPLEMENTED);
418 }
419
420 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
421 jclass klass,
422 jvmtiHeapObjectFilter object_filter,
423 jvmtiHeapObjectCallback heap_object_callback,
424 const void* user_data) {
425 return ERR(NOT_IMPLEMENTED);
426 }
427
428 static jvmtiError GetLocalObject(jvmtiEnv* env,
429 jthread thread,
430 jint depth,
431 jint slot,
432 jobject* value_ptr) {
433 return ERR(NOT_IMPLEMENTED);
434 }
435
436 static jvmtiError GetLocalInstance(jvmtiEnv* env,
437 jthread thread,
438 jint depth,
439 jobject* value_ptr) {
440 return ERR(NOT_IMPLEMENTED);
441 }
442
443 static jvmtiError GetLocalInt(jvmtiEnv* env,
444 jthread thread,
445 jint depth,
446 jint slot,
447 jint* value_ptr) {
448 return ERR(NOT_IMPLEMENTED);
449 }
450
451 static jvmtiError GetLocalLong(jvmtiEnv* env,
452 jthread thread,
453 jint depth,
454 jint slot,
455 jlong* value_ptr) {
456 return ERR(NOT_IMPLEMENTED);
457 }
458
459 static jvmtiError GetLocalFloat(jvmtiEnv* env,
460 jthread thread,
461 jint depth,
462 jint slot,
463 jfloat* value_ptr) {
464 return ERR(NOT_IMPLEMENTED);
465 }
466
467 static jvmtiError GetLocalDouble(jvmtiEnv* env,
468 jthread thread,
469 jint depth,
470 jint slot,
471 jdouble* value_ptr) {
472 return ERR(NOT_IMPLEMENTED);
473 }
474
475 static jvmtiError SetLocalObject(jvmtiEnv* env,
476 jthread thread,
477 jint depth,
478 jint slot,
479 jobject value) {
480 return ERR(NOT_IMPLEMENTED);
481 }
482
483 static jvmtiError SetLocalInt(jvmtiEnv* env,
484 jthread thread,
485 jint depth,
486 jint slot,
487 jint value) {
488 return ERR(NOT_IMPLEMENTED);
489 }
490
491 static jvmtiError SetLocalLong(jvmtiEnv* env,
492 jthread thread,
493 jint depth,
494 jint slot,
495 jlong value) {
496 return ERR(NOT_IMPLEMENTED);
497 }
498
499 static jvmtiError SetLocalFloat(jvmtiEnv* env,
500 jthread thread,
501 jint depth,
502 jint slot,
503 jfloat value) {
504 return ERR(NOT_IMPLEMENTED);
505 }
506
507 static jvmtiError SetLocalDouble(jvmtiEnv* env,
508 jthread thread,
509 jint depth,
510 jint slot,
511 jdouble value) {
512 return ERR(NOT_IMPLEMENTED);
513 }
514
515 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
516 return ERR(NOT_IMPLEMENTED);
517 }
518
519 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
520 return ERR(NOT_IMPLEMENTED);
521 }
522
523 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
524 return ERR(NOT_IMPLEMENTED);
525 }
526
527 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
528 return ERR(NOT_IMPLEMENTED);
529 }
530
531 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
532 return ERR(NOT_IMPLEMENTED);
533 }
534
535 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
536 return ERR(NOT_IMPLEMENTED);
537 }
538
539 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700540 HeapUtil heap_util(&gObjectTagTable);
541 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700542 }
543
544 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
545 jobject initiating_loader,
546 jint* class_count_ptr,
547 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800548 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700549 }
550
551 static jvmtiError GetClassSignature(jvmtiEnv* env,
552 jclass klass,
553 char** signature_ptr,
554 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700555 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700556 }
557
558 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800559 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700560 }
561
562 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
563 return ERR(NOT_IMPLEMENTED);
564 }
565
566 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800567 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700568 }
569
570 static jvmtiError GetClassMethods(jvmtiEnv* env,
571 jclass klass,
572 jint* method_count_ptr,
573 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800574 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700575 }
576
577 static jvmtiError GetClassFields(jvmtiEnv* env,
578 jclass klass,
579 jint* field_count_ptr,
580 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800581 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700582 }
583
584 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
585 jclass klass,
586 jint* interface_count_ptr,
587 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800588 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700589 }
590
591 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
592 jclass klass,
593 jint* minor_version_ptr,
594 jint* major_version_ptr) {
595 return ERR(NOT_IMPLEMENTED);
596 }
597
598 static jvmtiError GetConstantPool(jvmtiEnv* env,
599 jclass klass,
600 jint* constant_pool_count_ptr,
601 jint* constant_pool_byte_count_ptr,
602 unsigned char** constant_pool_bytes_ptr) {
603 return ERR(NOT_IMPLEMENTED);
604 }
605
606 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800607 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700608 }
609
610 static jvmtiError IsArrayClass(jvmtiEnv* env,
611 jclass klass,
612 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800613 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700614 }
615
616 static jvmtiError IsModifiableClass(jvmtiEnv* env,
617 jclass klass,
618 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800619 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700620 }
621
622 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800623 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700624 }
625
626 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
627 jclass klass,
628 char** source_debug_extension_ptr) {
629 return ERR(NOT_IMPLEMENTED);
630 }
631
632 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
633 return ERR(NOT_IMPLEMENTED);
634 }
635
636 static jvmtiError RedefineClasses(jvmtiEnv* env,
637 jint class_count,
638 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800639 std::string error_msg;
640 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
641 art::Runtime::Current(),
642 art::Thread::Current(),
643 class_count,
644 class_definitions,
645 &error_msg);
646 if (res != OK) {
647 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
648 }
649 return res;
Alex Light49948e92016-08-11 15:35:28 -0700650 }
651
652 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800653 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700654 }
655
656 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800657 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700658 }
659
660 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
661 jobject object,
662 jvmtiMonitorUsage* info_ptr) {
663 return ERR(NOT_IMPLEMENTED);
664 }
665
666 static jvmtiError GetFieldName(jvmtiEnv* env,
667 jclass klass,
668 jfieldID field,
669 char** name_ptr,
670 char** signature_ptr,
671 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800672 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700673 }
674
675 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
676 jclass klass,
677 jfieldID field,
678 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800679 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700680 }
681
682 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
683 jclass klass,
684 jfieldID field,
685 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800686 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700687 }
688
689 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
690 jclass klass,
691 jfieldID field,
692 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800693 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700694 }
695
696 static jvmtiError GetMethodName(jvmtiEnv* env,
697 jmethodID method,
698 char** name_ptr,
699 char** signature_ptr,
700 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700701 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700702 }
703
704 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
705 jmethodID method,
706 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700707 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700708 }
709
710 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
711 jmethodID method,
712 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700713 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700714 }
715
716 static jvmtiError GetMaxLocals(jvmtiEnv* env,
717 jmethodID method,
718 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800719 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700720 }
721
722 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
723 jmethodID method,
724 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800725 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700726 }
727
728 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
729 jmethodID method,
730 jint* entry_count_ptr,
731 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800732 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700733 }
734
735 static jvmtiError GetMethodLocation(jvmtiEnv* env,
736 jmethodID method,
737 jlocation* start_location_ptr,
738 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800739 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700740 }
741
742 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
743 jmethodID method,
744 jint* entry_count_ptr,
745 jvmtiLocalVariableEntry** table_ptr) {
746 return ERR(NOT_IMPLEMENTED);
747 }
748
749 static jvmtiError GetBytecodes(jvmtiEnv* env,
750 jmethodID method,
751 jint* bytecode_count_ptr,
752 unsigned char** bytecodes_ptr) {
753 return ERR(NOT_IMPLEMENTED);
754 }
755
756 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800757 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700758 }
759
760 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800761 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700762 }
763
764 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800765 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700766 }
767
768 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
769 return ERR(NOT_IMPLEMENTED);
770 }
771
772 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
773 return ERR(NOT_IMPLEMENTED);
774 }
775
776 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800777 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700778 }
779
780 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800781 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700782 }
783
784 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800785 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700786 }
787
788 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800789 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700790 }
791
792 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800793 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700794 }
795
796 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800797 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700798 }
799
800 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800801 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700802 }
803
804 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
805 return ERR(NOT_IMPLEMENTED);
806 }
807
808 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
809 return ERR(NOT_IMPLEMENTED);
810 }
811
Andreas Gampe77708d92016-10-07 11:48:21 -0700812 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
813 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700814 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
815 const jvmtiEventCallbacks* callbacks,
816 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700817 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700818 if (size_of_callbacks < 0) {
819 return ERR(ILLEGAL_ARGUMENT);
820 }
821
822 if (callbacks == nullptr) {
823 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
824 return ERR(NONE);
825 }
826
827 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
828 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
829 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
830 static_cast<size_t>(size_of_callbacks));
831 copy_size = art::RoundDown(copy_size, sizeof(void*));
832 memcpy(tmp.get(), callbacks, copy_size);
833
834 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
835
836 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700837 }
838
839 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
840 jvmtiEventMode mode,
841 jvmtiEvent event_type,
842 jthread event_thread,
843 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700844 ENSURE_VALID_ENV(env);
845 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700846 art::Thread* art_thread = nullptr;
847 if (event_thread != nullptr) {
848 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
849 art::ScopedObjectAccess soa(art::Thread::Current());
850 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
851 art_thread = art::Thread::FromManagedThread(soa, event_thread);
852
853 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
854 art_thread->IsStillStarting()) {
855 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
856 return ERR(THREAD_NOT_ALIVE);
857 }
858 }
859
860 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700861 }
862
863 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
864 return ERR(NOT_IMPLEMENTED);
865 }
866
867 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
868 jint* extension_count_ptr,
869 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800870 // We do not have any extension functions.
871 *extension_count_ptr = 0;
872 *extensions = nullptr;
873
874 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700875 }
876
877 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
878 jint* extension_count_ptr,
879 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800880 // We do not have any extension events.
881 *extension_count_ptr = 0;
882 *extensions = nullptr;
883
884 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700885 }
886
887 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
888 jint extension_event_index,
889 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800890 // We do not have any extension events, so any call is illegal.
891 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700892 }
893
894 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700895 ENSURE_VALID_ENV(env);
896 ENSURE_NON_NULL(capabilities_ptr);
897 *capabilities_ptr = kPotentialCapabilities;
898 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700899 }
900
901 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700902 ENSURE_VALID_ENV(env);
903 ENSURE_NON_NULL(capabilities_ptr);
904 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
905 jvmtiError ret = OK;
906#define ADD_CAPABILITY(e) \
907 do { \
908 if (capabilities_ptr->e == 1) { \
909 if (kPotentialCapabilities.e == 1) { \
910 art_env->capabilities.e = 1;\
911 } else { \
912 ret = ERR(NOT_AVAILABLE); \
913 } \
914 } \
915 } while (false)
916
917 ADD_CAPABILITY(can_tag_objects);
918 ADD_CAPABILITY(can_generate_field_modification_events);
919 ADD_CAPABILITY(can_generate_field_access_events);
920 ADD_CAPABILITY(can_get_bytecodes);
921 ADD_CAPABILITY(can_get_synthetic_attribute);
922 ADD_CAPABILITY(can_get_owned_monitor_info);
923 ADD_CAPABILITY(can_get_current_contended_monitor);
924 ADD_CAPABILITY(can_get_monitor_info);
925 ADD_CAPABILITY(can_pop_frame);
926 ADD_CAPABILITY(can_redefine_classes);
927 ADD_CAPABILITY(can_signal_thread);
928 ADD_CAPABILITY(can_get_source_file_name);
929 ADD_CAPABILITY(can_get_line_numbers);
930 ADD_CAPABILITY(can_get_source_debug_extension);
931 ADD_CAPABILITY(can_access_local_variables);
932 ADD_CAPABILITY(can_maintain_original_method_order);
933 ADD_CAPABILITY(can_generate_single_step_events);
934 ADD_CAPABILITY(can_generate_exception_events);
935 ADD_CAPABILITY(can_generate_frame_pop_events);
936 ADD_CAPABILITY(can_generate_breakpoint_events);
937 ADD_CAPABILITY(can_suspend);
938 ADD_CAPABILITY(can_redefine_any_class);
939 ADD_CAPABILITY(can_get_current_thread_cpu_time);
940 ADD_CAPABILITY(can_get_thread_cpu_time);
941 ADD_CAPABILITY(can_generate_method_entry_events);
942 ADD_CAPABILITY(can_generate_method_exit_events);
943 ADD_CAPABILITY(can_generate_all_class_hook_events);
944 ADD_CAPABILITY(can_generate_compiled_method_load_events);
945 ADD_CAPABILITY(can_generate_monitor_events);
946 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
947 ADD_CAPABILITY(can_generate_native_method_bind_events);
948 ADD_CAPABILITY(can_generate_garbage_collection_events);
949 ADD_CAPABILITY(can_generate_object_free_events);
950 ADD_CAPABILITY(can_force_early_return);
951 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
952 ADD_CAPABILITY(can_get_constant_pool);
953 ADD_CAPABILITY(can_set_native_method_prefix);
954 ADD_CAPABILITY(can_retransform_classes);
955 ADD_CAPABILITY(can_retransform_any_class);
956 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
957 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
958#undef ADD_CAPABILITY
959 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700960 }
961
962 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
963 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700964 ENSURE_VALID_ENV(env);
965 ENSURE_NON_NULL(capabilities_ptr);
966 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
967#define DEL_CAPABILITY(e) \
968 do { \
969 if (capabilities_ptr->e == 1) { \
970 art_env->capabilities.e = 0;\
971 } \
972 } while (false)
973
974 DEL_CAPABILITY(can_tag_objects);
975 DEL_CAPABILITY(can_generate_field_modification_events);
976 DEL_CAPABILITY(can_generate_field_access_events);
977 DEL_CAPABILITY(can_get_bytecodes);
978 DEL_CAPABILITY(can_get_synthetic_attribute);
979 DEL_CAPABILITY(can_get_owned_monitor_info);
980 DEL_CAPABILITY(can_get_current_contended_monitor);
981 DEL_CAPABILITY(can_get_monitor_info);
982 DEL_CAPABILITY(can_pop_frame);
983 DEL_CAPABILITY(can_redefine_classes);
984 DEL_CAPABILITY(can_signal_thread);
985 DEL_CAPABILITY(can_get_source_file_name);
986 DEL_CAPABILITY(can_get_line_numbers);
987 DEL_CAPABILITY(can_get_source_debug_extension);
988 DEL_CAPABILITY(can_access_local_variables);
989 DEL_CAPABILITY(can_maintain_original_method_order);
990 DEL_CAPABILITY(can_generate_single_step_events);
991 DEL_CAPABILITY(can_generate_exception_events);
992 DEL_CAPABILITY(can_generate_frame_pop_events);
993 DEL_CAPABILITY(can_generate_breakpoint_events);
994 DEL_CAPABILITY(can_suspend);
995 DEL_CAPABILITY(can_redefine_any_class);
996 DEL_CAPABILITY(can_get_current_thread_cpu_time);
997 DEL_CAPABILITY(can_get_thread_cpu_time);
998 DEL_CAPABILITY(can_generate_method_entry_events);
999 DEL_CAPABILITY(can_generate_method_exit_events);
1000 DEL_CAPABILITY(can_generate_all_class_hook_events);
1001 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1002 DEL_CAPABILITY(can_generate_monitor_events);
1003 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1004 DEL_CAPABILITY(can_generate_native_method_bind_events);
1005 DEL_CAPABILITY(can_generate_garbage_collection_events);
1006 DEL_CAPABILITY(can_generate_object_free_events);
1007 DEL_CAPABILITY(can_force_early_return);
1008 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1009 DEL_CAPABILITY(can_get_constant_pool);
1010 DEL_CAPABILITY(can_set_native_method_prefix);
1011 DEL_CAPABILITY(can_retransform_classes);
1012 DEL_CAPABILITY(can_retransform_any_class);
1013 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1014 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1015#undef DEL_CAPABILITY
1016 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001017 }
1018
1019 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001020 ENSURE_VALID_ENV(env);
1021 ENSURE_NON_NULL(capabilities_ptr);
1022 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1023 *capabilities_ptr = artenv->capabilities;
1024 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001025 }
1026
1027 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1028 return ERR(NOT_IMPLEMENTED);
1029 }
1030
1031 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1032 return ERR(NOT_IMPLEMENTED);
1033 }
1034
1035 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1036 return ERR(NOT_IMPLEMENTED);
1037 }
1038
1039 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1040 return ERR(NOT_IMPLEMENTED);
1041 }
1042
1043 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001044 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001045 }
1046
1047 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001048 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001049 }
1050
1051 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001052 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001053 }
1054
1055 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001056 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001057 }
1058
1059 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001060 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001061 }
1062
1063 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001064 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001065 }
1066
1067 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001068 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001069 }
1070
1071 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001072 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001073 }
1074
1075 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1076 return ERR(NOT_IMPLEMENTED);
1077 }
1078
1079 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001080 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001081 delete env;
1082 return OK;
1083 }
1084
1085 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001086 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001087 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1088 return OK;
1089 }
1090
1091 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001092 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001093 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1094 return OK;
1095 }
1096
1097 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001098 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001099 *version_ptr = JVMTI_VERSION;
1100 return OK;
1101 }
1102
1103 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001104 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001105 switch (error) {
1106#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001107 jvmtiError res = CopyString(env, \
1108 "JVMTI_ERROR_"#e, \
1109 reinterpret_cast<unsigned char**>(name_ptr)); \
1110 if (res != OK) { \
1111 *name_ptr = nullptr; \
1112 return res; \
1113 } else { \
1114 return OK; \
1115 } \
Alex Light49948e92016-08-11 15:35:28 -07001116 } while (false)
1117 ERROR_CASE(NONE);
1118 ERROR_CASE(INVALID_THREAD);
1119 ERROR_CASE(INVALID_THREAD_GROUP);
1120 ERROR_CASE(INVALID_PRIORITY);
1121 ERROR_CASE(THREAD_NOT_SUSPENDED);
1122 ERROR_CASE(THREAD_NOT_ALIVE);
1123 ERROR_CASE(INVALID_OBJECT);
1124 ERROR_CASE(INVALID_CLASS);
1125 ERROR_CASE(CLASS_NOT_PREPARED);
1126 ERROR_CASE(INVALID_METHODID);
1127 ERROR_CASE(INVALID_LOCATION);
1128 ERROR_CASE(INVALID_FIELDID);
1129 ERROR_CASE(NO_MORE_FRAMES);
1130 ERROR_CASE(OPAQUE_FRAME);
1131 ERROR_CASE(TYPE_MISMATCH);
1132 ERROR_CASE(INVALID_SLOT);
1133 ERROR_CASE(DUPLICATE);
1134 ERROR_CASE(NOT_FOUND);
1135 ERROR_CASE(INVALID_MONITOR);
1136 ERROR_CASE(NOT_MONITOR_OWNER);
1137 ERROR_CASE(INTERRUPT);
1138 ERROR_CASE(INVALID_CLASS_FORMAT);
1139 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1140 ERROR_CASE(FAILS_VERIFICATION);
1141 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1142 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1143 ERROR_CASE(INVALID_TYPESTATE);
1144 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1145 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1146 ERROR_CASE(UNSUPPORTED_VERSION);
1147 ERROR_CASE(NAMES_DONT_MATCH);
1148 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1149 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1150 ERROR_CASE(UNMODIFIABLE_CLASS);
1151 ERROR_CASE(NOT_AVAILABLE);
1152 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1153 ERROR_CASE(NULL_POINTER);
1154 ERROR_CASE(ABSENT_INFORMATION);
1155 ERROR_CASE(INVALID_EVENT_TYPE);
1156 ERROR_CASE(ILLEGAL_ARGUMENT);
1157 ERROR_CASE(NATIVE_METHOD);
1158 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1159 ERROR_CASE(OUT_OF_MEMORY);
1160 ERROR_CASE(ACCESS_DENIED);
1161 ERROR_CASE(WRONG_PHASE);
1162 ERROR_CASE(INTERNAL);
1163 ERROR_CASE(UNATTACHED_THREAD);
1164 ERROR_CASE(INVALID_ENVIRONMENT);
1165#undef ERROR_CASE
1166 default: {
Alex Light41960712017-01-06 14:44:23 -08001167 jvmtiError res = CopyString(env,
1168 "JVMTI_ERROR_UNKNOWN",
1169 reinterpret_cast<unsigned char**>(name_ptr));
1170 if (res != OK) {
1171 *name_ptr = nullptr;
1172 return res;
1173 } else {
1174 return ERR(ILLEGAL_ARGUMENT);
1175 }
Alex Light49948e92016-08-11 15:35:28 -07001176 }
1177 }
1178 }
1179
1180 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001181 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1182 // OTHER is special, as it's 0, so can't do a bit check.
1183 bool val = (value == JNI_TRUE) ? true : false;
1184
1185 art::gLogVerbosity.collector = val;
1186 art::gLogVerbosity.compiler = val;
1187 art::gLogVerbosity.deopt = val;
1188 art::gLogVerbosity.heap = val;
1189 art::gLogVerbosity.jdwp = val;
1190 art::gLogVerbosity.jit = val;
1191 art::gLogVerbosity.monitor = val;
1192 art::gLogVerbosity.oat = val;
1193 art::gLogVerbosity.profiler = val;
1194 art::gLogVerbosity.signals = val;
1195 art::gLogVerbosity.simulator = val;
1196 art::gLogVerbosity.startup = val;
1197 art::gLogVerbosity.third_party_jni = val;
1198 art::gLogVerbosity.threads = val;
1199 art::gLogVerbosity.verifier = val;
1200 art::gLogVerbosity.image = val;
1201
1202 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1203
1204 art::gLogVerbosity.agents = val;
1205 } else {
1206 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1207 // semantics.
1208 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1209 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1210 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1211 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1212 if ((flag & ~kMask) != 0) {
1213 return ERR(ILLEGAL_ARGUMENT);
1214 }
1215
1216 bool val = (value == JNI_TRUE) ? true : false;
1217
1218 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1219 art::gLogVerbosity.gc = val;
1220 }
1221
1222 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1223 art::gLogVerbosity.class_linker = val;
1224 }
1225
1226 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1227 art::gLogVerbosity.jni = val;
1228 }
1229 }
1230
1231 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001232 }
1233
1234 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
Andreas Gampeacfc9572017-01-17 18:36:56 -08001235 // Report BCI as jlocation format. We report dex bytecode indices.
1236 if (format_ptr == nullptr) {
1237 return ERR(NULL_POINTER);
1238 }
1239 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1240 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001241 }
Alex Light9c20a142016-08-23 15:05:12 -07001242
1243 // TODO Remove this once events are working.
1244 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1245 jclass klass,
1246 jvmtiEventClassFileLoadHook hook) {
1247 std::vector<jclass> classes;
1248 classes.push_back(klass);
1249 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1250 }
1251
1252 // TODO This will be called by the event handler for the art::ti Event Load Event
1253 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1254 const std::vector<jclass>& classes,
1255 jvmtiEventClassFileLoadHook hook) {
1256 if (!IsValidEnv(env)) {
1257 return ERR(INVALID_ENVIRONMENT);
1258 }
Alex Lighta01de592016-11-15 10:43:06 -08001259 jvmtiError res = OK;
1260 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001261 for (jclass klass : classes) {
1262 JNIEnv* jni_env = nullptr;
1263 jobject loader = nullptr;
1264 std::string name;
1265 jobject protection_domain = nullptr;
1266 jint data_len = 0;
1267 unsigned char* dex_data = nullptr;
1268 jvmtiError ret = OK;
1269 std::string location;
1270 if ((ret = GetTransformationData(env,
1271 klass,
1272 /*out*/&location,
1273 /*out*/&jni_env,
1274 /*out*/&loader,
1275 /*out*/&name,
1276 /*out*/&protection_domain,
1277 /*out*/&data_len,
1278 /*out*/&dex_data)) != OK) {
1279 // TODO Do something more here? Maybe give log statements?
1280 return ret;
1281 }
1282 jint new_data_len = 0;
1283 unsigned char* new_dex_data = nullptr;
1284 hook(env,
1285 jni_env,
1286 klass,
1287 loader,
1288 name.c_str(),
1289 protection_domain,
1290 data_len,
1291 dex_data,
1292 /*out*/&new_data_len,
1293 /*out*/&new_dex_data);
1294 // Check if anything actually changed.
1295 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001296 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1297 res = Redefiner::RedefineClasses(env,
1298 art::Runtime::Current(),
1299 art::Thread::Current(),
1300 1,
1301 &def,
1302 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001303 env->Deallocate(new_dex_data);
1304 }
1305 // Deallocate the old dex data.
1306 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001307 if (res != OK) {
1308 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1309 return res;
1310 }
Alex Light9c20a142016-08-23 15:05:12 -07001311 }
1312 return OK;
1313 }
Alex Light49948e92016-08-11 15:35:28 -07001314};
1315
1316static bool IsJvmtiVersion(jint version) {
1317 return version == JVMTI_VERSION_1 ||
1318 version == JVMTI_VERSION_1_0 ||
1319 version == JVMTI_VERSION_1_1 ||
1320 version == JVMTI_VERSION_1_2 ||
1321 version == JVMTI_VERSION;
1322}
1323
1324// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1325// is a pointer to the uninitialized memory for an art::ti::Env.
1326static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1327 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1328 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001329
1330 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001331}
1332
1333// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1334// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1335// returns false and does not modify the 'env' pointer.
1336static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1337 if (IsJvmtiVersion(version)) {
1338 CreateArtJvmTiEnv(vm, env);
1339 return JNI_OK;
1340 } else {
1341 printf("version 0x%x is not valid!", version);
1342 return JNI_EVERSION;
1343 }
1344}
1345
1346// The plugin initialization function. This adds the jvmti environment.
1347extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001348 art::Runtime* runtime = art::Runtime::Current();
1349 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1350 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001351 return true;
1352}
1353
1354// The actual struct holding all of the entrypoints into the jvmti interface.
1355const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001356 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1357 // TODO Remove once we have events working.
1358 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1359 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001360 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001361 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001362 JvmtiFunctions::GetAllThreads,
1363 JvmtiFunctions::SuspendThread,
1364 JvmtiFunctions::ResumeThread,
1365 JvmtiFunctions::StopThread,
1366 JvmtiFunctions::InterruptThread,
1367 JvmtiFunctions::GetThreadInfo,
1368 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1369 JvmtiFunctions::GetCurrentContendedMonitor,
1370 JvmtiFunctions::RunAgentThread,
1371 JvmtiFunctions::GetTopThreadGroups,
1372 JvmtiFunctions::GetThreadGroupInfo,
1373 JvmtiFunctions::GetThreadGroupChildren,
1374 JvmtiFunctions::GetFrameCount,
1375 JvmtiFunctions::GetThreadState,
1376 JvmtiFunctions::GetCurrentThread,
1377 JvmtiFunctions::GetFrameLocation,
1378 JvmtiFunctions::NotifyFramePop, // 20
1379 JvmtiFunctions::GetLocalObject,
1380 JvmtiFunctions::GetLocalInt,
1381 JvmtiFunctions::GetLocalLong,
1382 JvmtiFunctions::GetLocalFloat,
1383 JvmtiFunctions::GetLocalDouble,
1384 JvmtiFunctions::SetLocalObject,
1385 JvmtiFunctions::SetLocalInt,
1386 JvmtiFunctions::SetLocalLong,
1387 JvmtiFunctions::SetLocalFloat,
1388 JvmtiFunctions::SetLocalDouble, // 30
1389 JvmtiFunctions::CreateRawMonitor,
1390 JvmtiFunctions::DestroyRawMonitor,
1391 JvmtiFunctions::RawMonitorEnter,
1392 JvmtiFunctions::RawMonitorExit,
1393 JvmtiFunctions::RawMonitorWait,
1394 JvmtiFunctions::RawMonitorNotify,
1395 JvmtiFunctions::RawMonitorNotifyAll,
1396 JvmtiFunctions::SetBreakpoint,
1397 JvmtiFunctions::ClearBreakpoint,
1398 nullptr, // reserved40
1399 JvmtiFunctions::SetFieldAccessWatch,
1400 JvmtiFunctions::ClearFieldAccessWatch,
1401 JvmtiFunctions::SetFieldModificationWatch,
1402 JvmtiFunctions::ClearFieldModificationWatch,
1403 JvmtiFunctions::IsModifiableClass,
1404 JvmtiFunctions::Allocate,
1405 JvmtiFunctions::Deallocate,
1406 JvmtiFunctions::GetClassSignature,
1407 JvmtiFunctions::GetClassStatus,
1408 JvmtiFunctions::GetSourceFileName, // 50
1409 JvmtiFunctions::GetClassModifiers,
1410 JvmtiFunctions::GetClassMethods,
1411 JvmtiFunctions::GetClassFields,
1412 JvmtiFunctions::GetImplementedInterfaces,
1413 JvmtiFunctions::IsInterface,
1414 JvmtiFunctions::IsArrayClass,
1415 JvmtiFunctions::GetClassLoader,
1416 JvmtiFunctions::GetObjectHashCode,
1417 JvmtiFunctions::GetObjectMonitorUsage,
1418 JvmtiFunctions::GetFieldName, // 60
1419 JvmtiFunctions::GetFieldDeclaringClass,
1420 JvmtiFunctions::GetFieldModifiers,
1421 JvmtiFunctions::IsFieldSynthetic,
1422 JvmtiFunctions::GetMethodName,
1423 JvmtiFunctions::GetMethodDeclaringClass,
1424 JvmtiFunctions::GetMethodModifiers,
1425 nullptr, // reserved67
1426 JvmtiFunctions::GetMaxLocals,
1427 JvmtiFunctions::GetArgumentsSize,
1428 JvmtiFunctions::GetLineNumberTable, // 70
1429 JvmtiFunctions::GetMethodLocation,
1430 JvmtiFunctions::GetLocalVariableTable,
1431 JvmtiFunctions::SetNativeMethodPrefix,
1432 JvmtiFunctions::SetNativeMethodPrefixes,
1433 JvmtiFunctions::GetBytecodes,
1434 JvmtiFunctions::IsMethodNative,
1435 JvmtiFunctions::IsMethodSynthetic,
1436 JvmtiFunctions::GetLoadedClasses,
1437 JvmtiFunctions::GetClassLoaderClasses,
1438 JvmtiFunctions::PopFrame, // 80
1439 JvmtiFunctions::ForceEarlyReturnObject,
1440 JvmtiFunctions::ForceEarlyReturnInt,
1441 JvmtiFunctions::ForceEarlyReturnLong,
1442 JvmtiFunctions::ForceEarlyReturnFloat,
1443 JvmtiFunctions::ForceEarlyReturnDouble,
1444 JvmtiFunctions::ForceEarlyReturnVoid,
1445 JvmtiFunctions::RedefineClasses,
1446 JvmtiFunctions::GetVersionNumber,
1447 JvmtiFunctions::GetCapabilities,
1448 JvmtiFunctions::GetSourceDebugExtension, // 90
1449 JvmtiFunctions::IsMethodObsolete,
1450 JvmtiFunctions::SuspendThreadList,
1451 JvmtiFunctions::ResumeThreadList,
1452 nullptr, // reserved94
1453 nullptr, // reserved95
1454 nullptr, // reserved96
1455 nullptr, // reserved97
1456 nullptr, // reserved98
1457 nullptr, // reserved99
1458 JvmtiFunctions::GetAllStackTraces, // 100
1459 JvmtiFunctions::GetThreadListStackTraces,
1460 JvmtiFunctions::GetThreadLocalStorage,
1461 JvmtiFunctions::SetThreadLocalStorage,
1462 JvmtiFunctions::GetStackTrace,
1463 nullptr, // reserved105
1464 JvmtiFunctions::GetTag,
1465 JvmtiFunctions::SetTag,
1466 JvmtiFunctions::ForceGarbageCollection,
1467 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1468 JvmtiFunctions::IterateOverReachableObjects, // 110
1469 JvmtiFunctions::IterateOverHeap,
1470 JvmtiFunctions::IterateOverInstancesOfClass,
1471 nullptr, // reserved113
1472 JvmtiFunctions::GetObjectsWithTags,
1473 JvmtiFunctions::FollowReferences,
1474 JvmtiFunctions::IterateThroughHeap,
1475 nullptr, // reserved117
1476 nullptr, // reserved118
1477 nullptr, // reserved119
1478 JvmtiFunctions::SetJNIFunctionTable, // 120
1479 JvmtiFunctions::GetJNIFunctionTable,
1480 JvmtiFunctions::SetEventCallbacks,
1481 JvmtiFunctions::GenerateEvents,
1482 JvmtiFunctions::GetExtensionFunctions,
1483 JvmtiFunctions::GetExtensionEvents,
1484 JvmtiFunctions::SetExtensionEventCallback,
1485 JvmtiFunctions::DisposeEnvironment,
1486 JvmtiFunctions::GetErrorName,
1487 JvmtiFunctions::GetJLocationFormat,
1488 JvmtiFunctions::GetSystemProperties, // 130
1489 JvmtiFunctions::GetSystemProperty,
1490 JvmtiFunctions::SetSystemProperty,
1491 JvmtiFunctions::GetPhase,
1492 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1493 JvmtiFunctions::GetCurrentThreadCpuTime,
1494 JvmtiFunctions::GetThreadCpuTimerInfo,
1495 JvmtiFunctions::GetThreadCpuTime,
1496 JvmtiFunctions::GetTimerInfo,
1497 JvmtiFunctions::GetTime,
1498 JvmtiFunctions::GetPotentialCapabilities, // 140
1499 nullptr, // reserved141
1500 JvmtiFunctions::AddCapabilities,
1501 JvmtiFunctions::RelinquishCapabilities,
1502 JvmtiFunctions::GetAvailableProcessors,
1503 JvmtiFunctions::GetClassVersionNumbers,
1504 JvmtiFunctions::GetConstantPool,
1505 JvmtiFunctions::GetEnvironmentLocalStorage,
1506 JvmtiFunctions::SetEnvironmentLocalStorage,
1507 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1508 JvmtiFunctions::SetVerboseFlag, // 150
1509 JvmtiFunctions::AddToSystemClassLoaderSearch,
1510 JvmtiFunctions::RetransformClasses,
1511 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1512 JvmtiFunctions::GetObjectSize,
1513 JvmtiFunctions::GetLocalInstance,
1514};
1515
1516}; // namespace openjdkjvmti