blob: 03903841e5d4e8de77565ad2dd629ee2b87cd9c9 [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>
33#include <vector>
34
Alex Light49948e92016-08-11 15:35:28 -070035#include <jni.h>
Alex Light9c20a142016-08-23 15:05:12 -070036
Alex Light49948e92016-08-11 15:35:28 -070037#include "openjdkjvmti/jvmti.h"
38
Andreas Gampedb6dcb62016-09-13 09:05:59 -070039#include "art_jvmti.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070040#include "base/mutex.h"
41#include "events-inl.h"
Alex Light49948e92016-08-11 15:35:28 -070042#include "jni_env_ext-inl.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070043#include "obj_ptr-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080044#include "object_tagging.h"
Alex Light9c20a142016-08-23 15:05:12 -070045#include "runtime.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070046#include "scoped_thread_state_change-inl.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070047#include "thread-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080048#include "thread_list.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070049#include "ti_class.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080050#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070051#include "ti_heap.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070052#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080053#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080054#include "ti_object.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080055#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080056#include "ti_redefine.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070057#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080058#include "ti_thread.h"
Andreas Gampe02afcde2017-01-12 17:34:39 -080059#include "ti_threadgroup.h"
Alex Light9c20a142016-08-23 15:05:12 -070060#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070061
62// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
63// easier to create.
64#pragma GCC diagnostic ignored "-Wunused-parameter"
65
66namespace openjdkjvmti {
67
Andreas Gampe77708d92016-10-07 11:48:21 -070068EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070069ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070070
Alex Lighte6574242016-08-17 09:56:24 -070071#define ENSURE_NON_NULL(n) \
72 do { \
73 if ((n) == nullptr) { \
74 return ERR(NULL_POINTER); \
75 } \
76 } while (false)
77
Alex Light49948e92016-08-11 15:35:28 -070078class JvmtiFunctions {
79 private:
80 static bool IsValidEnv(jvmtiEnv* env) {
81 return env != nullptr;
82 }
83
Alex Lighte6574242016-08-17 09:56:24 -070084#define ENSURE_VALID_ENV(env) \
85 do { \
86 if (!IsValidEnv(env)) { \
87 return ERR(INVALID_ENVIRONMENT); \
88 } \
89 } while (false)
90
91#define ENSURE_HAS_CAP(env, cap) \
92 do { \
93 ENSURE_VALID_ENV(env); \
94 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
95 return ERR(MUST_POSSESS_CAPABILITY); \
96 } \
97 } while (false)
98
Alex Light49948e92016-08-11 15:35:28 -070099 public:
100 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700101 ENSURE_VALID_ENV(env);
102 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700103 if (size < 0) {
104 return ERR(ILLEGAL_ARGUMENT);
105 } else if (size == 0) {
106 *mem_ptr = nullptr;
107 return OK;
108 }
109 *mem_ptr = static_cast<unsigned char*>(malloc(size));
110 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
111 }
112
113 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700114 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700115 if (mem != nullptr) {
116 free(mem);
117 }
118 return OK;
119 }
120
121 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800122 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700123 }
124
125 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800126 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700127 }
128
129 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
130 return ERR(NOT_IMPLEMENTED);
131 }
132
133 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
134 return ERR(NOT_IMPLEMENTED);
135 }
136
137 static jvmtiError SuspendThreadList(jvmtiEnv* env,
138 jint request_count,
139 const jthread* request_list,
140 jvmtiError* results) {
141 return ERR(NOT_IMPLEMENTED);
142 }
143
144 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
145 return ERR(NOT_IMPLEMENTED);
146 }
147
148 static jvmtiError ResumeThreadList(jvmtiEnv* env,
149 jint request_count,
150 const jthread* request_list,
151 jvmtiError* results) {
152 return ERR(NOT_IMPLEMENTED);
153 }
154
155 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
156 return ERR(NOT_IMPLEMENTED);
157 }
158
159 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
160 return ERR(NOT_IMPLEMENTED);
161 }
162
163 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800164 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700165 }
166
167 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
168 jthread thread,
169 jint* owned_monitor_count_ptr,
170 jobject** owned_monitors_ptr) {
171 return ERR(NOT_IMPLEMENTED);
172 }
173
174 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
175 jthread thread,
176 jint* monitor_info_count_ptr,
177 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
178 return ERR(NOT_IMPLEMENTED);
179 }
180
181 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
182 jthread thread,
183 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700184 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700185 }
186
187 static jvmtiError RunAgentThread(jvmtiEnv* env,
188 jthread thread,
189 jvmtiStartFunction proc,
190 const void* arg,
191 jint priority) {
192 return ERR(NOT_IMPLEMENTED);
193 }
194
195 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
196 return ERR(NOT_IMPLEMENTED);
197 }
198
199 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
200 return ERR(NOT_IMPLEMENTED);
201 }
202
203 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
204 jint* group_count_ptr,
205 jthreadGroup** groups_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800206 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700207 }
208
209 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
210 jthreadGroup group,
211 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800212 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700213 }
214
215 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
216 jthreadGroup group,
217 jint* thread_count_ptr,
218 jthread** threads_ptr,
219 jint* group_count_ptr,
220 jthreadGroup** groups_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800221 return ThreadGroupUtil::GetThreadGroupChildren(env,
222 group,
223 thread_count_ptr,
224 threads_ptr,
225 group_count_ptr,
226 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700227 }
228
229 static jvmtiError GetStackTrace(jvmtiEnv* env,
230 jthread thread,
231 jint start_depth,
232 jint max_frame_count,
233 jvmtiFrameInfo* frame_buffer,
234 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700235 return StackUtil::GetStackTrace(env,
236 thread,
237 start_depth,
238 max_frame_count,
239 frame_buffer,
240 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700241 }
242
243 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
244 jint max_frame_count,
245 jvmtiStackInfo** stack_info_ptr,
246 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800247 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700248 }
249
250 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
251 jint thread_count,
252 const jthread* thread_list,
253 jint max_frame_count,
254 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800255 return StackUtil::GetThreadListStackTraces(env,
256 thread_count,
257 thread_list,
258 max_frame_count,
259 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700260 }
261
262 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800263 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700264 }
265
266 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
267 return ERR(NOT_IMPLEMENTED);
268 }
269
270 static jvmtiError GetFrameLocation(jvmtiEnv* env,
271 jthread thread,
272 jint depth,
273 jmethodID* method_ptr,
274 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800275 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700276 }
277
278 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
279 return ERR(NOT_IMPLEMENTED);
280 }
281
282 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
283 return ERR(NOT_IMPLEMENTED);
284 }
285
286 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
287 return ERR(NOT_IMPLEMENTED);
288 }
289
290 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
291 return ERR(NOT_IMPLEMENTED);
292 }
293
294 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
295 return ERR(NOT_IMPLEMENTED);
296 }
297
298 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
299 return ERR(NOT_IMPLEMENTED);
300 }
301
302 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
303 return ERR(NOT_IMPLEMENTED);
304 }
305
306 static jvmtiError FollowReferences(jvmtiEnv* env,
307 jint heap_filter,
308 jclass klass,
309 jobject initial_object,
310 const jvmtiHeapCallbacks* callbacks,
311 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700312 HeapUtil heap_util(&gObjectTagTable);
313 return heap_util.FollowReferences(env,
314 heap_filter,
315 klass,
316 initial_object,
317 callbacks,
318 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700319 }
320
321 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
322 jint heap_filter,
323 jclass klass,
324 const jvmtiHeapCallbacks* callbacks,
325 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700326 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700327 HeapUtil heap_util(&gObjectTagTable);
328 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700329 }
330
331 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700332 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700333
334 JNIEnv* jni_env = GetJniEnv(env);
335 if (jni_env == nullptr) {
336 return ERR(INTERNAL);
337 }
338
339 art::ScopedObjectAccess soa(jni_env);
340 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
341 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
342 *tag_ptr = 0;
343 }
344
345 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700346 }
347
348 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700349 ENSURE_HAS_CAP(env, can_tag_objects);
350
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700351 if (object == nullptr) {
352 return ERR(NULL_POINTER);
353 }
354
355 JNIEnv* jni_env = GetJniEnv(env);
356 if (jni_env == nullptr) {
357 return ERR(INTERNAL);
358 }
359
360 art::ScopedObjectAccess soa(jni_env);
361 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700362 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700363
364 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700365 }
366
367 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
368 jint tag_count,
369 const jlong* tags,
370 jint* count_ptr,
371 jobject** object_result_ptr,
372 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700373 ENSURE_HAS_CAP(env, can_tag_objects);
374
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700375 JNIEnv* jni_env = GetJniEnv(env);
376 if (jni_env == nullptr) {
377 return ERR(INTERNAL);
378 }
379
380 art::ScopedObjectAccess soa(jni_env);
381 return gObjectTagTable.GetTaggedObjects(env,
382 tag_count,
383 tags,
384 count_ptr,
385 object_result_ptr,
386 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700387 }
388
389 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700390 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700391 }
392
393 static jvmtiError IterateOverObjectsReachableFromObject(
394 jvmtiEnv* env,
395 jobject object,
396 jvmtiObjectReferenceCallback object_reference_callback,
397 const void* user_data) {
398 return ERR(NOT_IMPLEMENTED);
399 }
400
401 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
402 jvmtiHeapRootCallback heap_root_callback,
403 jvmtiStackReferenceCallback stack_ref_callback,
404 jvmtiObjectReferenceCallback object_ref_callback,
405 const void* user_data) {
406 return ERR(NOT_IMPLEMENTED);
407 }
408
409 static jvmtiError IterateOverHeap(jvmtiEnv* env,
410 jvmtiHeapObjectFilter object_filter,
411 jvmtiHeapObjectCallback heap_object_callback,
412 const void* user_data) {
413 return ERR(NOT_IMPLEMENTED);
414 }
415
416 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
417 jclass klass,
418 jvmtiHeapObjectFilter object_filter,
419 jvmtiHeapObjectCallback heap_object_callback,
420 const void* user_data) {
421 return ERR(NOT_IMPLEMENTED);
422 }
423
424 static jvmtiError GetLocalObject(jvmtiEnv* env,
425 jthread thread,
426 jint depth,
427 jint slot,
428 jobject* value_ptr) {
429 return ERR(NOT_IMPLEMENTED);
430 }
431
432 static jvmtiError GetLocalInstance(jvmtiEnv* env,
433 jthread thread,
434 jint depth,
435 jobject* value_ptr) {
436 return ERR(NOT_IMPLEMENTED);
437 }
438
439 static jvmtiError GetLocalInt(jvmtiEnv* env,
440 jthread thread,
441 jint depth,
442 jint slot,
443 jint* value_ptr) {
444 return ERR(NOT_IMPLEMENTED);
445 }
446
447 static jvmtiError GetLocalLong(jvmtiEnv* env,
448 jthread thread,
449 jint depth,
450 jint slot,
451 jlong* value_ptr) {
452 return ERR(NOT_IMPLEMENTED);
453 }
454
455 static jvmtiError GetLocalFloat(jvmtiEnv* env,
456 jthread thread,
457 jint depth,
458 jint slot,
459 jfloat* value_ptr) {
460 return ERR(NOT_IMPLEMENTED);
461 }
462
463 static jvmtiError GetLocalDouble(jvmtiEnv* env,
464 jthread thread,
465 jint depth,
466 jint slot,
467 jdouble* value_ptr) {
468 return ERR(NOT_IMPLEMENTED);
469 }
470
471 static jvmtiError SetLocalObject(jvmtiEnv* env,
472 jthread thread,
473 jint depth,
474 jint slot,
475 jobject value) {
476 return ERR(NOT_IMPLEMENTED);
477 }
478
479 static jvmtiError SetLocalInt(jvmtiEnv* env,
480 jthread thread,
481 jint depth,
482 jint slot,
483 jint value) {
484 return ERR(NOT_IMPLEMENTED);
485 }
486
487 static jvmtiError SetLocalLong(jvmtiEnv* env,
488 jthread thread,
489 jint depth,
490 jint slot,
491 jlong value) {
492 return ERR(NOT_IMPLEMENTED);
493 }
494
495 static jvmtiError SetLocalFloat(jvmtiEnv* env,
496 jthread thread,
497 jint depth,
498 jint slot,
499 jfloat value) {
500 return ERR(NOT_IMPLEMENTED);
501 }
502
503 static jvmtiError SetLocalDouble(jvmtiEnv* env,
504 jthread thread,
505 jint depth,
506 jint slot,
507 jdouble value) {
508 return ERR(NOT_IMPLEMENTED);
509 }
510
511 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
512 return ERR(NOT_IMPLEMENTED);
513 }
514
515 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
516 return ERR(NOT_IMPLEMENTED);
517 }
518
519 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
520 return ERR(NOT_IMPLEMENTED);
521 }
522
523 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
524 return ERR(NOT_IMPLEMENTED);
525 }
526
527 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
528 return ERR(NOT_IMPLEMENTED);
529 }
530
531 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
532 return ERR(NOT_IMPLEMENTED);
533 }
534
535 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700536 HeapUtil heap_util(&gObjectTagTable);
537 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700538 }
539
540 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
541 jobject initiating_loader,
542 jint* class_count_ptr,
543 jclass** classes_ptr) {
544 return ERR(NOT_IMPLEMENTED);
545 }
546
547 static jvmtiError GetClassSignature(jvmtiEnv* env,
548 jclass klass,
549 char** signature_ptr,
550 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700551 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700552 }
553
554 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800555 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700556 }
557
558 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
559 return ERR(NOT_IMPLEMENTED);
560 }
561
562 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800563 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700564 }
565
566 static jvmtiError GetClassMethods(jvmtiEnv* env,
567 jclass klass,
568 jint* method_count_ptr,
569 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800570 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700571 }
572
573 static jvmtiError GetClassFields(jvmtiEnv* env,
574 jclass klass,
575 jint* field_count_ptr,
576 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800577 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700578 }
579
580 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
581 jclass klass,
582 jint* interface_count_ptr,
583 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800584 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700585 }
586
587 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
588 jclass klass,
589 jint* minor_version_ptr,
590 jint* major_version_ptr) {
591 return ERR(NOT_IMPLEMENTED);
592 }
593
594 static jvmtiError GetConstantPool(jvmtiEnv* env,
595 jclass klass,
596 jint* constant_pool_count_ptr,
597 jint* constant_pool_byte_count_ptr,
598 unsigned char** constant_pool_bytes_ptr) {
599 return ERR(NOT_IMPLEMENTED);
600 }
601
602 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800603 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700604 }
605
606 static jvmtiError IsArrayClass(jvmtiEnv* env,
607 jclass klass,
608 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800609 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700610 }
611
612 static jvmtiError IsModifiableClass(jvmtiEnv* env,
613 jclass klass,
614 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800615 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700616 }
617
618 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800619 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700620 }
621
622 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
623 jclass klass,
624 char** source_debug_extension_ptr) {
625 return ERR(NOT_IMPLEMENTED);
626 }
627
628 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
629 return ERR(NOT_IMPLEMENTED);
630 }
631
632 static jvmtiError RedefineClasses(jvmtiEnv* env,
633 jint class_count,
634 const jvmtiClassDefinition* class_definitions) {
635 return ERR(NOT_IMPLEMENTED);
636 }
637
638 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800639 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700640 }
641
642 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800643 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700644 }
645
646 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
647 jobject object,
648 jvmtiMonitorUsage* info_ptr) {
649 return ERR(NOT_IMPLEMENTED);
650 }
651
652 static jvmtiError GetFieldName(jvmtiEnv* env,
653 jclass klass,
654 jfieldID field,
655 char** name_ptr,
656 char** signature_ptr,
657 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800658 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700659 }
660
661 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
662 jclass klass,
663 jfieldID field,
664 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800665 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700666 }
667
668 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
669 jclass klass,
670 jfieldID field,
671 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800672 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700673 }
674
675 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
676 jclass klass,
677 jfieldID field,
678 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800679 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700680 }
681
682 static jvmtiError GetMethodName(jvmtiEnv* env,
683 jmethodID method,
684 char** name_ptr,
685 char** signature_ptr,
686 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700687 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700688 }
689
690 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
691 jmethodID method,
692 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700693 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700694 }
695
696 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
697 jmethodID method,
698 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700699 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700700 }
701
702 static jvmtiError GetMaxLocals(jvmtiEnv* env,
703 jmethodID method,
704 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800705 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700706 }
707
708 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
709 jmethodID method,
710 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800711 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700712 }
713
714 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
715 jmethodID method,
716 jint* entry_count_ptr,
717 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800718 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700719 }
720
721 static jvmtiError GetMethodLocation(jvmtiEnv* env,
722 jmethodID method,
723 jlocation* start_location_ptr,
724 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800725 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700726 }
727
728 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
729 jmethodID method,
730 jint* entry_count_ptr,
731 jvmtiLocalVariableEntry** table_ptr) {
732 return ERR(NOT_IMPLEMENTED);
733 }
734
735 static jvmtiError GetBytecodes(jvmtiEnv* env,
736 jmethodID method,
737 jint* bytecode_count_ptr,
738 unsigned char** bytecodes_ptr) {
739 return ERR(NOT_IMPLEMENTED);
740 }
741
742 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800743 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700744 }
745
746 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800747 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700748 }
749
750 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800751 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700752 }
753
754 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
755 return ERR(NOT_IMPLEMENTED);
756 }
757
758 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
759 return ERR(NOT_IMPLEMENTED);
760 }
761
762 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800763 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700764 }
765
766 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800767 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700768 }
769
770 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800771 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700772 }
773
774 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800775 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700776 }
777
778 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800779 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700780 }
781
782 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800783 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700784 }
785
786 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800787 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700788 }
789
790 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
791 return ERR(NOT_IMPLEMENTED);
792 }
793
794 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
795 return ERR(NOT_IMPLEMENTED);
796 }
797
Andreas Gampe77708d92016-10-07 11:48:21 -0700798 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
799 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700800 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
801 const jvmtiEventCallbacks* callbacks,
802 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700803 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700804 if (size_of_callbacks < 0) {
805 return ERR(ILLEGAL_ARGUMENT);
806 }
807
808 if (callbacks == nullptr) {
809 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
810 return ERR(NONE);
811 }
812
813 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
814 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
815 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
816 static_cast<size_t>(size_of_callbacks));
817 copy_size = art::RoundDown(copy_size, sizeof(void*));
818 memcpy(tmp.get(), callbacks, copy_size);
819
820 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
821
822 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700823 }
824
825 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
826 jvmtiEventMode mode,
827 jvmtiEvent event_type,
828 jthread event_thread,
829 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700830 ENSURE_VALID_ENV(env);
831 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700832 art::Thread* art_thread = nullptr;
833 if (event_thread != nullptr) {
834 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
835 art::ScopedObjectAccess soa(art::Thread::Current());
836 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
837 art_thread = art::Thread::FromManagedThread(soa, event_thread);
838
839 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
840 art_thread->IsStillStarting()) {
841 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
842 return ERR(THREAD_NOT_ALIVE);
843 }
844 }
845
846 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700847 }
848
849 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
850 return ERR(NOT_IMPLEMENTED);
851 }
852
853 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
854 jint* extension_count_ptr,
855 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800856 // We do not have any extension functions.
857 *extension_count_ptr = 0;
858 *extensions = nullptr;
859
860 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700861 }
862
863 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
864 jint* extension_count_ptr,
865 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800866 // We do not have any extension events.
867 *extension_count_ptr = 0;
868 *extensions = nullptr;
869
870 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700871 }
872
873 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
874 jint extension_event_index,
875 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800876 // We do not have any extension events, so any call is illegal.
877 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700878 }
879
880 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700881 ENSURE_VALID_ENV(env);
882 ENSURE_NON_NULL(capabilities_ptr);
883 *capabilities_ptr = kPotentialCapabilities;
884 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700885 }
886
887 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700888 ENSURE_VALID_ENV(env);
889 ENSURE_NON_NULL(capabilities_ptr);
890 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
891 jvmtiError ret = OK;
892#define ADD_CAPABILITY(e) \
893 do { \
894 if (capabilities_ptr->e == 1) { \
895 if (kPotentialCapabilities.e == 1) { \
896 art_env->capabilities.e = 1;\
897 } else { \
898 ret = ERR(NOT_AVAILABLE); \
899 } \
900 } \
901 } while (false)
902
903 ADD_CAPABILITY(can_tag_objects);
904 ADD_CAPABILITY(can_generate_field_modification_events);
905 ADD_CAPABILITY(can_generate_field_access_events);
906 ADD_CAPABILITY(can_get_bytecodes);
907 ADD_CAPABILITY(can_get_synthetic_attribute);
908 ADD_CAPABILITY(can_get_owned_monitor_info);
909 ADD_CAPABILITY(can_get_current_contended_monitor);
910 ADD_CAPABILITY(can_get_monitor_info);
911 ADD_CAPABILITY(can_pop_frame);
912 ADD_CAPABILITY(can_redefine_classes);
913 ADD_CAPABILITY(can_signal_thread);
914 ADD_CAPABILITY(can_get_source_file_name);
915 ADD_CAPABILITY(can_get_line_numbers);
916 ADD_CAPABILITY(can_get_source_debug_extension);
917 ADD_CAPABILITY(can_access_local_variables);
918 ADD_CAPABILITY(can_maintain_original_method_order);
919 ADD_CAPABILITY(can_generate_single_step_events);
920 ADD_CAPABILITY(can_generate_exception_events);
921 ADD_CAPABILITY(can_generate_frame_pop_events);
922 ADD_CAPABILITY(can_generate_breakpoint_events);
923 ADD_CAPABILITY(can_suspend);
924 ADD_CAPABILITY(can_redefine_any_class);
925 ADD_CAPABILITY(can_get_current_thread_cpu_time);
926 ADD_CAPABILITY(can_get_thread_cpu_time);
927 ADD_CAPABILITY(can_generate_method_entry_events);
928 ADD_CAPABILITY(can_generate_method_exit_events);
929 ADD_CAPABILITY(can_generate_all_class_hook_events);
930 ADD_CAPABILITY(can_generate_compiled_method_load_events);
931 ADD_CAPABILITY(can_generate_monitor_events);
932 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
933 ADD_CAPABILITY(can_generate_native_method_bind_events);
934 ADD_CAPABILITY(can_generate_garbage_collection_events);
935 ADD_CAPABILITY(can_generate_object_free_events);
936 ADD_CAPABILITY(can_force_early_return);
937 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
938 ADD_CAPABILITY(can_get_constant_pool);
939 ADD_CAPABILITY(can_set_native_method_prefix);
940 ADD_CAPABILITY(can_retransform_classes);
941 ADD_CAPABILITY(can_retransform_any_class);
942 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
943 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
944#undef ADD_CAPABILITY
945 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700946 }
947
948 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
949 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700950 ENSURE_VALID_ENV(env);
951 ENSURE_NON_NULL(capabilities_ptr);
952 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
953#define DEL_CAPABILITY(e) \
954 do { \
955 if (capabilities_ptr->e == 1) { \
956 art_env->capabilities.e = 0;\
957 } \
958 } while (false)
959
960 DEL_CAPABILITY(can_tag_objects);
961 DEL_CAPABILITY(can_generate_field_modification_events);
962 DEL_CAPABILITY(can_generate_field_access_events);
963 DEL_CAPABILITY(can_get_bytecodes);
964 DEL_CAPABILITY(can_get_synthetic_attribute);
965 DEL_CAPABILITY(can_get_owned_monitor_info);
966 DEL_CAPABILITY(can_get_current_contended_monitor);
967 DEL_CAPABILITY(can_get_monitor_info);
968 DEL_CAPABILITY(can_pop_frame);
969 DEL_CAPABILITY(can_redefine_classes);
970 DEL_CAPABILITY(can_signal_thread);
971 DEL_CAPABILITY(can_get_source_file_name);
972 DEL_CAPABILITY(can_get_line_numbers);
973 DEL_CAPABILITY(can_get_source_debug_extension);
974 DEL_CAPABILITY(can_access_local_variables);
975 DEL_CAPABILITY(can_maintain_original_method_order);
976 DEL_CAPABILITY(can_generate_single_step_events);
977 DEL_CAPABILITY(can_generate_exception_events);
978 DEL_CAPABILITY(can_generate_frame_pop_events);
979 DEL_CAPABILITY(can_generate_breakpoint_events);
980 DEL_CAPABILITY(can_suspend);
981 DEL_CAPABILITY(can_redefine_any_class);
982 DEL_CAPABILITY(can_get_current_thread_cpu_time);
983 DEL_CAPABILITY(can_get_thread_cpu_time);
984 DEL_CAPABILITY(can_generate_method_entry_events);
985 DEL_CAPABILITY(can_generate_method_exit_events);
986 DEL_CAPABILITY(can_generate_all_class_hook_events);
987 DEL_CAPABILITY(can_generate_compiled_method_load_events);
988 DEL_CAPABILITY(can_generate_monitor_events);
989 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
990 DEL_CAPABILITY(can_generate_native_method_bind_events);
991 DEL_CAPABILITY(can_generate_garbage_collection_events);
992 DEL_CAPABILITY(can_generate_object_free_events);
993 DEL_CAPABILITY(can_force_early_return);
994 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
995 DEL_CAPABILITY(can_get_constant_pool);
996 DEL_CAPABILITY(can_set_native_method_prefix);
997 DEL_CAPABILITY(can_retransform_classes);
998 DEL_CAPABILITY(can_retransform_any_class);
999 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1000 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1001#undef DEL_CAPABILITY
1002 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001003 }
1004
1005 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001006 ENSURE_VALID_ENV(env);
1007 ENSURE_NON_NULL(capabilities_ptr);
1008 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1009 *capabilities_ptr = artenv->capabilities;
1010 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001011 }
1012
1013 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1014 return ERR(NOT_IMPLEMENTED);
1015 }
1016
1017 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1018 return ERR(NOT_IMPLEMENTED);
1019 }
1020
1021 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1022 return ERR(NOT_IMPLEMENTED);
1023 }
1024
1025 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1026 return ERR(NOT_IMPLEMENTED);
1027 }
1028
1029 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1030 return ERR(NOT_IMPLEMENTED);
1031 }
1032
1033 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
1034 return ERR(NOT_IMPLEMENTED);
1035 }
1036
1037 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
1038 return ERR(NOT_IMPLEMENTED);
1039 }
1040
1041 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1042 return ERR(NOT_IMPLEMENTED);
1043 }
1044
1045 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1046 return ERR(NOT_IMPLEMENTED);
1047 }
1048
1049 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001050 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001051 }
1052
1053 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001054 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001055 }
1056
1057 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001058 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001059 }
1060
1061 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1062 return ERR(NOT_IMPLEMENTED);
1063 }
1064
1065 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001066 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001067 delete env;
1068 return OK;
1069 }
1070
1071 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001072 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001073 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1074 return OK;
1075 }
1076
1077 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001078 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001079 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1080 return OK;
1081 }
1082
1083 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001084 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001085 *version_ptr = JVMTI_VERSION;
1086 return OK;
1087 }
1088
1089 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001090 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001091 switch (error) {
1092#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001093 jvmtiError res = CopyString(env, \
1094 "JVMTI_ERROR_"#e, \
1095 reinterpret_cast<unsigned char**>(name_ptr)); \
1096 if (res != OK) { \
1097 *name_ptr = nullptr; \
1098 return res; \
1099 } else { \
1100 return OK; \
1101 } \
Alex Light49948e92016-08-11 15:35:28 -07001102 } while (false)
1103 ERROR_CASE(NONE);
1104 ERROR_CASE(INVALID_THREAD);
1105 ERROR_CASE(INVALID_THREAD_GROUP);
1106 ERROR_CASE(INVALID_PRIORITY);
1107 ERROR_CASE(THREAD_NOT_SUSPENDED);
1108 ERROR_CASE(THREAD_NOT_ALIVE);
1109 ERROR_CASE(INVALID_OBJECT);
1110 ERROR_CASE(INVALID_CLASS);
1111 ERROR_CASE(CLASS_NOT_PREPARED);
1112 ERROR_CASE(INVALID_METHODID);
1113 ERROR_CASE(INVALID_LOCATION);
1114 ERROR_CASE(INVALID_FIELDID);
1115 ERROR_CASE(NO_MORE_FRAMES);
1116 ERROR_CASE(OPAQUE_FRAME);
1117 ERROR_CASE(TYPE_MISMATCH);
1118 ERROR_CASE(INVALID_SLOT);
1119 ERROR_CASE(DUPLICATE);
1120 ERROR_CASE(NOT_FOUND);
1121 ERROR_CASE(INVALID_MONITOR);
1122 ERROR_CASE(NOT_MONITOR_OWNER);
1123 ERROR_CASE(INTERRUPT);
1124 ERROR_CASE(INVALID_CLASS_FORMAT);
1125 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1126 ERROR_CASE(FAILS_VERIFICATION);
1127 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1128 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1129 ERROR_CASE(INVALID_TYPESTATE);
1130 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1131 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1132 ERROR_CASE(UNSUPPORTED_VERSION);
1133 ERROR_CASE(NAMES_DONT_MATCH);
1134 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1135 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1136 ERROR_CASE(UNMODIFIABLE_CLASS);
1137 ERROR_CASE(NOT_AVAILABLE);
1138 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1139 ERROR_CASE(NULL_POINTER);
1140 ERROR_CASE(ABSENT_INFORMATION);
1141 ERROR_CASE(INVALID_EVENT_TYPE);
1142 ERROR_CASE(ILLEGAL_ARGUMENT);
1143 ERROR_CASE(NATIVE_METHOD);
1144 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1145 ERROR_CASE(OUT_OF_MEMORY);
1146 ERROR_CASE(ACCESS_DENIED);
1147 ERROR_CASE(WRONG_PHASE);
1148 ERROR_CASE(INTERNAL);
1149 ERROR_CASE(UNATTACHED_THREAD);
1150 ERROR_CASE(INVALID_ENVIRONMENT);
1151#undef ERROR_CASE
1152 default: {
Alex Light41960712017-01-06 14:44:23 -08001153 jvmtiError res = CopyString(env,
1154 "JVMTI_ERROR_UNKNOWN",
1155 reinterpret_cast<unsigned char**>(name_ptr));
1156 if (res != OK) {
1157 *name_ptr = nullptr;
1158 return res;
1159 } else {
1160 return ERR(ILLEGAL_ARGUMENT);
1161 }
Alex Light49948e92016-08-11 15:35:28 -07001162 }
1163 }
1164 }
1165
1166 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
1167 return ERR(NOT_IMPLEMENTED);
1168 }
1169
1170 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1171 return ERR(NOT_IMPLEMENTED);
1172 }
Alex Light9c20a142016-08-23 15:05:12 -07001173
1174 // TODO Remove this once events are working.
1175 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1176 jclass klass,
1177 jvmtiEventClassFileLoadHook hook) {
1178 std::vector<jclass> classes;
1179 classes.push_back(klass);
1180 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1181 }
1182
Alex Light1e07ca62016-12-02 11:40:56 -08001183 static jvmtiError RedefineClassDirect(ArtJvmTiEnv* env,
1184 jclass klass,
1185 jint dex_size,
1186 unsigned char* dex_file) {
1187 if (!IsValidEnv(env)) {
1188 return ERR(INVALID_ENVIRONMENT);
1189 }
1190 jvmtiError ret = OK;
1191 std::string location;
1192 if ((ret = GetClassLocation(env, klass, &location)) != OK) {
1193 // TODO Do something more here? Maybe give log statements?
1194 return ret;
1195 }
1196 std::string error;
1197 ret = Redefiner::RedefineClass(env,
1198 art::Runtime::Current(),
1199 art::Thread::Current(),
1200 klass,
1201 location,
1202 dex_size,
1203 reinterpret_cast<uint8_t*>(dex_file),
1204 &error);
1205 if (ret != OK) {
Alex Light460d1b42017-01-10 15:37:17 +00001206 LOG(WARNING) << "FAILURE TO REDEFINE " << error;
Alex Light1e07ca62016-12-02 11:40:56 -08001207 }
1208 return ret;
1209 }
1210
Alex Light9c20a142016-08-23 15:05:12 -07001211 // TODO This will be called by the event handler for the art::ti Event Load Event
1212 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1213 const std::vector<jclass>& classes,
1214 jvmtiEventClassFileLoadHook hook) {
1215 if (!IsValidEnv(env)) {
1216 return ERR(INVALID_ENVIRONMENT);
1217 }
Alex Lighta01de592016-11-15 10:43:06 -08001218 jvmtiError res = OK;
1219 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001220 for (jclass klass : classes) {
1221 JNIEnv* jni_env = nullptr;
1222 jobject loader = nullptr;
1223 std::string name;
1224 jobject protection_domain = nullptr;
1225 jint data_len = 0;
1226 unsigned char* dex_data = nullptr;
1227 jvmtiError ret = OK;
1228 std::string location;
1229 if ((ret = GetTransformationData(env,
1230 klass,
1231 /*out*/&location,
1232 /*out*/&jni_env,
1233 /*out*/&loader,
1234 /*out*/&name,
1235 /*out*/&protection_domain,
1236 /*out*/&data_len,
1237 /*out*/&dex_data)) != OK) {
1238 // TODO Do something more here? Maybe give log statements?
1239 return ret;
1240 }
1241 jint new_data_len = 0;
1242 unsigned char* new_dex_data = nullptr;
1243 hook(env,
1244 jni_env,
1245 klass,
1246 loader,
1247 name.c_str(),
1248 protection_domain,
1249 data_len,
1250 dex_data,
1251 /*out*/&new_data_len,
1252 /*out*/&new_dex_data);
1253 // Check if anything actually changed.
1254 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Lighta01de592016-11-15 10:43:06 -08001255 res = Redefiner::RedefineClass(env,
1256 art::Runtime::Current(),
1257 art::Thread::Current(),
1258 klass,
1259 location,
1260 new_data_len,
1261 new_dex_data,
1262 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001263 env->Deallocate(new_dex_data);
1264 }
1265 // Deallocate the old dex data.
1266 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001267 if (res != OK) {
1268 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1269 return res;
1270 }
Alex Light9c20a142016-08-23 15:05:12 -07001271 }
1272 return OK;
1273 }
Alex Light49948e92016-08-11 15:35:28 -07001274};
1275
1276static bool IsJvmtiVersion(jint version) {
1277 return version == JVMTI_VERSION_1 ||
1278 version == JVMTI_VERSION_1_0 ||
1279 version == JVMTI_VERSION_1_1 ||
1280 version == JVMTI_VERSION_1_2 ||
1281 version == JVMTI_VERSION;
1282}
1283
1284// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1285// is a pointer to the uninitialized memory for an art::ti::Env.
1286static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1287 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1288 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001289
1290 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001291}
1292
1293// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1294// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1295// returns false and does not modify the 'env' pointer.
1296static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1297 if (IsJvmtiVersion(version)) {
1298 CreateArtJvmTiEnv(vm, env);
1299 return JNI_OK;
1300 } else {
1301 printf("version 0x%x is not valid!", version);
1302 return JNI_EVERSION;
1303 }
1304}
1305
1306// The plugin initialization function. This adds the jvmti environment.
1307extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001308 art::Runtime* runtime = art::Runtime::Current();
1309 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1310 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001311 return true;
1312}
1313
1314// The actual struct holding all of the entrypoints into the jvmti interface.
1315const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001316 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1317 // TODO Remove once we have events working.
1318 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1319 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001320 JvmtiFunctions::SetEventNotificationMode,
Alex Light1e07ca62016-12-02 11:40:56 -08001321 // SPECIAL FUNCTION: RedefineClassDirect Is normally reserved3
1322 // TODO Remove once we have events working.
1323 reinterpret_cast<void*>(JvmtiFunctions::RedefineClassDirect),
1324 // nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001325 JvmtiFunctions::GetAllThreads,
1326 JvmtiFunctions::SuspendThread,
1327 JvmtiFunctions::ResumeThread,
1328 JvmtiFunctions::StopThread,
1329 JvmtiFunctions::InterruptThread,
1330 JvmtiFunctions::GetThreadInfo,
1331 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1332 JvmtiFunctions::GetCurrentContendedMonitor,
1333 JvmtiFunctions::RunAgentThread,
1334 JvmtiFunctions::GetTopThreadGroups,
1335 JvmtiFunctions::GetThreadGroupInfo,
1336 JvmtiFunctions::GetThreadGroupChildren,
1337 JvmtiFunctions::GetFrameCount,
1338 JvmtiFunctions::GetThreadState,
1339 JvmtiFunctions::GetCurrentThread,
1340 JvmtiFunctions::GetFrameLocation,
1341 JvmtiFunctions::NotifyFramePop, // 20
1342 JvmtiFunctions::GetLocalObject,
1343 JvmtiFunctions::GetLocalInt,
1344 JvmtiFunctions::GetLocalLong,
1345 JvmtiFunctions::GetLocalFloat,
1346 JvmtiFunctions::GetLocalDouble,
1347 JvmtiFunctions::SetLocalObject,
1348 JvmtiFunctions::SetLocalInt,
1349 JvmtiFunctions::SetLocalLong,
1350 JvmtiFunctions::SetLocalFloat,
1351 JvmtiFunctions::SetLocalDouble, // 30
1352 JvmtiFunctions::CreateRawMonitor,
1353 JvmtiFunctions::DestroyRawMonitor,
1354 JvmtiFunctions::RawMonitorEnter,
1355 JvmtiFunctions::RawMonitorExit,
1356 JvmtiFunctions::RawMonitorWait,
1357 JvmtiFunctions::RawMonitorNotify,
1358 JvmtiFunctions::RawMonitorNotifyAll,
1359 JvmtiFunctions::SetBreakpoint,
1360 JvmtiFunctions::ClearBreakpoint,
1361 nullptr, // reserved40
1362 JvmtiFunctions::SetFieldAccessWatch,
1363 JvmtiFunctions::ClearFieldAccessWatch,
1364 JvmtiFunctions::SetFieldModificationWatch,
1365 JvmtiFunctions::ClearFieldModificationWatch,
1366 JvmtiFunctions::IsModifiableClass,
1367 JvmtiFunctions::Allocate,
1368 JvmtiFunctions::Deallocate,
1369 JvmtiFunctions::GetClassSignature,
1370 JvmtiFunctions::GetClassStatus,
1371 JvmtiFunctions::GetSourceFileName, // 50
1372 JvmtiFunctions::GetClassModifiers,
1373 JvmtiFunctions::GetClassMethods,
1374 JvmtiFunctions::GetClassFields,
1375 JvmtiFunctions::GetImplementedInterfaces,
1376 JvmtiFunctions::IsInterface,
1377 JvmtiFunctions::IsArrayClass,
1378 JvmtiFunctions::GetClassLoader,
1379 JvmtiFunctions::GetObjectHashCode,
1380 JvmtiFunctions::GetObjectMonitorUsage,
1381 JvmtiFunctions::GetFieldName, // 60
1382 JvmtiFunctions::GetFieldDeclaringClass,
1383 JvmtiFunctions::GetFieldModifiers,
1384 JvmtiFunctions::IsFieldSynthetic,
1385 JvmtiFunctions::GetMethodName,
1386 JvmtiFunctions::GetMethodDeclaringClass,
1387 JvmtiFunctions::GetMethodModifiers,
1388 nullptr, // reserved67
1389 JvmtiFunctions::GetMaxLocals,
1390 JvmtiFunctions::GetArgumentsSize,
1391 JvmtiFunctions::GetLineNumberTable, // 70
1392 JvmtiFunctions::GetMethodLocation,
1393 JvmtiFunctions::GetLocalVariableTable,
1394 JvmtiFunctions::SetNativeMethodPrefix,
1395 JvmtiFunctions::SetNativeMethodPrefixes,
1396 JvmtiFunctions::GetBytecodes,
1397 JvmtiFunctions::IsMethodNative,
1398 JvmtiFunctions::IsMethodSynthetic,
1399 JvmtiFunctions::GetLoadedClasses,
1400 JvmtiFunctions::GetClassLoaderClasses,
1401 JvmtiFunctions::PopFrame, // 80
1402 JvmtiFunctions::ForceEarlyReturnObject,
1403 JvmtiFunctions::ForceEarlyReturnInt,
1404 JvmtiFunctions::ForceEarlyReturnLong,
1405 JvmtiFunctions::ForceEarlyReturnFloat,
1406 JvmtiFunctions::ForceEarlyReturnDouble,
1407 JvmtiFunctions::ForceEarlyReturnVoid,
1408 JvmtiFunctions::RedefineClasses,
1409 JvmtiFunctions::GetVersionNumber,
1410 JvmtiFunctions::GetCapabilities,
1411 JvmtiFunctions::GetSourceDebugExtension, // 90
1412 JvmtiFunctions::IsMethodObsolete,
1413 JvmtiFunctions::SuspendThreadList,
1414 JvmtiFunctions::ResumeThreadList,
1415 nullptr, // reserved94
1416 nullptr, // reserved95
1417 nullptr, // reserved96
1418 nullptr, // reserved97
1419 nullptr, // reserved98
1420 nullptr, // reserved99
1421 JvmtiFunctions::GetAllStackTraces, // 100
1422 JvmtiFunctions::GetThreadListStackTraces,
1423 JvmtiFunctions::GetThreadLocalStorage,
1424 JvmtiFunctions::SetThreadLocalStorage,
1425 JvmtiFunctions::GetStackTrace,
1426 nullptr, // reserved105
1427 JvmtiFunctions::GetTag,
1428 JvmtiFunctions::SetTag,
1429 JvmtiFunctions::ForceGarbageCollection,
1430 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1431 JvmtiFunctions::IterateOverReachableObjects, // 110
1432 JvmtiFunctions::IterateOverHeap,
1433 JvmtiFunctions::IterateOverInstancesOfClass,
1434 nullptr, // reserved113
1435 JvmtiFunctions::GetObjectsWithTags,
1436 JvmtiFunctions::FollowReferences,
1437 JvmtiFunctions::IterateThroughHeap,
1438 nullptr, // reserved117
1439 nullptr, // reserved118
1440 nullptr, // reserved119
1441 JvmtiFunctions::SetJNIFunctionTable, // 120
1442 JvmtiFunctions::GetJNIFunctionTable,
1443 JvmtiFunctions::SetEventCallbacks,
1444 JvmtiFunctions::GenerateEvents,
1445 JvmtiFunctions::GetExtensionFunctions,
1446 JvmtiFunctions::GetExtensionEvents,
1447 JvmtiFunctions::SetExtensionEventCallback,
1448 JvmtiFunctions::DisposeEnvironment,
1449 JvmtiFunctions::GetErrorName,
1450 JvmtiFunctions::GetJLocationFormat,
1451 JvmtiFunctions::GetSystemProperties, // 130
1452 JvmtiFunctions::GetSystemProperty,
1453 JvmtiFunctions::SetSystemProperty,
1454 JvmtiFunctions::GetPhase,
1455 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1456 JvmtiFunctions::GetCurrentThreadCpuTime,
1457 JvmtiFunctions::GetThreadCpuTimerInfo,
1458 JvmtiFunctions::GetThreadCpuTime,
1459 JvmtiFunctions::GetTimerInfo,
1460 JvmtiFunctions::GetTime,
1461 JvmtiFunctions::GetPotentialCapabilities, // 140
1462 nullptr, // reserved141
1463 JvmtiFunctions::AddCapabilities,
1464 JvmtiFunctions::RelinquishCapabilities,
1465 JvmtiFunctions::GetAvailableProcessors,
1466 JvmtiFunctions::GetClassVersionNumbers,
1467 JvmtiFunctions::GetConstantPool,
1468 JvmtiFunctions::GetEnvironmentLocalStorage,
1469 JvmtiFunctions::SetEnvironmentLocalStorage,
1470 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1471 JvmtiFunctions::SetVerboseFlag, // 150
1472 JvmtiFunctions::AddToSystemClassLoaderSearch,
1473 JvmtiFunctions::RetransformClasses,
1474 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1475 JvmtiFunctions::GetObjectSize,
1476 JvmtiFunctions::GetLocalInstance,
1477};
1478
1479}; // namespace openjdkjvmti