blob: 3825c41e764e211cd02d618dcb24a58d0b6ddf06 [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 Gampeb5eb94a2016-10-27 19:23:09 -070059#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080060#include "ti_thread.h"
Alex Light9c20a142016-08-23 15:05:12 -070061#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070062
63// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
64// easier to create.
65#pragma GCC diagnostic ignored "-Wunused-parameter"
66
67namespace openjdkjvmti {
68
Andreas Gampe77708d92016-10-07 11:48:21 -070069EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070070ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070071
Alex Lighte6574242016-08-17 09:56:24 -070072#define ENSURE_NON_NULL(n) \
73 do { \
74 if ((n) == nullptr) { \
75 return ERR(NULL_POINTER); \
76 } \
77 } while (false)
78
Alex Light49948e92016-08-11 15:35:28 -070079class JvmtiFunctions {
80 private:
81 static bool IsValidEnv(jvmtiEnv* env) {
82 return env != nullptr;
83 }
84
Alex Lighte6574242016-08-17 09:56:24 -070085#define ENSURE_VALID_ENV(env) \
86 do { \
87 if (!IsValidEnv(env)) { \
88 return ERR(INVALID_ENVIRONMENT); \
89 } \
90 } while (false)
91
92#define ENSURE_HAS_CAP(env, cap) \
93 do { \
94 ENSURE_VALID_ENV(env); \
95 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
96 return ERR(MUST_POSSESS_CAPABILITY); \
97 } \
98 } while (false)
99
Alex Light49948e92016-08-11 15:35:28 -0700100 public:
101 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700102 ENSURE_VALID_ENV(env);
103 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700104 if (size < 0) {
105 return ERR(ILLEGAL_ARGUMENT);
106 } else if (size == 0) {
107 *mem_ptr = nullptr;
108 return OK;
109 }
110 *mem_ptr = static_cast<unsigned char*>(malloc(size));
111 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
112 }
113
114 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700115 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700116 if (mem != nullptr) {
117 free(mem);
118 }
119 return OK;
120 }
121
122 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800123 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700124 }
125
126 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800127 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700128 }
129
130 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800131 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700132 }
133
134 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
135 return ERR(NOT_IMPLEMENTED);
136 }
137
138 static jvmtiError SuspendThreadList(jvmtiEnv* env,
139 jint request_count,
140 const jthread* request_list,
141 jvmtiError* results) {
142 return ERR(NOT_IMPLEMENTED);
143 }
144
145 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
146 return ERR(NOT_IMPLEMENTED);
147 }
148
149 static jvmtiError ResumeThreadList(jvmtiEnv* env,
150 jint request_count,
151 const jthread* request_list,
152 jvmtiError* results) {
153 return ERR(NOT_IMPLEMENTED);
154 }
155
156 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
157 return ERR(NOT_IMPLEMENTED);
158 }
159
160 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
161 return ERR(NOT_IMPLEMENTED);
162 }
163
164 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800165 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700166 }
167
168 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
169 jthread thread,
170 jint* owned_monitor_count_ptr,
171 jobject** owned_monitors_ptr) {
172 return ERR(NOT_IMPLEMENTED);
173 }
174
175 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
176 jthread thread,
177 jint* monitor_info_count_ptr,
178 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
179 return ERR(NOT_IMPLEMENTED);
180 }
181
182 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
183 jthread thread,
184 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700185 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700186 }
187
188 static jvmtiError RunAgentThread(jvmtiEnv* env,
189 jthread thread,
190 jvmtiStartFunction proc,
191 const void* arg,
192 jint priority) {
193 return ERR(NOT_IMPLEMENTED);
194 }
195
196 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
197 return ERR(NOT_IMPLEMENTED);
198 }
199
200 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
201 return ERR(NOT_IMPLEMENTED);
202 }
203
204 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
205 jint* group_count_ptr,
206 jthreadGroup** groups_ptr) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000207 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700208 }
209
210 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
211 jthreadGroup group,
212 jvmtiThreadGroupInfo* info_ptr) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000213 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700214 }
215
216 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
217 jthreadGroup group,
218 jint* thread_count_ptr,
219 jthread** threads_ptr,
220 jint* group_count_ptr,
221 jthreadGroup** groups_ptr) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000222 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700223 }
224
225 static jvmtiError GetStackTrace(jvmtiEnv* env,
226 jthread thread,
227 jint start_depth,
228 jint max_frame_count,
229 jvmtiFrameInfo* frame_buffer,
230 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700231 return StackUtil::GetStackTrace(env,
232 thread,
233 start_depth,
234 max_frame_count,
235 frame_buffer,
236 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700237 }
238
239 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
240 jint max_frame_count,
241 jvmtiStackInfo** stack_info_ptr,
242 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800243 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700244 }
245
246 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
247 jint thread_count,
248 const jthread* thread_list,
249 jint max_frame_count,
250 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800251 return StackUtil::GetThreadListStackTraces(env,
252 thread_count,
253 thread_list,
254 max_frame_count,
255 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700256 }
257
258 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800259 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700260 }
261
262 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
263 return ERR(NOT_IMPLEMENTED);
264 }
265
266 static jvmtiError GetFrameLocation(jvmtiEnv* env,
267 jthread thread,
268 jint depth,
269 jmethodID* method_ptr,
270 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800271 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700272 }
273
274 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
275 return ERR(NOT_IMPLEMENTED);
276 }
277
278 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
279 return ERR(NOT_IMPLEMENTED);
280 }
281
282 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
283 return ERR(NOT_IMPLEMENTED);
284 }
285
286 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
287 return ERR(NOT_IMPLEMENTED);
288 }
289
290 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
291 return ERR(NOT_IMPLEMENTED);
292 }
293
294 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
295 return ERR(NOT_IMPLEMENTED);
296 }
297
298 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
299 return ERR(NOT_IMPLEMENTED);
300 }
301
302 static jvmtiError FollowReferences(jvmtiEnv* env,
303 jint heap_filter,
304 jclass klass,
305 jobject initial_object,
306 const jvmtiHeapCallbacks* callbacks,
307 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700308 HeapUtil heap_util(&gObjectTagTable);
309 return heap_util.FollowReferences(env,
310 heap_filter,
311 klass,
312 initial_object,
313 callbacks,
314 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700315 }
316
317 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
318 jint heap_filter,
319 jclass klass,
320 const jvmtiHeapCallbacks* callbacks,
321 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700322 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700323 HeapUtil heap_util(&gObjectTagTable);
324 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700325 }
326
327 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700328 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700329
330 JNIEnv* jni_env = GetJniEnv(env);
331 if (jni_env == nullptr) {
332 return ERR(INTERNAL);
333 }
334
335 art::ScopedObjectAccess soa(jni_env);
336 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
337 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
338 *tag_ptr = 0;
339 }
340
341 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700342 }
343
344 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700345 ENSURE_HAS_CAP(env, can_tag_objects);
346
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700347 if (object == nullptr) {
348 return ERR(NULL_POINTER);
349 }
350
351 JNIEnv* jni_env = GetJniEnv(env);
352 if (jni_env == nullptr) {
353 return ERR(INTERNAL);
354 }
355
356 art::ScopedObjectAccess soa(jni_env);
357 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700358 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700359
360 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700361 }
362
363 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
364 jint tag_count,
365 const jlong* tags,
366 jint* count_ptr,
367 jobject** object_result_ptr,
368 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700369 ENSURE_HAS_CAP(env, can_tag_objects);
370
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700371 JNIEnv* jni_env = GetJniEnv(env);
372 if (jni_env == nullptr) {
373 return ERR(INTERNAL);
374 }
375
376 art::ScopedObjectAccess soa(jni_env);
377 return gObjectTagTable.GetTaggedObjects(env,
378 tag_count,
379 tags,
380 count_ptr,
381 object_result_ptr,
382 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700383 }
384
385 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700386 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700387 }
388
389 static jvmtiError IterateOverObjectsReachableFromObject(
390 jvmtiEnv* env,
391 jobject object,
392 jvmtiObjectReferenceCallback object_reference_callback,
393 const void* user_data) {
394 return ERR(NOT_IMPLEMENTED);
395 }
396
397 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
398 jvmtiHeapRootCallback heap_root_callback,
399 jvmtiStackReferenceCallback stack_ref_callback,
400 jvmtiObjectReferenceCallback object_ref_callback,
401 const void* user_data) {
402 return ERR(NOT_IMPLEMENTED);
403 }
404
405 static jvmtiError IterateOverHeap(jvmtiEnv* env,
406 jvmtiHeapObjectFilter object_filter,
407 jvmtiHeapObjectCallback heap_object_callback,
408 const void* user_data) {
409 return ERR(NOT_IMPLEMENTED);
410 }
411
412 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
413 jclass klass,
414 jvmtiHeapObjectFilter object_filter,
415 jvmtiHeapObjectCallback heap_object_callback,
416 const void* user_data) {
417 return ERR(NOT_IMPLEMENTED);
418 }
419
420 static jvmtiError GetLocalObject(jvmtiEnv* env,
421 jthread thread,
422 jint depth,
423 jint slot,
424 jobject* value_ptr) {
425 return ERR(NOT_IMPLEMENTED);
426 }
427
428 static jvmtiError GetLocalInstance(jvmtiEnv* env,
429 jthread thread,
430 jint depth,
431 jobject* value_ptr) {
432 return ERR(NOT_IMPLEMENTED);
433 }
434
435 static jvmtiError GetLocalInt(jvmtiEnv* env,
436 jthread thread,
437 jint depth,
438 jint slot,
439 jint* value_ptr) {
440 return ERR(NOT_IMPLEMENTED);
441 }
442
443 static jvmtiError GetLocalLong(jvmtiEnv* env,
444 jthread thread,
445 jint depth,
446 jint slot,
447 jlong* value_ptr) {
448 return ERR(NOT_IMPLEMENTED);
449 }
450
451 static jvmtiError GetLocalFloat(jvmtiEnv* env,
452 jthread thread,
453 jint depth,
454 jint slot,
455 jfloat* value_ptr) {
456 return ERR(NOT_IMPLEMENTED);
457 }
458
459 static jvmtiError GetLocalDouble(jvmtiEnv* env,
460 jthread thread,
461 jint depth,
462 jint slot,
463 jdouble* value_ptr) {
464 return ERR(NOT_IMPLEMENTED);
465 }
466
467 static jvmtiError SetLocalObject(jvmtiEnv* env,
468 jthread thread,
469 jint depth,
470 jint slot,
471 jobject value) {
472 return ERR(NOT_IMPLEMENTED);
473 }
474
475 static jvmtiError SetLocalInt(jvmtiEnv* env,
476 jthread thread,
477 jint depth,
478 jint slot,
479 jint value) {
480 return ERR(NOT_IMPLEMENTED);
481 }
482
483 static jvmtiError SetLocalLong(jvmtiEnv* env,
484 jthread thread,
485 jint depth,
486 jint slot,
487 jlong value) {
488 return ERR(NOT_IMPLEMENTED);
489 }
490
491 static jvmtiError SetLocalFloat(jvmtiEnv* env,
492 jthread thread,
493 jint depth,
494 jint slot,
495 jfloat value) {
496 return ERR(NOT_IMPLEMENTED);
497 }
498
499 static jvmtiError SetLocalDouble(jvmtiEnv* env,
500 jthread thread,
501 jint depth,
502 jint slot,
503 jdouble value) {
504 return ERR(NOT_IMPLEMENTED);
505 }
506
507 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
508 return ERR(NOT_IMPLEMENTED);
509 }
510
511 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
512 return ERR(NOT_IMPLEMENTED);
513 }
514
515 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
516 return ERR(NOT_IMPLEMENTED);
517 }
518
519 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
520 return ERR(NOT_IMPLEMENTED);
521 }
522
523 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
524 return ERR(NOT_IMPLEMENTED);
525 }
526
527 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
528 return ERR(NOT_IMPLEMENTED);
529 }
530
531 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700532 HeapUtil heap_util(&gObjectTagTable);
533 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700534 }
535
536 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
537 jobject initiating_loader,
538 jint* class_count_ptr,
539 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800540 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700541 }
542
543 static jvmtiError GetClassSignature(jvmtiEnv* env,
544 jclass klass,
545 char** signature_ptr,
546 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700547 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700548 }
549
550 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800551 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700552 }
553
554 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
555 return ERR(NOT_IMPLEMENTED);
556 }
557
558 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800559 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700560 }
561
562 static jvmtiError GetClassMethods(jvmtiEnv* env,
563 jclass klass,
564 jint* method_count_ptr,
565 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800566 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700567 }
568
569 static jvmtiError GetClassFields(jvmtiEnv* env,
570 jclass klass,
571 jint* field_count_ptr,
572 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800573 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700574 }
575
576 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
577 jclass klass,
578 jint* interface_count_ptr,
579 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800580 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700581 }
582
583 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
584 jclass klass,
585 jint* minor_version_ptr,
586 jint* major_version_ptr) {
587 return ERR(NOT_IMPLEMENTED);
588 }
589
590 static jvmtiError GetConstantPool(jvmtiEnv* env,
591 jclass klass,
592 jint* constant_pool_count_ptr,
593 jint* constant_pool_byte_count_ptr,
594 unsigned char** constant_pool_bytes_ptr) {
595 return ERR(NOT_IMPLEMENTED);
596 }
597
598 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800599 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700600 }
601
602 static jvmtiError IsArrayClass(jvmtiEnv* env,
603 jclass klass,
604 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800605 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700606 }
607
608 static jvmtiError IsModifiableClass(jvmtiEnv* env,
609 jclass klass,
610 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800611 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700612 }
613
614 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800615 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700616 }
617
618 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
619 jclass klass,
620 char** source_debug_extension_ptr) {
621 return ERR(NOT_IMPLEMENTED);
622 }
623
624 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
625 return ERR(NOT_IMPLEMENTED);
626 }
627
628 static jvmtiError RedefineClasses(jvmtiEnv* env,
629 jint class_count,
630 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800631 std::string error_msg;
632 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
633 art::Runtime::Current(),
634 art::Thread::Current(),
635 class_count,
636 class_definitions,
637 &error_msg);
638 if (res != OK) {
639 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
640 }
641 return res;
Alex Light49948e92016-08-11 15:35:28 -0700642 }
643
644 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800645 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700646 }
647
648 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800649 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700650 }
651
652 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
653 jobject object,
654 jvmtiMonitorUsage* info_ptr) {
655 return ERR(NOT_IMPLEMENTED);
656 }
657
658 static jvmtiError GetFieldName(jvmtiEnv* env,
659 jclass klass,
660 jfieldID field,
661 char** name_ptr,
662 char** signature_ptr,
663 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800664 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700665 }
666
667 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
668 jclass klass,
669 jfieldID field,
670 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800671 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700672 }
673
674 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
675 jclass klass,
676 jfieldID field,
677 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800678 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700679 }
680
681 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
682 jclass klass,
683 jfieldID field,
684 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800685 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700686 }
687
688 static jvmtiError GetMethodName(jvmtiEnv* env,
689 jmethodID method,
690 char** name_ptr,
691 char** signature_ptr,
692 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700693 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700694 }
695
696 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
697 jmethodID method,
698 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700699 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700700 }
701
702 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
703 jmethodID method,
704 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700705 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700706 }
707
708 static jvmtiError GetMaxLocals(jvmtiEnv* env,
709 jmethodID method,
710 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800711 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700712 }
713
714 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
715 jmethodID method,
716 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800717 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700718 }
719
720 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
721 jmethodID method,
722 jint* entry_count_ptr,
723 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800724 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700725 }
726
727 static jvmtiError GetMethodLocation(jvmtiEnv* env,
728 jmethodID method,
729 jlocation* start_location_ptr,
730 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800731 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700732 }
733
734 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
735 jmethodID method,
736 jint* entry_count_ptr,
737 jvmtiLocalVariableEntry** table_ptr) {
738 return ERR(NOT_IMPLEMENTED);
739 }
740
741 static jvmtiError GetBytecodes(jvmtiEnv* env,
742 jmethodID method,
743 jint* bytecode_count_ptr,
744 unsigned char** bytecodes_ptr) {
745 return ERR(NOT_IMPLEMENTED);
746 }
747
748 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800749 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700750 }
751
752 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800753 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700754 }
755
756 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800757 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700758 }
759
760 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
761 return ERR(NOT_IMPLEMENTED);
762 }
763
764 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
765 return ERR(NOT_IMPLEMENTED);
766 }
767
768 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800769 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700770 }
771
772 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800773 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700774 }
775
776 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800777 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700778 }
779
780 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800781 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700782 }
783
784 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800785 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700786 }
787
788 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800789 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700790 }
791
792 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800793 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700794 }
795
796 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
797 return ERR(NOT_IMPLEMENTED);
798 }
799
800 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
801 return ERR(NOT_IMPLEMENTED);
802 }
803
Andreas Gampe77708d92016-10-07 11:48:21 -0700804 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
805 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700806 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
807 const jvmtiEventCallbacks* callbacks,
808 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700809 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700810 if (size_of_callbacks < 0) {
811 return ERR(ILLEGAL_ARGUMENT);
812 }
813
814 if (callbacks == nullptr) {
815 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
816 return ERR(NONE);
817 }
818
819 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
820 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
821 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
822 static_cast<size_t>(size_of_callbacks));
823 copy_size = art::RoundDown(copy_size, sizeof(void*));
824 memcpy(tmp.get(), callbacks, copy_size);
825
826 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
827
828 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700829 }
830
831 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
832 jvmtiEventMode mode,
833 jvmtiEvent event_type,
834 jthread event_thread,
835 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700836 ENSURE_VALID_ENV(env);
837 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700838 art::Thread* art_thread = nullptr;
839 if (event_thread != nullptr) {
840 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
841 art::ScopedObjectAccess soa(art::Thread::Current());
842 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
843 art_thread = art::Thread::FromManagedThread(soa, event_thread);
844
845 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
846 art_thread->IsStillStarting()) {
847 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
848 return ERR(THREAD_NOT_ALIVE);
849 }
850 }
851
852 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700853 }
854
855 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
856 return ERR(NOT_IMPLEMENTED);
857 }
858
859 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
860 jint* extension_count_ptr,
861 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800862 // We do not have any extension functions.
863 *extension_count_ptr = 0;
864 *extensions = nullptr;
865
866 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700867 }
868
869 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
870 jint* extension_count_ptr,
871 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800872 // We do not have any extension events.
873 *extension_count_ptr = 0;
874 *extensions = nullptr;
875
876 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700877 }
878
879 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
880 jint extension_event_index,
881 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800882 // We do not have any extension events, so any call is illegal.
883 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700884 }
885
886 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700887 ENSURE_VALID_ENV(env);
888 ENSURE_NON_NULL(capabilities_ptr);
889 *capabilities_ptr = kPotentialCapabilities;
890 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700891 }
892
893 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700894 ENSURE_VALID_ENV(env);
895 ENSURE_NON_NULL(capabilities_ptr);
896 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
897 jvmtiError ret = OK;
898#define ADD_CAPABILITY(e) \
899 do { \
900 if (capabilities_ptr->e == 1) { \
901 if (kPotentialCapabilities.e == 1) { \
902 art_env->capabilities.e = 1;\
903 } else { \
904 ret = ERR(NOT_AVAILABLE); \
905 } \
906 } \
907 } while (false)
908
909 ADD_CAPABILITY(can_tag_objects);
910 ADD_CAPABILITY(can_generate_field_modification_events);
911 ADD_CAPABILITY(can_generate_field_access_events);
912 ADD_CAPABILITY(can_get_bytecodes);
913 ADD_CAPABILITY(can_get_synthetic_attribute);
914 ADD_CAPABILITY(can_get_owned_monitor_info);
915 ADD_CAPABILITY(can_get_current_contended_monitor);
916 ADD_CAPABILITY(can_get_monitor_info);
917 ADD_CAPABILITY(can_pop_frame);
918 ADD_CAPABILITY(can_redefine_classes);
919 ADD_CAPABILITY(can_signal_thread);
920 ADD_CAPABILITY(can_get_source_file_name);
921 ADD_CAPABILITY(can_get_line_numbers);
922 ADD_CAPABILITY(can_get_source_debug_extension);
923 ADD_CAPABILITY(can_access_local_variables);
924 ADD_CAPABILITY(can_maintain_original_method_order);
925 ADD_CAPABILITY(can_generate_single_step_events);
926 ADD_CAPABILITY(can_generate_exception_events);
927 ADD_CAPABILITY(can_generate_frame_pop_events);
928 ADD_CAPABILITY(can_generate_breakpoint_events);
929 ADD_CAPABILITY(can_suspend);
930 ADD_CAPABILITY(can_redefine_any_class);
931 ADD_CAPABILITY(can_get_current_thread_cpu_time);
932 ADD_CAPABILITY(can_get_thread_cpu_time);
933 ADD_CAPABILITY(can_generate_method_entry_events);
934 ADD_CAPABILITY(can_generate_method_exit_events);
935 ADD_CAPABILITY(can_generate_all_class_hook_events);
936 ADD_CAPABILITY(can_generate_compiled_method_load_events);
937 ADD_CAPABILITY(can_generate_monitor_events);
938 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
939 ADD_CAPABILITY(can_generate_native_method_bind_events);
940 ADD_CAPABILITY(can_generate_garbage_collection_events);
941 ADD_CAPABILITY(can_generate_object_free_events);
942 ADD_CAPABILITY(can_force_early_return);
943 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
944 ADD_CAPABILITY(can_get_constant_pool);
945 ADD_CAPABILITY(can_set_native_method_prefix);
946 ADD_CAPABILITY(can_retransform_classes);
947 ADD_CAPABILITY(can_retransform_any_class);
948 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
949 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
950#undef ADD_CAPABILITY
951 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700952 }
953
954 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
955 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700956 ENSURE_VALID_ENV(env);
957 ENSURE_NON_NULL(capabilities_ptr);
958 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
959#define DEL_CAPABILITY(e) \
960 do { \
961 if (capabilities_ptr->e == 1) { \
962 art_env->capabilities.e = 0;\
963 } \
964 } while (false)
965
966 DEL_CAPABILITY(can_tag_objects);
967 DEL_CAPABILITY(can_generate_field_modification_events);
968 DEL_CAPABILITY(can_generate_field_access_events);
969 DEL_CAPABILITY(can_get_bytecodes);
970 DEL_CAPABILITY(can_get_synthetic_attribute);
971 DEL_CAPABILITY(can_get_owned_monitor_info);
972 DEL_CAPABILITY(can_get_current_contended_monitor);
973 DEL_CAPABILITY(can_get_monitor_info);
974 DEL_CAPABILITY(can_pop_frame);
975 DEL_CAPABILITY(can_redefine_classes);
976 DEL_CAPABILITY(can_signal_thread);
977 DEL_CAPABILITY(can_get_source_file_name);
978 DEL_CAPABILITY(can_get_line_numbers);
979 DEL_CAPABILITY(can_get_source_debug_extension);
980 DEL_CAPABILITY(can_access_local_variables);
981 DEL_CAPABILITY(can_maintain_original_method_order);
982 DEL_CAPABILITY(can_generate_single_step_events);
983 DEL_CAPABILITY(can_generate_exception_events);
984 DEL_CAPABILITY(can_generate_frame_pop_events);
985 DEL_CAPABILITY(can_generate_breakpoint_events);
986 DEL_CAPABILITY(can_suspend);
987 DEL_CAPABILITY(can_redefine_any_class);
988 DEL_CAPABILITY(can_get_current_thread_cpu_time);
989 DEL_CAPABILITY(can_get_thread_cpu_time);
990 DEL_CAPABILITY(can_generate_method_entry_events);
991 DEL_CAPABILITY(can_generate_method_exit_events);
992 DEL_CAPABILITY(can_generate_all_class_hook_events);
993 DEL_CAPABILITY(can_generate_compiled_method_load_events);
994 DEL_CAPABILITY(can_generate_monitor_events);
995 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
996 DEL_CAPABILITY(can_generate_native_method_bind_events);
997 DEL_CAPABILITY(can_generate_garbage_collection_events);
998 DEL_CAPABILITY(can_generate_object_free_events);
999 DEL_CAPABILITY(can_force_early_return);
1000 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1001 DEL_CAPABILITY(can_get_constant_pool);
1002 DEL_CAPABILITY(can_set_native_method_prefix);
1003 DEL_CAPABILITY(can_retransform_classes);
1004 DEL_CAPABILITY(can_retransform_any_class);
1005 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1006 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1007#undef DEL_CAPABILITY
1008 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001009 }
1010
1011 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001012 ENSURE_VALID_ENV(env);
1013 ENSURE_NON_NULL(capabilities_ptr);
1014 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1015 *capabilities_ptr = artenv->capabilities;
1016 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001017 }
1018
1019 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1020 return ERR(NOT_IMPLEMENTED);
1021 }
1022
1023 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1024 return ERR(NOT_IMPLEMENTED);
1025 }
1026
1027 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1028 return ERR(NOT_IMPLEMENTED);
1029 }
1030
1031 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1032 return ERR(NOT_IMPLEMENTED);
1033 }
1034
1035 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1036 return ERR(NOT_IMPLEMENTED);
1037 }
1038
1039 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
1040 return ERR(NOT_IMPLEMENTED);
1041 }
1042
1043 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
1044 return ERR(NOT_IMPLEMENTED);
1045 }
1046
1047 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1048 return ERR(NOT_IMPLEMENTED);
1049 }
1050
1051 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1052 return ERR(NOT_IMPLEMENTED);
1053 }
1054
1055 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001056 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001057 }
1058
1059 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001060 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001061 }
1062
1063 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001064 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001065 }
1066
1067 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1068 return ERR(NOT_IMPLEMENTED);
1069 }
1070
1071 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001072 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001073 delete env;
1074 return OK;
1075 }
1076
1077 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001078 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001079 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1080 return OK;
1081 }
1082
1083 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001084 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001085 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1086 return OK;
1087 }
1088
1089 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001090 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001091 *version_ptr = JVMTI_VERSION;
1092 return OK;
1093 }
1094
1095 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001096 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001097 switch (error) {
1098#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001099 jvmtiError res = CopyString(env, \
1100 "JVMTI_ERROR_"#e, \
1101 reinterpret_cast<unsigned char**>(name_ptr)); \
1102 if (res != OK) { \
1103 *name_ptr = nullptr; \
1104 return res; \
1105 } else { \
1106 return OK; \
1107 } \
Alex Light49948e92016-08-11 15:35:28 -07001108 } while (false)
1109 ERROR_CASE(NONE);
1110 ERROR_CASE(INVALID_THREAD);
1111 ERROR_CASE(INVALID_THREAD_GROUP);
1112 ERROR_CASE(INVALID_PRIORITY);
1113 ERROR_CASE(THREAD_NOT_SUSPENDED);
1114 ERROR_CASE(THREAD_NOT_ALIVE);
1115 ERROR_CASE(INVALID_OBJECT);
1116 ERROR_CASE(INVALID_CLASS);
1117 ERROR_CASE(CLASS_NOT_PREPARED);
1118 ERROR_CASE(INVALID_METHODID);
1119 ERROR_CASE(INVALID_LOCATION);
1120 ERROR_CASE(INVALID_FIELDID);
1121 ERROR_CASE(NO_MORE_FRAMES);
1122 ERROR_CASE(OPAQUE_FRAME);
1123 ERROR_CASE(TYPE_MISMATCH);
1124 ERROR_CASE(INVALID_SLOT);
1125 ERROR_CASE(DUPLICATE);
1126 ERROR_CASE(NOT_FOUND);
1127 ERROR_CASE(INVALID_MONITOR);
1128 ERROR_CASE(NOT_MONITOR_OWNER);
1129 ERROR_CASE(INTERRUPT);
1130 ERROR_CASE(INVALID_CLASS_FORMAT);
1131 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1132 ERROR_CASE(FAILS_VERIFICATION);
1133 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1134 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1135 ERROR_CASE(INVALID_TYPESTATE);
1136 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1137 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1138 ERROR_CASE(UNSUPPORTED_VERSION);
1139 ERROR_CASE(NAMES_DONT_MATCH);
1140 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1141 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1142 ERROR_CASE(UNMODIFIABLE_CLASS);
1143 ERROR_CASE(NOT_AVAILABLE);
1144 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1145 ERROR_CASE(NULL_POINTER);
1146 ERROR_CASE(ABSENT_INFORMATION);
1147 ERROR_CASE(INVALID_EVENT_TYPE);
1148 ERROR_CASE(ILLEGAL_ARGUMENT);
1149 ERROR_CASE(NATIVE_METHOD);
1150 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1151 ERROR_CASE(OUT_OF_MEMORY);
1152 ERROR_CASE(ACCESS_DENIED);
1153 ERROR_CASE(WRONG_PHASE);
1154 ERROR_CASE(INTERNAL);
1155 ERROR_CASE(UNATTACHED_THREAD);
1156 ERROR_CASE(INVALID_ENVIRONMENT);
1157#undef ERROR_CASE
1158 default: {
Alex Light41960712017-01-06 14:44:23 -08001159 jvmtiError res = CopyString(env,
1160 "JVMTI_ERROR_UNKNOWN",
1161 reinterpret_cast<unsigned char**>(name_ptr));
1162 if (res != OK) {
1163 *name_ptr = nullptr;
1164 return res;
1165 } else {
1166 return ERR(ILLEGAL_ARGUMENT);
1167 }
Alex Light49948e92016-08-11 15:35:28 -07001168 }
1169 }
1170 }
1171
1172 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001173 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1174 // OTHER is special, as it's 0, so can't do a bit check.
1175 bool val = (value == JNI_TRUE) ? true : false;
1176
1177 art::gLogVerbosity.collector = val;
1178 art::gLogVerbosity.compiler = val;
1179 art::gLogVerbosity.deopt = val;
1180 art::gLogVerbosity.heap = val;
1181 art::gLogVerbosity.jdwp = val;
1182 art::gLogVerbosity.jit = val;
1183 art::gLogVerbosity.monitor = val;
1184 art::gLogVerbosity.oat = val;
1185 art::gLogVerbosity.profiler = val;
1186 art::gLogVerbosity.signals = val;
1187 art::gLogVerbosity.simulator = val;
1188 art::gLogVerbosity.startup = val;
1189 art::gLogVerbosity.third_party_jni = val;
1190 art::gLogVerbosity.threads = val;
1191 art::gLogVerbosity.verifier = val;
1192 art::gLogVerbosity.image = val;
1193
1194 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1195
1196 art::gLogVerbosity.agents = val;
1197 } else {
1198 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1199 // semantics.
1200 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1201 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1202 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1203 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1204 if ((flag & ~kMask) != 0) {
1205 return ERR(ILLEGAL_ARGUMENT);
1206 }
1207
1208 bool val = (value == JNI_TRUE) ? true : false;
1209
1210 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1211 art::gLogVerbosity.gc = val;
1212 }
1213
1214 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1215 art::gLogVerbosity.class_linker = val;
1216 }
1217
1218 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1219 art::gLogVerbosity.jni = val;
1220 }
1221 }
1222
1223 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001224 }
1225
1226 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1227 return ERR(NOT_IMPLEMENTED);
1228 }
Alex Light9c20a142016-08-23 15:05:12 -07001229
1230 // TODO Remove this once events are working.
1231 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1232 jclass klass,
1233 jvmtiEventClassFileLoadHook hook) {
1234 std::vector<jclass> classes;
1235 classes.push_back(klass);
1236 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1237 }
1238
1239 // TODO This will be called by the event handler for the art::ti Event Load Event
1240 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1241 const std::vector<jclass>& classes,
1242 jvmtiEventClassFileLoadHook hook) {
1243 if (!IsValidEnv(env)) {
1244 return ERR(INVALID_ENVIRONMENT);
1245 }
Alex Lighta01de592016-11-15 10:43:06 -08001246 jvmtiError res = OK;
1247 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001248 for (jclass klass : classes) {
1249 JNIEnv* jni_env = nullptr;
1250 jobject loader = nullptr;
1251 std::string name;
1252 jobject protection_domain = nullptr;
1253 jint data_len = 0;
1254 unsigned char* dex_data = nullptr;
1255 jvmtiError ret = OK;
1256 std::string location;
1257 if ((ret = GetTransformationData(env,
1258 klass,
1259 /*out*/&location,
1260 /*out*/&jni_env,
1261 /*out*/&loader,
1262 /*out*/&name,
1263 /*out*/&protection_domain,
1264 /*out*/&data_len,
1265 /*out*/&dex_data)) != OK) {
1266 // TODO Do something more here? Maybe give log statements?
1267 return ret;
1268 }
1269 jint new_data_len = 0;
1270 unsigned char* new_dex_data = nullptr;
1271 hook(env,
1272 jni_env,
1273 klass,
1274 loader,
1275 name.c_str(),
1276 protection_domain,
1277 data_len,
1278 dex_data,
1279 /*out*/&new_data_len,
1280 /*out*/&new_dex_data);
1281 // Check if anything actually changed.
1282 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001283 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1284 res = Redefiner::RedefineClasses(env,
1285 art::Runtime::Current(),
1286 art::Thread::Current(),
1287 1,
1288 &def,
1289 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001290 env->Deallocate(new_dex_data);
1291 }
1292 // Deallocate the old dex data.
1293 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001294 if (res != OK) {
1295 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1296 return res;
1297 }
Alex Light9c20a142016-08-23 15:05:12 -07001298 }
1299 return OK;
1300 }
Alex Light49948e92016-08-11 15:35:28 -07001301};
1302
1303static bool IsJvmtiVersion(jint version) {
1304 return version == JVMTI_VERSION_1 ||
1305 version == JVMTI_VERSION_1_0 ||
1306 version == JVMTI_VERSION_1_1 ||
1307 version == JVMTI_VERSION_1_2 ||
1308 version == JVMTI_VERSION;
1309}
1310
1311// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1312// is a pointer to the uninitialized memory for an art::ti::Env.
1313static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1314 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1315 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001316
1317 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001318}
1319
1320// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1321// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1322// returns false and does not modify the 'env' pointer.
1323static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1324 if (IsJvmtiVersion(version)) {
1325 CreateArtJvmTiEnv(vm, env);
1326 return JNI_OK;
1327 } else {
1328 printf("version 0x%x is not valid!", version);
1329 return JNI_EVERSION;
1330 }
1331}
1332
1333// The plugin initialization function. This adds the jvmti environment.
1334extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001335 art::Runtime* runtime = art::Runtime::Current();
1336 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1337 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001338 return true;
1339}
1340
1341// The actual struct holding all of the entrypoints into the jvmti interface.
1342const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001343 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1344 // TODO Remove once we have events working.
1345 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1346 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001347 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001348 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001349 JvmtiFunctions::GetAllThreads,
1350 JvmtiFunctions::SuspendThread,
1351 JvmtiFunctions::ResumeThread,
1352 JvmtiFunctions::StopThread,
1353 JvmtiFunctions::InterruptThread,
1354 JvmtiFunctions::GetThreadInfo,
1355 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1356 JvmtiFunctions::GetCurrentContendedMonitor,
1357 JvmtiFunctions::RunAgentThread,
1358 JvmtiFunctions::GetTopThreadGroups,
1359 JvmtiFunctions::GetThreadGroupInfo,
1360 JvmtiFunctions::GetThreadGroupChildren,
1361 JvmtiFunctions::GetFrameCount,
1362 JvmtiFunctions::GetThreadState,
1363 JvmtiFunctions::GetCurrentThread,
1364 JvmtiFunctions::GetFrameLocation,
1365 JvmtiFunctions::NotifyFramePop, // 20
1366 JvmtiFunctions::GetLocalObject,
1367 JvmtiFunctions::GetLocalInt,
1368 JvmtiFunctions::GetLocalLong,
1369 JvmtiFunctions::GetLocalFloat,
1370 JvmtiFunctions::GetLocalDouble,
1371 JvmtiFunctions::SetLocalObject,
1372 JvmtiFunctions::SetLocalInt,
1373 JvmtiFunctions::SetLocalLong,
1374 JvmtiFunctions::SetLocalFloat,
1375 JvmtiFunctions::SetLocalDouble, // 30
1376 JvmtiFunctions::CreateRawMonitor,
1377 JvmtiFunctions::DestroyRawMonitor,
1378 JvmtiFunctions::RawMonitorEnter,
1379 JvmtiFunctions::RawMonitorExit,
1380 JvmtiFunctions::RawMonitorWait,
1381 JvmtiFunctions::RawMonitorNotify,
1382 JvmtiFunctions::RawMonitorNotifyAll,
1383 JvmtiFunctions::SetBreakpoint,
1384 JvmtiFunctions::ClearBreakpoint,
1385 nullptr, // reserved40
1386 JvmtiFunctions::SetFieldAccessWatch,
1387 JvmtiFunctions::ClearFieldAccessWatch,
1388 JvmtiFunctions::SetFieldModificationWatch,
1389 JvmtiFunctions::ClearFieldModificationWatch,
1390 JvmtiFunctions::IsModifiableClass,
1391 JvmtiFunctions::Allocate,
1392 JvmtiFunctions::Deallocate,
1393 JvmtiFunctions::GetClassSignature,
1394 JvmtiFunctions::GetClassStatus,
1395 JvmtiFunctions::GetSourceFileName, // 50
1396 JvmtiFunctions::GetClassModifiers,
1397 JvmtiFunctions::GetClassMethods,
1398 JvmtiFunctions::GetClassFields,
1399 JvmtiFunctions::GetImplementedInterfaces,
1400 JvmtiFunctions::IsInterface,
1401 JvmtiFunctions::IsArrayClass,
1402 JvmtiFunctions::GetClassLoader,
1403 JvmtiFunctions::GetObjectHashCode,
1404 JvmtiFunctions::GetObjectMonitorUsage,
1405 JvmtiFunctions::GetFieldName, // 60
1406 JvmtiFunctions::GetFieldDeclaringClass,
1407 JvmtiFunctions::GetFieldModifiers,
1408 JvmtiFunctions::IsFieldSynthetic,
1409 JvmtiFunctions::GetMethodName,
1410 JvmtiFunctions::GetMethodDeclaringClass,
1411 JvmtiFunctions::GetMethodModifiers,
1412 nullptr, // reserved67
1413 JvmtiFunctions::GetMaxLocals,
1414 JvmtiFunctions::GetArgumentsSize,
1415 JvmtiFunctions::GetLineNumberTable, // 70
1416 JvmtiFunctions::GetMethodLocation,
1417 JvmtiFunctions::GetLocalVariableTable,
1418 JvmtiFunctions::SetNativeMethodPrefix,
1419 JvmtiFunctions::SetNativeMethodPrefixes,
1420 JvmtiFunctions::GetBytecodes,
1421 JvmtiFunctions::IsMethodNative,
1422 JvmtiFunctions::IsMethodSynthetic,
1423 JvmtiFunctions::GetLoadedClasses,
1424 JvmtiFunctions::GetClassLoaderClasses,
1425 JvmtiFunctions::PopFrame, // 80
1426 JvmtiFunctions::ForceEarlyReturnObject,
1427 JvmtiFunctions::ForceEarlyReturnInt,
1428 JvmtiFunctions::ForceEarlyReturnLong,
1429 JvmtiFunctions::ForceEarlyReturnFloat,
1430 JvmtiFunctions::ForceEarlyReturnDouble,
1431 JvmtiFunctions::ForceEarlyReturnVoid,
1432 JvmtiFunctions::RedefineClasses,
1433 JvmtiFunctions::GetVersionNumber,
1434 JvmtiFunctions::GetCapabilities,
1435 JvmtiFunctions::GetSourceDebugExtension, // 90
1436 JvmtiFunctions::IsMethodObsolete,
1437 JvmtiFunctions::SuspendThreadList,
1438 JvmtiFunctions::ResumeThreadList,
1439 nullptr, // reserved94
1440 nullptr, // reserved95
1441 nullptr, // reserved96
1442 nullptr, // reserved97
1443 nullptr, // reserved98
1444 nullptr, // reserved99
1445 JvmtiFunctions::GetAllStackTraces, // 100
1446 JvmtiFunctions::GetThreadListStackTraces,
1447 JvmtiFunctions::GetThreadLocalStorage,
1448 JvmtiFunctions::SetThreadLocalStorage,
1449 JvmtiFunctions::GetStackTrace,
1450 nullptr, // reserved105
1451 JvmtiFunctions::GetTag,
1452 JvmtiFunctions::SetTag,
1453 JvmtiFunctions::ForceGarbageCollection,
1454 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1455 JvmtiFunctions::IterateOverReachableObjects, // 110
1456 JvmtiFunctions::IterateOverHeap,
1457 JvmtiFunctions::IterateOverInstancesOfClass,
1458 nullptr, // reserved113
1459 JvmtiFunctions::GetObjectsWithTags,
1460 JvmtiFunctions::FollowReferences,
1461 JvmtiFunctions::IterateThroughHeap,
1462 nullptr, // reserved117
1463 nullptr, // reserved118
1464 nullptr, // reserved119
1465 JvmtiFunctions::SetJNIFunctionTable, // 120
1466 JvmtiFunctions::GetJNIFunctionTable,
1467 JvmtiFunctions::SetEventCallbacks,
1468 JvmtiFunctions::GenerateEvents,
1469 JvmtiFunctions::GetExtensionFunctions,
1470 JvmtiFunctions::GetExtensionEvents,
1471 JvmtiFunctions::SetExtensionEventCallback,
1472 JvmtiFunctions::DisposeEnvironment,
1473 JvmtiFunctions::GetErrorName,
1474 JvmtiFunctions::GetJLocationFormat,
1475 JvmtiFunctions::GetSystemProperties, // 130
1476 JvmtiFunctions::GetSystemProperty,
1477 JvmtiFunctions::SetSystemProperty,
1478 JvmtiFunctions::GetPhase,
1479 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1480 JvmtiFunctions::GetCurrentThreadCpuTime,
1481 JvmtiFunctions::GetThreadCpuTimerInfo,
1482 JvmtiFunctions::GetThreadCpuTime,
1483 JvmtiFunctions::GetTimerInfo,
1484 JvmtiFunctions::GetTime,
1485 JvmtiFunctions::GetPotentialCapabilities, // 140
1486 nullptr, // reserved141
1487 JvmtiFunctions::AddCapabilities,
1488 JvmtiFunctions::RelinquishCapabilities,
1489 JvmtiFunctions::GetAvailableProcessors,
1490 JvmtiFunctions::GetClassVersionNumbers,
1491 JvmtiFunctions::GetConstantPool,
1492 JvmtiFunctions::GetEnvironmentLocalStorage,
1493 JvmtiFunctions::SetEnvironmentLocalStorage,
1494 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1495 JvmtiFunctions::SetVerboseFlag, // 150
1496 JvmtiFunctions::AddToSystemClassLoaderSearch,
1497 JvmtiFunctions::RetransformClasses,
1498 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1499 JvmtiFunctions::GetObjectSize,
1500 JvmtiFunctions::GetLocalInstance,
1501};
1502
1503}; // namespace openjdkjvmti