blob: 8b789593727a264bec63819a0a8594dd5e627058 [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"
Andreas Gampe02afcde2017-01-12 17:34:39 -080061#include "ti_threadgroup.h"
Alex Light9c20a142016-08-23 15:05:12 -070062#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070063
64// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
65// easier to create.
66#pragma GCC diagnostic ignored "-Wunused-parameter"
67
68namespace openjdkjvmti {
69
Andreas Gampe77708d92016-10-07 11:48:21 -070070EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070071ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070072
Alex Lighte6574242016-08-17 09:56:24 -070073#define ENSURE_NON_NULL(n) \
74 do { \
75 if ((n) == nullptr) { \
76 return ERR(NULL_POINTER); \
77 } \
78 } while (false)
79
Alex Light49948e92016-08-11 15:35:28 -070080class JvmtiFunctions {
81 private:
82 static bool IsValidEnv(jvmtiEnv* env) {
83 return env != nullptr;
84 }
85
Alex Lighte6574242016-08-17 09:56:24 -070086#define ENSURE_VALID_ENV(env) \
87 do { \
88 if (!IsValidEnv(env)) { \
89 return ERR(INVALID_ENVIRONMENT); \
90 } \
91 } while (false)
92
93#define ENSURE_HAS_CAP(env, cap) \
94 do { \
95 ENSURE_VALID_ENV(env); \
96 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
97 return ERR(MUST_POSSESS_CAPABILITY); \
98 } \
99 } while (false)
100
Alex Light49948e92016-08-11 15:35:28 -0700101 public:
102 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700103 ENSURE_VALID_ENV(env);
104 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700105 if (size < 0) {
106 return ERR(ILLEGAL_ARGUMENT);
107 } else if (size == 0) {
108 *mem_ptr = nullptr;
109 return OK;
110 }
111 *mem_ptr = static_cast<unsigned char*>(malloc(size));
112 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
113 }
114
115 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700116 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700117 if (mem != nullptr) {
118 free(mem);
119 }
120 return OK;
121 }
122
123 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800124 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700125 }
126
127 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800128 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700129 }
130
131 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
132 return ERR(NOT_IMPLEMENTED);
133 }
134
135 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
136 return ERR(NOT_IMPLEMENTED);
137 }
138
139 static jvmtiError SuspendThreadList(jvmtiEnv* env,
140 jint request_count,
141 const jthread* request_list,
142 jvmtiError* results) {
143 return ERR(NOT_IMPLEMENTED);
144 }
145
146 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
147 return ERR(NOT_IMPLEMENTED);
148 }
149
150 static jvmtiError ResumeThreadList(jvmtiEnv* env,
151 jint request_count,
152 const jthread* request_list,
153 jvmtiError* results) {
154 return ERR(NOT_IMPLEMENTED);
155 }
156
157 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
158 return ERR(NOT_IMPLEMENTED);
159 }
160
161 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
162 return ERR(NOT_IMPLEMENTED);
163 }
164
165 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800166 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700167 }
168
169 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
170 jthread thread,
171 jint* owned_monitor_count_ptr,
172 jobject** owned_monitors_ptr) {
173 return ERR(NOT_IMPLEMENTED);
174 }
175
176 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
177 jthread thread,
178 jint* monitor_info_count_ptr,
179 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
180 return ERR(NOT_IMPLEMENTED);
181 }
182
183 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
184 jthread thread,
185 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700186 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700187 }
188
189 static jvmtiError RunAgentThread(jvmtiEnv* env,
190 jthread thread,
191 jvmtiStartFunction proc,
192 const void* arg,
193 jint priority) {
194 return ERR(NOT_IMPLEMENTED);
195 }
196
197 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
198 return ERR(NOT_IMPLEMENTED);
199 }
200
201 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
202 return ERR(NOT_IMPLEMENTED);
203 }
204
205 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
206 jint* group_count_ptr,
207 jthreadGroup** groups_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800208 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700209 }
210
211 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
212 jthreadGroup group,
213 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800214 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700215 }
216
217 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
218 jthreadGroup group,
219 jint* thread_count_ptr,
220 jthread** threads_ptr,
221 jint* group_count_ptr,
222 jthreadGroup** groups_ptr) {
Andreas Gampe02afcde2017-01-12 17:34:39 -0800223 return ThreadGroupUtil::GetThreadGroupChildren(env,
224 group,
225 thread_count_ptr,
226 threads_ptr,
227 group_count_ptr,
228 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700229 }
230
231 static jvmtiError GetStackTrace(jvmtiEnv* env,
232 jthread thread,
233 jint start_depth,
234 jint max_frame_count,
235 jvmtiFrameInfo* frame_buffer,
236 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700237 return StackUtil::GetStackTrace(env,
238 thread,
239 start_depth,
240 max_frame_count,
241 frame_buffer,
242 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700243 }
244
245 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
246 jint max_frame_count,
247 jvmtiStackInfo** stack_info_ptr,
248 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800249 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700250 }
251
252 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
253 jint thread_count,
254 const jthread* thread_list,
255 jint max_frame_count,
256 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800257 return StackUtil::GetThreadListStackTraces(env,
258 thread_count,
259 thread_list,
260 max_frame_count,
261 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700262 }
263
264 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800265 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700266 }
267
268 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
269 return ERR(NOT_IMPLEMENTED);
270 }
271
272 static jvmtiError GetFrameLocation(jvmtiEnv* env,
273 jthread thread,
274 jint depth,
275 jmethodID* method_ptr,
276 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800277 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700278 }
279
280 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
281 return ERR(NOT_IMPLEMENTED);
282 }
283
284 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
285 return ERR(NOT_IMPLEMENTED);
286 }
287
288 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
289 return ERR(NOT_IMPLEMENTED);
290 }
291
292 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
293 return ERR(NOT_IMPLEMENTED);
294 }
295
296 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
297 return ERR(NOT_IMPLEMENTED);
298 }
299
300 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
301 return ERR(NOT_IMPLEMENTED);
302 }
303
304 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
305 return ERR(NOT_IMPLEMENTED);
306 }
307
308 static jvmtiError FollowReferences(jvmtiEnv* env,
309 jint heap_filter,
310 jclass klass,
311 jobject initial_object,
312 const jvmtiHeapCallbacks* callbacks,
313 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700314 HeapUtil heap_util(&gObjectTagTable);
315 return heap_util.FollowReferences(env,
316 heap_filter,
317 klass,
318 initial_object,
319 callbacks,
320 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700321 }
322
323 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
324 jint heap_filter,
325 jclass klass,
326 const jvmtiHeapCallbacks* callbacks,
327 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700328 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700329 HeapUtil heap_util(&gObjectTagTable);
330 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700331 }
332
333 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700334 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700335
336 JNIEnv* jni_env = GetJniEnv(env);
337 if (jni_env == nullptr) {
338 return ERR(INTERNAL);
339 }
340
341 art::ScopedObjectAccess soa(jni_env);
342 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
343 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
344 *tag_ptr = 0;
345 }
346
347 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700348 }
349
350 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700351 ENSURE_HAS_CAP(env, can_tag_objects);
352
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700353 if (object == nullptr) {
354 return ERR(NULL_POINTER);
355 }
356
357 JNIEnv* jni_env = GetJniEnv(env);
358 if (jni_env == nullptr) {
359 return ERR(INTERNAL);
360 }
361
362 art::ScopedObjectAccess soa(jni_env);
363 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700364 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700365
366 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700367 }
368
369 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
370 jint tag_count,
371 const jlong* tags,
372 jint* count_ptr,
373 jobject** object_result_ptr,
374 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700375 ENSURE_HAS_CAP(env, can_tag_objects);
376
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700377 JNIEnv* jni_env = GetJniEnv(env);
378 if (jni_env == nullptr) {
379 return ERR(INTERNAL);
380 }
381
382 art::ScopedObjectAccess soa(jni_env);
383 return gObjectTagTable.GetTaggedObjects(env,
384 tag_count,
385 tags,
386 count_ptr,
387 object_result_ptr,
388 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700389 }
390
391 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700392 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700393 }
394
395 static jvmtiError IterateOverObjectsReachableFromObject(
396 jvmtiEnv* env,
397 jobject object,
398 jvmtiObjectReferenceCallback object_reference_callback,
399 const void* user_data) {
400 return ERR(NOT_IMPLEMENTED);
401 }
402
403 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
404 jvmtiHeapRootCallback heap_root_callback,
405 jvmtiStackReferenceCallback stack_ref_callback,
406 jvmtiObjectReferenceCallback object_ref_callback,
407 const void* user_data) {
408 return ERR(NOT_IMPLEMENTED);
409 }
410
411 static jvmtiError IterateOverHeap(jvmtiEnv* env,
412 jvmtiHeapObjectFilter object_filter,
413 jvmtiHeapObjectCallback heap_object_callback,
414 const void* user_data) {
415 return ERR(NOT_IMPLEMENTED);
416 }
417
418 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
419 jclass klass,
420 jvmtiHeapObjectFilter object_filter,
421 jvmtiHeapObjectCallback heap_object_callback,
422 const void* user_data) {
423 return ERR(NOT_IMPLEMENTED);
424 }
425
426 static jvmtiError GetLocalObject(jvmtiEnv* env,
427 jthread thread,
428 jint depth,
429 jint slot,
430 jobject* value_ptr) {
431 return ERR(NOT_IMPLEMENTED);
432 }
433
434 static jvmtiError GetLocalInstance(jvmtiEnv* env,
435 jthread thread,
436 jint depth,
437 jobject* value_ptr) {
438 return ERR(NOT_IMPLEMENTED);
439 }
440
441 static jvmtiError GetLocalInt(jvmtiEnv* env,
442 jthread thread,
443 jint depth,
444 jint slot,
445 jint* value_ptr) {
446 return ERR(NOT_IMPLEMENTED);
447 }
448
449 static jvmtiError GetLocalLong(jvmtiEnv* env,
450 jthread thread,
451 jint depth,
452 jint slot,
453 jlong* value_ptr) {
454 return ERR(NOT_IMPLEMENTED);
455 }
456
457 static jvmtiError GetLocalFloat(jvmtiEnv* env,
458 jthread thread,
459 jint depth,
460 jint slot,
461 jfloat* value_ptr) {
462 return ERR(NOT_IMPLEMENTED);
463 }
464
465 static jvmtiError GetLocalDouble(jvmtiEnv* env,
466 jthread thread,
467 jint depth,
468 jint slot,
469 jdouble* value_ptr) {
470 return ERR(NOT_IMPLEMENTED);
471 }
472
473 static jvmtiError SetLocalObject(jvmtiEnv* env,
474 jthread thread,
475 jint depth,
476 jint slot,
477 jobject value) {
478 return ERR(NOT_IMPLEMENTED);
479 }
480
481 static jvmtiError SetLocalInt(jvmtiEnv* env,
482 jthread thread,
483 jint depth,
484 jint slot,
485 jint value) {
486 return ERR(NOT_IMPLEMENTED);
487 }
488
489 static jvmtiError SetLocalLong(jvmtiEnv* env,
490 jthread thread,
491 jint depth,
492 jint slot,
493 jlong value) {
494 return ERR(NOT_IMPLEMENTED);
495 }
496
497 static jvmtiError SetLocalFloat(jvmtiEnv* env,
498 jthread thread,
499 jint depth,
500 jint slot,
501 jfloat value) {
502 return ERR(NOT_IMPLEMENTED);
503 }
504
505 static jvmtiError SetLocalDouble(jvmtiEnv* env,
506 jthread thread,
507 jint depth,
508 jint slot,
509 jdouble value) {
510 return ERR(NOT_IMPLEMENTED);
511 }
512
513 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
514 return ERR(NOT_IMPLEMENTED);
515 }
516
517 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
518 return ERR(NOT_IMPLEMENTED);
519 }
520
521 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
522 return ERR(NOT_IMPLEMENTED);
523 }
524
525 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
526 return ERR(NOT_IMPLEMENTED);
527 }
528
529 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
530 return ERR(NOT_IMPLEMENTED);
531 }
532
533 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
534 return ERR(NOT_IMPLEMENTED);
535 }
536
537 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700538 HeapUtil heap_util(&gObjectTagTable);
539 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700540 }
541
542 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
543 jobject initiating_loader,
544 jint* class_count_ptr,
545 jclass** classes_ptr) {
546 return ERR(NOT_IMPLEMENTED);
547 }
548
549 static jvmtiError GetClassSignature(jvmtiEnv* env,
550 jclass klass,
551 char** signature_ptr,
552 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700553 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700554 }
555
556 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800557 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700558 }
559
560 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
561 return ERR(NOT_IMPLEMENTED);
562 }
563
564 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800565 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700566 }
567
568 static jvmtiError GetClassMethods(jvmtiEnv* env,
569 jclass klass,
570 jint* method_count_ptr,
571 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800572 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700573 }
574
575 static jvmtiError GetClassFields(jvmtiEnv* env,
576 jclass klass,
577 jint* field_count_ptr,
578 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800579 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700580 }
581
582 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
583 jclass klass,
584 jint* interface_count_ptr,
585 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800586 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700587 }
588
589 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
590 jclass klass,
591 jint* minor_version_ptr,
592 jint* major_version_ptr) {
593 return ERR(NOT_IMPLEMENTED);
594 }
595
596 static jvmtiError GetConstantPool(jvmtiEnv* env,
597 jclass klass,
598 jint* constant_pool_count_ptr,
599 jint* constant_pool_byte_count_ptr,
600 unsigned char** constant_pool_bytes_ptr) {
601 return ERR(NOT_IMPLEMENTED);
602 }
603
604 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800605 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700606 }
607
608 static jvmtiError IsArrayClass(jvmtiEnv* env,
609 jclass klass,
610 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800611 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700612 }
613
614 static jvmtiError IsModifiableClass(jvmtiEnv* env,
615 jclass klass,
616 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800617 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700618 }
619
620 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800621 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700622 }
623
624 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
625 jclass klass,
626 char** source_debug_extension_ptr) {
627 return ERR(NOT_IMPLEMENTED);
628 }
629
630 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
631 return ERR(NOT_IMPLEMENTED);
632 }
633
634 static jvmtiError RedefineClasses(jvmtiEnv* env,
635 jint class_count,
636 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800637 std::string error_msg;
638 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
639 art::Runtime::Current(),
640 art::Thread::Current(),
641 class_count,
642 class_definitions,
643 &error_msg);
644 if (res != OK) {
645 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
646 }
647 return res;
Alex Light49948e92016-08-11 15:35:28 -0700648 }
649
650 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800651 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700652 }
653
654 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800655 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700656 }
657
658 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
659 jobject object,
660 jvmtiMonitorUsage* info_ptr) {
661 return ERR(NOT_IMPLEMENTED);
662 }
663
664 static jvmtiError GetFieldName(jvmtiEnv* env,
665 jclass klass,
666 jfieldID field,
667 char** name_ptr,
668 char** signature_ptr,
669 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800670 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700671 }
672
673 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
674 jclass klass,
675 jfieldID field,
676 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800677 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700678 }
679
680 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
681 jclass klass,
682 jfieldID field,
683 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800684 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700685 }
686
687 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
688 jclass klass,
689 jfieldID field,
690 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800691 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700692 }
693
694 static jvmtiError GetMethodName(jvmtiEnv* env,
695 jmethodID method,
696 char** name_ptr,
697 char** signature_ptr,
698 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700699 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700700 }
701
702 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
703 jmethodID method,
704 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700705 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700706 }
707
708 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
709 jmethodID method,
710 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700711 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700712 }
713
714 static jvmtiError GetMaxLocals(jvmtiEnv* env,
715 jmethodID method,
716 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800717 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700718 }
719
720 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
721 jmethodID method,
722 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800723 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700724 }
725
726 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
727 jmethodID method,
728 jint* entry_count_ptr,
729 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800730 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700731 }
732
733 static jvmtiError GetMethodLocation(jvmtiEnv* env,
734 jmethodID method,
735 jlocation* start_location_ptr,
736 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800737 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700738 }
739
740 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
741 jmethodID method,
742 jint* entry_count_ptr,
743 jvmtiLocalVariableEntry** table_ptr) {
744 return ERR(NOT_IMPLEMENTED);
745 }
746
747 static jvmtiError GetBytecodes(jvmtiEnv* env,
748 jmethodID method,
749 jint* bytecode_count_ptr,
750 unsigned char** bytecodes_ptr) {
751 return ERR(NOT_IMPLEMENTED);
752 }
753
754 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800755 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700756 }
757
758 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800759 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700760 }
761
762 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800763 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700764 }
765
766 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
767 return ERR(NOT_IMPLEMENTED);
768 }
769
770 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
771 return ERR(NOT_IMPLEMENTED);
772 }
773
774 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800775 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700776 }
777
778 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800779 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700780 }
781
782 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800783 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700784 }
785
786 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800787 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700788 }
789
790 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800791 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700792 }
793
794 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800795 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700796 }
797
798 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800799 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700800 }
801
802 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
803 return ERR(NOT_IMPLEMENTED);
804 }
805
806 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
807 return ERR(NOT_IMPLEMENTED);
808 }
809
Andreas Gampe77708d92016-10-07 11:48:21 -0700810 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
811 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700812 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
813 const jvmtiEventCallbacks* callbacks,
814 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700815 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700816 if (size_of_callbacks < 0) {
817 return ERR(ILLEGAL_ARGUMENT);
818 }
819
820 if (callbacks == nullptr) {
821 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
822 return ERR(NONE);
823 }
824
825 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
826 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
827 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
828 static_cast<size_t>(size_of_callbacks));
829 copy_size = art::RoundDown(copy_size, sizeof(void*));
830 memcpy(tmp.get(), callbacks, copy_size);
831
832 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
833
834 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700835 }
836
837 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
838 jvmtiEventMode mode,
839 jvmtiEvent event_type,
840 jthread event_thread,
841 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700842 ENSURE_VALID_ENV(env);
843 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700844 art::Thread* art_thread = nullptr;
845 if (event_thread != nullptr) {
846 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
847 art::ScopedObjectAccess soa(art::Thread::Current());
848 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
849 art_thread = art::Thread::FromManagedThread(soa, event_thread);
850
851 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
852 art_thread->IsStillStarting()) {
853 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
854 return ERR(THREAD_NOT_ALIVE);
855 }
856 }
857
858 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700859 }
860
861 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
862 return ERR(NOT_IMPLEMENTED);
863 }
864
865 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
866 jint* extension_count_ptr,
867 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800868 // We do not have any extension functions.
869 *extension_count_ptr = 0;
870 *extensions = nullptr;
871
872 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700873 }
874
875 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
876 jint* extension_count_ptr,
877 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800878 // We do not have any extension events.
879 *extension_count_ptr = 0;
880 *extensions = nullptr;
881
882 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700883 }
884
885 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
886 jint extension_event_index,
887 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800888 // We do not have any extension events, so any call is illegal.
889 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700890 }
891
892 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700893 ENSURE_VALID_ENV(env);
894 ENSURE_NON_NULL(capabilities_ptr);
895 *capabilities_ptr = kPotentialCapabilities;
896 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700897 }
898
899 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700900 ENSURE_VALID_ENV(env);
901 ENSURE_NON_NULL(capabilities_ptr);
902 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
903 jvmtiError ret = OK;
904#define ADD_CAPABILITY(e) \
905 do { \
906 if (capabilities_ptr->e == 1) { \
907 if (kPotentialCapabilities.e == 1) { \
908 art_env->capabilities.e = 1;\
909 } else { \
910 ret = ERR(NOT_AVAILABLE); \
911 } \
912 } \
913 } while (false)
914
915 ADD_CAPABILITY(can_tag_objects);
916 ADD_CAPABILITY(can_generate_field_modification_events);
917 ADD_CAPABILITY(can_generate_field_access_events);
918 ADD_CAPABILITY(can_get_bytecodes);
919 ADD_CAPABILITY(can_get_synthetic_attribute);
920 ADD_CAPABILITY(can_get_owned_monitor_info);
921 ADD_CAPABILITY(can_get_current_contended_monitor);
922 ADD_CAPABILITY(can_get_monitor_info);
923 ADD_CAPABILITY(can_pop_frame);
924 ADD_CAPABILITY(can_redefine_classes);
925 ADD_CAPABILITY(can_signal_thread);
926 ADD_CAPABILITY(can_get_source_file_name);
927 ADD_CAPABILITY(can_get_line_numbers);
928 ADD_CAPABILITY(can_get_source_debug_extension);
929 ADD_CAPABILITY(can_access_local_variables);
930 ADD_CAPABILITY(can_maintain_original_method_order);
931 ADD_CAPABILITY(can_generate_single_step_events);
932 ADD_CAPABILITY(can_generate_exception_events);
933 ADD_CAPABILITY(can_generate_frame_pop_events);
934 ADD_CAPABILITY(can_generate_breakpoint_events);
935 ADD_CAPABILITY(can_suspend);
936 ADD_CAPABILITY(can_redefine_any_class);
937 ADD_CAPABILITY(can_get_current_thread_cpu_time);
938 ADD_CAPABILITY(can_get_thread_cpu_time);
939 ADD_CAPABILITY(can_generate_method_entry_events);
940 ADD_CAPABILITY(can_generate_method_exit_events);
941 ADD_CAPABILITY(can_generate_all_class_hook_events);
942 ADD_CAPABILITY(can_generate_compiled_method_load_events);
943 ADD_CAPABILITY(can_generate_monitor_events);
944 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
945 ADD_CAPABILITY(can_generate_native_method_bind_events);
946 ADD_CAPABILITY(can_generate_garbage_collection_events);
947 ADD_CAPABILITY(can_generate_object_free_events);
948 ADD_CAPABILITY(can_force_early_return);
949 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
950 ADD_CAPABILITY(can_get_constant_pool);
951 ADD_CAPABILITY(can_set_native_method_prefix);
952 ADD_CAPABILITY(can_retransform_classes);
953 ADD_CAPABILITY(can_retransform_any_class);
954 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
955 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
956#undef ADD_CAPABILITY
957 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700958 }
959
960 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
961 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700962 ENSURE_VALID_ENV(env);
963 ENSURE_NON_NULL(capabilities_ptr);
964 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
965#define DEL_CAPABILITY(e) \
966 do { \
967 if (capabilities_ptr->e == 1) { \
968 art_env->capabilities.e = 0;\
969 } \
970 } while (false)
971
972 DEL_CAPABILITY(can_tag_objects);
973 DEL_CAPABILITY(can_generate_field_modification_events);
974 DEL_CAPABILITY(can_generate_field_access_events);
975 DEL_CAPABILITY(can_get_bytecodes);
976 DEL_CAPABILITY(can_get_synthetic_attribute);
977 DEL_CAPABILITY(can_get_owned_monitor_info);
978 DEL_CAPABILITY(can_get_current_contended_monitor);
979 DEL_CAPABILITY(can_get_monitor_info);
980 DEL_CAPABILITY(can_pop_frame);
981 DEL_CAPABILITY(can_redefine_classes);
982 DEL_CAPABILITY(can_signal_thread);
983 DEL_CAPABILITY(can_get_source_file_name);
984 DEL_CAPABILITY(can_get_line_numbers);
985 DEL_CAPABILITY(can_get_source_debug_extension);
986 DEL_CAPABILITY(can_access_local_variables);
987 DEL_CAPABILITY(can_maintain_original_method_order);
988 DEL_CAPABILITY(can_generate_single_step_events);
989 DEL_CAPABILITY(can_generate_exception_events);
990 DEL_CAPABILITY(can_generate_frame_pop_events);
991 DEL_CAPABILITY(can_generate_breakpoint_events);
992 DEL_CAPABILITY(can_suspend);
993 DEL_CAPABILITY(can_redefine_any_class);
994 DEL_CAPABILITY(can_get_current_thread_cpu_time);
995 DEL_CAPABILITY(can_get_thread_cpu_time);
996 DEL_CAPABILITY(can_generate_method_entry_events);
997 DEL_CAPABILITY(can_generate_method_exit_events);
998 DEL_CAPABILITY(can_generate_all_class_hook_events);
999 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1000 DEL_CAPABILITY(can_generate_monitor_events);
1001 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1002 DEL_CAPABILITY(can_generate_native_method_bind_events);
1003 DEL_CAPABILITY(can_generate_garbage_collection_events);
1004 DEL_CAPABILITY(can_generate_object_free_events);
1005 DEL_CAPABILITY(can_force_early_return);
1006 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1007 DEL_CAPABILITY(can_get_constant_pool);
1008 DEL_CAPABILITY(can_set_native_method_prefix);
1009 DEL_CAPABILITY(can_retransform_classes);
1010 DEL_CAPABILITY(can_retransform_any_class);
1011 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1012 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1013#undef DEL_CAPABILITY
1014 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001015 }
1016
1017 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001018 ENSURE_VALID_ENV(env);
1019 ENSURE_NON_NULL(capabilities_ptr);
1020 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1021 *capabilities_ptr = artenv->capabilities;
1022 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001023 }
1024
1025 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1026 return ERR(NOT_IMPLEMENTED);
1027 }
1028
1029 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1030 return ERR(NOT_IMPLEMENTED);
1031 }
1032
1033 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1034 return ERR(NOT_IMPLEMENTED);
1035 }
1036
1037 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1038 return ERR(NOT_IMPLEMENTED);
1039 }
1040
1041 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1042 return ERR(NOT_IMPLEMENTED);
1043 }
1044
1045 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
1046 return ERR(NOT_IMPLEMENTED);
1047 }
1048
1049 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
1050 return ERR(NOT_IMPLEMENTED);
1051 }
1052
1053 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1054 return ERR(NOT_IMPLEMENTED);
1055 }
1056
1057 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1058 return ERR(NOT_IMPLEMENTED);
1059 }
1060
1061 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001062 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001063 }
1064
1065 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001066 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001067 }
1068
1069 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001070 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001071 }
1072
1073 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1074 return ERR(NOT_IMPLEMENTED);
1075 }
1076
1077 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001078 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001079 delete env;
1080 return OK;
1081 }
1082
1083 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001084 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001085 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1086 return OK;
1087 }
1088
1089 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001090 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001091 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1092 return OK;
1093 }
1094
1095 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001096 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001097 *version_ptr = JVMTI_VERSION;
1098 return OK;
1099 }
1100
1101 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001102 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001103 switch (error) {
1104#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001105 jvmtiError res = CopyString(env, \
1106 "JVMTI_ERROR_"#e, \
1107 reinterpret_cast<unsigned char**>(name_ptr)); \
1108 if (res != OK) { \
1109 *name_ptr = nullptr; \
1110 return res; \
1111 } else { \
1112 return OK; \
1113 } \
Alex Light49948e92016-08-11 15:35:28 -07001114 } while (false)
1115 ERROR_CASE(NONE);
1116 ERROR_CASE(INVALID_THREAD);
1117 ERROR_CASE(INVALID_THREAD_GROUP);
1118 ERROR_CASE(INVALID_PRIORITY);
1119 ERROR_CASE(THREAD_NOT_SUSPENDED);
1120 ERROR_CASE(THREAD_NOT_ALIVE);
1121 ERROR_CASE(INVALID_OBJECT);
1122 ERROR_CASE(INVALID_CLASS);
1123 ERROR_CASE(CLASS_NOT_PREPARED);
1124 ERROR_CASE(INVALID_METHODID);
1125 ERROR_CASE(INVALID_LOCATION);
1126 ERROR_CASE(INVALID_FIELDID);
1127 ERROR_CASE(NO_MORE_FRAMES);
1128 ERROR_CASE(OPAQUE_FRAME);
1129 ERROR_CASE(TYPE_MISMATCH);
1130 ERROR_CASE(INVALID_SLOT);
1131 ERROR_CASE(DUPLICATE);
1132 ERROR_CASE(NOT_FOUND);
1133 ERROR_CASE(INVALID_MONITOR);
1134 ERROR_CASE(NOT_MONITOR_OWNER);
1135 ERROR_CASE(INTERRUPT);
1136 ERROR_CASE(INVALID_CLASS_FORMAT);
1137 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1138 ERROR_CASE(FAILS_VERIFICATION);
1139 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1140 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1141 ERROR_CASE(INVALID_TYPESTATE);
1142 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1143 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1144 ERROR_CASE(UNSUPPORTED_VERSION);
1145 ERROR_CASE(NAMES_DONT_MATCH);
1146 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1147 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1148 ERROR_CASE(UNMODIFIABLE_CLASS);
1149 ERROR_CASE(NOT_AVAILABLE);
1150 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1151 ERROR_CASE(NULL_POINTER);
1152 ERROR_CASE(ABSENT_INFORMATION);
1153 ERROR_CASE(INVALID_EVENT_TYPE);
1154 ERROR_CASE(ILLEGAL_ARGUMENT);
1155 ERROR_CASE(NATIVE_METHOD);
1156 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1157 ERROR_CASE(OUT_OF_MEMORY);
1158 ERROR_CASE(ACCESS_DENIED);
1159 ERROR_CASE(WRONG_PHASE);
1160 ERROR_CASE(INTERNAL);
1161 ERROR_CASE(UNATTACHED_THREAD);
1162 ERROR_CASE(INVALID_ENVIRONMENT);
1163#undef ERROR_CASE
1164 default: {
Alex Light41960712017-01-06 14:44:23 -08001165 jvmtiError res = CopyString(env,
1166 "JVMTI_ERROR_UNKNOWN",
1167 reinterpret_cast<unsigned char**>(name_ptr));
1168 if (res != OK) {
1169 *name_ptr = nullptr;
1170 return res;
1171 } else {
1172 return ERR(ILLEGAL_ARGUMENT);
1173 }
Alex Light49948e92016-08-11 15:35:28 -07001174 }
1175 }
1176 }
1177
1178 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001179 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1180 // OTHER is special, as it's 0, so can't do a bit check.
1181 bool val = (value == JNI_TRUE) ? true : false;
1182
1183 art::gLogVerbosity.collector = val;
1184 art::gLogVerbosity.compiler = val;
1185 art::gLogVerbosity.deopt = val;
1186 art::gLogVerbosity.heap = val;
1187 art::gLogVerbosity.jdwp = val;
1188 art::gLogVerbosity.jit = val;
1189 art::gLogVerbosity.monitor = val;
1190 art::gLogVerbosity.oat = val;
1191 art::gLogVerbosity.profiler = val;
1192 art::gLogVerbosity.signals = val;
1193 art::gLogVerbosity.simulator = val;
1194 art::gLogVerbosity.startup = val;
1195 art::gLogVerbosity.third_party_jni = val;
1196 art::gLogVerbosity.threads = val;
1197 art::gLogVerbosity.verifier = val;
1198 art::gLogVerbosity.image = val;
1199
1200 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1201
1202 art::gLogVerbosity.agents = val;
1203 } else {
1204 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1205 // semantics.
1206 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1207 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1208 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1209 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1210 if ((flag & ~kMask) != 0) {
1211 return ERR(ILLEGAL_ARGUMENT);
1212 }
1213
1214 bool val = (value == JNI_TRUE) ? true : false;
1215
1216 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1217 art::gLogVerbosity.gc = val;
1218 }
1219
1220 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1221 art::gLogVerbosity.class_linker = val;
1222 }
1223
1224 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1225 art::gLogVerbosity.jni = val;
1226 }
1227 }
1228
1229 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001230 }
1231
1232 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1233 return ERR(NOT_IMPLEMENTED);
1234 }
Alex Light9c20a142016-08-23 15:05:12 -07001235
1236 // TODO Remove this once events are working.
1237 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1238 jclass klass,
1239 jvmtiEventClassFileLoadHook hook) {
1240 std::vector<jclass> classes;
1241 classes.push_back(klass);
1242 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1243 }
1244
1245 // TODO This will be called by the event handler for the art::ti Event Load Event
1246 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1247 const std::vector<jclass>& classes,
1248 jvmtiEventClassFileLoadHook hook) {
1249 if (!IsValidEnv(env)) {
1250 return ERR(INVALID_ENVIRONMENT);
1251 }
Alex Lighta01de592016-11-15 10:43:06 -08001252 jvmtiError res = OK;
1253 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001254 for (jclass klass : classes) {
1255 JNIEnv* jni_env = nullptr;
1256 jobject loader = nullptr;
1257 std::string name;
1258 jobject protection_domain = nullptr;
1259 jint data_len = 0;
1260 unsigned char* dex_data = nullptr;
1261 jvmtiError ret = OK;
1262 std::string location;
1263 if ((ret = GetTransformationData(env,
1264 klass,
1265 /*out*/&location,
1266 /*out*/&jni_env,
1267 /*out*/&loader,
1268 /*out*/&name,
1269 /*out*/&protection_domain,
1270 /*out*/&data_len,
1271 /*out*/&dex_data)) != OK) {
1272 // TODO Do something more here? Maybe give log statements?
1273 return ret;
1274 }
1275 jint new_data_len = 0;
1276 unsigned char* new_dex_data = nullptr;
1277 hook(env,
1278 jni_env,
1279 klass,
1280 loader,
1281 name.c_str(),
1282 protection_domain,
1283 data_len,
1284 dex_data,
1285 /*out*/&new_data_len,
1286 /*out*/&new_dex_data);
1287 // Check if anything actually changed.
1288 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001289 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1290 res = Redefiner::RedefineClasses(env,
1291 art::Runtime::Current(),
1292 art::Thread::Current(),
1293 1,
1294 &def,
1295 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001296 env->Deallocate(new_dex_data);
1297 }
1298 // Deallocate the old dex data.
1299 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001300 if (res != OK) {
1301 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1302 return res;
1303 }
Alex Light9c20a142016-08-23 15:05:12 -07001304 }
1305 return OK;
1306 }
Alex Light49948e92016-08-11 15:35:28 -07001307};
1308
1309static bool IsJvmtiVersion(jint version) {
1310 return version == JVMTI_VERSION_1 ||
1311 version == JVMTI_VERSION_1_0 ||
1312 version == JVMTI_VERSION_1_1 ||
1313 version == JVMTI_VERSION_1_2 ||
1314 version == JVMTI_VERSION;
1315}
1316
1317// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1318// is a pointer to the uninitialized memory for an art::ti::Env.
1319static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1320 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1321 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001322
1323 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001324}
1325
1326// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1327// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1328// returns false and does not modify the 'env' pointer.
1329static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1330 if (IsJvmtiVersion(version)) {
1331 CreateArtJvmTiEnv(vm, env);
1332 return JNI_OK;
1333 } else {
1334 printf("version 0x%x is not valid!", version);
1335 return JNI_EVERSION;
1336 }
1337}
1338
1339// The plugin initialization function. This adds the jvmti environment.
1340extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001341 art::Runtime* runtime = art::Runtime::Current();
1342 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1343 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001344 return true;
1345}
1346
1347// The actual struct holding all of the entrypoints into the jvmti interface.
1348const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001349 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1350 // TODO Remove once we have events working.
1351 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1352 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001353 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001354 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001355 JvmtiFunctions::GetAllThreads,
1356 JvmtiFunctions::SuspendThread,
1357 JvmtiFunctions::ResumeThread,
1358 JvmtiFunctions::StopThread,
1359 JvmtiFunctions::InterruptThread,
1360 JvmtiFunctions::GetThreadInfo,
1361 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1362 JvmtiFunctions::GetCurrentContendedMonitor,
1363 JvmtiFunctions::RunAgentThread,
1364 JvmtiFunctions::GetTopThreadGroups,
1365 JvmtiFunctions::GetThreadGroupInfo,
1366 JvmtiFunctions::GetThreadGroupChildren,
1367 JvmtiFunctions::GetFrameCount,
1368 JvmtiFunctions::GetThreadState,
1369 JvmtiFunctions::GetCurrentThread,
1370 JvmtiFunctions::GetFrameLocation,
1371 JvmtiFunctions::NotifyFramePop, // 20
1372 JvmtiFunctions::GetLocalObject,
1373 JvmtiFunctions::GetLocalInt,
1374 JvmtiFunctions::GetLocalLong,
1375 JvmtiFunctions::GetLocalFloat,
1376 JvmtiFunctions::GetLocalDouble,
1377 JvmtiFunctions::SetLocalObject,
1378 JvmtiFunctions::SetLocalInt,
1379 JvmtiFunctions::SetLocalLong,
1380 JvmtiFunctions::SetLocalFloat,
1381 JvmtiFunctions::SetLocalDouble, // 30
1382 JvmtiFunctions::CreateRawMonitor,
1383 JvmtiFunctions::DestroyRawMonitor,
1384 JvmtiFunctions::RawMonitorEnter,
1385 JvmtiFunctions::RawMonitorExit,
1386 JvmtiFunctions::RawMonitorWait,
1387 JvmtiFunctions::RawMonitorNotify,
1388 JvmtiFunctions::RawMonitorNotifyAll,
1389 JvmtiFunctions::SetBreakpoint,
1390 JvmtiFunctions::ClearBreakpoint,
1391 nullptr, // reserved40
1392 JvmtiFunctions::SetFieldAccessWatch,
1393 JvmtiFunctions::ClearFieldAccessWatch,
1394 JvmtiFunctions::SetFieldModificationWatch,
1395 JvmtiFunctions::ClearFieldModificationWatch,
1396 JvmtiFunctions::IsModifiableClass,
1397 JvmtiFunctions::Allocate,
1398 JvmtiFunctions::Deallocate,
1399 JvmtiFunctions::GetClassSignature,
1400 JvmtiFunctions::GetClassStatus,
1401 JvmtiFunctions::GetSourceFileName, // 50
1402 JvmtiFunctions::GetClassModifiers,
1403 JvmtiFunctions::GetClassMethods,
1404 JvmtiFunctions::GetClassFields,
1405 JvmtiFunctions::GetImplementedInterfaces,
1406 JvmtiFunctions::IsInterface,
1407 JvmtiFunctions::IsArrayClass,
1408 JvmtiFunctions::GetClassLoader,
1409 JvmtiFunctions::GetObjectHashCode,
1410 JvmtiFunctions::GetObjectMonitorUsage,
1411 JvmtiFunctions::GetFieldName, // 60
1412 JvmtiFunctions::GetFieldDeclaringClass,
1413 JvmtiFunctions::GetFieldModifiers,
1414 JvmtiFunctions::IsFieldSynthetic,
1415 JvmtiFunctions::GetMethodName,
1416 JvmtiFunctions::GetMethodDeclaringClass,
1417 JvmtiFunctions::GetMethodModifiers,
1418 nullptr, // reserved67
1419 JvmtiFunctions::GetMaxLocals,
1420 JvmtiFunctions::GetArgumentsSize,
1421 JvmtiFunctions::GetLineNumberTable, // 70
1422 JvmtiFunctions::GetMethodLocation,
1423 JvmtiFunctions::GetLocalVariableTable,
1424 JvmtiFunctions::SetNativeMethodPrefix,
1425 JvmtiFunctions::SetNativeMethodPrefixes,
1426 JvmtiFunctions::GetBytecodes,
1427 JvmtiFunctions::IsMethodNative,
1428 JvmtiFunctions::IsMethodSynthetic,
1429 JvmtiFunctions::GetLoadedClasses,
1430 JvmtiFunctions::GetClassLoaderClasses,
1431 JvmtiFunctions::PopFrame, // 80
1432 JvmtiFunctions::ForceEarlyReturnObject,
1433 JvmtiFunctions::ForceEarlyReturnInt,
1434 JvmtiFunctions::ForceEarlyReturnLong,
1435 JvmtiFunctions::ForceEarlyReturnFloat,
1436 JvmtiFunctions::ForceEarlyReturnDouble,
1437 JvmtiFunctions::ForceEarlyReturnVoid,
1438 JvmtiFunctions::RedefineClasses,
1439 JvmtiFunctions::GetVersionNumber,
1440 JvmtiFunctions::GetCapabilities,
1441 JvmtiFunctions::GetSourceDebugExtension, // 90
1442 JvmtiFunctions::IsMethodObsolete,
1443 JvmtiFunctions::SuspendThreadList,
1444 JvmtiFunctions::ResumeThreadList,
1445 nullptr, // reserved94
1446 nullptr, // reserved95
1447 nullptr, // reserved96
1448 nullptr, // reserved97
1449 nullptr, // reserved98
1450 nullptr, // reserved99
1451 JvmtiFunctions::GetAllStackTraces, // 100
1452 JvmtiFunctions::GetThreadListStackTraces,
1453 JvmtiFunctions::GetThreadLocalStorage,
1454 JvmtiFunctions::SetThreadLocalStorage,
1455 JvmtiFunctions::GetStackTrace,
1456 nullptr, // reserved105
1457 JvmtiFunctions::GetTag,
1458 JvmtiFunctions::SetTag,
1459 JvmtiFunctions::ForceGarbageCollection,
1460 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1461 JvmtiFunctions::IterateOverReachableObjects, // 110
1462 JvmtiFunctions::IterateOverHeap,
1463 JvmtiFunctions::IterateOverInstancesOfClass,
1464 nullptr, // reserved113
1465 JvmtiFunctions::GetObjectsWithTags,
1466 JvmtiFunctions::FollowReferences,
1467 JvmtiFunctions::IterateThroughHeap,
1468 nullptr, // reserved117
1469 nullptr, // reserved118
1470 nullptr, // reserved119
1471 JvmtiFunctions::SetJNIFunctionTable, // 120
1472 JvmtiFunctions::GetJNIFunctionTable,
1473 JvmtiFunctions::SetEventCallbacks,
1474 JvmtiFunctions::GenerateEvents,
1475 JvmtiFunctions::GetExtensionFunctions,
1476 JvmtiFunctions::GetExtensionEvents,
1477 JvmtiFunctions::SetExtensionEventCallback,
1478 JvmtiFunctions::DisposeEnvironment,
1479 JvmtiFunctions::GetErrorName,
1480 JvmtiFunctions::GetJLocationFormat,
1481 JvmtiFunctions::GetSystemProperties, // 130
1482 JvmtiFunctions::GetSystemProperty,
1483 JvmtiFunctions::SetSystemProperty,
1484 JvmtiFunctions::GetPhase,
1485 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1486 JvmtiFunctions::GetCurrentThreadCpuTime,
1487 JvmtiFunctions::GetThreadCpuTimerInfo,
1488 JvmtiFunctions::GetThreadCpuTime,
1489 JvmtiFunctions::GetTimerInfo,
1490 JvmtiFunctions::GetTime,
1491 JvmtiFunctions::GetPotentialCapabilities, // 140
1492 nullptr, // reserved141
1493 JvmtiFunctions::AddCapabilities,
1494 JvmtiFunctions::RelinquishCapabilities,
1495 JvmtiFunctions::GetAvailableProcessors,
1496 JvmtiFunctions::GetClassVersionNumbers,
1497 JvmtiFunctions::GetConstantPool,
1498 JvmtiFunctions::GetEnvironmentLocalStorage,
1499 JvmtiFunctions::SetEnvironmentLocalStorage,
1500 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1501 JvmtiFunctions::SetVerboseFlag, // 150
1502 JvmtiFunctions::AddToSystemClassLoaderSearch,
1503 JvmtiFunctions::RetransformClasses,
1504 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1505 JvmtiFunctions::GetObjectSize,
1506 JvmtiFunctions::GetLocalInstance,
1507};
1508
1509}; // namespace openjdkjvmti