blob: 3cba81771c8f1d39dab9da7133f3f2d19c3d0b42 [file] [log] [blame]
Alex Light49948e92016-08-11 15:35:28 -07001/* Copyright (C) 2016 The Android Open Source Project
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This file implements interfaces from the file jvmti.h. This implementation
5 * is licensed under the same terms as the file jvmti.h. The
6 * copyright and license information for the file jvmti.h follows.
7 *
8 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Oracle designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Oracle in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 * or visit www.oracle.com if you need additional information or have any
29 * questions.
30 */
31
Alex Light9c20a142016-08-23 15:05:12 -070032#include <string>
Andreas Gampef37e3022017-01-13 17:54:46 -080033#include <type_traits>
Alex Light9c20a142016-08-23 15:05:12 -070034#include <vector>
35
Alex Light49948e92016-08-11 15:35:28 -070036#include <jni.h>
Alex Light9c20a142016-08-23 15:05:12 -070037
Alex Light49948e92016-08-11 15:35:28 -070038#include "openjdkjvmti/jvmti.h"
39
Andreas Gampedb6dcb62016-09-13 09:05:59 -070040#include "art_jvmti.h"
Andreas Gampef37e3022017-01-13 17:54:46 -080041#include "base/logging.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070042#include "base/mutex.h"
43#include "events-inl.h"
Alex Light49948e92016-08-11 15:35:28 -070044#include "jni_env_ext-inl.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070045#include "obj_ptr-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080046#include "object_tagging.h"
Alex Light9c20a142016-08-23 15:05:12 -070047#include "runtime.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070048#include "scoped_thread_state_change-inl.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070049#include "thread-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080050#include "thread_list.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070051#include "ti_class.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080052#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070053#include "ti_heap.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070054#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080055#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080056#include "ti_object.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080057#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080058#include "ti_redefine.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070059#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080060#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000061#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080062#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070063#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070064
65// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
66// easier to create.
67#pragma GCC diagnostic ignored "-Wunused-parameter"
68
69namespace openjdkjvmti {
70
Andreas Gampe77708d92016-10-07 11:48:21 -070071EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070072ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070073
Alex Lighte6574242016-08-17 09:56:24 -070074#define ENSURE_NON_NULL(n) \
75 do { \
76 if ((n) == nullptr) { \
77 return ERR(NULL_POINTER); \
78 } \
79 } while (false)
80
Alex Light49948e92016-08-11 15:35:28 -070081class JvmtiFunctions {
82 private:
83 static bool IsValidEnv(jvmtiEnv* env) {
84 return env != nullptr;
85 }
86
Alex Lighte6574242016-08-17 09:56:24 -070087#define ENSURE_VALID_ENV(env) \
88 do { \
89 if (!IsValidEnv(env)) { \
90 return ERR(INVALID_ENVIRONMENT); \
91 } \
92 } while (false)
93
94#define ENSURE_HAS_CAP(env, cap) \
95 do { \
96 ENSURE_VALID_ENV(env); \
97 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
98 return ERR(MUST_POSSESS_CAPABILITY); \
99 } \
100 } while (false)
101
Alex Light49948e92016-08-11 15:35:28 -0700102 public:
103 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700104 ENSURE_VALID_ENV(env);
105 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700106 if (size < 0) {
107 return ERR(ILLEGAL_ARGUMENT);
108 } else if (size == 0) {
109 *mem_ptr = nullptr;
110 return OK;
111 }
112 *mem_ptr = static_cast<unsigned char*>(malloc(size));
113 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
114 }
115
116 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700117 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700118 if (mem != nullptr) {
119 free(mem);
120 }
121 return OK;
122 }
123
124 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800125 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700126 }
127
128 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800129 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700130 }
131
132 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800133 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700134 }
135
136 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
137 return ERR(NOT_IMPLEMENTED);
138 }
139
140 static jvmtiError SuspendThreadList(jvmtiEnv* env,
141 jint request_count,
142 const jthread* request_list,
143 jvmtiError* results) {
144 return ERR(NOT_IMPLEMENTED);
145 }
146
147 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
148 return ERR(NOT_IMPLEMENTED);
149 }
150
151 static jvmtiError ResumeThreadList(jvmtiEnv* env,
152 jint request_count,
153 const jthread* request_list,
154 jvmtiError* results) {
155 return ERR(NOT_IMPLEMENTED);
156 }
157
158 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
159 return ERR(NOT_IMPLEMENTED);
160 }
161
162 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
163 return ERR(NOT_IMPLEMENTED);
164 }
165
166 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800167 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700168 }
169
170 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
171 jthread thread,
172 jint* owned_monitor_count_ptr,
173 jobject** owned_monitors_ptr) {
174 return ERR(NOT_IMPLEMENTED);
175 }
176
177 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
178 jthread thread,
179 jint* monitor_info_count_ptr,
180 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
181 return ERR(NOT_IMPLEMENTED);
182 }
183
184 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
185 jthread thread,
186 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700187 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700188 }
189
190 static jvmtiError RunAgentThread(jvmtiEnv* env,
191 jthread thread,
192 jvmtiStartFunction proc,
193 const void* arg,
194 jint priority) {
195 return ERR(NOT_IMPLEMENTED);
196 }
197
198 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
199 return ERR(NOT_IMPLEMENTED);
200 }
201
202 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
203 return ERR(NOT_IMPLEMENTED);
204 }
205
206 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
207 jint* group_count_ptr,
208 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000209 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700210 }
211
212 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
213 jthreadGroup group,
214 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000215 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700216 }
217
218 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
219 jthreadGroup group,
220 jint* thread_count_ptr,
221 jthread** threads_ptr,
222 jint* group_count_ptr,
223 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000224 return ThreadGroupUtil::GetThreadGroupChildren(env,
225 group,
226 thread_count_ptr,
227 threads_ptr,
228 group_count_ptr,
229 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700230 }
231
232 static jvmtiError GetStackTrace(jvmtiEnv* env,
233 jthread thread,
234 jint start_depth,
235 jint max_frame_count,
236 jvmtiFrameInfo* frame_buffer,
237 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700238 return StackUtil::GetStackTrace(env,
239 thread,
240 start_depth,
241 max_frame_count,
242 frame_buffer,
243 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700244 }
245
246 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
247 jint max_frame_count,
248 jvmtiStackInfo** stack_info_ptr,
249 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800250 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700251 }
252
253 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
254 jint thread_count,
255 const jthread* thread_list,
256 jint max_frame_count,
257 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800258 return StackUtil::GetThreadListStackTraces(env,
259 thread_count,
260 thread_list,
261 max_frame_count,
262 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700263 }
264
265 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800266 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700267 }
268
269 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
270 return ERR(NOT_IMPLEMENTED);
271 }
272
273 static jvmtiError GetFrameLocation(jvmtiEnv* env,
274 jthread thread,
275 jint depth,
276 jmethodID* method_ptr,
277 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800278 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700279 }
280
281 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
282 return ERR(NOT_IMPLEMENTED);
283 }
284
285 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
286 return ERR(NOT_IMPLEMENTED);
287 }
288
289 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
290 return ERR(NOT_IMPLEMENTED);
291 }
292
293 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
294 return ERR(NOT_IMPLEMENTED);
295 }
296
297 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
298 return ERR(NOT_IMPLEMENTED);
299 }
300
301 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
302 return ERR(NOT_IMPLEMENTED);
303 }
304
305 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
306 return ERR(NOT_IMPLEMENTED);
307 }
308
309 static jvmtiError FollowReferences(jvmtiEnv* env,
310 jint heap_filter,
311 jclass klass,
312 jobject initial_object,
313 const jvmtiHeapCallbacks* callbacks,
314 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700315 HeapUtil heap_util(&gObjectTagTable);
316 return heap_util.FollowReferences(env,
317 heap_filter,
318 klass,
319 initial_object,
320 callbacks,
321 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700322 }
323
324 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
325 jint heap_filter,
326 jclass klass,
327 const jvmtiHeapCallbacks* callbacks,
328 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700329 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700330 HeapUtil heap_util(&gObjectTagTable);
331 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700332 }
333
334 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700335 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700336
337 JNIEnv* jni_env = GetJniEnv(env);
338 if (jni_env == nullptr) {
339 return ERR(INTERNAL);
340 }
341
342 art::ScopedObjectAccess soa(jni_env);
343 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
344 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
345 *tag_ptr = 0;
346 }
347
348 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700349 }
350
351 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700352 ENSURE_HAS_CAP(env, can_tag_objects);
353
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700354 if (object == nullptr) {
355 return ERR(NULL_POINTER);
356 }
357
358 JNIEnv* jni_env = GetJniEnv(env);
359 if (jni_env == nullptr) {
360 return ERR(INTERNAL);
361 }
362
363 art::ScopedObjectAccess soa(jni_env);
364 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700365 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700366
367 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700368 }
369
370 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
371 jint tag_count,
372 const jlong* tags,
373 jint* count_ptr,
374 jobject** object_result_ptr,
375 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700376 ENSURE_HAS_CAP(env, can_tag_objects);
377
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700378 JNIEnv* jni_env = GetJniEnv(env);
379 if (jni_env == nullptr) {
380 return ERR(INTERNAL);
381 }
382
383 art::ScopedObjectAccess soa(jni_env);
384 return gObjectTagTable.GetTaggedObjects(env,
385 tag_count,
386 tags,
387 count_ptr,
388 object_result_ptr,
389 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700390 }
391
392 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700393 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700394 }
395
396 static jvmtiError IterateOverObjectsReachableFromObject(
397 jvmtiEnv* env,
398 jobject object,
399 jvmtiObjectReferenceCallback object_reference_callback,
400 const void* user_data) {
401 return ERR(NOT_IMPLEMENTED);
402 }
403
404 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
405 jvmtiHeapRootCallback heap_root_callback,
406 jvmtiStackReferenceCallback stack_ref_callback,
407 jvmtiObjectReferenceCallback object_ref_callback,
408 const void* user_data) {
409 return ERR(NOT_IMPLEMENTED);
410 }
411
412 static jvmtiError IterateOverHeap(jvmtiEnv* env,
413 jvmtiHeapObjectFilter object_filter,
414 jvmtiHeapObjectCallback heap_object_callback,
415 const void* user_data) {
416 return ERR(NOT_IMPLEMENTED);
417 }
418
419 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
420 jclass klass,
421 jvmtiHeapObjectFilter object_filter,
422 jvmtiHeapObjectCallback heap_object_callback,
423 const void* user_data) {
424 return ERR(NOT_IMPLEMENTED);
425 }
426
427 static jvmtiError GetLocalObject(jvmtiEnv* env,
428 jthread thread,
429 jint depth,
430 jint slot,
431 jobject* value_ptr) {
432 return ERR(NOT_IMPLEMENTED);
433 }
434
435 static jvmtiError GetLocalInstance(jvmtiEnv* env,
436 jthread thread,
437 jint depth,
438 jobject* value_ptr) {
439 return ERR(NOT_IMPLEMENTED);
440 }
441
442 static jvmtiError GetLocalInt(jvmtiEnv* env,
443 jthread thread,
444 jint depth,
445 jint slot,
446 jint* value_ptr) {
447 return ERR(NOT_IMPLEMENTED);
448 }
449
450 static jvmtiError GetLocalLong(jvmtiEnv* env,
451 jthread thread,
452 jint depth,
453 jint slot,
454 jlong* value_ptr) {
455 return ERR(NOT_IMPLEMENTED);
456 }
457
458 static jvmtiError GetLocalFloat(jvmtiEnv* env,
459 jthread thread,
460 jint depth,
461 jint slot,
462 jfloat* value_ptr) {
463 return ERR(NOT_IMPLEMENTED);
464 }
465
466 static jvmtiError GetLocalDouble(jvmtiEnv* env,
467 jthread thread,
468 jint depth,
469 jint slot,
470 jdouble* value_ptr) {
471 return ERR(NOT_IMPLEMENTED);
472 }
473
474 static jvmtiError SetLocalObject(jvmtiEnv* env,
475 jthread thread,
476 jint depth,
477 jint slot,
478 jobject value) {
479 return ERR(NOT_IMPLEMENTED);
480 }
481
482 static jvmtiError SetLocalInt(jvmtiEnv* env,
483 jthread thread,
484 jint depth,
485 jint slot,
486 jint value) {
487 return ERR(NOT_IMPLEMENTED);
488 }
489
490 static jvmtiError SetLocalLong(jvmtiEnv* env,
491 jthread thread,
492 jint depth,
493 jint slot,
494 jlong value) {
495 return ERR(NOT_IMPLEMENTED);
496 }
497
498 static jvmtiError SetLocalFloat(jvmtiEnv* env,
499 jthread thread,
500 jint depth,
501 jint slot,
502 jfloat value) {
503 return ERR(NOT_IMPLEMENTED);
504 }
505
506 static jvmtiError SetLocalDouble(jvmtiEnv* env,
507 jthread thread,
508 jint depth,
509 jint slot,
510 jdouble value) {
511 return ERR(NOT_IMPLEMENTED);
512 }
513
514 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
515 return ERR(NOT_IMPLEMENTED);
516 }
517
518 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
519 return ERR(NOT_IMPLEMENTED);
520 }
521
522 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
523 return ERR(NOT_IMPLEMENTED);
524 }
525
526 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
527 return ERR(NOT_IMPLEMENTED);
528 }
529
530 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
531 return ERR(NOT_IMPLEMENTED);
532 }
533
534 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
535 return ERR(NOT_IMPLEMENTED);
536 }
537
538 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700539 HeapUtil heap_util(&gObjectTagTable);
540 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700541 }
542
543 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
544 jobject initiating_loader,
545 jint* class_count_ptr,
546 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800547 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700548 }
549
550 static jvmtiError GetClassSignature(jvmtiEnv* env,
551 jclass klass,
552 char** signature_ptr,
553 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700554 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700555 }
556
557 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800558 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700559 }
560
561 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
562 return ERR(NOT_IMPLEMENTED);
563 }
564
565 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800566 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700567 }
568
569 static jvmtiError GetClassMethods(jvmtiEnv* env,
570 jclass klass,
571 jint* method_count_ptr,
572 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800573 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700574 }
575
576 static jvmtiError GetClassFields(jvmtiEnv* env,
577 jclass klass,
578 jint* field_count_ptr,
579 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800580 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700581 }
582
583 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
584 jclass klass,
585 jint* interface_count_ptr,
586 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800587 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700588 }
589
590 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
591 jclass klass,
592 jint* minor_version_ptr,
593 jint* major_version_ptr) {
594 return ERR(NOT_IMPLEMENTED);
595 }
596
597 static jvmtiError GetConstantPool(jvmtiEnv* env,
598 jclass klass,
599 jint* constant_pool_count_ptr,
600 jint* constant_pool_byte_count_ptr,
601 unsigned char** constant_pool_bytes_ptr) {
602 return ERR(NOT_IMPLEMENTED);
603 }
604
605 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800606 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700607 }
608
609 static jvmtiError IsArrayClass(jvmtiEnv* env,
610 jclass klass,
611 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800612 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700613 }
614
615 static jvmtiError IsModifiableClass(jvmtiEnv* env,
616 jclass klass,
617 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800618 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700619 }
620
621 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800622 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700623 }
624
625 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
626 jclass klass,
627 char** source_debug_extension_ptr) {
628 return ERR(NOT_IMPLEMENTED);
629 }
630
631 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
632 return ERR(NOT_IMPLEMENTED);
633 }
634
635 static jvmtiError RedefineClasses(jvmtiEnv* env,
636 jint class_count,
637 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800638 std::string error_msg;
639 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
640 art::Runtime::Current(),
641 art::Thread::Current(),
642 class_count,
643 class_definitions,
644 &error_msg);
645 if (res != OK) {
646 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
647 }
648 return res;
Alex Light49948e92016-08-11 15:35:28 -0700649 }
650
651 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800652 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700653 }
654
655 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800656 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700657 }
658
659 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
660 jobject object,
661 jvmtiMonitorUsage* info_ptr) {
662 return ERR(NOT_IMPLEMENTED);
663 }
664
665 static jvmtiError GetFieldName(jvmtiEnv* env,
666 jclass klass,
667 jfieldID field,
668 char** name_ptr,
669 char** signature_ptr,
670 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800671 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700672 }
673
674 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
675 jclass klass,
676 jfieldID field,
677 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800678 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700679 }
680
681 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
682 jclass klass,
683 jfieldID field,
684 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800685 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700686 }
687
688 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
689 jclass klass,
690 jfieldID field,
691 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800692 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700693 }
694
695 static jvmtiError GetMethodName(jvmtiEnv* env,
696 jmethodID method,
697 char** name_ptr,
698 char** signature_ptr,
699 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700700 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700701 }
702
703 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
704 jmethodID method,
705 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700706 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700707 }
708
709 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
710 jmethodID method,
711 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700712 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700713 }
714
715 static jvmtiError GetMaxLocals(jvmtiEnv* env,
716 jmethodID method,
717 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800718 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700719 }
720
721 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
722 jmethodID method,
723 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800724 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700725 }
726
727 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
728 jmethodID method,
729 jint* entry_count_ptr,
730 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800731 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700732 }
733
734 static jvmtiError GetMethodLocation(jvmtiEnv* env,
735 jmethodID method,
736 jlocation* start_location_ptr,
737 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800738 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700739 }
740
741 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
742 jmethodID method,
743 jint* entry_count_ptr,
744 jvmtiLocalVariableEntry** table_ptr) {
745 return ERR(NOT_IMPLEMENTED);
746 }
747
748 static jvmtiError GetBytecodes(jvmtiEnv* env,
749 jmethodID method,
750 jint* bytecode_count_ptr,
751 unsigned char** bytecodes_ptr) {
752 return ERR(NOT_IMPLEMENTED);
753 }
754
755 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800756 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700757 }
758
759 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800760 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700761 }
762
763 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800764 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700765 }
766
767 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
768 return ERR(NOT_IMPLEMENTED);
769 }
770
771 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
772 return ERR(NOT_IMPLEMENTED);
773 }
774
775 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800776 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700777 }
778
779 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800780 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700781 }
782
783 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800784 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700785 }
786
787 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800788 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700789 }
790
791 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800792 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700793 }
794
795 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800796 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700797 }
798
799 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800800 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700801 }
802
803 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
804 return ERR(NOT_IMPLEMENTED);
805 }
806
807 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
808 return ERR(NOT_IMPLEMENTED);
809 }
810
Andreas Gampe77708d92016-10-07 11:48:21 -0700811 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
812 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700813 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
814 const jvmtiEventCallbacks* callbacks,
815 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700816 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700817 if (size_of_callbacks < 0) {
818 return ERR(ILLEGAL_ARGUMENT);
819 }
820
821 if (callbacks == nullptr) {
822 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
823 return ERR(NONE);
824 }
825
826 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
827 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
828 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
829 static_cast<size_t>(size_of_callbacks));
830 copy_size = art::RoundDown(copy_size, sizeof(void*));
831 memcpy(tmp.get(), callbacks, copy_size);
832
833 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
834
835 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700836 }
837
838 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
839 jvmtiEventMode mode,
840 jvmtiEvent event_type,
841 jthread event_thread,
842 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700843 ENSURE_VALID_ENV(env);
844 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700845 art::Thread* art_thread = nullptr;
846 if (event_thread != nullptr) {
847 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
848 art::ScopedObjectAccess soa(art::Thread::Current());
849 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
850 art_thread = art::Thread::FromManagedThread(soa, event_thread);
851
852 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
853 art_thread->IsStillStarting()) {
854 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
855 return ERR(THREAD_NOT_ALIVE);
856 }
857 }
858
Alex Light40d87f42017-01-18 10:27:06 -0800859 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
860 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -0700861 }
862
863 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
864 return ERR(NOT_IMPLEMENTED);
865 }
866
867 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
868 jint* extension_count_ptr,
869 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800870 // We do not have any extension functions.
871 *extension_count_ptr = 0;
872 *extensions = nullptr;
873
874 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700875 }
876
877 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
878 jint* extension_count_ptr,
879 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800880 // We do not have any extension events.
881 *extension_count_ptr = 0;
882 *extensions = nullptr;
883
884 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700885 }
886
887 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
888 jint extension_event_index,
889 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800890 // We do not have any extension events, so any call is illegal.
891 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700892 }
893
894 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700895 ENSURE_VALID_ENV(env);
896 ENSURE_NON_NULL(capabilities_ptr);
897 *capabilities_ptr = kPotentialCapabilities;
898 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700899 }
900
901 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700902 ENSURE_VALID_ENV(env);
903 ENSURE_NON_NULL(capabilities_ptr);
904 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
905 jvmtiError ret = OK;
Alex Light73afd322017-01-18 11:17:47 -0800906 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700907#define ADD_CAPABILITY(e) \
908 do { \
909 if (capabilities_ptr->e == 1) { \
910 if (kPotentialCapabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800911 if (art_env->capabilities.e != 1) { \
912 art_env->capabilities.e = 1; \
913 changed.e = 1; \
914 }\
Alex Lighte6574242016-08-17 09:56:24 -0700915 } else { \
916 ret = ERR(NOT_AVAILABLE); \
917 } \
918 } \
919 } while (false)
920
921 ADD_CAPABILITY(can_tag_objects);
922 ADD_CAPABILITY(can_generate_field_modification_events);
923 ADD_CAPABILITY(can_generate_field_access_events);
924 ADD_CAPABILITY(can_get_bytecodes);
925 ADD_CAPABILITY(can_get_synthetic_attribute);
926 ADD_CAPABILITY(can_get_owned_monitor_info);
927 ADD_CAPABILITY(can_get_current_contended_monitor);
928 ADD_CAPABILITY(can_get_monitor_info);
929 ADD_CAPABILITY(can_pop_frame);
930 ADD_CAPABILITY(can_redefine_classes);
931 ADD_CAPABILITY(can_signal_thread);
932 ADD_CAPABILITY(can_get_source_file_name);
933 ADD_CAPABILITY(can_get_line_numbers);
934 ADD_CAPABILITY(can_get_source_debug_extension);
935 ADD_CAPABILITY(can_access_local_variables);
936 ADD_CAPABILITY(can_maintain_original_method_order);
937 ADD_CAPABILITY(can_generate_single_step_events);
938 ADD_CAPABILITY(can_generate_exception_events);
939 ADD_CAPABILITY(can_generate_frame_pop_events);
940 ADD_CAPABILITY(can_generate_breakpoint_events);
941 ADD_CAPABILITY(can_suspend);
942 ADD_CAPABILITY(can_redefine_any_class);
943 ADD_CAPABILITY(can_get_current_thread_cpu_time);
944 ADD_CAPABILITY(can_get_thread_cpu_time);
945 ADD_CAPABILITY(can_generate_method_entry_events);
946 ADD_CAPABILITY(can_generate_method_exit_events);
947 ADD_CAPABILITY(can_generate_all_class_hook_events);
948 ADD_CAPABILITY(can_generate_compiled_method_load_events);
949 ADD_CAPABILITY(can_generate_monitor_events);
950 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
951 ADD_CAPABILITY(can_generate_native_method_bind_events);
952 ADD_CAPABILITY(can_generate_garbage_collection_events);
953 ADD_CAPABILITY(can_generate_object_free_events);
954 ADD_CAPABILITY(can_force_early_return);
955 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
956 ADD_CAPABILITY(can_get_constant_pool);
957 ADD_CAPABILITY(can_set_native_method_prefix);
958 ADD_CAPABILITY(can_retransform_classes);
959 ADD_CAPABILITY(can_retransform_any_class);
960 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
961 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
962#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -0800963 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
964 changed,
965 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -0700966 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700967 }
968
969 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
970 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700971 ENSURE_VALID_ENV(env);
972 ENSURE_NON_NULL(capabilities_ptr);
973 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light73afd322017-01-18 11:17:47 -0800974 jvmtiCapabilities changed;
Alex Lighte6574242016-08-17 09:56:24 -0700975#define DEL_CAPABILITY(e) \
976 do { \
977 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -0800978 if (art_env->capabilities.e == 1) { \
979 art_env->capabilities.e = 0;\
980 changed.e = 1; \
981 } \
Alex Lighte6574242016-08-17 09:56:24 -0700982 } \
983 } while (false)
984
985 DEL_CAPABILITY(can_tag_objects);
986 DEL_CAPABILITY(can_generate_field_modification_events);
987 DEL_CAPABILITY(can_generate_field_access_events);
988 DEL_CAPABILITY(can_get_bytecodes);
989 DEL_CAPABILITY(can_get_synthetic_attribute);
990 DEL_CAPABILITY(can_get_owned_monitor_info);
991 DEL_CAPABILITY(can_get_current_contended_monitor);
992 DEL_CAPABILITY(can_get_monitor_info);
993 DEL_CAPABILITY(can_pop_frame);
994 DEL_CAPABILITY(can_redefine_classes);
995 DEL_CAPABILITY(can_signal_thread);
996 DEL_CAPABILITY(can_get_source_file_name);
997 DEL_CAPABILITY(can_get_line_numbers);
998 DEL_CAPABILITY(can_get_source_debug_extension);
999 DEL_CAPABILITY(can_access_local_variables);
1000 DEL_CAPABILITY(can_maintain_original_method_order);
1001 DEL_CAPABILITY(can_generate_single_step_events);
1002 DEL_CAPABILITY(can_generate_exception_events);
1003 DEL_CAPABILITY(can_generate_frame_pop_events);
1004 DEL_CAPABILITY(can_generate_breakpoint_events);
1005 DEL_CAPABILITY(can_suspend);
1006 DEL_CAPABILITY(can_redefine_any_class);
1007 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1008 DEL_CAPABILITY(can_get_thread_cpu_time);
1009 DEL_CAPABILITY(can_generate_method_entry_events);
1010 DEL_CAPABILITY(can_generate_method_exit_events);
1011 DEL_CAPABILITY(can_generate_all_class_hook_events);
1012 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1013 DEL_CAPABILITY(can_generate_monitor_events);
1014 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1015 DEL_CAPABILITY(can_generate_native_method_bind_events);
1016 DEL_CAPABILITY(can_generate_garbage_collection_events);
1017 DEL_CAPABILITY(can_generate_object_free_events);
1018 DEL_CAPABILITY(can_force_early_return);
1019 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1020 DEL_CAPABILITY(can_get_constant_pool);
1021 DEL_CAPABILITY(can_set_native_method_prefix);
1022 DEL_CAPABILITY(can_retransform_classes);
1023 DEL_CAPABILITY(can_retransform_any_class);
1024 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1025 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1026#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001027 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1028 changed,
1029 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001030 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001031 }
1032
1033 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001034 ENSURE_VALID_ENV(env);
1035 ENSURE_NON_NULL(capabilities_ptr);
1036 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1037 *capabilities_ptr = artenv->capabilities;
1038 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001039 }
1040
1041 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1042 return ERR(NOT_IMPLEMENTED);
1043 }
1044
1045 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1046 return ERR(NOT_IMPLEMENTED);
1047 }
1048
1049 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1050 return ERR(NOT_IMPLEMENTED);
1051 }
1052
1053 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1054 return ERR(NOT_IMPLEMENTED);
1055 }
1056
1057 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001058 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001059 }
1060
1061 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001062 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001063 }
1064
1065 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001066 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001067 }
1068
1069 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1070 return ERR(NOT_IMPLEMENTED);
1071 }
1072
1073 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1074 return ERR(NOT_IMPLEMENTED);
1075 }
1076
1077 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001078 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001079 }
1080
1081 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001082 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001083 }
1084
1085 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001086 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001087 }
1088
1089 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1090 return ERR(NOT_IMPLEMENTED);
1091 }
1092
1093 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001094 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001095 delete env;
1096 return OK;
1097 }
1098
1099 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001100 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001101 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1102 return OK;
1103 }
1104
1105 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001106 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001107 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1108 return OK;
1109 }
1110
1111 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001112 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001113 *version_ptr = JVMTI_VERSION;
1114 return OK;
1115 }
1116
1117 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001118 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001119 switch (error) {
1120#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001121 jvmtiError res = CopyString(env, \
1122 "JVMTI_ERROR_"#e, \
1123 reinterpret_cast<unsigned char**>(name_ptr)); \
1124 if (res != OK) { \
1125 *name_ptr = nullptr; \
1126 return res; \
1127 } else { \
1128 return OK; \
1129 } \
Alex Light49948e92016-08-11 15:35:28 -07001130 } while (false)
1131 ERROR_CASE(NONE);
1132 ERROR_CASE(INVALID_THREAD);
1133 ERROR_CASE(INVALID_THREAD_GROUP);
1134 ERROR_CASE(INVALID_PRIORITY);
1135 ERROR_CASE(THREAD_NOT_SUSPENDED);
1136 ERROR_CASE(THREAD_NOT_ALIVE);
1137 ERROR_CASE(INVALID_OBJECT);
1138 ERROR_CASE(INVALID_CLASS);
1139 ERROR_CASE(CLASS_NOT_PREPARED);
1140 ERROR_CASE(INVALID_METHODID);
1141 ERROR_CASE(INVALID_LOCATION);
1142 ERROR_CASE(INVALID_FIELDID);
1143 ERROR_CASE(NO_MORE_FRAMES);
1144 ERROR_CASE(OPAQUE_FRAME);
1145 ERROR_CASE(TYPE_MISMATCH);
1146 ERROR_CASE(INVALID_SLOT);
1147 ERROR_CASE(DUPLICATE);
1148 ERROR_CASE(NOT_FOUND);
1149 ERROR_CASE(INVALID_MONITOR);
1150 ERROR_CASE(NOT_MONITOR_OWNER);
1151 ERROR_CASE(INTERRUPT);
1152 ERROR_CASE(INVALID_CLASS_FORMAT);
1153 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1154 ERROR_CASE(FAILS_VERIFICATION);
1155 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1156 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1157 ERROR_CASE(INVALID_TYPESTATE);
1158 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1159 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1160 ERROR_CASE(UNSUPPORTED_VERSION);
1161 ERROR_CASE(NAMES_DONT_MATCH);
1162 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1163 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1164 ERROR_CASE(UNMODIFIABLE_CLASS);
1165 ERROR_CASE(NOT_AVAILABLE);
1166 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1167 ERROR_CASE(NULL_POINTER);
1168 ERROR_CASE(ABSENT_INFORMATION);
1169 ERROR_CASE(INVALID_EVENT_TYPE);
1170 ERROR_CASE(ILLEGAL_ARGUMENT);
1171 ERROR_CASE(NATIVE_METHOD);
1172 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1173 ERROR_CASE(OUT_OF_MEMORY);
1174 ERROR_CASE(ACCESS_DENIED);
1175 ERROR_CASE(WRONG_PHASE);
1176 ERROR_CASE(INTERNAL);
1177 ERROR_CASE(UNATTACHED_THREAD);
1178 ERROR_CASE(INVALID_ENVIRONMENT);
1179#undef ERROR_CASE
1180 default: {
Alex Light41960712017-01-06 14:44:23 -08001181 jvmtiError res = CopyString(env,
1182 "JVMTI_ERROR_UNKNOWN",
1183 reinterpret_cast<unsigned char**>(name_ptr));
1184 if (res != OK) {
1185 *name_ptr = nullptr;
1186 return res;
1187 } else {
1188 return ERR(ILLEGAL_ARGUMENT);
1189 }
Alex Light49948e92016-08-11 15:35:28 -07001190 }
1191 }
1192 }
1193
1194 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001195 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1196 // OTHER is special, as it's 0, so can't do a bit check.
1197 bool val = (value == JNI_TRUE) ? true : false;
1198
1199 art::gLogVerbosity.collector = val;
1200 art::gLogVerbosity.compiler = val;
1201 art::gLogVerbosity.deopt = val;
1202 art::gLogVerbosity.heap = val;
1203 art::gLogVerbosity.jdwp = val;
1204 art::gLogVerbosity.jit = val;
1205 art::gLogVerbosity.monitor = val;
1206 art::gLogVerbosity.oat = val;
1207 art::gLogVerbosity.profiler = val;
1208 art::gLogVerbosity.signals = val;
1209 art::gLogVerbosity.simulator = val;
1210 art::gLogVerbosity.startup = val;
1211 art::gLogVerbosity.third_party_jni = val;
1212 art::gLogVerbosity.threads = val;
1213 art::gLogVerbosity.verifier = val;
1214 art::gLogVerbosity.image = val;
1215
1216 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1217
1218 art::gLogVerbosity.agents = val;
1219 } else {
1220 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1221 // semantics.
1222 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1223 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1224 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1225 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1226 if ((flag & ~kMask) != 0) {
1227 return ERR(ILLEGAL_ARGUMENT);
1228 }
1229
1230 bool val = (value == JNI_TRUE) ? true : false;
1231
1232 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1233 art::gLogVerbosity.gc = val;
1234 }
1235
1236 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1237 art::gLogVerbosity.class_linker = val;
1238 }
1239
1240 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1241 art::gLogVerbosity.jni = val;
1242 }
1243 }
1244
1245 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001246 }
1247
1248 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1249 return ERR(NOT_IMPLEMENTED);
1250 }
Alex Light9c20a142016-08-23 15:05:12 -07001251
1252 // TODO Remove this once events are working.
1253 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1254 jclass klass,
1255 jvmtiEventClassFileLoadHook hook) {
1256 std::vector<jclass> classes;
1257 classes.push_back(klass);
1258 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1259 }
1260
1261 // TODO This will be called by the event handler for the art::ti Event Load Event
1262 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1263 const std::vector<jclass>& classes,
1264 jvmtiEventClassFileLoadHook hook) {
1265 if (!IsValidEnv(env)) {
1266 return ERR(INVALID_ENVIRONMENT);
1267 }
Alex Lighta01de592016-11-15 10:43:06 -08001268 jvmtiError res = OK;
1269 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001270 for (jclass klass : classes) {
1271 JNIEnv* jni_env = nullptr;
1272 jobject loader = nullptr;
1273 std::string name;
1274 jobject protection_domain = nullptr;
1275 jint data_len = 0;
1276 unsigned char* dex_data = nullptr;
1277 jvmtiError ret = OK;
1278 std::string location;
1279 if ((ret = GetTransformationData(env,
1280 klass,
1281 /*out*/&location,
1282 /*out*/&jni_env,
1283 /*out*/&loader,
1284 /*out*/&name,
1285 /*out*/&protection_domain,
1286 /*out*/&data_len,
1287 /*out*/&dex_data)) != OK) {
1288 // TODO Do something more here? Maybe give log statements?
1289 return ret;
1290 }
1291 jint new_data_len = 0;
1292 unsigned char* new_dex_data = nullptr;
1293 hook(env,
1294 jni_env,
1295 klass,
1296 loader,
1297 name.c_str(),
1298 protection_domain,
1299 data_len,
1300 dex_data,
1301 /*out*/&new_data_len,
1302 /*out*/&new_dex_data);
1303 // Check if anything actually changed.
1304 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001305 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1306 res = Redefiner::RedefineClasses(env,
1307 art::Runtime::Current(),
1308 art::Thread::Current(),
1309 1,
1310 &def,
1311 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001312 env->Deallocate(new_dex_data);
1313 }
1314 // Deallocate the old dex data.
1315 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001316 if (res != OK) {
1317 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1318 return res;
1319 }
Alex Light9c20a142016-08-23 15:05:12 -07001320 }
1321 return OK;
1322 }
Alex Light49948e92016-08-11 15:35:28 -07001323};
1324
1325static bool IsJvmtiVersion(jint version) {
1326 return version == JVMTI_VERSION_1 ||
1327 version == JVMTI_VERSION_1_0 ||
1328 version == JVMTI_VERSION_1_1 ||
1329 version == JVMTI_VERSION_1_2 ||
1330 version == JVMTI_VERSION;
1331}
1332
1333// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1334// is a pointer to the uninitialized memory for an art::ti::Env.
1335static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1336 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1337 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001338
1339 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001340}
1341
1342// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1343// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1344// returns false and does not modify the 'env' pointer.
1345static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1346 if (IsJvmtiVersion(version)) {
1347 CreateArtJvmTiEnv(vm, env);
1348 return JNI_OK;
1349 } else {
1350 printf("version 0x%x is not valid!", version);
1351 return JNI_EVERSION;
1352 }
1353}
1354
1355// The plugin initialization function. This adds the jvmti environment.
1356extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001357 art::Runtime* runtime = art::Runtime::Current();
1358 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1359 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001360 return true;
1361}
1362
1363// The actual struct holding all of the entrypoints into the jvmti interface.
1364const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001365 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1366 // TODO Remove once we have events working.
1367 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1368 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001369 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001370 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001371 JvmtiFunctions::GetAllThreads,
1372 JvmtiFunctions::SuspendThread,
1373 JvmtiFunctions::ResumeThread,
1374 JvmtiFunctions::StopThread,
1375 JvmtiFunctions::InterruptThread,
1376 JvmtiFunctions::GetThreadInfo,
1377 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1378 JvmtiFunctions::GetCurrentContendedMonitor,
1379 JvmtiFunctions::RunAgentThread,
1380 JvmtiFunctions::GetTopThreadGroups,
1381 JvmtiFunctions::GetThreadGroupInfo,
1382 JvmtiFunctions::GetThreadGroupChildren,
1383 JvmtiFunctions::GetFrameCount,
1384 JvmtiFunctions::GetThreadState,
1385 JvmtiFunctions::GetCurrentThread,
1386 JvmtiFunctions::GetFrameLocation,
1387 JvmtiFunctions::NotifyFramePop, // 20
1388 JvmtiFunctions::GetLocalObject,
1389 JvmtiFunctions::GetLocalInt,
1390 JvmtiFunctions::GetLocalLong,
1391 JvmtiFunctions::GetLocalFloat,
1392 JvmtiFunctions::GetLocalDouble,
1393 JvmtiFunctions::SetLocalObject,
1394 JvmtiFunctions::SetLocalInt,
1395 JvmtiFunctions::SetLocalLong,
1396 JvmtiFunctions::SetLocalFloat,
1397 JvmtiFunctions::SetLocalDouble, // 30
1398 JvmtiFunctions::CreateRawMonitor,
1399 JvmtiFunctions::DestroyRawMonitor,
1400 JvmtiFunctions::RawMonitorEnter,
1401 JvmtiFunctions::RawMonitorExit,
1402 JvmtiFunctions::RawMonitorWait,
1403 JvmtiFunctions::RawMonitorNotify,
1404 JvmtiFunctions::RawMonitorNotifyAll,
1405 JvmtiFunctions::SetBreakpoint,
1406 JvmtiFunctions::ClearBreakpoint,
1407 nullptr, // reserved40
1408 JvmtiFunctions::SetFieldAccessWatch,
1409 JvmtiFunctions::ClearFieldAccessWatch,
1410 JvmtiFunctions::SetFieldModificationWatch,
1411 JvmtiFunctions::ClearFieldModificationWatch,
1412 JvmtiFunctions::IsModifiableClass,
1413 JvmtiFunctions::Allocate,
1414 JvmtiFunctions::Deallocate,
1415 JvmtiFunctions::GetClassSignature,
1416 JvmtiFunctions::GetClassStatus,
1417 JvmtiFunctions::GetSourceFileName, // 50
1418 JvmtiFunctions::GetClassModifiers,
1419 JvmtiFunctions::GetClassMethods,
1420 JvmtiFunctions::GetClassFields,
1421 JvmtiFunctions::GetImplementedInterfaces,
1422 JvmtiFunctions::IsInterface,
1423 JvmtiFunctions::IsArrayClass,
1424 JvmtiFunctions::GetClassLoader,
1425 JvmtiFunctions::GetObjectHashCode,
1426 JvmtiFunctions::GetObjectMonitorUsage,
1427 JvmtiFunctions::GetFieldName, // 60
1428 JvmtiFunctions::GetFieldDeclaringClass,
1429 JvmtiFunctions::GetFieldModifiers,
1430 JvmtiFunctions::IsFieldSynthetic,
1431 JvmtiFunctions::GetMethodName,
1432 JvmtiFunctions::GetMethodDeclaringClass,
1433 JvmtiFunctions::GetMethodModifiers,
1434 nullptr, // reserved67
1435 JvmtiFunctions::GetMaxLocals,
1436 JvmtiFunctions::GetArgumentsSize,
1437 JvmtiFunctions::GetLineNumberTable, // 70
1438 JvmtiFunctions::GetMethodLocation,
1439 JvmtiFunctions::GetLocalVariableTable,
1440 JvmtiFunctions::SetNativeMethodPrefix,
1441 JvmtiFunctions::SetNativeMethodPrefixes,
1442 JvmtiFunctions::GetBytecodes,
1443 JvmtiFunctions::IsMethodNative,
1444 JvmtiFunctions::IsMethodSynthetic,
1445 JvmtiFunctions::GetLoadedClasses,
1446 JvmtiFunctions::GetClassLoaderClasses,
1447 JvmtiFunctions::PopFrame, // 80
1448 JvmtiFunctions::ForceEarlyReturnObject,
1449 JvmtiFunctions::ForceEarlyReturnInt,
1450 JvmtiFunctions::ForceEarlyReturnLong,
1451 JvmtiFunctions::ForceEarlyReturnFloat,
1452 JvmtiFunctions::ForceEarlyReturnDouble,
1453 JvmtiFunctions::ForceEarlyReturnVoid,
1454 JvmtiFunctions::RedefineClasses,
1455 JvmtiFunctions::GetVersionNumber,
1456 JvmtiFunctions::GetCapabilities,
1457 JvmtiFunctions::GetSourceDebugExtension, // 90
1458 JvmtiFunctions::IsMethodObsolete,
1459 JvmtiFunctions::SuspendThreadList,
1460 JvmtiFunctions::ResumeThreadList,
1461 nullptr, // reserved94
1462 nullptr, // reserved95
1463 nullptr, // reserved96
1464 nullptr, // reserved97
1465 nullptr, // reserved98
1466 nullptr, // reserved99
1467 JvmtiFunctions::GetAllStackTraces, // 100
1468 JvmtiFunctions::GetThreadListStackTraces,
1469 JvmtiFunctions::GetThreadLocalStorage,
1470 JvmtiFunctions::SetThreadLocalStorage,
1471 JvmtiFunctions::GetStackTrace,
1472 nullptr, // reserved105
1473 JvmtiFunctions::GetTag,
1474 JvmtiFunctions::SetTag,
1475 JvmtiFunctions::ForceGarbageCollection,
1476 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1477 JvmtiFunctions::IterateOverReachableObjects, // 110
1478 JvmtiFunctions::IterateOverHeap,
1479 JvmtiFunctions::IterateOverInstancesOfClass,
1480 nullptr, // reserved113
1481 JvmtiFunctions::GetObjectsWithTags,
1482 JvmtiFunctions::FollowReferences,
1483 JvmtiFunctions::IterateThroughHeap,
1484 nullptr, // reserved117
1485 nullptr, // reserved118
1486 nullptr, // reserved119
1487 JvmtiFunctions::SetJNIFunctionTable, // 120
1488 JvmtiFunctions::GetJNIFunctionTable,
1489 JvmtiFunctions::SetEventCallbacks,
1490 JvmtiFunctions::GenerateEvents,
1491 JvmtiFunctions::GetExtensionFunctions,
1492 JvmtiFunctions::GetExtensionEvents,
1493 JvmtiFunctions::SetExtensionEventCallback,
1494 JvmtiFunctions::DisposeEnvironment,
1495 JvmtiFunctions::GetErrorName,
1496 JvmtiFunctions::GetJLocationFormat,
1497 JvmtiFunctions::GetSystemProperties, // 130
1498 JvmtiFunctions::GetSystemProperty,
1499 JvmtiFunctions::SetSystemProperty,
1500 JvmtiFunctions::GetPhase,
1501 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1502 JvmtiFunctions::GetCurrentThreadCpuTime,
1503 JvmtiFunctions::GetThreadCpuTimerInfo,
1504 JvmtiFunctions::GetThreadCpuTime,
1505 JvmtiFunctions::GetTimerInfo,
1506 JvmtiFunctions::GetTime,
1507 JvmtiFunctions::GetPotentialCapabilities, // 140
1508 nullptr, // reserved141
1509 JvmtiFunctions::AddCapabilities,
1510 JvmtiFunctions::RelinquishCapabilities,
1511 JvmtiFunctions::GetAvailableProcessors,
1512 JvmtiFunctions::GetClassVersionNumbers,
1513 JvmtiFunctions::GetConstantPool,
1514 JvmtiFunctions::GetEnvironmentLocalStorage,
1515 JvmtiFunctions::SetEnvironmentLocalStorage,
1516 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1517 JvmtiFunctions::SetVerboseFlag, // 150
1518 JvmtiFunctions::AddToSystemClassLoaderSearch,
1519 JvmtiFunctions::RetransformClasses,
1520 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1521 JvmtiFunctions::GetObjectSize,
1522 JvmtiFunctions::GetLocalInstance,
1523};
1524
1525}; // namespace openjdkjvmti