blob: f5020ffca18c02fd82664f4dcfb0224276f68f46 [file] [log] [blame]
Alex Light49948e92016-08-11 15:35:28 -07001/* Copyright (C) 2016 The Android Open Source Project
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This file implements interfaces from the file jvmti.h. This implementation
5 * is licensed under the same terms as the file jvmti.h. The
6 * copyright and license information for the file jvmti.h follows.
7 *
8 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10 *
11 * This code is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 only, as
13 * published by the Free Software Foundation. Oracle designates this
14 * particular file as subject to the "Classpath" exception as provided
15 * by Oracle in the LICENSE file that accompanied this code.
16 *
17 * This code is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 * version 2 for more details (a copy is included in the LICENSE file that
21 * accompanied this code).
22 *
23 * You should have received a copy of the GNU General Public License version
24 * 2 along with this work; if not, write to the Free Software Foundation,
25 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28 * or visit www.oracle.com if you need additional information or have any
29 * questions.
30 */
31
Alex Light9c20a142016-08-23 15:05:12 -070032#include <string>
Andreas Gampef37e3022017-01-13 17:54:46 -080033#include <type_traits>
Alex Light9c20a142016-08-23 15:05:12 -070034#include <vector>
35
Alex Light49948e92016-08-11 15:35:28 -070036#include <jni.h>
Alex Light9c20a142016-08-23 15:05:12 -070037
Alex Light49948e92016-08-11 15:35:28 -070038#include "openjdkjvmti/jvmti.h"
39
Andreas Gampedb6dcb62016-09-13 09:05:59 -070040#include "art_jvmti.h"
Andreas Gampef37e3022017-01-13 17:54:46 -080041#include "base/logging.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070042#include "base/mutex.h"
43#include "events-inl.h"
Alex Light49948e92016-08-11 15:35:28 -070044#include "jni_env_ext-inl.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070045#include "obj_ptr-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080046#include "object_tagging.h"
Alex Light9c20a142016-08-23 15:05:12 -070047#include "runtime.h"
Andreas Gampe6dee92e2016-09-12 19:58:13 -070048#include "scoped_thread_state_change-inl.h"
Andreas Gampe77708d92016-10-07 11:48:21 -070049#include "thread-inl.h"
Alex Lighta01de592016-11-15 10:43:06 -080050#include "thread_list.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070051#include "ti_class.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080052#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070053#include "ti_heap.h"
Andreas Gampe6f8e4f02017-01-16 18:18:14 -080054#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070055#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080056#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080057#include "ti_object.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080058#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080059#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080060#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070061#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080062#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000063#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080064#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070065#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070066
67// TODO Remove this at some point by annotating all the methods. It was put in to make the skeleton
68// easier to create.
69#pragma GCC diagnostic ignored "-Wunused-parameter"
70
71namespace openjdkjvmti {
72
Andreas Gampe77708d92016-10-07 11:48:21 -070073EventHandler gEventHandler;
Andreas Gampecc13b222016-10-10 19:09:09 -070074ObjectTagTable gObjectTagTable(&gEventHandler);
Andreas Gampe6dee92e2016-09-12 19:58:13 -070075
Alex Lighte6574242016-08-17 09:56:24 -070076#define ENSURE_NON_NULL(n) \
77 do { \
78 if ((n) == nullptr) { \
79 return ERR(NULL_POINTER); \
80 } \
81 } while (false)
82
Alex Light49948e92016-08-11 15:35:28 -070083class JvmtiFunctions {
84 private:
85 static bool IsValidEnv(jvmtiEnv* env) {
86 return env != nullptr;
87 }
88
Alex Lighte6574242016-08-17 09:56:24 -070089#define ENSURE_VALID_ENV(env) \
90 do { \
91 if (!IsValidEnv(env)) { \
92 return ERR(INVALID_ENVIRONMENT); \
93 } \
94 } while (false)
95
96#define ENSURE_HAS_CAP(env, cap) \
97 do { \
98 ENSURE_VALID_ENV(env); \
99 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
100 return ERR(MUST_POSSESS_CAPABILITY); \
101 } \
102 } while (false)
103
Alex Light49948e92016-08-11 15:35:28 -0700104 public:
105 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700106 ENSURE_VALID_ENV(env);
107 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700108 if (size < 0) {
109 return ERR(ILLEGAL_ARGUMENT);
110 } else if (size == 0) {
111 *mem_ptr = nullptr;
112 return OK;
113 }
114 *mem_ptr = static_cast<unsigned char*>(malloc(size));
115 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
116 }
117
118 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700119 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700120 if (mem != nullptr) {
121 free(mem);
122 }
123 return OK;
124 }
125
126 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800127 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700128 }
129
130 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800131 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700132 }
133
134 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800135 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700136 }
137
138 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
139 return ERR(NOT_IMPLEMENTED);
140 }
141
142 static jvmtiError SuspendThreadList(jvmtiEnv* env,
143 jint request_count,
144 const jthread* request_list,
145 jvmtiError* results) {
146 return ERR(NOT_IMPLEMENTED);
147 }
148
149 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
150 return ERR(NOT_IMPLEMENTED);
151 }
152
153 static jvmtiError ResumeThreadList(jvmtiEnv* env,
154 jint request_count,
155 const jthread* request_list,
156 jvmtiError* results) {
157 return ERR(NOT_IMPLEMENTED);
158 }
159
160 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
161 return ERR(NOT_IMPLEMENTED);
162 }
163
164 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
165 return ERR(NOT_IMPLEMENTED);
166 }
167
168 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800169 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700170 }
171
172 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
173 jthread thread,
174 jint* owned_monitor_count_ptr,
175 jobject** owned_monitors_ptr) {
176 return ERR(NOT_IMPLEMENTED);
177 }
178
179 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
180 jthread thread,
181 jint* monitor_info_count_ptr,
182 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
183 return ERR(NOT_IMPLEMENTED);
184 }
185
186 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
187 jthread thread,
188 jobject* monitor_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700189 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700190 }
191
192 static jvmtiError RunAgentThread(jvmtiEnv* env,
193 jthread thread,
194 jvmtiStartFunction proc,
195 const void* arg,
196 jint priority) {
197 return ERR(NOT_IMPLEMENTED);
198 }
199
200 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
201 return ERR(NOT_IMPLEMENTED);
202 }
203
204 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
205 return ERR(NOT_IMPLEMENTED);
206 }
207
208 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
209 jint* group_count_ptr,
210 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000211 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700212 }
213
214 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
215 jthreadGroup group,
216 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000217 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700218 }
219
220 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
221 jthreadGroup group,
222 jint* thread_count_ptr,
223 jthread** threads_ptr,
224 jint* group_count_ptr,
225 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000226 return ThreadGroupUtil::GetThreadGroupChildren(env,
227 group,
228 thread_count_ptr,
229 threads_ptr,
230 group_count_ptr,
231 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700232 }
233
234 static jvmtiError GetStackTrace(jvmtiEnv* env,
235 jthread thread,
236 jint start_depth,
237 jint max_frame_count,
238 jvmtiFrameInfo* frame_buffer,
239 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700240 return StackUtil::GetStackTrace(env,
241 thread,
242 start_depth,
243 max_frame_count,
244 frame_buffer,
245 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700246 }
247
248 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
249 jint max_frame_count,
250 jvmtiStackInfo** stack_info_ptr,
251 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800252 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700253 }
254
255 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
256 jint thread_count,
257 const jthread* thread_list,
258 jint max_frame_count,
259 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800260 return StackUtil::GetThreadListStackTraces(env,
261 thread_count,
262 thread_list,
263 max_frame_count,
264 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700265 }
266
267 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800268 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700269 }
270
271 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
272 return ERR(NOT_IMPLEMENTED);
273 }
274
275 static jvmtiError GetFrameLocation(jvmtiEnv* env,
276 jthread thread,
277 jint depth,
278 jmethodID* method_ptr,
279 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800280 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700281 }
282
283 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
284 return ERR(NOT_IMPLEMENTED);
285 }
286
287 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
288 return ERR(NOT_IMPLEMENTED);
289 }
290
291 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
292 return ERR(NOT_IMPLEMENTED);
293 }
294
295 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
296 return ERR(NOT_IMPLEMENTED);
297 }
298
299 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
300 return ERR(NOT_IMPLEMENTED);
301 }
302
303 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
304 return ERR(NOT_IMPLEMENTED);
305 }
306
307 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
308 return ERR(NOT_IMPLEMENTED);
309 }
310
311 static jvmtiError FollowReferences(jvmtiEnv* env,
312 jint heap_filter,
313 jclass klass,
314 jobject initial_object,
315 const jvmtiHeapCallbacks* callbacks,
316 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700317 HeapUtil heap_util(&gObjectTagTable);
318 return heap_util.FollowReferences(env,
319 heap_filter,
320 klass,
321 initial_object,
322 callbacks,
323 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700324 }
325
326 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
327 jint heap_filter,
328 jclass klass,
329 const jvmtiHeapCallbacks* callbacks,
330 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700331 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700332 HeapUtil heap_util(&gObjectTagTable);
333 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700334 }
335
336 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700337 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700338
339 JNIEnv* jni_env = GetJniEnv(env);
340 if (jni_env == nullptr) {
341 return ERR(INTERNAL);
342 }
343
344 art::ScopedObjectAccess soa(jni_env);
345 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
346 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
347 *tag_ptr = 0;
348 }
349
350 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700351 }
352
353 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700354 ENSURE_HAS_CAP(env, can_tag_objects);
355
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700356 if (object == nullptr) {
357 return ERR(NULL_POINTER);
358 }
359
360 JNIEnv* jni_env = GetJniEnv(env);
361 if (jni_env == nullptr) {
362 return ERR(INTERNAL);
363 }
364
365 art::ScopedObjectAccess soa(jni_env);
366 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700367 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700368
369 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700370 }
371
372 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
373 jint tag_count,
374 const jlong* tags,
375 jint* count_ptr,
376 jobject** object_result_ptr,
377 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700378 ENSURE_HAS_CAP(env, can_tag_objects);
379
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700380 JNIEnv* jni_env = GetJniEnv(env);
381 if (jni_env == nullptr) {
382 return ERR(INTERNAL);
383 }
384
385 art::ScopedObjectAccess soa(jni_env);
386 return gObjectTagTable.GetTaggedObjects(env,
387 tag_count,
388 tags,
389 count_ptr,
390 object_result_ptr,
391 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700392 }
393
394 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700395 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700396 }
397
398 static jvmtiError IterateOverObjectsReachableFromObject(
399 jvmtiEnv* env,
400 jobject object,
401 jvmtiObjectReferenceCallback object_reference_callback,
402 const void* user_data) {
403 return ERR(NOT_IMPLEMENTED);
404 }
405
406 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
407 jvmtiHeapRootCallback heap_root_callback,
408 jvmtiStackReferenceCallback stack_ref_callback,
409 jvmtiObjectReferenceCallback object_ref_callback,
410 const void* user_data) {
411 return ERR(NOT_IMPLEMENTED);
412 }
413
414 static jvmtiError IterateOverHeap(jvmtiEnv* env,
415 jvmtiHeapObjectFilter object_filter,
416 jvmtiHeapObjectCallback heap_object_callback,
417 const void* user_data) {
418 return ERR(NOT_IMPLEMENTED);
419 }
420
421 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
422 jclass klass,
423 jvmtiHeapObjectFilter object_filter,
424 jvmtiHeapObjectCallback heap_object_callback,
425 const void* user_data) {
426 return ERR(NOT_IMPLEMENTED);
427 }
428
429 static jvmtiError GetLocalObject(jvmtiEnv* env,
430 jthread thread,
431 jint depth,
432 jint slot,
433 jobject* value_ptr) {
434 return ERR(NOT_IMPLEMENTED);
435 }
436
437 static jvmtiError GetLocalInstance(jvmtiEnv* env,
438 jthread thread,
439 jint depth,
440 jobject* value_ptr) {
441 return ERR(NOT_IMPLEMENTED);
442 }
443
444 static jvmtiError GetLocalInt(jvmtiEnv* env,
445 jthread thread,
446 jint depth,
447 jint slot,
448 jint* value_ptr) {
449 return ERR(NOT_IMPLEMENTED);
450 }
451
452 static jvmtiError GetLocalLong(jvmtiEnv* env,
453 jthread thread,
454 jint depth,
455 jint slot,
456 jlong* value_ptr) {
457 return ERR(NOT_IMPLEMENTED);
458 }
459
460 static jvmtiError GetLocalFloat(jvmtiEnv* env,
461 jthread thread,
462 jint depth,
463 jint slot,
464 jfloat* value_ptr) {
465 return ERR(NOT_IMPLEMENTED);
466 }
467
468 static jvmtiError GetLocalDouble(jvmtiEnv* env,
469 jthread thread,
470 jint depth,
471 jint slot,
472 jdouble* value_ptr) {
473 return ERR(NOT_IMPLEMENTED);
474 }
475
476 static jvmtiError SetLocalObject(jvmtiEnv* env,
477 jthread thread,
478 jint depth,
479 jint slot,
480 jobject value) {
481 return ERR(NOT_IMPLEMENTED);
482 }
483
484 static jvmtiError SetLocalInt(jvmtiEnv* env,
485 jthread thread,
486 jint depth,
487 jint slot,
488 jint value) {
489 return ERR(NOT_IMPLEMENTED);
490 }
491
492 static jvmtiError SetLocalLong(jvmtiEnv* env,
493 jthread thread,
494 jint depth,
495 jint slot,
496 jlong value) {
497 return ERR(NOT_IMPLEMENTED);
498 }
499
500 static jvmtiError SetLocalFloat(jvmtiEnv* env,
501 jthread thread,
502 jint depth,
503 jint slot,
504 jfloat value) {
505 return ERR(NOT_IMPLEMENTED);
506 }
507
508 static jvmtiError SetLocalDouble(jvmtiEnv* env,
509 jthread thread,
510 jint depth,
511 jint slot,
512 jdouble value) {
513 return ERR(NOT_IMPLEMENTED);
514 }
515
516 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
517 return ERR(NOT_IMPLEMENTED);
518 }
519
520 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
521 return ERR(NOT_IMPLEMENTED);
522 }
523
524 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
525 return ERR(NOT_IMPLEMENTED);
526 }
527
528 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
529 return ERR(NOT_IMPLEMENTED);
530 }
531
532 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
533 return ERR(NOT_IMPLEMENTED);
534 }
535
536 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
537 return ERR(NOT_IMPLEMENTED);
538 }
539
540 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700541 HeapUtil heap_util(&gObjectTagTable);
542 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700543 }
544
545 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
546 jobject initiating_loader,
547 jint* class_count_ptr,
548 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800549 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700550 }
551
552 static jvmtiError GetClassSignature(jvmtiEnv* env,
553 jclass klass,
554 char** signature_ptr,
555 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700556 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700557 }
558
559 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800560 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700561 }
562
563 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
564 return ERR(NOT_IMPLEMENTED);
565 }
566
567 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800568 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700569 }
570
571 static jvmtiError GetClassMethods(jvmtiEnv* env,
572 jclass klass,
573 jint* method_count_ptr,
574 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800575 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700576 }
577
578 static jvmtiError GetClassFields(jvmtiEnv* env,
579 jclass klass,
580 jint* field_count_ptr,
581 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800582 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700583 }
584
585 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
586 jclass klass,
587 jint* interface_count_ptr,
588 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800589 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700590 }
591
592 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
593 jclass klass,
594 jint* minor_version_ptr,
595 jint* major_version_ptr) {
596 return ERR(NOT_IMPLEMENTED);
597 }
598
599 static jvmtiError GetConstantPool(jvmtiEnv* env,
600 jclass klass,
601 jint* constant_pool_count_ptr,
602 jint* constant_pool_byte_count_ptr,
603 unsigned char** constant_pool_bytes_ptr) {
604 return ERR(NOT_IMPLEMENTED);
605 }
606
607 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800608 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700609 }
610
611 static jvmtiError IsArrayClass(jvmtiEnv* env,
612 jclass klass,
613 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800614 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700615 }
616
617 static jvmtiError IsModifiableClass(jvmtiEnv* env,
618 jclass klass,
619 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800620 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700621 }
622
623 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800624 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700625 }
626
627 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
628 jclass klass,
629 char** source_debug_extension_ptr) {
630 return ERR(NOT_IMPLEMENTED);
631 }
632
633 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
634 return ERR(NOT_IMPLEMENTED);
635 }
636
637 static jvmtiError RedefineClasses(jvmtiEnv* env,
638 jint class_count,
639 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800640 std::string error_msg;
641 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
642 art::Runtime::Current(),
643 art::Thread::Current(),
644 class_count,
645 class_definitions,
646 &error_msg);
647 if (res != OK) {
648 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
649 }
650 return res;
Alex Light49948e92016-08-11 15:35:28 -0700651 }
652
653 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800654 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700655 }
656
657 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800658 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700659 }
660
661 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
662 jobject object,
663 jvmtiMonitorUsage* info_ptr) {
664 return ERR(NOT_IMPLEMENTED);
665 }
666
667 static jvmtiError GetFieldName(jvmtiEnv* env,
668 jclass klass,
669 jfieldID field,
670 char** name_ptr,
671 char** signature_ptr,
672 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800673 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700674 }
675
676 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
677 jclass klass,
678 jfieldID field,
679 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800680 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700681 }
682
683 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
684 jclass klass,
685 jfieldID field,
686 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800687 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700688 }
689
690 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
691 jclass klass,
692 jfieldID field,
693 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800694 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700695 }
696
697 static jvmtiError GetMethodName(jvmtiEnv* env,
698 jmethodID method,
699 char** name_ptr,
700 char** signature_ptr,
701 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700702 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700703 }
704
705 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
706 jmethodID method,
707 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700708 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700709 }
710
711 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
712 jmethodID method,
713 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700714 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700715 }
716
717 static jvmtiError GetMaxLocals(jvmtiEnv* env,
718 jmethodID method,
719 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800720 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700721 }
722
723 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
724 jmethodID method,
725 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800726 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700727 }
728
729 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
730 jmethodID method,
731 jint* entry_count_ptr,
732 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800733 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700734 }
735
736 static jvmtiError GetMethodLocation(jvmtiEnv* env,
737 jmethodID method,
738 jlocation* start_location_ptr,
739 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800740 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700741 }
742
743 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
744 jmethodID method,
745 jint* entry_count_ptr,
746 jvmtiLocalVariableEntry** table_ptr) {
747 return ERR(NOT_IMPLEMENTED);
748 }
749
750 static jvmtiError GetBytecodes(jvmtiEnv* env,
751 jmethodID method,
752 jint* bytecode_count_ptr,
753 unsigned char** bytecodes_ptr) {
754 return ERR(NOT_IMPLEMENTED);
755 }
756
757 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800758 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700759 }
760
761 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800762 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700763 }
764
765 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800766 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700767 }
768
769 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
770 return ERR(NOT_IMPLEMENTED);
771 }
772
773 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
774 return ERR(NOT_IMPLEMENTED);
775 }
776
777 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800778 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700779 }
780
781 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800782 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700783 }
784
785 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800786 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700787 }
788
789 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800790 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700791 }
792
793 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800794 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700795 }
796
797 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800798 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700799 }
800
801 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800802 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700803 }
804
805 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800806 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700807 }
808
809 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800810 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700811 }
812
Andreas Gampe77708d92016-10-07 11:48:21 -0700813 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
814 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700815 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
816 const jvmtiEventCallbacks* callbacks,
817 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700818 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700819 if (size_of_callbacks < 0) {
820 return ERR(ILLEGAL_ARGUMENT);
821 }
822
823 if (callbacks == nullptr) {
824 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
825 return ERR(NONE);
826 }
827
828 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
829 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
830 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
831 static_cast<size_t>(size_of_callbacks));
832 copy_size = art::RoundDown(copy_size, sizeof(void*));
833 memcpy(tmp.get(), callbacks, copy_size);
834
835 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
836
837 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700838 }
839
840 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
841 jvmtiEventMode mode,
842 jvmtiEvent event_type,
843 jthread event_thread,
844 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700845 ENSURE_VALID_ENV(env);
846 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700847 art::Thread* art_thread = nullptr;
848 if (event_thread != nullptr) {
849 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
850 art::ScopedObjectAccess soa(art::Thread::Current());
851 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
852 art_thread = art::Thread::FromManagedThread(soa, event_thread);
853
854 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
855 art_thread->IsStillStarting()) {
856 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
857 return ERR(THREAD_NOT_ALIVE);
858 }
859 }
860
861 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700862 }
863
864 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
865 return ERR(NOT_IMPLEMENTED);
866 }
867
868 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
869 jint* extension_count_ptr,
870 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800871 // We do not have any extension functions.
872 *extension_count_ptr = 0;
873 *extensions = nullptr;
874
875 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700876 }
877
878 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
879 jint* extension_count_ptr,
880 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800881 // We do not have any extension events.
882 *extension_count_ptr = 0;
883 *extensions = nullptr;
884
885 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700886 }
887
888 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
889 jint extension_event_index,
890 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800891 // We do not have any extension events, so any call is illegal.
892 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700893 }
894
895 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700896 ENSURE_VALID_ENV(env);
897 ENSURE_NON_NULL(capabilities_ptr);
898 *capabilities_ptr = kPotentialCapabilities;
899 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700900 }
901
902 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700903 ENSURE_VALID_ENV(env);
904 ENSURE_NON_NULL(capabilities_ptr);
905 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
906 jvmtiError ret = OK;
907#define ADD_CAPABILITY(e) \
908 do { \
909 if (capabilities_ptr->e == 1) { \
910 if (kPotentialCapabilities.e == 1) { \
911 art_env->capabilities.e = 1;\
912 } else { \
913 ret = ERR(NOT_AVAILABLE); \
914 } \
915 } \
916 } while (false)
917
918 ADD_CAPABILITY(can_tag_objects);
919 ADD_CAPABILITY(can_generate_field_modification_events);
920 ADD_CAPABILITY(can_generate_field_access_events);
921 ADD_CAPABILITY(can_get_bytecodes);
922 ADD_CAPABILITY(can_get_synthetic_attribute);
923 ADD_CAPABILITY(can_get_owned_monitor_info);
924 ADD_CAPABILITY(can_get_current_contended_monitor);
925 ADD_CAPABILITY(can_get_monitor_info);
926 ADD_CAPABILITY(can_pop_frame);
927 ADD_CAPABILITY(can_redefine_classes);
928 ADD_CAPABILITY(can_signal_thread);
929 ADD_CAPABILITY(can_get_source_file_name);
930 ADD_CAPABILITY(can_get_line_numbers);
931 ADD_CAPABILITY(can_get_source_debug_extension);
932 ADD_CAPABILITY(can_access_local_variables);
933 ADD_CAPABILITY(can_maintain_original_method_order);
934 ADD_CAPABILITY(can_generate_single_step_events);
935 ADD_CAPABILITY(can_generate_exception_events);
936 ADD_CAPABILITY(can_generate_frame_pop_events);
937 ADD_CAPABILITY(can_generate_breakpoint_events);
938 ADD_CAPABILITY(can_suspend);
939 ADD_CAPABILITY(can_redefine_any_class);
940 ADD_CAPABILITY(can_get_current_thread_cpu_time);
941 ADD_CAPABILITY(can_get_thread_cpu_time);
942 ADD_CAPABILITY(can_generate_method_entry_events);
943 ADD_CAPABILITY(can_generate_method_exit_events);
944 ADD_CAPABILITY(can_generate_all_class_hook_events);
945 ADD_CAPABILITY(can_generate_compiled_method_load_events);
946 ADD_CAPABILITY(can_generate_monitor_events);
947 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
948 ADD_CAPABILITY(can_generate_native_method_bind_events);
949 ADD_CAPABILITY(can_generate_garbage_collection_events);
950 ADD_CAPABILITY(can_generate_object_free_events);
951 ADD_CAPABILITY(can_force_early_return);
952 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
953 ADD_CAPABILITY(can_get_constant_pool);
954 ADD_CAPABILITY(can_set_native_method_prefix);
955 ADD_CAPABILITY(can_retransform_classes);
956 ADD_CAPABILITY(can_retransform_any_class);
957 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
958 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
959#undef ADD_CAPABILITY
960 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700961 }
962
963 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
964 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700965 ENSURE_VALID_ENV(env);
966 ENSURE_NON_NULL(capabilities_ptr);
967 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
968#define DEL_CAPABILITY(e) \
969 do { \
970 if (capabilities_ptr->e == 1) { \
971 art_env->capabilities.e = 0;\
972 } \
973 } while (false)
974
975 DEL_CAPABILITY(can_tag_objects);
976 DEL_CAPABILITY(can_generate_field_modification_events);
977 DEL_CAPABILITY(can_generate_field_access_events);
978 DEL_CAPABILITY(can_get_bytecodes);
979 DEL_CAPABILITY(can_get_synthetic_attribute);
980 DEL_CAPABILITY(can_get_owned_monitor_info);
981 DEL_CAPABILITY(can_get_current_contended_monitor);
982 DEL_CAPABILITY(can_get_monitor_info);
983 DEL_CAPABILITY(can_pop_frame);
984 DEL_CAPABILITY(can_redefine_classes);
985 DEL_CAPABILITY(can_signal_thread);
986 DEL_CAPABILITY(can_get_source_file_name);
987 DEL_CAPABILITY(can_get_line_numbers);
988 DEL_CAPABILITY(can_get_source_debug_extension);
989 DEL_CAPABILITY(can_access_local_variables);
990 DEL_CAPABILITY(can_maintain_original_method_order);
991 DEL_CAPABILITY(can_generate_single_step_events);
992 DEL_CAPABILITY(can_generate_exception_events);
993 DEL_CAPABILITY(can_generate_frame_pop_events);
994 DEL_CAPABILITY(can_generate_breakpoint_events);
995 DEL_CAPABILITY(can_suspend);
996 DEL_CAPABILITY(can_redefine_any_class);
997 DEL_CAPABILITY(can_get_current_thread_cpu_time);
998 DEL_CAPABILITY(can_get_thread_cpu_time);
999 DEL_CAPABILITY(can_generate_method_entry_events);
1000 DEL_CAPABILITY(can_generate_method_exit_events);
1001 DEL_CAPABILITY(can_generate_all_class_hook_events);
1002 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1003 DEL_CAPABILITY(can_generate_monitor_events);
1004 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1005 DEL_CAPABILITY(can_generate_native_method_bind_events);
1006 DEL_CAPABILITY(can_generate_garbage_collection_events);
1007 DEL_CAPABILITY(can_generate_object_free_events);
1008 DEL_CAPABILITY(can_force_early_return);
1009 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1010 DEL_CAPABILITY(can_get_constant_pool);
1011 DEL_CAPABILITY(can_set_native_method_prefix);
1012 DEL_CAPABILITY(can_retransform_classes);
1013 DEL_CAPABILITY(can_retransform_any_class);
1014 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1015 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1016#undef DEL_CAPABILITY
1017 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001018 }
1019
1020 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001021 ENSURE_VALID_ENV(env);
1022 ENSURE_NON_NULL(capabilities_ptr);
1023 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1024 *capabilities_ptr = artenv->capabilities;
1025 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001026 }
1027
1028 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1029 return ERR(NOT_IMPLEMENTED);
1030 }
1031
1032 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1033 return ERR(NOT_IMPLEMENTED);
1034 }
1035
1036 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1037 return ERR(NOT_IMPLEMENTED);
1038 }
1039
1040 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1041 return ERR(NOT_IMPLEMENTED);
1042 }
1043
1044 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001045 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001046 }
1047
1048 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001049 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001050 }
1051
1052 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001053 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001054 }
1055
1056 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001057 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001058 }
1059
1060 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001061 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001062 }
1063
1064 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001065 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001066 }
1067
1068 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001069 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001070 }
1071
1072 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001073 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001074 }
1075
1076 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1077 return ERR(NOT_IMPLEMENTED);
1078 }
1079
1080 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001081 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001082 delete env;
1083 return OK;
1084 }
1085
1086 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001087 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001088 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1089 return OK;
1090 }
1091
1092 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001093 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001094 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1095 return OK;
1096 }
1097
1098 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001099 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001100 *version_ptr = JVMTI_VERSION;
1101 return OK;
1102 }
1103
1104 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001105 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001106 switch (error) {
1107#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001108 jvmtiError res = CopyString(env, \
1109 "JVMTI_ERROR_"#e, \
1110 reinterpret_cast<unsigned char**>(name_ptr)); \
1111 if (res != OK) { \
1112 *name_ptr = nullptr; \
1113 return res; \
1114 } else { \
1115 return OK; \
1116 } \
Alex Light49948e92016-08-11 15:35:28 -07001117 } while (false)
1118 ERROR_CASE(NONE);
1119 ERROR_CASE(INVALID_THREAD);
1120 ERROR_CASE(INVALID_THREAD_GROUP);
1121 ERROR_CASE(INVALID_PRIORITY);
1122 ERROR_CASE(THREAD_NOT_SUSPENDED);
1123 ERROR_CASE(THREAD_NOT_ALIVE);
1124 ERROR_CASE(INVALID_OBJECT);
1125 ERROR_CASE(INVALID_CLASS);
1126 ERROR_CASE(CLASS_NOT_PREPARED);
1127 ERROR_CASE(INVALID_METHODID);
1128 ERROR_CASE(INVALID_LOCATION);
1129 ERROR_CASE(INVALID_FIELDID);
1130 ERROR_CASE(NO_MORE_FRAMES);
1131 ERROR_CASE(OPAQUE_FRAME);
1132 ERROR_CASE(TYPE_MISMATCH);
1133 ERROR_CASE(INVALID_SLOT);
1134 ERROR_CASE(DUPLICATE);
1135 ERROR_CASE(NOT_FOUND);
1136 ERROR_CASE(INVALID_MONITOR);
1137 ERROR_CASE(NOT_MONITOR_OWNER);
1138 ERROR_CASE(INTERRUPT);
1139 ERROR_CASE(INVALID_CLASS_FORMAT);
1140 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1141 ERROR_CASE(FAILS_VERIFICATION);
1142 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1143 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1144 ERROR_CASE(INVALID_TYPESTATE);
1145 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1146 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1147 ERROR_CASE(UNSUPPORTED_VERSION);
1148 ERROR_CASE(NAMES_DONT_MATCH);
1149 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1150 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1151 ERROR_CASE(UNMODIFIABLE_CLASS);
1152 ERROR_CASE(NOT_AVAILABLE);
1153 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1154 ERROR_CASE(NULL_POINTER);
1155 ERROR_CASE(ABSENT_INFORMATION);
1156 ERROR_CASE(INVALID_EVENT_TYPE);
1157 ERROR_CASE(ILLEGAL_ARGUMENT);
1158 ERROR_CASE(NATIVE_METHOD);
1159 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1160 ERROR_CASE(OUT_OF_MEMORY);
1161 ERROR_CASE(ACCESS_DENIED);
1162 ERROR_CASE(WRONG_PHASE);
1163 ERROR_CASE(INTERNAL);
1164 ERROR_CASE(UNATTACHED_THREAD);
1165 ERROR_CASE(INVALID_ENVIRONMENT);
1166#undef ERROR_CASE
1167 default: {
Alex Light41960712017-01-06 14:44:23 -08001168 jvmtiError res = CopyString(env,
1169 "JVMTI_ERROR_UNKNOWN",
1170 reinterpret_cast<unsigned char**>(name_ptr));
1171 if (res != OK) {
1172 *name_ptr = nullptr;
1173 return res;
1174 } else {
1175 return ERR(ILLEGAL_ARGUMENT);
1176 }
Alex Light49948e92016-08-11 15:35:28 -07001177 }
1178 }
1179 }
1180
1181 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001182 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1183 // OTHER is special, as it's 0, so can't do a bit check.
1184 bool val = (value == JNI_TRUE) ? true : false;
1185
1186 art::gLogVerbosity.collector = val;
1187 art::gLogVerbosity.compiler = val;
1188 art::gLogVerbosity.deopt = val;
1189 art::gLogVerbosity.heap = val;
1190 art::gLogVerbosity.jdwp = val;
1191 art::gLogVerbosity.jit = val;
1192 art::gLogVerbosity.monitor = val;
1193 art::gLogVerbosity.oat = val;
1194 art::gLogVerbosity.profiler = val;
1195 art::gLogVerbosity.signals = val;
1196 art::gLogVerbosity.simulator = val;
1197 art::gLogVerbosity.startup = val;
1198 art::gLogVerbosity.third_party_jni = val;
1199 art::gLogVerbosity.threads = val;
1200 art::gLogVerbosity.verifier = val;
1201 art::gLogVerbosity.image = val;
1202
1203 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1204
1205 art::gLogVerbosity.agents = val;
1206 } else {
1207 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1208 // semantics.
1209 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1210 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1211 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1212 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1213 if ((flag & ~kMask) != 0) {
1214 return ERR(ILLEGAL_ARGUMENT);
1215 }
1216
1217 bool val = (value == JNI_TRUE) ? true : false;
1218
1219 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1220 art::gLogVerbosity.gc = val;
1221 }
1222
1223 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1224 art::gLogVerbosity.class_linker = val;
1225 }
1226
1227 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1228 art::gLogVerbosity.jni = val;
1229 }
1230 }
1231
1232 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001233 }
1234
1235 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
Andreas Gampeacfc9572017-01-17 18:36:56 -08001236 // Report BCI as jlocation format. We report dex bytecode indices.
1237 if (format_ptr == nullptr) {
1238 return ERR(NULL_POINTER);
1239 }
1240 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1241 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001242 }
Alex Light9c20a142016-08-23 15:05:12 -07001243
1244 // TODO Remove this once events are working.
1245 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1246 jclass klass,
1247 jvmtiEventClassFileLoadHook hook) {
1248 std::vector<jclass> classes;
1249 classes.push_back(klass);
1250 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1251 }
1252
1253 // TODO This will be called by the event handler for the art::ti Event Load Event
1254 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1255 const std::vector<jclass>& classes,
1256 jvmtiEventClassFileLoadHook hook) {
1257 if (!IsValidEnv(env)) {
1258 return ERR(INVALID_ENVIRONMENT);
1259 }
Alex Lighta01de592016-11-15 10:43:06 -08001260 jvmtiError res = OK;
1261 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001262 for (jclass klass : classes) {
1263 JNIEnv* jni_env = nullptr;
1264 jobject loader = nullptr;
1265 std::string name;
1266 jobject protection_domain = nullptr;
1267 jint data_len = 0;
1268 unsigned char* dex_data = nullptr;
1269 jvmtiError ret = OK;
1270 std::string location;
1271 if ((ret = GetTransformationData(env,
1272 klass,
1273 /*out*/&location,
1274 /*out*/&jni_env,
1275 /*out*/&loader,
1276 /*out*/&name,
1277 /*out*/&protection_domain,
1278 /*out*/&data_len,
1279 /*out*/&dex_data)) != OK) {
1280 // TODO Do something more here? Maybe give log statements?
1281 return ret;
1282 }
1283 jint new_data_len = 0;
1284 unsigned char* new_dex_data = nullptr;
1285 hook(env,
1286 jni_env,
1287 klass,
1288 loader,
1289 name.c_str(),
1290 protection_domain,
1291 data_len,
1292 dex_data,
1293 /*out*/&new_data_len,
1294 /*out*/&new_dex_data);
1295 // Check if anything actually changed.
1296 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001297 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1298 res = Redefiner::RedefineClasses(env,
1299 art::Runtime::Current(),
1300 art::Thread::Current(),
1301 1,
1302 &def,
1303 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001304 env->Deallocate(new_dex_data);
1305 }
1306 // Deallocate the old dex data.
1307 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001308 if (res != OK) {
1309 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1310 return res;
1311 }
Alex Light9c20a142016-08-23 15:05:12 -07001312 }
1313 return OK;
1314 }
Alex Light49948e92016-08-11 15:35:28 -07001315};
1316
1317static bool IsJvmtiVersion(jint version) {
1318 return version == JVMTI_VERSION_1 ||
1319 version == JVMTI_VERSION_1_0 ||
1320 version == JVMTI_VERSION_1_1 ||
1321 version == JVMTI_VERSION_1_2 ||
1322 version == JVMTI_VERSION;
1323}
1324
1325// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1326// is a pointer to the uninitialized memory for an art::ti::Env.
1327static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1328 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1329 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001330
1331 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001332}
1333
1334// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1335// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1336// returns false and does not modify the 'env' pointer.
1337static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1338 if (IsJvmtiVersion(version)) {
1339 CreateArtJvmTiEnv(vm, env);
1340 return JNI_OK;
1341 } else {
1342 printf("version 0x%x is not valid!", version);
1343 return JNI_EVERSION;
1344 }
1345}
1346
1347// The plugin initialization function. This adds the jvmti environment.
1348extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001349 art::Runtime* runtime = art::Runtime::Current();
1350 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1351 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001352 return true;
1353}
1354
1355// The actual struct holding all of the entrypoints into the jvmti interface.
1356const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001357 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1358 // TODO Remove once we have events working.
1359 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1360 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001361 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001362 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001363 JvmtiFunctions::GetAllThreads,
1364 JvmtiFunctions::SuspendThread,
1365 JvmtiFunctions::ResumeThread,
1366 JvmtiFunctions::StopThread,
1367 JvmtiFunctions::InterruptThread,
1368 JvmtiFunctions::GetThreadInfo,
1369 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1370 JvmtiFunctions::GetCurrentContendedMonitor,
1371 JvmtiFunctions::RunAgentThread,
1372 JvmtiFunctions::GetTopThreadGroups,
1373 JvmtiFunctions::GetThreadGroupInfo,
1374 JvmtiFunctions::GetThreadGroupChildren,
1375 JvmtiFunctions::GetFrameCount,
1376 JvmtiFunctions::GetThreadState,
1377 JvmtiFunctions::GetCurrentThread,
1378 JvmtiFunctions::GetFrameLocation,
1379 JvmtiFunctions::NotifyFramePop, // 20
1380 JvmtiFunctions::GetLocalObject,
1381 JvmtiFunctions::GetLocalInt,
1382 JvmtiFunctions::GetLocalLong,
1383 JvmtiFunctions::GetLocalFloat,
1384 JvmtiFunctions::GetLocalDouble,
1385 JvmtiFunctions::SetLocalObject,
1386 JvmtiFunctions::SetLocalInt,
1387 JvmtiFunctions::SetLocalLong,
1388 JvmtiFunctions::SetLocalFloat,
1389 JvmtiFunctions::SetLocalDouble, // 30
1390 JvmtiFunctions::CreateRawMonitor,
1391 JvmtiFunctions::DestroyRawMonitor,
1392 JvmtiFunctions::RawMonitorEnter,
1393 JvmtiFunctions::RawMonitorExit,
1394 JvmtiFunctions::RawMonitorWait,
1395 JvmtiFunctions::RawMonitorNotify,
1396 JvmtiFunctions::RawMonitorNotifyAll,
1397 JvmtiFunctions::SetBreakpoint,
1398 JvmtiFunctions::ClearBreakpoint,
1399 nullptr, // reserved40
1400 JvmtiFunctions::SetFieldAccessWatch,
1401 JvmtiFunctions::ClearFieldAccessWatch,
1402 JvmtiFunctions::SetFieldModificationWatch,
1403 JvmtiFunctions::ClearFieldModificationWatch,
1404 JvmtiFunctions::IsModifiableClass,
1405 JvmtiFunctions::Allocate,
1406 JvmtiFunctions::Deallocate,
1407 JvmtiFunctions::GetClassSignature,
1408 JvmtiFunctions::GetClassStatus,
1409 JvmtiFunctions::GetSourceFileName, // 50
1410 JvmtiFunctions::GetClassModifiers,
1411 JvmtiFunctions::GetClassMethods,
1412 JvmtiFunctions::GetClassFields,
1413 JvmtiFunctions::GetImplementedInterfaces,
1414 JvmtiFunctions::IsInterface,
1415 JvmtiFunctions::IsArrayClass,
1416 JvmtiFunctions::GetClassLoader,
1417 JvmtiFunctions::GetObjectHashCode,
1418 JvmtiFunctions::GetObjectMonitorUsage,
1419 JvmtiFunctions::GetFieldName, // 60
1420 JvmtiFunctions::GetFieldDeclaringClass,
1421 JvmtiFunctions::GetFieldModifiers,
1422 JvmtiFunctions::IsFieldSynthetic,
1423 JvmtiFunctions::GetMethodName,
1424 JvmtiFunctions::GetMethodDeclaringClass,
1425 JvmtiFunctions::GetMethodModifiers,
1426 nullptr, // reserved67
1427 JvmtiFunctions::GetMaxLocals,
1428 JvmtiFunctions::GetArgumentsSize,
1429 JvmtiFunctions::GetLineNumberTable, // 70
1430 JvmtiFunctions::GetMethodLocation,
1431 JvmtiFunctions::GetLocalVariableTable,
1432 JvmtiFunctions::SetNativeMethodPrefix,
1433 JvmtiFunctions::SetNativeMethodPrefixes,
1434 JvmtiFunctions::GetBytecodes,
1435 JvmtiFunctions::IsMethodNative,
1436 JvmtiFunctions::IsMethodSynthetic,
1437 JvmtiFunctions::GetLoadedClasses,
1438 JvmtiFunctions::GetClassLoaderClasses,
1439 JvmtiFunctions::PopFrame, // 80
1440 JvmtiFunctions::ForceEarlyReturnObject,
1441 JvmtiFunctions::ForceEarlyReturnInt,
1442 JvmtiFunctions::ForceEarlyReturnLong,
1443 JvmtiFunctions::ForceEarlyReturnFloat,
1444 JvmtiFunctions::ForceEarlyReturnDouble,
1445 JvmtiFunctions::ForceEarlyReturnVoid,
1446 JvmtiFunctions::RedefineClasses,
1447 JvmtiFunctions::GetVersionNumber,
1448 JvmtiFunctions::GetCapabilities,
1449 JvmtiFunctions::GetSourceDebugExtension, // 90
1450 JvmtiFunctions::IsMethodObsolete,
1451 JvmtiFunctions::SuspendThreadList,
1452 JvmtiFunctions::ResumeThreadList,
1453 nullptr, // reserved94
1454 nullptr, // reserved95
1455 nullptr, // reserved96
1456 nullptr, // reserved97
1457 nullptr, // reserved98
1458 nullptr, // reserved99
1459 JvmtiFunctions::GetAllStackTraces, // 100
1460 JvmtiFunctions::GetThreadListStackTraces,
1461 JvmtiFunctions::GetThreadLocalStorage,
1462 JvmtiFunctions::SetThreadLocalStorage,
1463 JvmtiFunctions::GetStackTrace,
1464 nullptr, // reserved105
1465 JvmtiFunctions::GetTag,
1466 JvmtiFunctions::SetTag,
1467 JvmtiFunctions::ForceGarbageCollection,
1468 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1469 JvmtiFunctions::IterateOverReachableObjects, // 110
1470 JvmtiFunctions::IterateOverHeap,
1471 JvmtiFunctions::IterateOverInstancesOfClass,
1472 nullptr, // reserved113
1473 JvmtiFunctions::GetObjectsWithTags,
1474 JvmtiFunctions::FollowReferences,
1475 JvmtiFunctions::IterateThroughHeap,
1476 nullptr, // reserved117
1477 nullptr, // reserved118
1478 nullptr, // reserved119
1479 JvmtiFunctions::SetJNIFunctionTable, // 120
1480 JvmtiFunctions::GetJNIFunctionTable,
1481 JvmtiFunctions::SetEventCallbacks,
1482 JvmtiFunctions::GenerateEvents,
1483 JvmtiFunctions::GetExtensionFunctions,
1484 JvmtiFunctions::GetExtensionEvents,
1485 JvmtiFunctions::SetExtensionEventCallback,
1486 JvmtiFunctions::DisposeEnvironment,
1487 JvmtiFunctions::GetErrorName,
1488 JvmtiFunctions::GetJLocationFormat,
1489 JvmtiFunctions::GetSystemProperties, // 130
1490 JvmtiFunctions::GetSystemProperty,
1491 JvmtiFunctions::SetSystemProperty,
1492 JvmtiFunctions::GetPhase,
1493 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1494 JvmtiFunctions::GetCurrentThreadCpuTime,
1495 JvmtiFunctions::GetThreadCpuTimerInfo,
1496 JvmtiFunctions::GetThreadCpuTime,
1497 JvmtiFunctions::GetTimerInfo,
1498 JvmtiFunctions::GetTime,
1499 JvmtiFunctions::GetPotentialCapabilities, // 140
1500 nullptr, // reserved141
1501 JvmtiFunctions::AddCapabilities,
1502 JvmtiFunctions::RelinquishCapabilities,
1503 JvmtiFunctions::GetAvailableProcessors,
1504 JvmtiFunctions::GetClassVersionNumbers,
1505 JvmtiFunctions::GetConstantPool,
1506 JvmtiFunctions::GetEnvironmentLocalStorage,
1507 JvmtiFunctions::SetEnvironmentLocalStorage,
1508 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1509 JvmtiFunctions::SetVerboseFlag, // 150
1510 JvmtiFunctions::AddToSystemClassLoaderSearch,
1511 JvmtiFunctions::RetransformClasses,
1512 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1513 JvmtiFunctions::GetObjectSize,
1514 JvmtiFunctions::GetLocalInstance,
1515};
1516
1517}; // namespace openjdkjvmti