blob: 7882ece5c78e50286e73de333e16a66436353e5e [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 Gampe6f8e4f02017-01-16 18:18:14 -080054#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070055#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080056#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080057#include "ti_object.h"
Andreas Gampe96eca782017-01-19 19:45:30 -080058#include "ti_phase.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080059#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080060#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080061#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070062#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080063#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000064#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080065#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070066#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070067
68// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
69// easier to create.
70#pragma GCC diagnostic ignored "-Wunused-parameter"
71
72namespace openjdkjvmti {
73
Andreas Gampe77708d92016-10-07 11:48:21 -070074EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070075ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070076
Alex Lighte6574242016-08-17 09:56:24 -070077#define ENSURE_NON_NULL(n) \
78 do { \
79 if ((n) == nullptr) { \
80 return ERR(NULL_POINTER); \
81 } \
82 } while (false)
83
Alex Light49948e92016-08-11 15:35:28 -070084class JvmtiFunctions {
85 private:
86 static bool IsValidEnv(jvmtiEnv* env) {
87 return env != nullptr;
88 }
89
Alex Lighte6574242016-08-17 09:56:24 -070090#define ENSURE_VALID_ENV(env) \
91 do { \
92 if (!IsValidEnv(env)) { \
93 return ERR(INVALID_ENVIRONMENT); \
94 } \
95 } while (false)
96
97#define ENSURE_HAS_CAP(env, cap) \
98 do { \
99 ENSURE_VALID_ENV(env); \
100 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
101 return ERR(MUST_POSSESS_CAPABILITY); \
102 } \
103 } while (false)
104
Alex Light49948e92016-08-11 15:35:28 -0700105 public:
106 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700107 ENSURE_VALID_ENV(env);
108 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700109 if (size < 0) {
110 return ERR(ILLEGAL_ARGUMENT);
111 } else if (size == 0) {
112 *mem_ptr = nullptr;
113 return OK;
114 }
115 *mem_ptr = static_cast<unsigned char*>(malloc(size));
116 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
117 }
118
119 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700120 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700121 if (mem != nullptr) {
122 free(mem);
123 }
124 return OK;
125 }
126
127 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800128 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700129 }
130
131 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800132 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700133 }
134
135 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800136 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700137 }
138
139 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
140 return ERR(NOT_IMPLEMENTED);
141 }
142
143 static jvmtiError SuspendThreadList(jvmtiEnv* env,
144 jint request_count,
145 const jthread* request_list,
146 jvmtiError* results) {
147 return ERR(NOT_IMPLEMENTED);
148 }
149
150 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
151 return ERR(NOT_IMPLEMENTED);
152 }
153
154 static jvmtiError ResumeThreadList(jvmtiEnv* env,
155 jint request_count,
156 const jthread* request_list,
157 jvmtiError* results) {
158 return ERR(NOT_IMPLEMENTED);
159 }
160
161 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
162 return ERR(NOT_IMPLEMENTED);
163 }
164
165 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
166 return ERR(NOT_IMPLEMENTED);
167 }
168
169 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800170 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700171 }
172
173 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
174 jthread thread,
175 jint* owned_monitor_count_ptr,
176 jobject** owned_monitors_ptr) {
177 return ERR(NOT_IMPLEMENTED);
178 }
179
180 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
181 jthread thread,
182 jint* monitor_info_count_ptr,
183 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
184 return ERR(NOT_IMPLEMENTED);
185 }
186
187 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
188 jthread thread,
189 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700190 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700191 }
192
193 static jvmtiError RunAgentThread(jvmtiEnv* env,
194 jthread thread,
195 jvmtiStartFunction proc,
196 const void* arg,
197 jint priority) {
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800198 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700199 }
200
201 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
202 return ERR(NOT_IMPLEMENTED);
203 }
204
205 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
206 return ERR(NOT_IMPLEMENTED);
207 }
208
209 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
210 jint* group_count_ptr,
211 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000212 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700213 }
214
215 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
216 jthreadGroup group,
217 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000218 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700219 }
220
221 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
222 jthreadGroup group,
223 jint* thread_count_ptr,
224 jthread** threads_ptr,
225 jint* group_count_ptr,
226 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000227 return ThreadGroupUtil::GetThreadGroupChildren(env,
228 group,
229 thread_count_ptr,
230 threads_ptr,
231 group_count_ptr,
232 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700233 }
234
235 static jvmtiError GetStackTrace(jvmtiEnv* env,
236 jthread thread,
237 jint start_depth,
238 jint max_frame_count,
239 jvmtiFrameInfo* frame_buffer,
240 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700241 return StackUtil::GetStackTrace(env,
242 thread,
243 start_depth,
244 max_frame_count,
245 frame_buffer,
246 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700247 }
248
249 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
250 jint max_frame_count,
251 jvmtiStackInfo** stack_info_ptr,
252 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800253 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700254 }
255
256 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
257 jint thread_count,
258 const jthread* thread_list,
259 jint max_frame_count,
260 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800261 return StackUtil::GetThreadListStackTraces(env,
262 thread_count,
263 thread_list,
264 max_frame_count,
265 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700266 }
267
268 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800269 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700270 }
271
272 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
273 return ERR(NOT_IMPLEMENTED);
274 }
275
276 static jvmtiError GetFrameLocation(jvmtiEnv* env,
277 jthread thread,
278 jint depth,
279 jmethodID* method_ptr,
280 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800281 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700282 }
283
284 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
285 return ERR(NOT_IMPLEMENTED);
286 }
287
288 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
289 return ERR(NOT_IMPLEMENTED);
290 }
291
292 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
293 return ERR(NOT_IMPLEMENTED);
294 }
295
296 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
297 return ERR(NOT_IMPLEMENTED);
298 }
299
300 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
301 return ERR(NOT_IMPLEMENTED);
302 }
303
304 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
305 return ERR(NOT_IMPLEMENTED);
306 }
307
308 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
309 return ERR(NOT_IMPLEMENTED);
310 }
311
312 static jvmtiError FollowReferences(jvmtiEnv* env,
313 jint heap_filter,
314 jclass klass,
315 jobject initial_object,
316 const jvmtiHeapCallbacks* callbacks,
317 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700318 HeapUtil heap_util(&gObjectTagTable);
319 return heap_util.FollowReferences(env,
320 heap_filter,
321 klass,
322 initial_object,
323 callbacks,
324 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700325 }
326
327 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
328 jint heap_filter,
329 jclass klass,
330 const jvmtiHeapCallbacks* callbacks,
331 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700332 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700333 HeapUtil heap_util(&gObjectTagTable);
334 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700335 }
336
337 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700338 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700339
340 JNIEnv* jni_env = GetJniEnv(env);
341 if (jni_env == nullptr) {
342 return ERR(INTERNAL);
343 }
344
345 art::ScopedObjectAccess soa(jni_env);
346 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
347 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
348 *tag_ptr = 0;
349 }
350
351 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700352 }
353
354 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700355 ENSURE_HAS_CAP(env, can_tag_objects);
356
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700357 if (object == nullptr) {
358 return ERR(NULL_POINTER);
359 }
360
361 JNIEnv* jni_env = GetJniEnv(env);
362 if (jni_env == nullptr) {
363 return ERR(INTERNAL);
364 }
365
366 art::ScopedObjectAccess soa(jni_env);
367 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700368 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700369
370 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700371 }
372
373 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
374 jint tag_count,
375 const jlong* tags,
376 jint* count_ptr,
377 jobject** object_result_ptr,
378 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700379 ENSURE_HAS_CAP(env, can_tag_objects);
380
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700381 JNIEnv* jni_env = GetJniEnv(env);
382 if (jni_env == nullptr) {
383 return ERR(INTERNAL);
384 }
385
386 art::ScopedObjectAccess soa(jni_env);
387 return gObjectTagTable.GetTaggedObjects(env,
388 tag_count,
389 tags,
390 count_ptr,
391 object_result_ptr,
392 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700393 }
394
395 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700396 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700397 }
398
399 static jvmtiError IterateOverObjectsReachableFromObject(
400 jvmtiEnv* env,
401 jobject object,
402 jvmtiObjectReferenceCallback object_reference_callback,
403 const void* user_data) {
404 return ERR(NOT_IMPLEMENTED);
405 }
406
407 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
408 jvmtiHeapRootCallback heap_root_callback,
409 jvmtiStackReferenceCallback stack_ref_callback,
410 jvmtiObjectReferenceCallback object_ref_callback,
411 const void* user_data) {
412 return ERR(NOT_IMPLEMENTED);
413 }
414
415 static jvmtiError IterateOverHeap(jvmtiEnv* env,
416 jvmtiHeapObjectFilter object_filter,
417 jvmtiHeapObjectCallback heap_object_callback,
418 const void* user_data) {
419 return ERR(NOT_IMPLEMENTED);
420 }
421
422 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
423 jclass klass,
424 jvmtiHeapObjectFilter object_filter,
425 jvmtiHeapObjectCallback heap_object_callback,
426 const void* user_data) {
427 return ERR(NOT_IMPLEMENTED);
428 }
429
430 static jvmtiError GetLocalObject(jvmtiEnv* env,
431 jthread thread,
432 jint depth,
433 jint slot,
434 jobject* value_ptr) {
435 return ERR(NOT_IMPLEMENTED);
436 }
437
438 static jvmtiError GetLocalInstance(jvmtiEnv* env,
439 jthread thread,
440 jint depth,
441 jobject* value_ptr) {
442 return ERR(NOT_IMPLEMENTED);
443 }
444
445 static jvmtiError GetLocalInt(jvmtiEnv* env,
446 jthread thread,
447 jint depth,
448 jint slot,
449 jint* value_ptr) {
450 return ERR(NOT_IMPLEMENTED);
451 }
452
453 static jvmtiError GetLocalLong(jvmtiEnv* env,
454 jthread thread,
455 jint depth,
456 jint slot,
457 jlong* value_ptr) {
458 return ERR(NOT_IMPLEMENTED);
459 }
460
461 static jvmtiError GetLocalFloat(jvmtiEnv* env,
462 jthread thread,
463 jint depth,
464 jint slot,
465 jfloat* value_ptr) {
466 return ERR(NOT_IMPLEMENTED);
467 }
468
469 static jvmtiError GetLocalDouble(jvmtiEnv* env,
470 jthread thread,
471 jint depth,
472 jint slot,
473 jdouble* value_ptr) {
474 return ERR(NOT_IMPLEMENTED);
475 }
476
477 static jvmtiError SetLocalObject(jvmtiEnv* env,
478 jthread thread,
479 jint depth,
480 jint slot,
481 jobject value) {
482 return ERR(NOT_IMPLEMENTED);
483 }
484
485 static jvmtiError SetLocalInt(jvmtiEnv* env,
486 jthread thread,
487 jint depth,
488 jint slot,
489 jint value) {
490 return ERR(NOT_IMPLEMENTED);
491 }
492
493 static jvmtiError SetLocalLong(jvmtiEnv* env,
494 jthread thread,
495 jint depth,
496 jint slot,
497 jlong value) {
498 return ERR(NOT_IMPLEMENTED);
499 }
500
501 static jvmtiError SetLocalFloat(jvmtiEnv* env,
502 jthread thread,
503 jint depth,
504 jint slot,
505 jfloat value) {
506 return ERR(NOT_IMPLEMENTED);
507 }
508
509 static jvmtiError SetLocalDouble(jvmtiEnv* env,
510 jthread thread,
511 jint depth,
512 jint slot,
513 jdouble value) {
514 return ERR(NOT_IMPLEMENTED);
515 }
516
517 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
518 return ERR(NOT_IMPLEMENTED);
519 }
520
521 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
522 return ERR(NOT_IMPLEMENTED);
523 }
524
525 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
526 return ERR(NOT_IMPLEMENTED);
527 }
528
529 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
530 return ERR(NOT_IMPLEMENTED);
531 }
532
533 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
534 return ERR(NOT_IMPLEMENTED);
535 }
536
537 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
538 return ERR(NOT_IMPLEMENTED);
539 }
540
541 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700542 HeapUtil heap_util(&gObjectTagTable);
543 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700544 }
545
546 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
547 jobject initiating_loader,
548 jint* class_count_ptr,
549 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800550 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700551 }
552
553 static jvmtiError GetClassSignature(jvmtiEnv* env,
554 jclass klass,
555 char** signature_ptr,
556 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700557 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700558 }
559
560 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800561 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700562 }
563
564 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
565 return ERR(NOT_IMPLEMENTED);
566 }
567
568 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800569 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700570 }
571
572 static jvmtiError GetClassMethods(jvmtiEnv* env,
573 jclass klass,
574 jint* method_count_ptr,
575 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800576 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700577 }
578
579 static jvmtiError GetClassFields(jvmtiEnv* env,
580 jclass klass,
581 jint* field_count_ptr,
582 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800583 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700584 }
585
586 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
587 jclass klass,
588 jint* interface_count_ptr,
589 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800590 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700591 }
592
593 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
594 jclass klass,
595 jint* minor_version_ptr,
596 jint* major_version_ptr) {
597 return ERR(NOT_IMPLEMENTED);
598 }
599
600 static jvmtiError GetConstantPool(jvmtiEnv* env,
601 jclass klass,
602 jint* constant_pool_count_ptr,
603 jint* constant_pool_byte_count_ptr,
604 unsigned char** constant_pool_bytes_ptr) {
605 return ERR(NOT_IMPLEMENTED);
606 }
607
608 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800609 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700610 }
611
612 static jvmtiError IsArrayClass(jvmtiEnv* env,
613 jclass klass,
614 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800615 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700616 }
617
618 static jvmtiError IsModifiableClass(jvmtiEnv* env,
619 jclass klass,
620 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800621 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700622 }
623
624 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800625 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700626 }
627
628 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
629 jclass klass,
630 char** source_debug_extension_ptr) {
631 return ERR(NOT_IMPLEMENTED);
632 }
633
634 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light6ac57502017-01-19 15:05:06 -0800635 std::string error_msg;
636 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
637 art::Runtime::Current(),
638 art::Thread::Current(),
639 class_count,
640 classes,
641 &error_msg);
642 if (res != OK) {
643 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
644 }
645 return res;
Alex Light49948e92016-08-11 15:35:28 -0700646 }
647
648 static jvmtiError RedefineClasses(jvmtiEnv* env,
649 jint class_count,
650 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800651 std::string error_msg;
652 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
653 art::Runtime::Current(),
654 art::Thread::Current(),
655 class_count,
656 class_definitions,
657 &error_msg);
658 if (res != OK) {
659 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
660 }
661 return res;
Alex Light49948e92016-08-11 15:35:28 -0700662 }
663
664 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800665 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700666 }
667
668 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800669 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700670 }
671
672 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
673 jobject object,
674 jvmtiMonitorUsage* info_ptr) {
675 return ERR(NOT_IMPLEMENTED);
676 }
677
678 static jvmtiError GetFieldName(jvmtiEnv* env,
679 jclass klass,
680 jfieldID field,
681 char** name_ptr,
682 char** signature_ptr,
683 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800684 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700685 }
686
687 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
688 jclass klass,
689 jfieldID field,
690 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800691 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700692 }
693
694 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
695 jclass klass,
696 jfieldID field,
697 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800698 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700699 }
700
701 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
702 jclass klass,
703 jfieldID field,
704 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800705 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700706 }
707
708 static jvmtiError GetMethodName(jvmtiEnv* env,
709 jmethodID method,
710 char** name_ptr,
711 char** signature_ptr,
712 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700713 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700714 }
715
716 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
717 jmethodID method,
718 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700719 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700720 }
721
722 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
723 jmethodID method,
724 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700725 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700726 }
727
728 static jvmtiError GetMaxLocals(jvmtiEnv* env,
729 jmethodID method,
730 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800731 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700732 }
733
734 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
735 jmethodID method,
736 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800737 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700738 }
739
740 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
741 jmethodID method,
742 jint* entry_count_ptr,
743 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800744 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700745 }
746
747 static jvmtiError GetMethodLocation(jvmtiEnv* env,
748 jmethodID method,
749 jlocation* start_location_ptr,
750 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800751 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700752 }
753
754 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
755 jmethodID method,
756 jint* entry_count_ptr,
757 jvmtiLocalVariableEntry** table_ptr) {
758 return ERR(NOT_IMPLEMENTED);
759 }
760
761 static jvmtiError GetBytecodes(jvmtiEnv* env,
762 jmethodID method,
763 jint* bytecode_count_ptr,
764 unsigned char** bytecodes_ptr) {
765 return ERR(NOT_IMPLEMENTED);
766 }
767
768 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800769 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700770 }
771
772 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800773 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700774 }
775
776 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800777 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700778 }
779
780 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
781 return ERR(NOT_IMPLEMENTED);
782 }
783
784 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
785 return ERR(NOT_IMPLEMENTED);
786 }
787
788 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800789 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700790 }
791
792 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800793 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700794 }
795
796 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800797 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700798 }
799
800 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800801 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700802 }
803
804 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800805 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700806 }
807
808 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800809 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700810 }
811
812 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800813 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700814 }
815
816 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800817 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700818 }
819
820 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800821 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700822 }
823
Andreas Gampe77708d92016-10-07 11:48:21 -0700824 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
825 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700826 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
827 const jvmtiEventCallbacks* callbacks,
828 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700829 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700830 if (size_of_callbacks < 0) {
831 return ERR(ILLEGAL_ARGUMENT);
832 }
833
834 if (callbacks == nullptr) {
835 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
836 return ERR(NONE);
837 }
838
839 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
840 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
841 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
842 static_cast<size_t>(size_of_callbacks));
843 copy_size = art::RoundDown(copy_size, sizeof(void*));
844 memcpy(tmp.get(), callbacks, copy_size);
845
846 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
847
848 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700849 }
850
851 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
852 jvmtiEventMode mode,
853 jvmtiEvent event_type,
854 jthread event_thread,
855 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700856 ENSURE_VALID_ENV(env);
857 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700858 art::Thread* art_thread = nullptr;
859 if (event_thread != nullptr) {
860 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
861 art::ScopedObjectAccess soa(art::Thread::Current());
862 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
863 art_thread = art::Thread::FromManagedThread(soa, event_thread);
864
865 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
866 art_thread->IsStillStarting()) {
867 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
868 return ERR(THREAD_NOT_ALIVE);
869 }
870 }
871
Alex Light40d87f42017-01-18 10:27:06 -0800872 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
873 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -0700874 }
875
876 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
877 return ERR(NOT_IMPLEMENTED);
878 }
879
880 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
881 jint* extension_count_ptr,
882 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800883 // We do not have any extension functions.
884 *extension_count_ptr = 0;
885 *extensions = nullptr;
886
887 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700888 }
889
890 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
891 jint* extension_count_ptr,
892 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800893 // We do not have any extension events.
894 *extension_count_ptr = 0;
895 *extensions = nullptr;
896
897 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700898 }
899
900 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
901 jint extension_event_index,
902 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800903 // We do not have any extension events, so any call is illegal.
904 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700905 }
906
907 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700908 ENSURE_VALID_ENV(env);
909 ENSURE_NON_NULL(capabilities_ptr);
910 *capabilities_ptr = kPotentialCapabilities;
911 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700912 }
913
914 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700915 ENSURE_VALID_ENV(env);
916 ENSURE_NON_NULL(capabilities_ptr);
917 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
918 jvmtiError ret = OK;
Alex Light73afd322017-01-18 11:17:47 -0800919 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700920#define ADD_CAPABILITY(e) \
921 do { \
922 if (capabilities_ptr->e == 1) { \
923 if (kPotentialCapabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800924 if (art_env->capabilities.e != 1) { \
925 art_env->capabilities.e = 1; \
926 changed.e = 1; \
927 }\
Alex Lighte6574242016-08-17 09:56:24 -0700928 } else { \
929 ret = ERR(NOT_AVAILABLE); \
930 } \
931 } \
932 } while (false)
933
934 ADD_CAPABILITY(can_tag_objects);
935 ADD_CAPABILITY(can_generate_field_modification_events);
936 ADD_CAPABILITY(can_generate_field_access_events);
937 ADD_CAPABILITY(can_get_bytecodes);
938 ADD_CAPABILITY(can_get_synthetic_attribute);
939 ADD_CAPABILITY(can_get_owned_monitor_info);
940 ADD_CAPABILITY(can_get_current_contended_monitor);
941 ADD_CAPABILITY(can_get_monitor_info);
942 ADD_CAPABILITY(can_pop_frame);
943 ADD_CAPABILITY(can_redefine_classes);
944 ADD_CAPABILITY(can_signal_thread);
945 ADD_CAPABILITY(can_get_source_file_name);
946 ADD_CAPABILITY(can_get_line_numbers);
947 ADD_CAPABILITY(can_get_source_debug_extension);
948 ADD_CAPABILITY(can_access_local_variables);
949 ADD_CAPABILITY(can_maintain_original_method_order);
950 ADD_CAPABILITY(can_generate_single_step_events);
951 ADD_CAPABILITY(can_generate_exception_events);
952 ADD_CAPABILITY(can_generate_frame_pop_events);
953 ADD_CAPABILITY(can_generate_breakpoint_events);
954 ADD_CAPABILITY(can_suspend);
955 ADD_CAPABILITY(can_redefine_any_class);
956 ADD_CAPABILITY(can_get_current_thread_cpu_time);
957 ADD_CAPABILITY(can_get_thread_cpu_time);
958 ADD_CAPABILITY(can_generate_method_entry_events);
959 ADD_CAPABILITY(can_generate_method_exit_events);
960 ADD_CAPABILITY(can_generate_all_class_hook_events);
961 ADD_CAPABILITY(can_generate_compiled_method_load_events);
962 ADD_CAPABILITY(can_generate_monitor_events);
963 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
964 ADD_CAPABILITY(can_generate_native_method_bind_events);
965 ADD_CAPABILITY(can_generate_garbage_collection_events);
966 ADD_CAPABILITY(can_generate_object_free_events);
967 ADD_CAPABILITY(can_force_early_return);
968 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
969 ADD_CAPABILITY(can_get_constant_pool);
970 ADD_CAPABILITY(can_set_native_method_prefix);
971 ADD_CAPABILITY(can_retransform_classes);
972 ADD_CAPABILITY(can_retransform_any_class);
973 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
974 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
975#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -0800976 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
977 changed,
978 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -0700979 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700980 }
981
982 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
983 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700984 ENSURE_VALID_ENV(env);
985 ENSURE_NON_NULL(capabilities_ptr);
986 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light73afd322017-01-18 11:17:47 -0800987 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700988#define DEL_CAPABILITY(e) \
989 do { \
990 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800991 if (art_env->capabilities.e == 1) { \
992 art_env->capabilities.e = 0;\
993 changed.e = 1; \
994 } \
Alex Lighte6574242016-08-17 09:56:24 -0700995 } \
996 } while (false)
997
998 DEL_CAPABILITY(can_tag_objects);
999 DEL_CAPABILITY(can_generate_field_modification_events);
1000 DEL_CAPABILITY(can_generate_field_access_events);
1001 DEL_CAPABILITY(can_get_bytecodes);
1002 DEL_CAPABILITY(can_get_synthetic_attribute);
1003 DEL_CAPABILITY(can_get_owned_monitor_info);
1004 DEL_CAPABILITY(can_get_current_contended_monitor);
1005 DEL_CAPABILITY(can_get_monitor_info);
1006 DEL_CAPABILITY(can_pop_frame);
1007 DEL_CAPABILITY(can_redefine_classes);
1008 DEL_CAPABILITY(can_signal_thread);
1009 DEL_CAPABILITY(can_get_source_file_name);
1010 DEL_CAPABILITY(can_get_line_numbers);
1011 DEL_CAPABILITY(can_get_source_debug_extension);
1012 DEL_CAPABILITY(can_access_local_variables);
1013 DEL_CAPABILITY(can_maintain_original_method_order);
1014 DEL_CAPABILITY(can_generate_single_step_events);
1015 DEL_CAPABILITY(can_generate_exception_events);
1016 DEL_CAPABILITY(can_generate_frame_pop_events);
1017 DEL_CAPABILITY(can_generate_breakpoint_events);
1018 DEL_CAPABILITY(can_suspend);
1019 DEL_CAPABILITY(can_redefine_any_class);
1020 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1021 DEL_CAPABILITY(can_get_thread_cpu_time);
1022 DEL_CAPABILITY(can_generate_method_entry_events);
1023 DEL_CAPABILITY(can_generate_method_exit_events);
1024 DEL_CAPABILITY(can_generate_all_class_hook_events);
1025 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1026 DEL_CAPABILITY(can_generate_monitor_events);
1027 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1028 DEL_CAPABILITY(can_generate_native_method_bind_events);
1029 DEL_CAPABILITY(can_generate_garbage_collection_events);
1030 DEL_CAPABILITY(can_generate_object_free_events);
1031 DEL_CAPABILITY(can_force_early_return);
1032 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1033 DEL_CAPABILITY(can_get_constant_pool);
1034 DEL_CAPABILITY(can_set_native_method_prefix);
1035 DEL_CAPABILITY(can_retransform_classes);
1036 DEL_CAPABILITY(can_retransform_any_class);
1037 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1038 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1039#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001040 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1041 changed,
1042 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001043 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001044 }
1045
1046 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001047 ENSURE_VALID_ENV(env);
1048 ENSURE_NON_NULL(capabilities_ptr);
1049 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1050 *capabilities_ptr = artenv->capabilities;
1051 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001052 }
1053
1054 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1055 return ERR(NOT_IMPLEMENTED);
1056 }
1057
1058 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1059 return ERR(NOT_IMPLEMENTED);
1060 }
1061
1062 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1063 return ERR(NOT_IMPLEMENTED);
1064 }
1065
1066 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1067 return ERR(NOT_IMPLEMENTED);
1068 }
1069
1070 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001071 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001072 }
1073
1074 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001075 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001076 }
1077
1078 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001079 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001080 }
1081
1082 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001083 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001084 }
1085
1086 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001087 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001088 }
1089
1090 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001091 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001092 }
1093
1094 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001095 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001096 }
1097
1098 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001099 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001100 }
1101
1102 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Andreas Gampe96eca782017-01-19 19:45:30 -08001103 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001104 }
1105
1106 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001107 ENSURE_VALID_ENV(env);
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001108 gEventHandler.RemoveArtJvmTiEnv(ArtJvmTiEnv::AsArtJvmTiEnv(env));
Alex Light49948e92016-08-11 15:35:28 -07001109 delete env;
1110 return OK;
1111 }
1112
1113 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001114 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001115 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1116 return OK;
1117 }
1118
1119 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001120 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001121 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1122 return OK;
1123 }
1124
1125 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001126 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001127 *version_ptr = JVMTI_VERSION;
1128 return OK;
1129 }
1130
1131 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001132 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001133 switch (error) {
1134#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001135 jvmtiError res = CopyString(env, \
1136 "JVMTI_ERROR_"#e, \
1137 reinterpret_cast<unsigned char**>(name_ptr)); \
1138 if (res != OK) { \
1139 *name_ptr = nullptr; \
1140 return res; \
1141 } else { \
1142 return OK; \
1143 } \
Alex Light49948e92016-08-11 15:35:28 -07001144 } while (false)
1145 ERROR_CASE(NONE);
1146 ERROR_CASE(INVALID_THREAD);
1147 ERROR_CASE(INVALID_THREAD_GROUP);
1148 ERROR_CASE(INVALID_PRIORITY);
1149 ERROR_CASE(THREAD_NOT_SUSPENDED);
1150 ERROR_CASE(THREAD_NOT_ALIVE);
1151 ERROR_CASE(INVALID_OBJECT);
1152 ERROR_CASE(INVALID_CLASS);
1153 ERROR_CASE(CLASS_NOT_PREPARED);
1154 ERROR_CASE(INVALID_METHODID);
1155 ERROR_CASE(INVALID_LOCATION);
1156 ERROR_CASE(INVALID_FIELDID);
1157 ERROR_CASE(NO_MORE_FRAMES);
1158 ERROR_CASE(OPAQUE_FRAME);
1159 ERROR_CASE(TYPE_MISMATCH);
1160 ERROR_CASE(INVALID_SLOT);
1161 ERROR_CASE(DUPLICATE);
1162 ERROR_CASE(NOT_FOUND);
1163 ERROR_CASE(INVALID_MONITOR);
1164 ERROR_CASE(NOT_MONITOR_OWNER);
1165 ERROR_CASE(INTERRUPT);
1166 ERROR_CASE(INVALID_CLASS_FORMAT);
1167 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1168 ERROR_CASE(FAILS_VERIFICATION);
1169 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1170 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1171 ERROR_CASE(INVALID_TYPESTATE);
1172 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1173 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1174 ERROR_CASE(UNSUPPORTED_VERSION);
1175 ERROR_CASE(NAMES_DONT_MATCH);
1176 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1177 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1178 ERROR_CASE(UNMODIFIABLE_CLASS);
1179 ERROR_CASE(NOT_AVAILABLE);
1180 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1181 ERROR_CASE(NULL_POINTER);
1182 ERROR_CASE(ABSENT_INFORMATION);
1183 ERROR_CASE(INVALID_EVENT_TYPE);
1184 ERROR_CASE(ILLEGAL_ARGUMENT);
1185 ERROR_CASE(NATIVE_METHOD);
1186 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1187 ERROR_CASE(OUT_OF_MEMORY);
1188 ERROR_CASE(ACCESS_DENIED);
1189 ERROR_CASE(WRONG_PHASE);
1190 ERROR_CASE(INTERNAL);
1191 ERROR_CASE(UNATTACHED_THREAD);
1192 ERROR_CASE(INVALID_ENVIRONMENT);
1193#undef ERROR_CASE
1194 default: {
Alex Light41960712017-01-06 14:44:23 -08001195 jvmtiError res = CopyString(env,
1196 "JVMTI_ERROR_UNKNOWN",
1197 reinterpret_cast<unsigned char**>(name_ptr));
1198 if (res != OK) {
1199 *name_ptr = nullptr;
1200 return res;
1201 } else {
1202 return ERR(ILLEGAL_ARGUMENT);
1203 }
Alex Light49948e92016-08-11 15:35:28 -07001204 }
1205 }
1206 }
1207
1208 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001209 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1210 // OTHER is special, as it's 0, so can't do a bit check.
1211 bool val = (value == JNI_TRUE) ? true : false;
1212
1213 art::gLogVerbosity.collector = val;
1214 art::gLogVerbosity.compiler = val;
1215 art::gLogVerbosity.deopt = val;
1216 art::gLogVerbosity.heap = val;
1217 art::gLogVerbosity.jdwp = val;
1218 art::gLogVerbosity.jit = val;
1219 art::gLogVerbosity.monitor = val;
1220 art::gLogVerbosity.oat = val;
1221 art::gLogVerbosity.profiler = val;
1222 art::gLogVerbosity.signals = val;
1223 art::gLogVerbosity.simulator = val;
1224 art::gLogVerbosity.startup = val;
1225 art::gLogVerbosity.third_party_jni = val;
1226 art::gLogVerbosity.threads = val;
1227 art::gLogVerbosity.verifier = val;
1228 art::gLogVerbosity.image = val;
1229
1230 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1231
1232 art::gLogVerbosity.agents = val;
1233 } else {
1234 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1235 // semantics.
1236 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1237 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1238 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1239 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1240 if ((flag & ~kMask) != 0) {
1241 return ERR(ILLEGAL_ARGUMENT);
1242 }
1243
1244 bool val = (value == JNI_TRUE) ? true : false;
1245
1246 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1247 art::gLogVerbosity.gc = val;
1248 }
1249
1250 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1251 art::gLogVerbosity.class_linker = val;
1252 }
1253
1254 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1255 art::gLogVerbosity.jni = val;
1256 }
1257 }
1258
1259 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001260 }
1261
1262 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
Andreas Gampeacfc9572017-01-17 18:36:56 -08001263 // Report BCI as jlocation format. We report dex bytecode indices.
1264 if (format_ptr == nullptr) {
1265 return ERR(NULL_POINTER);
1266 }
1267 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1268 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001269 }
1270};
1271
1272static bool IsJvmtiVersion(jint version) {
1273 return version == JVMTI_VERSION_1 ||
1274 version == JVMTI_VERSION_1_0 ||
1275 version == JVMTI_VERSION_1_1 ||
1276 version == JVMTI_VERSION_1_2 ||
1277 version == JVMTI_VERSION;
1278}
1279
1280// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1281// is a pointer to the uninitialized memory for an art::ti::Env.
1282static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1283 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1284 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001285
1286 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001287}
1288
1289// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1290// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1291// returns false and does not modify the 'env' pointer.
1292static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1293 if (IsJvmtiVersion(version)) {
1294 CreateArtJvmTiEnv(vm, env);
1295 return JNI_OK;
1296 } else {
1297 printf("version 0x%x is not valid!", version);
1298 return JNI_EVERSION;
1299 }
1300}
1301
1302// The plugin initialization function. This adds the jvmti environment.
1303extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001304 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001305
1306 if (runtime->IsStarted()) {
1307 PhaseUtil::SetToLive();
1308 } else {
1309 PhaseUtil::SetToOnLoad();
1310 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001311 PhaseUtil::Register(&gEventHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001312
Andreas Gampee08a2be2016-10-06 13:13:30 -07001313 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1314 runtime->AddSystemWeakHolder(&gObjectTagTable);
Andreas Gampe96eca782017-01-19 19:45:30 -08001315
Alex Light49948e92016-08-11 15:35:28 -07001316 return true;
1317}
1318
1319// The actual struct holding all of the entrypoints into the jvmti interface.
1320const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001321 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001322 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001323 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001324 JvmtiFunctions::GetAllThreads,
1325 JvmtiFunctions::SuspendThread,
1326 JvmtiFunctions::ResumeThread,
1327 JvmtiFunctions::StopThread,
1328 JvmtiFunctions::InterruptThread,
1329 JvmtiFunctions::GetThreadInfo,
1330 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1331 JvmtiFunctions::GetCurrentContendedMonitor,
1332 JvmtiFunctions::RunAgentThread,
1333 JvmtiFunctions::GetTopThreadGroups,
1334 JvmtiFunctions::GetThreadGroupInfo,
1335 JvmtiFunctions::GetThreadGroupChildren,
1336 JvmtiFunctions::GetFrameCount,
1337 JvmtiFunctions::GetThreadState,
1338 JvmtiFunctions::GetCurrentThread,
1339 JvmtiFunctions::GetFrameLocation,
1340 JvmtiFunctions::NotifyFramePop, // 20
1341 JvmtiFunctions::GetLocalObject,
1342 JvmtiFunctions::GetLocalInt,
1343 JvmtiFunctions::GetLocalLong,
1344 JvmtiFunctions::GetLocalFloat,
1345 JvmtiFunctions::GetLocalDouble,
1346 JvmtiFunctions::SetLocalObject,
1347 JvmtiFunctions::SetLocalInt,
1348 JvmtiFunctions::SetLocalLong,
1349 JvmtiFunctions::SetLocalFloat,
1350 JvmtiFunctions::SetLocalDouble, // 30
1351 JvmtiFunctions::CreateRawMonitor,
1352 JvmtiFunctions::DestroyRawMonitor,
1353 JvmtiFunctions::RawMonitorEnter,
1354 JvmtiFunctions::RawMonitorExit,
1355 JvmtiFunctions::RawMonitorWait,
1356 JvmtiFunctions::RawMonitorNotify,
1357 JvmtiFunctions::RawMonitorNotifyAll,
1358 JvmtiFunctions::SetBreakpoint,
1359 JvmtiFunctions::ClearBreakpoint,
1360 nullptr, // reserved40
1361 JvmtiFunctions::SetFieldAccessWatch,
1362 JvmtiFunctions::ClearFieldAccessWatch,
1363 JvmtiFunctions::SetFieldModificationWatch,
1364 JvmtiFunctions::ClearFieldModificationWatch,
1365 JvmtiFunctions::IsModifiableClass,
1366 JvmtiFunctions::Allocate,
1367 JvmtiFunctions::Deallocate,
1368 JvmtiFunctions::GetClassSignature,
1369 JvmtiFunctions::GetClassStatus,
1370 JvmtiFunctions::GetSourceFileName, // 50
1371 JvmtiFunctions::GetClassModifiers,
1372 JvmtiFunctions::GetClassMethods,
1373 JvmtiFunctions::GetClassFields,
1374 JvmtiFunctions::GetImplementedInterfaces,
1375 JvmtiFunctions::IsInterface,
1376 JvmtiFunctions::IsArrayClass,
1377 JvmtiFunctions::GetClassLoader,
1378 JvmtiFunctions::GetObjectHashCode,
1379 JvmtiFunctions::GetObjectMonitorUsage,
1380 JvmtiFunctions::GetFieldName, // 60
1381 JvmtiFunctions::GetFieldDeclaringClass,
1382 JvmtiFunctions::GetFieldModifiers,
1383 JvmtiFunctions::IsFieldSynthetic,
1384 JvmtiFunctions::GetMethodName,
1385 JvmtiFunctions::GetMethodDeclaringClass,
1386 JvmtiFunctions::GetMethodModifiers,
1387 nullptr, // reserved67
1388 JvmtiFunctions::GetMaxLocals,
1389 JvmtiFunctions::GetArgumentsSize,
1390 JvmtiFunctions::GetLineNumberTable, // 70
1391 JvmtiFunctions::GetMethodLocation,
1392 JvmtiFunctions::GetLocalVariableTable,
1393 JvmtiFunctions::SetNativeMethodPrefix,
1394 JvmtiFunctions::SetNativeMethodPrefixes,
1395 JvmtiFunctions::GetBytecodes,
1396 JvmtiFunctions::IsMethodNative,
1397 JvmtiFunctions::IsMethodSynthetic,
1398 JvmtiFunctions::GetLoadedClasses,
1399 JvmtiFunctions::GetClassLoaderClasses,
1400 JvmtiFunctions::PopFrame, // 80
1401 JvmtiFunctions::ForceEarlyReturnObject,
1402 JvmtiFunctions::ForceEarlyReturnInt,
1403 JvmtiFunctions::ForceEarlyReturnLong,
1404 JvmtiFunctions::ForceEarlyReturnFloat,
1405 JvmtiFunctions::ForceEarlyReturnDouble,
1406 JvmtiFunctions::ForceEarlyReturnVoid,
1407 JvmtiFunctions::RedefineClasses,
1408 JvmtiFunctions::GetVersionNumber,
1409 JvmtiFunctions::GetCapabilities,
1410 JvmtiFunctions::GetSourceDebugExtension, // 90
1411 JvmtiFunctions::IsMethodObsolete,
1412 JvmtiFunctions::SuspendThreadList,
1413 JvmtiFunctions::ResumeThreadList,
1414 nullptr, // reserved94
1415 nullptr, // reserved95
1416 nullptr, // reserved96
1417 nullptr, // reserved97
1418 nullptr, // reserved98
1419 nullptr, // reserved99
1420 JvmtiFunctions::GetAllStackTraces, // 100
1421 JvmtiFunctions::GetThreadListStackTraces,
1422 JvmtiFunctions::GetThreadLocalStorage,
1423 JvmtiFunctions::SetThreadLocalStorage,
1424 JvmtiFunctions::GetStackTrace,
1425 nullptr, // reserved105
1426 JvmtiFunctions::GetTag,
1427 JvmtiFunctions::SetTag,
1428 JvmtiFunctions::ForceGarbageCollection,
1429 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1430 JvmtiFunctions::IterateOverReachableObjects, // 110
1431 JvmtiFunctions::IterateOverHeap,
1432 JvmtiFunctions::IterateOverInstancesOfClass,
1433 nullptr, // reserved113
1434 JvmtiFunctions::GetObjectsWithTags,
1435 JvmtiFunctions::FollowReferences,
1436 JvmtiFunctions::IterateThroughHeap,
1437 nullptr, // reserved117
1438 nullptr, // reserved118
1439 nullptr, // reserved119
1440 JvmtiFunctions::SetJNIFunctionTable, // 120
1441 JvmtiFunctions::GetJNIFunctionTable,
1442 JvmtiFunctions::SetEventCallbacks,
1443 JvmtiFunctions::GenerateEvents,
1444 JvmtiFunctions::GetExtensionFunctions,
1445 JvmtiFunctions::GetExtensionEvents,
1446 JvmtiFunctions::SetExtensionEventCallback,
1447 JvmtiFunctions::DisposeEnvironment,
1448 JvmtiFunctions::GetErrorName,
1449 JvmtiFunctions::GetJLocationFormat,
1450 JvmtiFunctions::GetSystemProperties, // 130
1451 JvmtiFunctions::GetSystemProperty,
1452 JvmtiFunctions::SetSystemProperty,
1453 JvmtiFunctions::GetPhase,
1454 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1455 JvmtiFunctions::GetCurrentThreadCpuTime,
1456 JvmtiFunctions::GetThreadCpuTimerInfo,
1457 JvmtiFunctions::GetThreadCpuTime,
1458 JvmtiFunctions::GetTimerInfo,
1459 JvmtiFunctions::GetTime,
1460 JvmtiFunctions::GetPotentialCapabilities, // 140
1461 nullptr, // reserved141
1462 JvmtiFunctions::AddCapabilities,
1463 JvmtiFunctions::RelinquishCapabilities,
1464 JvmtiFunctions::GetAvailableProcessors,
1465 JvmtiFunctions::GetClassVersionNumbers,
1466 JvmtiFunctions::GetConstantPool,
1467 JvmtiFunctions::GetEnvironmentLocalStorage,
1468 JvmtiFunctions::SetEnvironmentLocalStorage,
1469 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1470 JvmtiFunctions::SetVerboseFlag, // 150
1471 JvmtiFunctions::AddToSystemClassLoaderSearch,
1472 JvmtiFunctions::RetransformClasses,
1473 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1474 JvmtiFunctions::GetObjectSize,
1475 JvmtiFunctions::GetLocalInstance,
1476};
1477
1478}; // namespace openjdkjvmti