blob: 417d1041a8f4909e45345ee238326324d79ef42a [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 Gampeeb0cea12017-01-23 08:50:04 -080052#include "ti_dump.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080053#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070054#include "ti_heap.h"
Andreas Gampe6f8e4f02017-01-16 18:18:14 -080055#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070056#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080057#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080058#include "ti_object.h"
Andreas Gampe96eca782017-01-19 19:45:30 -080059#include "ti_phase.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080060#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080061#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080062#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070063#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080064#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000065#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080066#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070067#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070068
69// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
70// easier to create.
71#pragma GCC diagnostic ignored "-Wunused-parameter"
72
73namespace openjdkjvmti {
74
Andreas Gampe77708d92016-10-07 11:48:21 -070075EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070076ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070077
Alex Lighte6574242016-08-17 09:56:24 -070078#define ENSURE_NON_NULL(n) \
79 do { \
80 if ((n) == nullptr) { \
81 return ERR(NULL_POINTER); \
82 } \
83 } while (false)
84
Alex Light49948e92016-08-11 15:35:28 -070085class JvmtiFunctions {
86 private:
87 static bool IsValidEnv(jvmtiEnv* env) {
88 return env != nullptr;
89 }
90
Alex Lighte6574242016-08-17 09:56:24 -070091#define ENSURE_VALID_ENV(env) \
92 do { \
93 if (!IsValidEnv(env)) { \
94 return ERR(INVALID_ENVIRONMENT); \
95 } \
96 } while (false)
97
98#define ENSURE_HAS_CAP(env, cap) \
99 do { \
100 ENSURE_VALID_ENV(env); \
101 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
102 return ERR(MUST_POSSESS_CAPABILITY); \
103 } \
104 } while (false)
105
Alex Light49948e92016-08-11 15:35:28 -0700106 public:
107 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700108 ENSURE_VALID_ENV(env);
109 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700110 if (size < 0) {
111 return ERR(ILLEGAL_ARGUMENT);
112 } else if (size == 0) {
113 *mem_ptr = nullptr;
114 return OK;
115 }
116 *mem_ptr = static_cast<unsigned char*>(malloc(size));
117 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
118 }
119
120 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700121 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700122 if (mem != nullptr) {
123 free(mem);
124 }
125 return OK;
126 }
127
128 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800129 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700130 }
131
132 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800133 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700134 }
135
136 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800137 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700138 }
139
140 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
141 return ERR(NOT_IMPLEMENTED);
142 }
143
144 static jvmtiError SuspendThreadList(jvmtiEnv* env,
145 jint request_count,
146 const jthread* request_list,
147 jvmtiError* results) {
148 return ERR(NOT_IMPLEMENTED);
149 }
150
151 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
152 return ERR(NOT_IMPLEMENTED);
153 }
154
155 static jvmtiError ResumeThreadList(jvmtiEnv* env,
156 jint request_count,
157 const jthread* request_list,
158 jvmtiError* results) {
159 return ERR(NOT_IMPLEMENTED);
160 }
161
162 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
163 return ERR(NOT_IMPLEMENTED);
164 }
165
166 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
167 return ERR(NOT_IMPLEMENTED);
168 }
169
170 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800171 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700172 }
173
174 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
175 jthread thread,
176 jint* owned_monitor_count_ptr,
177 jobject** owned_monitors_ptr) {
178 return ERR(NOT_IMPLEMENTED);
179 }
180
181 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
182 jthread thread,
183 jint* monitor_info_count_ptr,
184 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
185 return ERR(NOT_IMPLEMENTED);
186 }
187
188 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
189 jthread thread,
190 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700191 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700192 }
193
194 static jvmtiError RunAgentThread(jvmtiEnv* env,
195 jthread thread,
196 jvmtiStartFunction proc,
197 const void* arg,
198 jint priority) {
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800199 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700200 }
201
202 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800203 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700204 }
205
206 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800207 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700208 }
209
210 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
211 jint* group_count_ptr,
212 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000213 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700214 }
215
216 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
217 jthreadGroup group,
218 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000219 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700220 }
221
222 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
223 jthreadGroup group,
224 jint* thread_count_ptr,
225 jthread** threads_ptr,
226 jint* group_count_ptr,
227 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000228 return ThreadGroupUtil::GetThreadGroupChildren(env,
229 group,
230 thread_count_ptr,
231 threads_ptr,
232 group_count_ptr,
233 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700234 }
235
236 static jvmtiError GetStackTrace(jvmtiEnv* env,
237 jthread thread,
238 jint start_depth,
239 jint max_frame_count,
240 jvmtiFrameInfo* frame_buffer,
241 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700242 return StackUtil::GetStackTrace(env,
243 thread,
244 start_depth,
245 max_frame_count,
246 frame_buffer,
247 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700248 }
249
250 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
251 jint max_frame_count,
252 jvmtiStackInfo** stack_info_ptr,
253 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800254 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700255 }
256
257 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
258 jint thread_count,
259 const jthread* thread_list,
260 jint max_frame_count,
261 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800262 return StackUtil::GetThreadListStackTraces(env,
263 thread_count,
264 thread_list,
265 max_frame_count,
266 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700267 }
268
269 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800270 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700271 }
272
273 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
274 return ERR(NOT_IMPLEMENTED);
275 }
276
277 static jvmtiError GetFrameLocation(jvmtiEnv* env,
278 jthread thread,
279 jint depth,
280 jmethodID* method_ptr,
281 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800282 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700283 }
284
285 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
286 return ERR(NOT_IMPLEMENTED);
287 }
288
289 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
290 return ERR(NOT_IMPLEMENTED);
291 }
292
293 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
294 return ERR(NOT_IMPLEMENTED);
295 }
296
297 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
298 return ERR(NOT_IMPLEMENTED);
299 }
300
301 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
302 return ERR(NOT_IMPLEMENTED);
303 }
304
305 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
306 return ERR(NOT_IMPLEMENTED);
307 }
308
309 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
310 return ERR(NOT_IMPLEMENTED);
311 }
312
313 static jvmtiError FollowReferences(jvmtiEnv* env,
314 jint heap_filter,
315 jclass klass,
316 jobject initial_object,
317 const jvmtiHeapCallbacks* callbacks,
318 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700319 HeapUtil heap_util(&gObjectTagTable);
320 return heap_util.FollowReferences(env,
321 heap_filter,
322 klass,
323 initial_object,
324 callbacks,
325 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700326 }
327
328 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
329 jint heap_filter,
330 jclass klass,
331 const jvmtiHeapCallbacks* callbacks,
332 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700333 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700334 HeapUtil heap_util(&gObjectTagTable);
335 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700336 }
337
338 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700339 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700340
341 JNIEnv* jni_env = GetJniEnv(env);
342 if (jni_env == nullptr) {
343 return ERR(INTERNAL);
344 }
345
346 art::ScopedObjectAccess soa(jni_env);
347 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
348 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
349 *tag_ptr = 0;
350 }
351
352 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700353 }
354
355 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700356 ENSURE_HAS_CAP(env, can_tag_objects);
357
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700358 if (object == nullptr) {
359 return ERR(NULL_POINTER);
360 }
361
362 JNIEnv* jni_env = GetJniEnv(env);
363 if (jni_env == nullptr) {
364 return ERR(INTERNAL);
365 }
366
367 art::ScopedObjectAccess soa(jni_env);
368 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700369 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700370
371 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700372 }
373
374 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
375 jint tag_count,
376 const jlong* tags,
377 jint* count_ptr,
378 jobject** object_result_ptr,
379 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700380 ENSURE_HAS_CAP(env, can_tag_objects);
381
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700382 JNIEnv* jni_env = GetJniEnv(env);
383 if (jni_env == nullptr) {
384 return ERR(INTERNAL);
385 }
386
387 art::ScopedObjectAccess soa(jni_env);
388 return gObjectTagTable.GetTaggedObjects(env,
389 tag_count,
390 tags,
391 count_ptr,
392 object_result_ptr,
393 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700394 }
395
396 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700397 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700398 }
399
400 static jvmtiError IterateOverObjectsReachableFromObject(
401 jvmtiEnv* env,
402 jobject object,
403 jvmtiObjectReferenceCallback object_reference_callback,
404 const void* user_data) {
405 return ERR(NOT_IMPLEMENTED);
406 }
407
408 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
409 jvmtiHeapRootCallback heap_root_callback,
410 jvmtiStackReferenceCallback stack_ref_callback,
411 jvmtiObjectReferenceCallback object_ref_callback,
412 const void* user_data) {
413 return ERR(NOT_IMPLEMENTED);
414 }
415
416 static jvmtiError IterateOverHeap(jvmtiEnv* env,
417 jvmtiHeapObjectFilter object_filter,
418 jvmtiHeapObjectCallback heap_object_callback,
419 const void* user_data) {
420 return ERR(NOT_IMPLEMENTED);
421 }
422
423 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
424 jclass klass,
425 jvmtiHeapObjectFilter object_filter,
426 jvmtiHeapObjectCallback heap_object_callback,
427 const void* user_data) {
428 return ERR(NOT_IMPLEMENTED);
429 }
430
431 static jvmtiError GetLocalObject(jvmtiEnv* env,
432 jthread thread,
433 jint depth,
434 jint slot,
435 jobject* value_ptr) {
436 return ERR(NOT_IMPLEMENTED);
437 }
438
439 static jvmtiError GetLocalInstance(jvmtiEnv* env,
440 jthread thread,
441 jint depth,
442 jobject* value_ptr) {
443 return ERR(NOT_IMPLEMENTED);
444 }
445
446 static jvmtiError GetLocalInt(jvmtiEnv* env,
447 jthread thread,
448 jint depth,
449 jint slot,
450 jint* value_ptr) {
451 return ERR(NOT_IMPLEMENTED);
452 }
453
454 static jvmtiError GetLocalLong(jvmtiEnv* env,
455 jthread thread,
456 jint depth,
457 jint slot,
458 jlong* value_ptr) {
459 return ERR(NOT_IMPLEMENTED);
460 }
461
462 static jvmtiError GetLocalFloat(jvmtiEnv* env,
463 jthread thread,
464 jint depth,
465 jint slot,
466 jfloat* value_ptr) {
467 return ERR(NOT_IMPLEMENTED);
468 }
469
470 static jvmtiError GetLocalDouble(jvmtiEnv* env,
471 jthread thread,
472 jint depth,
473 jint slot,
474 jdouble* value_ptr) {
475 return ERR(NOT_IMPLEMENTED);
476 }
477
478 static jvmtiError SetLocalObject(jvmtiEnv* env,
479 jthread thread,
480 jint depth,
481 jint slot,
482 jobject value) {
483 return ERR(NOT_IMPLEMENTED);
484 }
485
486 static jvmtiError SetLocalInt(jvmtiEnv* env,
487 jthread thread,
488 jint depth,
489 jint slot,
490 jint value) {
491 return ERR(NOT_IMPLEMENTED);
492 }
493
494 static jvmtiError SetLocalLong(jvmtiEnv* env,
495 jthread thread,
496 jint depth,
497 jint slot,
498 jlong value) {
499 return ERR(NOT_IMPLEMENTED);
500 }
501
502 static jvmtiError SetLocalFloat(jvmtiEnv* env,
503 jthread thread,
504 jint depth,
505 jint slot,
506 jfloat value) {
507 return ERR(NOT_IMPLEMENTED);
508 }
509
510 static jvmtiError SetLocalDouble(jvmtiEnv* env,
511 jthread thread,
512 jint depth,
513 jint slot,
514 jdouble value) {
515 return ERR(NOT_IMPLEMENTED);
516 }
517
518 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
519 return ERR(NOT_IMPLEMENTED);
520 }
521
522 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
523 return ERR(NOT_IMPLEMENTED);
524 }
525
526 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
527 return ERR(NOT_IMPLEMENTED);
528 }
529
530 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
531 return ERR(NOT_IMPLEMENTED);
532 }
533
534 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
535 return ERR(NOT_IMPLEMENTED);
536 }
537
538 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
539 return ERR(NOT_IMPLEMENTED);
540 }
541
542 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700543 HeapUtil heap_util(&gObjectTagTable);
544 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700545 }
546
547 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
548 jobject initiating_loader,
549 jint* class_count_ptr,
550 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800551 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700552 }
553
554 static jvmtiError GetClassSignature(jvmtiEnv* env,
555 jclass klass,
556 char** signature_ptr,
557 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700558 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700559 }
560
561 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800562 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700563 }
564
565 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
566 return ERR(NOT_IMPLEMENTED);
567 }
568
569 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800570 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700571 }
572
573 static jvmtiError GetClassMethods(jvmtiEnv* env,
574 jclass klass,
575 jint* method_count_ptr,
576 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800577 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700578 }
579
580 static jvmtiError GetClassFields(jvmtiEnv* env,
581 jclass klass,
582 jint* field_count_ptr,
583 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800584 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700585 }
586
587 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
588 jclass klass,
589 jint* interface_count_ptr,
590 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800591 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700592 }
593
594 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
595 jclass klass,
596 jint* minor_version_ptr,
597 jint* major_version_ptr) {
Andreas Gampe812a2442017-01-19 22:04:46 -0800598 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700599 }
600
601 static jvmtiError GetConstantPool(jvmtiEnv* env,
602 jclass klass,
603 jint* constant_pool_count_ptr,
604 jint* constant_pool_byte_count_ptr,
605 unsigned char** constant_pool_bytes_ptr) {
606 return ERR(NOT_IMPLEMENTED);
607 }
608
609 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800610 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700611 }
612
613 static jvmtiError IsArrayClass(jvmtiEnv* env,
614 jclass klass,
615 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800616 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700617 }
618
619 static jvmtiError IsModifiableClass(jvmtiEnv* env,
620 jclass klass,
621 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800622 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700623 }
624
625 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800626 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700627 }
628
629 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
630 jclass klass,
631 char** source_debug_extension_ptr) {
632 return ERR(NOT_IMPLEMENTED);
633 }
634
635 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light6ac57502017-01-19 15:05:06 -0800636 std::string error_msg;
637 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
638 art::Runtime::Current(),
639 art::Thread::Current(),
640 class_count,
641 classes,
642 &error_msg);
643 if (res != OK) {
644 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
645 }
646 return res;
Alex Light49948e92016-08-11 15:35:28 -0700647 }
648
649 static jvmtiError RedefineClasses(jvmtiEnv* env,
650 jint class_count,
651 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800652 std::string error_msg;
653 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
654 art::Runtime::Current(),
655 art::Thread::Current(),
656 class_count,
657 class_definitions,
658 &error_msg);
659 if (res != OK) {
660 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
661 }
662 return res;
Alex Light49948e92016-08-11 15:35:28 -0700663 }
664
665 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800666 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700667 }
668
669 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800670 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700671 }
672
673 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
674 jobject object,
675 jvmtiMonitorUsage* info_ptr) {
676 return ERR(NOT_IMPLEMENTED);
677 }
678
679 static jvmtiError GetFieldName(jvmtiEnv* env,
680 jclass klass,
681 jfieldID field,
682 char** name_ptr,
683 char** signature_ptr,
684 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800685 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700686 }
687
688 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
689 jclass klass,
690 jfieldID field,
691 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800692 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700693 }
694
695 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
696 jclass klass,
697 jfieldID field,
698 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800699 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700700 }
701
702 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
703 jclass klass,
704 jfieldID field,
705 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800706 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700707 }
708
709 static jvmtiError GetMethodName(jvmtiEnv* env,
710 jmethodID method,
711 char** name_ptr,
712 char** signature_ptr,
713 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700714 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700715 }
716
717 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
718 jmethodID method,
719 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700720 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700721 }
722
723 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
724 jmethodID method,
725 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700726 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700727 }
728
729 static jvmtiError GetMaxLocals(jvmtiEnv* env,
730 jmethodID method,
731 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800732 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700733 }
734
735 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
736 jmethodID method,
737 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800738 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700739 }
740
741 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
742 jmethodID method,
743 jint* entry_count_ptr,
744 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800745 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700746 }
747
748 static jvmtiError GetMethodLocation(jvmtiEnv* env,
749 jmethodID method,
750 jlocation* start_location_ptr,
751 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800752 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700753 }
754
755 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
756 jmethodID method,
757 jint* entry_count_ptr,
758 jvmtiLocalVariableEntry** table_ptr) {
759 return ERR(NOT_IMPLEMENTED);
760 }
761
762 static jvmtiError GetBytecodes(jvmtiEnv* env,
763 jmethodID method,
764 jint* bytecode_count_ptr,
765 unsigned char** bytecodes_ptr) {
766 return ERR(NOT_IMPLEMENTED);
767 }
768
769 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800770 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700771 }
772
773 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800774 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700775 }
776
777 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800778 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700779 }
780
781 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
782 return ERR(NOT_IMPLEMENTED);
783 }
784
785 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
786 return ERR(NOT_IMPLEMENTED);
787 }
788
789 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800790 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700791 }
792
793 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800794 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700795 }
796
797 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800798 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700799 }
800
801 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800802 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700803 }
804
805 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800806 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700807 }
808
809 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800810 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700811 }
812
813 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800814 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700815 }
816
817 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800818 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700819 }
820
821 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800822 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700823 }
824
Andreas Gampe77708d92016-10-07 11:48:21 -0700825 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
826 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700827 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
828 const jvmtiEventCallbacks* callbacks,
829 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700830 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700831 if (size_of_callbacks < 0) {
832 return ERR(ILLEGAL_ARGUMENT);
833 }
834
835 if (callbacks == nullptr) {
836 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
837 return ERR(NONE);
838 }
839
840 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
841 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
842 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
843 static_cast<size_t>(size_of_callbacks));
844 copy_size = art::RoundDown(copy_size, sizeof(void*));
845 memcpy(tmp.get(), callbacks, copy_size);
846
847 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
848
849 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700850 }
851
852 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
853 jvmtiEventMode mode,
854 jvmtiEvent event_type,
855 jthread event_thread,
856 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700857 ENSURE_VALID_ENV(env);
858 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700859 art::Thread* art_thread = nullptr;
860 if (event_thread != nullptr) {
861 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
862 art::ScopedObjectAccess soa(art::Thread::Current());
863 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
864 art_thread = art::Thread::FromManagedThread(soa, event_thread);
865
866 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
867 art_thread->IsStillStarting()) {
868 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
869 return ERR(THREAD_NOT_ALIVE);
870 }
871 }
872
Alex Light40d87f42017-01-18 10:27:06 -0800873 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
874 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -0700875 }
876
877 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
878 return ERR(NOT_IMPLEMENTED);
879 }
880
881 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
882 jint* extension_count_ptr,
883 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800884 // We do not have any extension functions.
885 *extension_count_ptr = 0;
886 *extensions = nullptr;
887
888 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700889 }
890
891 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
892 jint* extension_count_ptr,
893 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800894 // We do not have any extension events.
895 *extension_count_ptr = 0;
896 *extensions = nullptr;
897
898 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700899 }
900
901 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
902 jint extension_event_index,
903 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800904 // We do not have any extension events, so any call is illegal.
905 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700906 }
907
908 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700909 ENSURE_VALID_ENV(env);
910 ENSURE_NON_NULL(capabilities_ptr);
911 *capabilities_ptr = kPotentialCapabilities;
912 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700913 }
914
915 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700916 ENSURE_VALID_ENV(env);
917 ENSURE_NON_NULL(capabilities_ptr);
918 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
919 jvmtiError ret = OK;
Alex Light73afd322017-01-18 11:17:47 -0800920 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700921#define ADD_CAPABILITY(e) \
922 do { \
923 if (capabilities_ptr->e == 1) { \
924 if (kPotentialCapabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800925 if (art_env->capabilities.e != 1) { \
926 art_env->capabilities.e = 1; \
927 changed.e = 1; \
928 }\
Alex Lighte6574242016-08-17 09:56:24 -0700929 } else { \
930 ret = ERR(NOT_AVAILABLE); \
931 } \
932 } \
933 } while (false)
934
935 ADD_CAPABILITY(can_tag_objects);
936 ADD_CAPABILITY(can_generate_field_modification_events);
937 ADD_CAPABILITY(can_generate_field_access_events);
938 ADD_CAPABILITY(can_get_bytecodes);
939 ADD_CAPABILITY(can_get_synthetic_attribute);
940 ADD_CAPABILITY(can_get_owned_monitor_info);
941 ADD_CAPABILITY(can_get_current_contended_monitor);
942 ADD_CAPABILITY(can_get_monitor_info);
943 ADD_CAPABILITY(can_pop_frame);
944 ADD_CAPABILITY(can_redefine_classes);
945 ADD_CAPABILITY(can_signal_thread);
946 ADD_CAPABILITY(can_get_source_file_name);
947 ADD_CAPABILITY(can_get_line_numbers);
948 ADD_CAPABILITY(can_get_source_debug_extension);
949 ADD_CAPABILITY(can_access_local_variables);
950 ADD_CAPABILITY(can_maintain_original_method_order);
951 ADD_CAPABILITY(can_generate_single_step_events);
952 ADD_CAPABILITY(can_generate_exception_events);
953 ADD_CAPABILITY(can_generate_frame_pop_events);
954 ADD_CAPABILITY(can_generate_breakpoint_events);
955 ADD_CAPABILITY(can_suspend);
956 ADD_CAPABILITY(can_redefine_any_class);
957 ADD_CAPABILITY(can_get_current_thread_cpu_time);
958 ADD_CAPABILITY(can_get_thread_cpu_time);
959 ADD_CAPABILITY(can_generate_method_entry_events);
960 ADD_CAPABILITY(can_generate_method_exit_events);
961 ADD_CAPABILITY(can_generate_all_class_hook_events);
962 ADD_CAPABILITY(can_generate_compiled_method_load_events);
963 ADD_CAPABILITY(can_generate_monitor_events);
964 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
965 ADD_CAPABILITY(can_generate_native_method_bind_events);
966 ADD_CAPABILITY(can_generate_garbage_collection_events);
967 ADD_CAPABILITY(can_generate_object_free_events);
968 ADD_CAPABILITY(can_force_early_return);
969 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
970 ADD_CAPABILITY(can_get_constant_pool);
971 ADD_CAPABILITY(can_set_native_method_prefix);
972 ADD_CAPABILITY(can_retransform_classes);
973 ADD_CAPABILITY(can_retransform_any_class);
974 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
975 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
976#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -0800977 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
978 changed,
979 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -0700980 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700981 }
982
983 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
984 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700985 ENSURE_VALID_ENV(env);
986 ENSURE_NON_NULL(capabilities_ptr);
987 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light73afd322017-01-18 11:17:47 -0800988 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700989#define DEL_CAPABILITY(e) \
990 do { \
991 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800992 if (art_env->capabilities.e == 1) { \
993 art_env->capabilities.e = 0;\
994 changed.e = 1; \
995 } \
Alex Lighte6574242016-08-17 09:56:24 -0700996 } \
997 } while (false)
998
999 DEL_CAPABILITY(can_tag_objects);
1000 DEL_CAPABILITY(can_generate_field_modification_events);
1001 DEL_CAPABILITY(can_generate_field_access_events);
1002 DEL_CAPABILITY(can_get_bytecodes);
1003 DEL_CAPABILITY(can_get_synthetic_attribute);
1004 DEL_CAPABILITY(can_get_owned_monitor_info);
1005 DEL_CAPABILITY(can_get_current_contended_monitor);
1006 DEL_CAPABILITY(can_get_monitor_info);
1007 DEL_CAPABILITY(can_pop_frame);
1008 DEL_CAPABILITY(can_redefine_classes);
1009 DEL_CAPABILITY(can_signal_thread);
1010 DEL_CAPABILITY(can_get_source_file_name);
1011 DEL_CAPABILITY(can_get_line_numbers);
1012 DEL_CAPABILITY(can_get_source_debug_extension);
1013 DEL_CAPABILITY(can_access_local_variables);
1014 DEL_CAPABILITY(can_maintain_original_method_order);
1015 DEL_CAPABILITY(can_generate_single_step_events);
1016 DEL_CAPABILITY(can_generate_exception_events);
1017 DEL_CAPABILITY(can_generate_frame_pop_events);
1018 DEL_CAPABILITY(can_generate_breakpoint_events);
1019 DEL_CAPABILITY(can_suspend);
1020 DEL_CAPABILITY(can_redefine_any_class);
1021 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1022 DEL_CAPABILITY(can_get_thread_cpu_time);
1023 DEL_CAPABILITY(can_generate_method_entry_events);
1024 DEL_CAPABILITY(can_generate_method_exit_events);
1025 DEL_CAPABILITY(can_generate_all_class_hook_events);
1026 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1027 DEL_CAPABILITY(can_generate_monitor_events);
1028 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1029 DEL_CAPABILITY(can_generate_native_method_bind_events);
1030 DEL_CAPABILITY(can_generate_garbage_collection_events);
1031 DEL_CAPABILITY(can_generate_object_free_events);
1032 DEL_CAPABILITY(can_force_early_return);
1033 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1034 DEL_CAPABILITY(can_get_constant_pool);
1035 DEL_CAPABILITY(can_set_native_method_prefix);
1036 DEL_CAPABILITY(can_retransform_classes);
1037 DEL_CAPABILITY(can_retransform_any_class);
1038 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1039 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1040#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001041 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1042 changed,
1043 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001044 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001045 }
1046
1047 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001048 ENSURE_VALID_ENV(env);
1049 ENSURE_NON_NULL(capabilities_ptr);
1050 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1051 *capabilities_ptr = artenv->capabilities;
1052 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001053 }
1054
1055 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1056 return ERR(NOT_IMPLEMENTED);
1057 }
1058
1059 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1060 return ERR(NOT_IMPLEMENTED);
1061 }
1062
1063 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1064 return ERR(NOT_IMPLEMENTED);
1065 }
1066
1067 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1068 return ERR(NOT_IMPLEMENTED);
1069 }
1070
1071 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001072 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001073 }
1074
1075 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001076 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001077 }
1078
1079 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001080 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001081 }
1082
1083 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001084 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001085 }
1086
1087 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001088 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001089 }
1090
1091 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001092 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001093 }
1094
1095 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001096 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001097 }
1098
1099 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001100 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001101 }
1102
1103 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Andreas Gampe96eca782017-01-19 19:45:30 -08001104 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001105 }
1106
1107 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001108 ENSURE_VALID_ENV(env);
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001109 gEventHandler.RemoveArtJvmTiEnv(ArtJvmTiEnv::AsArtJvmTiEnv(env));
Alex Light49948e92016-08-11 15:35:28 -07001110 delete env;
1111 return OK;
1112 }
1113
1114 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001115 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001116 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1117 return OK;
1118 }
1119
1120 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001121 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001122 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1123 return OK;
1124 }
1125
1126 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001127 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001128 *version_ptr = JVMTI_VERSION;
1129 return OK;
1130 }
1131
1132 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001133 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001134 switch (error) {
1135#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001136 jvmtiError res = CopyString(env, \
1137 "JVMTI_ERROR_"#e, \
1138 reinterpret_cast<unsigned char**>(name_ptr)); \
1139 if (res != OK) { \
1140 *name_ptr = nullptr; \
1141 return res; \
1142 } else { \
1143 return OK; \
1144 } \
Alex Light49948e92016-08-11 15:35:28 -07001145 } while (false)
1146 ERROR_CASE(NONE);
1147 ERROR_CASE(INVALID_THREAD);
1148 ERROR_CASE(INVALID_THREAD_GROUP);
1149 ERROR_CASE(INVALID_PRIORITY);
1150 ERROR_CASE(THREAD_NOT_SUSPENDED);
1151 ERROR_CASE(THREAD_NOT_ALIVE);
1152 ERROR_CASE(INVALID_OBJECT);
1153 ERROR_CASE(INVALID_CLASS);
1154 ERROR_CASE(CLASS_NOT_PREPARED);
1155 ERROR_CASE(INVALID_METHODID);
1156 ERROR_CASE(INVALID_LOCATION);
1157 ERROR_CASE(INVALID_FIELDID);
1158 ERROR_CASE(NO_MORE_FRAMES);
1159 ERROR_CASE(OPAQUE_FRAME);
1160 ERROR_CASE(TYPE_MISMATCH);
1161 ERROR_CASE(INVALID_SLOT);
1162 ERROR_CASE(DUPLICATE);
1163 ERROR_CASE(NOT_FOUND);
1164 ERROR_CASE(INVALID_MONITOR);
1165 ERROR_CASE(NOT_MONITOR_OWNER);
1166 ERROR_CASE(INTERRUPT);
1167 ERROR_CASE(INVALID_CLASS_FORMAT);
1168 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1169 ERROR_CASE(FAILS_VERIFICATION);
1170 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1171 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1172 ERROR_CASE(INVALID_TYPESTATE);
1173 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1174 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1175 ERROR_CASE(UNSUPPORTED_VERSION);
1176 ERROR_CASE(NAMES_DONT_MATCH);
1177 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1178 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1179 ERROR_CASE(UNMODIFIABLE_CLASS);
1180 ERROR_CASE(NOT_AVAILABLE);
1181 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1182 ERROR_CASE(NULL_POINTER);
1183 ERROR_CASE(ABSENT_INFORMATION);
1184 ERROR_CASE(INVALID_EVENT_TYPE);
1185 ERROR_CASE(ILLEGAL_ARGUMENT);
1186 ERROR_CASE(NATIVE_METHOD);
1187 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1188 ERROR_CASE(OUT_OF_MEMORY);
1189 ERROR_CASE(ACCESS_DENIED);
1190 ERROR_CASE(WRONG_PHASE);
1191 ERROR_CASE(INTERNAL);
1192 ERROR_CASE(UNATTACHED_THREAD);
1193 ERROR_CASE(INVALID_ENVIRONMENT);
1194#undef ERROR_CASE
1195 default: {
Alex Light41960712017-01-06 14:44:23 -08001196 jvmtiError res = CopyString(env,
1197 "JVMTI_ERROR_UNKNOWN",
1198 reinterpret_cast<unsigned char**>(name_ptr));
1199 if (res != OK) {
1200 *name_ptr = nullptr;
1201 return res;
1202 } else {
1203 return ERR(ILLEGAL_ARGUMENT);
1204 }
Alex Light49948e92016-08-11 15:35:28 -07001205 }
1206 }
1207 }
1208
1209 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001210 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1211 // OTHER is special, as it's 0, so can't do a bit check.
1212 bool val = (value == JNI_TRUE) ? true : false;
1213
1214 art::gLogVerbosity.collector = val;
1215 art::gLogVerbosity.compiler = val;
1216 art::gLogVerbosity.deopt = val;
1217 art::gLogVerbosity.heap = val;
1218 art::gLogVerbosity.jdwp = val;
1219 art::gLogVerbosity.jit = val;
1220 art::gLogVerbosity.monitor = val;
1221 art::gLogVerbosity.oat = val;
1222 art::gLogVerbosity.profiler = val;
1223 art::gLogVerbosity.signals = val;
1224 art::gLogVerbosity.simulator = val;
1225 art::gLogVerbosity.startup = val;
1226 art::gLogVerbosity.third_party_jni = val;
1227 art::gLogVerbosity.threads = val;
1228 art::gLogVerbosity.verifier = val;
1229 art::gLogVerbosity.image = val;
1230
1231 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1232
1233 art::gLogVerbosity.agents = val;
1234 } else {
1235 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1236 // semantics.
1237 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1238 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1239 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1240 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1241 if ((flag & ~kMask) != 0) {
1242 return ERR(ILLEGAL_ARGUMENT);
1243 }
1244
1245 bool val = (value == JNI_TRUE) ? true : false;
1246
1247 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1248 art::gLogVerbosity.gc = val;
1249 }
1250
1251 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1252 art::gLogVerbosity.class_linker = val;
1253 }
1254
1255 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1256 art::gLogVerbosity.jni = val;
1257 }
1258 }
1259
1260 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001261 }
1262
1263 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
Andreas Gampeacfc9572017-01-17 18:36:56 -08001264 // Report BCI as jlocation format. We report dex bytecode indices.
1265 if (format_ptr == nullptr) {
1266 return ERR(NULL_POINTER);
1267 }
1268 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1269 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001270 }
1271};
1272
1273static bool IsJvmtiVersion(jint version) {
1274 return version == JVMTI_VERSION_1 ||
1275 version == JVMTI_VERSION_1_0 ||
1276 version == JVMTI_VERSION_1_1 ||
1277 version == JVMTI_VERSION_1_2 ||
1278 version == JVMTI_VERSION;
1279}
1280
1281// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1282// is a pointer to the uninitialized memory for an art::ti::Env.
1283static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1284 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1285 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001286
1287 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001288}
1289
1290// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1291// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1292// returns false and does not modify the 'env' pointer.
1293static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1294 if (IsJvmtiVersion(version)) {
1295 CreateArtJvmTiEnv(vm, env);
1296 return JNI_OK;
1297 } else {
1298 printf("version 0x%x is not valid!", version);
1299 return JNI_EVERSION;
1300 }
1301}
1302
1303// The plugin initialization function. This adds the jvmti environment.
1304extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001305 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001306
1307 if (runtime->IsStarted()) {
1308 PhaseUtil::SetToLive();
1309 } else {
1310 PhaseUtil::SetToOnLoad();
1311 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001312 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001313 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001314 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001315 DumpUtil::Register(&gEventHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001316
Andreas Gampee08a2be2016-10-06 13:13:30 -07001317 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1318 runtime->AddSystemWeakHolder(&gObjectTagTable);
Andreas Gampe96eca782017-01-19 19:45:30 -08001319
Alex Light49948e92016-08-11 15:35:28 -07001320 return true;
1321}
1322
Andreas Gampeeafaf572017-01-20 12:34:15 -08001323extern "C" bool ArtPlugin_Deinitialize() {
1324 PhaseUtil::Unregister();
1325 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001326 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001327 DumpUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001328
1329 return true;
1330}
1331
Alex Light49948e92016-08-11 15:35:28 -07001332// The actual struct holding all of the entrypoints into the jvmti interface.
1333const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001334 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001335 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001336 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001337 JvmtiFunctions::GetAllThreads,
1338 JvmtiFunctions::SuspendThread,
1339 JvmtiFunctions::ResumeThread,
1340 JvmtiFunctions::StopThread,
1341 JvmtiFunctions::InterruptThread,
1342 JvmtiFunctions::GetThreadInfo,
1343 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1344 JvmtiFunctions::GetCurrentContendedMonitor,
1345 JvmtiFunctions::RunAgentThread,
1346 JvmtiFunctions::GetTopThreadGroups,
1347 JvmtiFunctions::GetThreadGroupInfo,
1348 JvmtiFunctions::GetThreadGroupChildren,
1349 JvmtiFunctions::GetFrameCount,
1350 JvmtiFunctions::GetThreadState,
1351 JvmtiFunctions::GetCurrentThread,
1352 JvmtiFunctions::GetFrameLocation,
1353 JvmtiFunctions::NotifyFramePop, // 20
1354 JvmtiFunctions::GetLocalObject,
1355 JvmtiFunctions::GetLocalInt,
1356 JvmtiFunctions::GetLocalLong,
1357 JvmtiFunctions::GetLocalFloat,
1358 JvmtiFunctions::GetLocalDouble,
1359 JvmtiFunctions::SetLocalObject,
1360 JvmtiFunctions::SetLocalInt,
1361 JvmtiFunctions::SetLocalLong,
1362 JvmtiFunctions::SetLocalFloat,
1363 JvmtiFunctions::SetLocalDouble, // 30
1364 JvmtiFunctions::CreateRawMonitor,
1365 JvmtiFunctions::DestroyRawMonitor,
1366 JvmtiFunctions::RawMonitorEnter,
1367 JvmtiFunctions::RawMonitorExit,
1368 JvmtiFunctions::RawMonitorWait,
1369 JvmtiFunctions::RawMonitorNotify,
1370 JvmtiFunctions::RawMonitorNotifyAll,
1371 JvmtiFunctions::SetBreakpoint,
1372 JvmtiFunctions::ClearBreakpoint,
1373 nullptr, // reserved40
1374 JvmtiFunctions::SetFieldAccessWatch,
1375 JvmtiFunctions::ClearFieldAccessWatch,
1376 JvmtiFunctions::SetFieldModificationWatch,
1377 JvmtiFunctions::ClearFieldModificationWatch,
1378 JvmtiFunctions::IsModifiableClass,
1379 JvmtiFunctions::Allocate,
1380 JvmtiFunctions::Deallocate,
1381 JvmtiFunctions::GetClassSignature,
1382 JvmtiFunctions::GetClassStatus,
1383 JvmtiFunctions::GetSourceFileName, // 50
1384 JvmtiFunctions::GetClassModifiers,
1385 JvmtiFunctions::GetClassMethods,
1386 JvmtiFunctions::GetClassFields,
1387 JvmtiFunctions::GetImplementedInterfaces,
1388 JvmtiFunctions::IsInterface,
1389 JvmtiFunctions::IsArrayClass,
1390 JvmtiFunctions::GetClassLoader,
1391 JvmtiFunctions::GetObjectHashCode,
1392 JvmtiFunctions::GetObjectMonitorUsage,
1393 JvmtiFunctions::GetFieldName, // 60
1394 JvmtiFunctions::GetFieldDeclaringClass,
1395 JvmtiFunctions::GetFieldModifiers,
1396 JvmtiFunctions::IsFieldSynthetic,
1397 JvmtiFunctions::GetMethodName,
1398 JvmtiFunctions::GetMethodDeclaringClass,
1399 JvmtiFunctions::GetMethodModifiers,
1400 nullptr, // reserved67
1401 JvmtiFunctions::GetMaxLocals,
1402 JvmtiFunctions::GetArgumentsSize,
1403 JvmtiFunctions::GetLineNumberTable, // 70
1404 JvmtiFunctions::GetMethodLocation,
1405 JvmtiFunctions::GetLocalVariableTable,
1406 JvmtiFunctions::SetNativeMethodPrefix,
1407 JvmtiFunctions::SetNativeMethodPrefixes,
1408 JvmtiFunctions::GetBytecodes,
1409 JvmtiFunctions::IsMethodNative,
1410 JvmtiFunctions::IsMethodSynthetic,
1411 JvmtiFunctions::GetLoadedClasses,
1412 JvmtiFunctions::GetClassLoaderClasses,
1413 JvmtiFunctions::PopFrame, // 80
1414 JvmtiFunctions::ForceEarlyReturnObject,
1415 JvmtiFunctions::ForceEarlyReturnInt,
1416 JvmtiFunctions::ForceEarlyReturnLong,
1417 JvmtiFunctions::ForceEarlyReturnFloat,
1418 JvmtiFunctions::ForceEarlyReturnDouble,
1419 JvmtiFunctions::ForceEarlyReturnVoid,
1420 JvmtiFunctions::RedefineClasses,
1421 JvmtiFunctions::GetVersionNumber,
1422 JvmtiFunctions::GetCapabilities,
1423 JvmtiFunctions::GetSourceDebugExtension, // 90
1424 JvmtiFunctions::IsMethodObsolete,
1425 JvmtiFunctions::SuspendThreadList,
1426 JvmtiFunctions::ResumeThreadList,
1427 nullptr, // reserved94
1428 nullptr, // reserved95
1429 nullptr, // reserved96
1430 nullptr, // reserved97
1431 nullptr, // reserved98
1432 nullptr, // reserved99
1433 JvmtiFunctions::GetAllStackTraces, // 100
1434 JvmtiFunctions::GetThreadListStackTraces,
1435 JvmtiFunctions::GetThreadLocalStorage,
1436 JvmtiFunctions::SetThreadLocalStorage,
1437 JvmtiFunctions::GetStackTrace,
1438 nullptr, // reserved105
1439 JvmtiFunctions::GetTag,
1440 JvmtiFunctions::SetTag,
1441 JvmtiFunctions::ForceGarbageCollection,
1442 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1443 JvmtiFunctions::IterateOverReachableObjects, // 110
1444 JvmtiFunctions::IterateOverHeap,
1445 JvmtiFunctions::IterateOverInstancesOfClass,
1446 nullptr, // reserved113
1447 JvmtiFunctions::GetObjectsWithTags,
1448 JvmtiFunctions::FollowReferences,
1449 JvmtiFunctions::IterateThroughHeap,
1450 nullptr, // reserved117
1451 nullptr, // reserved118
1452 nullptr, // reserved119
1453 JvmtiFunctions::SetJNIFunctionTable, // 120
1454 JvmtiFunctions::GetJNIFunctionTable,
1455 JvmtiFunctions::SetEventCallbacks,
1456 JvmtiFunctions::GenerateEvents,
1457 JvmtiFunctions::GetExtensionFunctions,
1458 JvmtiFunctions::GetExtensionEvents,
1459 JvmtiFunctions::SetExtensionEventCallback,
1460 JvmtiFunctions::DisposeEnvironment,
1461 JvmtiFunctions::GetErrorName,
1462 JvmtiFunctions::GetJLocationFormat,
1463 JvmtiFunctions::GetSystemProperties, // 130
1464 JvmtiFunctions::GetSystemProperty,
1465 JvmtiFunctions::SetSystemProperty,
1466 JvmtiFunctions::GetPhase,
1467 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1468 JvmtiFunctions::GetCurrentThreadCpuTime,
1469 JvmtiFunctions::GetThreadCpuTimerInfo,
1470 JvmtiFunctions::GetThreadCpuTime,
1471 JvmtiFunctions::GetTimerInfo,
1472 JvmtiFunctions::GetTime,
1473 JvmtiFunctions::GetPotentialCapabilities, // 140
1474 nullptr, // reserved141
1475 JvmtiFunctions::AddCapabilities,
1476 JvmtiFunctions::RelinquishCapabilities,
1477 JvmtiFunctions::GetAvailableProcessors,
1478 JvmtiFunctions::GetClassVersionNumbers,
1479 JvmtiFunctions::GetConstantPool,
1480 JvmtiFunctions::GetEnvironmentLocalStorage,
1481 JvmtiFunctions::SetEnvironmentLocalStorage,
1482 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1483 JvmtiFunctions::SetVerboseFlag, // 150
1484 JvmtiFunctions::AddToSystemClassLoaderSearch,
1485 JvmtiFunctions::RetransformClasses,
1486 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1487 JvmtiFunctions::GetObjectSize,
1488 JvmtiFunctions::GetLocalInstance,
1489};
1490
1491}; // namespace openjdkjvmti