blob: 2ffd7ecdb5376667a938f4ad298bfad2384fe2ef [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 Gampece7732b2017-01-17 15:50:26 -080059#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070060#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080061#include "ti_thread.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) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000209 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700210 }
211
212 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
213 jthreadGroup group,
214 jvmtiThreadGroupInfo* info_ptr) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000215 return ERR(NOT_IMPLEMENTED);
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) {
Nicolas Geoffray87071bf2017-01-16 10:27:16 +0000224 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700225 }
226
227 static jvmtiError GetStackTrace(jvmtiEnv* env,
228 jthread thread,
229 jint start_depth,
230 jint max_frame_count,
231 jvmtiFrameInfo* frame_buffer,
232 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700233 return StackUtil::GetStackTrace(env,
234 thread,
235 start_depth,
236 max_frame_count,
237 frame_buffer,
238 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700239 }
240
241 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
242 jint max_frame_count,
243 jvmtiStackInfo** stack_info_ptr,
244 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800245 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700246 }
247
248 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
249 jint thread_count,
250 const jthread* thread_list,
251 jint max_frame_count,
252 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800253 return StackUtil::GetThreadListStackTraces(env,
254 thread_count,
255 thread_list,
256 max_frame_count,
257 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700258 }
259
260 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800261 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700262 }
263
264 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
265 return ERR(NOT_IMPLEMENTED);
266 }
267
268 static jvmtiError GetFrameLocation(jvmtiEnv* env,
269 jthread thread,
270 jint depth,
271 jmethodID* method_ptr,
272 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800273 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700274 }
275
276 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
277 return ERR(NOT_IMPLEMENTED);
278 }
279
280 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
281 return ERR(NOT_IMPLEMENTED);
282 }
283
284 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
285 return ERR(NOT_IMPLEMENTED);
286 }
287
288 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
289 return ERR(NOT_IMPLEMENTED);
290 }
291
292 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
293 return ERR(NOT_IMPLEMENTED);
294 }
295
296 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
297 return ERR(NOT_IMPLEMENTED);
298 }
299
300 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
301 return ERR(NOT_IMPLEMENTED);
302 }
303
304 static jvmtiError FollowReferences(jvmtiEnv* env,
305 jint heap_filter,
306 jclass klass,
307 jobject initial_object,
308 const jvmtiHeapCallbacks* callbacks,
309 const void* user_data) {
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700310 HeapUtil heap_util(&gObjectTagTable);
311 return heap_util.FollowReferences(env,
312 heap_filter,
313 klass,
314 initial_object,
315 callbacks,
316 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700317 }
318
319 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
320 jint heap_filter,
321 jclass klass,
322 const jvmtiHeapCallbacks* callbacks,
323 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700324 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampee54d9922016-10-11 19:55:37 -0700325 HeapUtil heap_util(&gObjectTagTable);
326 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700327 }
328
329 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700330 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700331
332 JNIEnv* jni_env = GetJniEnv(env);
333 if (jni_env == nullptr) {
334 return ERR(INTERNAL);
335 }
336
337 art::ScopedObjectAccess soa(jni_env);
338 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
339 if (!gObjectTagTable.GetTag(obj.Ptr(), tag_ptr)) {
340 *tag_ptr = 0;
341 }
342
343 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700344 }
345
346 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700347 ENSURE_HAS_CAP(env, can_tag_objects);
348
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700349 if (object == nullptr) {
350 return ERR(NULL_POINTER);
351 }
352
353 JNIEnv* jni_env = GetJniEnv(env);
354 if (jni_env == nullptr) {
355 return ERR(INTERNAL);
356 }
357
358 art::ScopedObjectAccess soa(jni_env);
359 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampee54eee12016-10-20 19:03:58 -0700360 gObjectTagTable.Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700361
362 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700363 }
364
365 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
366 jint tag_count,
367 const jlong* tags,
368 jint* count_ptr,
369 jobject** object_result_ptr,
370 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700371 ENSURE_HAS_CAP(env, can_tag_objects);
372
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700373 JNIEnv* jni_env = GetJniEnv(env);
374 if (jni_env == nullptr) {
375 return ERR(INTERNAL);
376 }
377
378 art::ScopedObjectAccess soa(jni_env);
379 return gObjectTagTable.GetTaggedObjects(env,
380 tag_count,
381 tags,
382 count_ptr,
383 object_result_ptr,
384 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700385 }
386
387 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700388 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700389 }
390
391 static jvmtiError IterateOverObjectsReachableFromObject(
392 jvmtiEnv* env,
393 jobject object,
394 jvmtiObjectReferenceCallback object_reference_callback,
395 const void* user_data) {
396 return ERR(NOT_IMPLEMENTED);
397 }
398
399 static jvmtiError IterateOverReachableObjects(jvmtiEnv* env,
400 jvmtiHeapRootCallback heap_root_callback,
401 jvmtiStackReferenceCallback stack_ref_callback,
402 jvmtiObjectReferenceCallback object_ref_callback,
403 const void* user_data) {
404 return ERR(NOT_IMPLEMENTED);
405 }
406
407 static jvmtiError IterateOverHeap(jvmtiEnv* env,
408 jvmtiHeapObjectFilter object_filter,
409 jvmtiHeapObjectCallback heap_object_callback,
410 const void* user_data) {
411 return ERR(NOT_IMPLEMENTED);
412 }
413
414 static jvmtiError IterateOverInstancesOfClass(jvmtiEnv* env,
415 jclass klass,
416 jvmtiHeapObjectFilter object_filter,
417 jvmtiHeapObjectCallback heap_object_callback,
418 const void* user_data) {
419 return ERR(NOT_IMPLEMENTED);
420 }
421
422 static jvmtiError GetLocalObject(jvmtiEnv* env,
423 jthread thread,
424 jint depth,
425 jint slot,
426 jobject* value_ptr) {
427 return ERR(NOT_IMPLEMENTED);
428 }
429
430 static jvmtiError GetLocalInstance(jvmtiEnv* env,
431 jthread thread,
432 jint depth,
433 jobject* value_ptr) {
434 return ERR(NOT_IMPLEMENTED);
435 }
436
437 static jvmtiError GetLocalInt(jvmtiEnv* env,
438 jthread thread,
439 jint depth,
440 jint slot,
441 jint* value_ptr) {
442 return ERR(NOT_IMPLEMENTED);
443 }
444
445 static jvmtiError GetLocalLong(jvmtiEnv* env,
446 jthread thread,
447 jint depth,
448 jint slot,
449 jlong* value_ptr) {
450 return ERR(NOT_IMPLEMENTED);
451 }
452
453 static jvmtiError GetLocalFloat(jvmtiEnv* env,
454 jthread thread,
455 jint depth,
456 jint slot,
457 jfloat* value_ptr) {
458 return ERR(NOT_IMPLEMENTED);
459 }
460
461 static jvmtiError GetLocalDouble(jvmtiEnv* env,
462 jthread thread,
463 jint depth,
464 jint slot,
465 jdouble* value_ptr) {
466 return ERR(NOT_IMPLEMENTED);
467 }
468
469 static jvmtiError SetLocalObject(jvmtiEnv* env,
470 jthread thread,
471 jint depth,
472 jint slot,
473 jobject value) {
474 return ERR(NOT_IMPLEMENTED);
475 }
476
477 static jvmtiError SetLocalInt(jvmtiEnv* env,
478 jthread thread,
479 jint depth,
480 jint slot,
481 jint value) {
482 return ERR(NOT_IMPLEMENTED);
483 }
484
485 static jvmtiError SetLocalLong(jvmtiEnv* env,
486 jthread thread,
487 jint depth,
488 jint slot,
489 jlong value) {
490 return ERR(NOT_IMPLEMENTED);
491 }
492
493 static jvmtiError SetLocalFloat(jvmtiEnv* env,
494 jthread thread,
495 jint depth,
496 jint slot,
497 jfloat value) {
498 return ERR(NOT_IMPLEMENTED);
499 }
500
501 static jvmtiError SetLocalDouble(jvmtiEnv* env,
502 jthread thread,
503 jint depth,
504 jint slot,
505 jdouble value) {
506 return ERR(NOT_IMPLEMENTED);
507 }
508
509 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
510 return ERR(NOT_IMPLEMENTED);
511 }
512
513 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
514 return ERR(NOT_IMPLEMENTED);
515 }
516
517 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
518 return ERR(NOT_IMPLEMENTED);
519 }
520
521 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
522 return ERR(NOT_IMPLEMENTED);
523 }
524
525 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
526 return ERR(NOT_IMPLEMENTED);
527 }
528
529 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
530 return ERR(NOT_IMPLEMENTED);
531 }
532
533 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700534 HeapUtil heap_util(&gObjectTagTable);
535 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700536 }
537
538 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
539 jobject initiating_loader,
540 jint* class_count_ptr,
541 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800542 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700543 }
544
545 static jvmtiError GetClassSignature(jvmtiEnv* env,
546 jclass klass,
547 char** signature_ptr,
548 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700549 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700550 }
551
552 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800553 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700554 }
555
556 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
557 return ERR(NOT_IMPLEMENTED);
558 }
559
560 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800561 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700562 }
563
564 static jvmtiError GetClassMethods(jvmtiEnv* env,
565 jclass klass,
566 jint* method_count_ptr,
567 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800568 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700569 }
570
571 static jvmtiError GetClassFields(jvmtiEnv* env,
572 jclass klass,
573 jint* field_count_ptr,
574 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800575 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700576 }
577
578 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
579 jclass klass,
580 jint* interface_count_ptr,
581 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800582 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700583 }
584
585 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
586 jclass klass,
587 jint* minor_version_ptr,
588 jint* major_version_ptr) {
589 return ERR(NOT_IMPLEMENTED);
590 }
591
592 static jvmtiError GetConstantPool(jvmtiEnv* env,
593 jclass klass,
594 jint* constant_pool_count_ptr,
595 jint* constant_pool_byte_count_ptr,
596 unsigned char** constant_pool_bytes_ptr) {
597 return ERR(NOT_IMPLEMENTED);
598 }
599
600 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800601 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700602 }
603
604 static jvmtiError IsArrayClass(jvmtiEnv* env,
605 jclass klass,
606 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800607 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700608 }
609
610 static jvmtiError IsModifiableClass(jvmtiEnv* env,
611 jclass klass,
612 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800613 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700614 }
615
616 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800617 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700618 }
619
620 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
621 jclass klass,
622 char** source_debug_extension_ptr) {
623 return ERR(NOT_IMPLEMENTED);
624 }
625
626 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
627 return ERR(NOT_IMPLEMENTED);
628 }
629
630 static jvmtiError RedefineClasses(jvmtiEnv* env,
631 jint class_count,
632 const jvmtiClassDefinition* class_definitions) {
Alex Light0e692732017-01-10 15:00:05 -0800633 std::string error_msg;
634 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
635 art::Runtime::Current(),
636 art::Thread::Current(),
637 class_count,
638 class_definitions,
639 &error_msg);
640 if (res != OK) {
641 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
642 }
643 return res;
Alex Light49948e92016-08-11 15:35:28 -0700644 }
645
646 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800647 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700648 }
649
650 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800651 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700652 }
653
654 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
655 jobject object,
656 jvmtiMonitorUsage* info_ptr) {
657 return ERR(NOT_IMPLEMENTED);
658 }
659
660 static jvmtiError GetFieldName(jvmtiEnv* env,
661 jclass klass,
662 jfieldID field,
663 char** name_ptr,
664 char** signature_ptr,
665 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800666 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700667 }
668
669 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
670 jclass klass,
671 jfieldID field,
672 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800673 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700674 }
675
676 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
677 jclass klass,
678 jfieldID field,
679 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800680 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700681 }
682
683 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
684 jclass klass,
685 jfieldID field,
686 jboolean* is_synthetic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800687 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700688 }
689
690 static jvmtiError GetMethodName(jvmtiEnv* env,
691 jmethodID method,
692 char** name_ptr,
693 char** signature_ptr,
694 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700695 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700696 }
697
698 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
699 jmethodID method,
700 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700701 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700702 }
703
704 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
705 jmethodID method,
706 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700707 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700708 }
709
710 static jvmtiError GetMaxLocals(jvmtiEnv* env,
711 jmethodID method,
712 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800713 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700714 }
715
716 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
717 jmethodID method,
718 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800719 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700720 }
721
722 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
723 jmethodID method,
724 jint* entry_count_ptr,
725 jvmtiLineNumberEntry** table_ptr) {
Andreas Gampeda3e5612016-12-13 19:00:53 -0800726 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700727 }
728
729 static jvmtiError GetMethodLocation(jvmtiEnv* env,
730 jmethodID method,
731 jlocation* start_location_ptr,
732 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800733 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700734 }
735
736 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
737 jmethodID method,
738 jint* entry_count_ptr,
739 jvmtiLocalVariableEntry** table_ptr) {
740 return ERR(NOT_IMPLEMENTED);
741 }
742
743 static jvmtiError GetBytecodes(jvmtiEnv* env,
744 jmethodID method,
745 jint* bytecode_count_ptr,
746 unsigned char** bytecodes_ptr) {
747 return ERR(NOT_IMPLEMENTED);
748 }
749
750 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800751 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700752 }
753
754 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800755 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700756 }
757
758 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800759 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700760 }
761
762 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix) {
763 return ERR(NOT_IMPLEMENTED);
764 }
765
766 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env, jint prefix_count, char** prefixes) {
767 return ERR(NOT_IMPLEMENTED);
768 }
769
770 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800771 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700772 }
773
774 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800775 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700776 }
777
778 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800779 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700780 }
781
782 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800783 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700784 }
785
786 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800787 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700788 }
789
790 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800791 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700792 }
793
794 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800795 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700796 }
797
798 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
799 return ERR(NOT_IMPLEMENTED);
800 }
801
802 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
803 return ERR(NOT_IMPLEMENTED);
804 }
805
Andreas Gampe77708d92016-10-07 11:48:21 -0700806 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
807 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700808 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
809 const jvmtiEventCallbacks* callbacks,
810 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700811 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700812 if (size_of_callbacks < 0) {
813 return ERR(ILLEGAL_ARGUMENT);
814 }
815
816 if (callbacks == nullptr) {
817 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
818 return ERR(NONE);
819 }
820
821 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
822 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
823 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
824 static_cast<size_t>(size_of_callbacks));
825 copy_size = art::RoundDown(copy_size, sizeof(void*));
826 memcpy(tmp.get(), callbacks, copy_size);
827
828 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
829
830 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700831 }
832
833 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
834 jvmtiEventMode mode,
835 jvmtiEvent event_type,
836 jthread event_thread,
837 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700838 ENSURE_VALID_ENV(env);
839 // TODO: Check for capabilities.
Andreas Gampe77708d92016-10-07 11:48:21 -0700840 art::Thread* art_thread = nullptr;
841 if (event_thread != nullptr) {
842 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
843 art::ScopedObjectAccess soa(art::Thread::Current());
844 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
845 art_thread = art::Thread::FromManagedThread(soa, event_thread);
846
847 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
848 art_thread->IsStillStarting()) {
849 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
850 return ERR(THREAD_NOT_ALIVE);
851 }
852 }
853
854 return gEventHandler.SetEvent(ArtJvmTiEnv::AsArtJvmTiEnv(env), art_thread, event_type, mode);
Alex Light49948e92016-08-11 15:35:28 -0700855 }
856
857 static jvmtiError GenerateEvents(jvmtiEnv* env, jvmtiEvent event_type) {
858 return ERR(NOT_IMPLEMENTED);
859 }
860
861 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
862 jint* extension_count_ptr,
863 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800864 // We do not have any extension functions.
865 *extension_count_ptr = 0;
866 *extensions = nullptr;
867
868 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700869 }
870
871 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
872 jint* extension_count_ptr,
873 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800874 // We do not have any extension events.
875 *extension_count_ptr = 0;
876 *extensions = nullptr;
877
878 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700879 }
880
881 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
882 jint extension_event_index,
883 jvmtiExtensionEvent callback) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800884 // We do not have any extension events, so any call is illegal.
885 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700886 }
887
888 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700889 ENSURE_VALID_ENV(env);
890 ENSURE_NON_NULL(capabilities_ptr);
891 *capabilities_ptr = kPotentialCapabilities;
892 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700893 }
894
895 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700896 ENSURE_VALID_ENV(env);
897 ENSURE_NON_NULL(capabilities_ptr);
898 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
899 jvmtiError ret = OK;
900#define ADD_CAPABILITY(e) \
901 do { \
902 if (capabilities_ptr->e == 1) { \
903 if (kPotentialCapabilities.e == 1) { \
904 art_env->capabilities.e = 1;\
905 } else { \
906 ret = ERR(NOT_AVAILABLE); \
907 } \
908 } \
909 } while (false)
910
911 ADD_CAPABILITY(can_tag_objects);
912 ADD_CAPABILITY(can_generate_field_modification_events);
913 ADD_CAPABILITY(can_generate_field_access_events);
914 ADD_CAPABILITY(can_get_bytecodes);
915 ADD_CAPABILITY(can_get_synthetic_attribute);
916 ADD_CAPABILITY(can_get_owned_monitor_info);
917 ADD_CAPABILITY(can_get_current_contended_monitor);
918 ADD_CAPABILITY(can_get_monitor_info);
919 ADD_CAPABILITY(can_pop_frame);
920 ADD_CAPABILITY(can_redefine_classes);
921 ADD_CAPABILITY(can_signal_thread);
922 ADD_CAPABILITY(can_get_source_file_name);
923 ADD_CAPABILITY(can_get_line_numbers);
924 ADD_CAPABILITY(can_get_source_debug_extension);
925 ADD_CAPABILITY(can_access_local_variables);
926 ADD_CAPABILITY(can_maintain_original_method_order);
927 ADD_CAPABILITY(can_generate_single_step_events);
928 ADD_CAPABILITY(can_generate_exception_events);
929 ADD_CAPABILITY(can_generate_frame_pop_events);
930 ADD_CAPABILITY(can_generate_breakpoint_events);
931 ADD_CAPABILITY(can_suspend);
932 ADD_CAPABILITY(can_redefine_any_class);
933 ADD_CAPABILITY(can_get_current_thread_cpu_time);
934 ADD_CAPABILITY(can_get_thread_cpu_time);
935 ADD_CAPABILITY(can_generate_method_entry_events);
936 ADD_CAPABILITY(can_generate_method_exit_events);
937 ADD_CAPABILITY(can_generate_all_class_hook_events);
938 ADD_CAPABILITY(can_generate_compiled_method_load_events);
939 ADD_CAPABILITY(can_generate_monitor_events);
940 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
941 ADD_CAPABILITY(can_generate_native_method_bind_events);
942 ADD_CAPABILITY(can_generate_garbage_collection_events);
943 ADD_CAPABILITY(can_generate_object_free_events);
944 ADD_CAPABILITY(can_force_early_return);
945 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
946 ADD_CAPABILITY(can_get_constant_pool);
947 ADD_CAPABILITY(can_set_native_method_prefix);
948 ADD_CAPABILITY(can_retransform_classes);
949 ADD_CAPABILITY(can_retransform_any_class);
950 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
951 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
952#undef ADD_CAPABILITY
953 return ret;
Alex Light49948e92016-08-11 15:35:28 -0700954 }
955
956 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
957 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700958 ENSURE_VALID_ENV(env);
959 ENSURE_NON_NULL(capabilities_ptr);
960 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
961#define DEL_CAPABILITY(e) \
962 do { \
963 if (capabilities_ptr->e == 1) { \
964 art_env->capabilities.e = 0;\
965 } \
966 } while (false)
967
968 DEL_CAPABILITY(can_tag_objects);
969 DEL_CAPABILITY(can_generate_field_modification_events);
970 DEL_CAPABILITY(can_generate_field_access_events);
971 DEL_CAPABILITY(can_get_bytecodes);
972 DEL_CAPABILITY(can_get_synthetic_attribute);
973 DEL_CAPABILITY(can_get_owned_monitor_info);
974 DEL_CAPABILITY(can_get_current_contended_monitor);
975 DEL_CAPABILITY(can_get_monitor_info);
976 DEL_CAPABILITY(can_pop_frame);
977 DEL_CAPABILITY(can_redefine_classes);
978 DEL_CAPABILITY(can_signal_thread);
979 DEL_CAPABILITY(can_get_source_file_name);
980 DEL_CAPABILITY(can_get_line_numbers);
981 DEL_CAPABILITY(can_get_source_debug_extension);
982 DEL_CAPABILITY(can_access_local_variables);
983 DEL_CAPABILITY(can_maintain_original_method_order);
984 DEL_CAPABILITY(can_generate_single_step_events);
985 DEL_CAPABILITY(can_generate_exception_events);
986 DEL_CAPABILITY(can_generate_frame_pop_events);
987 DEL_CAPABILITY(can_generate_breakpoint_events);
988 DEL_CAPABILITY(can_suspend);
989 DEL_CAPABILITY(can_redefine_any_class);
990 DEL_CAPABILITY(can_get_current_thread_cpu_time);
991 DEL_CAPABILITY(can_get_thread_cpu_time);
992 DEL_CAPABILITY(can_generate_method_entry_events);
993 DEL_CAPABILITY(can_generate_method_exit_events);
994 DEL_CAPABILITY(can_generate_all_class_hook_events);
995 DEL_CAPABILITY(can_generate_compiled_method_load_events);
996 DEL_CAPABILITY(can_generate_monitor_events);
997 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
998 DEL_CAPABILITY(can_generate_native_method_bind_events);
999 DEL_CAPABILITY(can_generate_garbage_collection_events);
1000 DEL_CAPABILITY(can_generate_object_free_events);
1001 DEL_CAPABILITY(can_force_early_return);
1002 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1003 DEL_CAPABILITY(can_get_constant_pool);
1004 DEL_CAPABILITY(can_set_native_method_prefix);
1005 DEL_CAPABILITY(can_retransform_classes);
1006 DEL_CAPABILITY(can_retransform_any_class);
1007 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1008 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1009#undef DEL_CAPABILITY
1010 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001011 }
1012
1013 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001014 ENSURE_VALID_ENV(env);
1015 ENSURE_NON_NULL(capabilities_ptr);
1016 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1017 *capabilities_ptr = artenv->capabilities;
1018 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001019 }
1020
1021 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1022 return ERR(NOT_IMPLEMENTED);
1023 }
1024
1025 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr) {
1026 return ERR(NOT_IMPLEMENTED);
1027 }
1028
1029 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1030 return ERR(NOT_IMPLEMENTED);
1031 }
1032
1033 static jvmtiError GetThreadCpuTime(jvmtiEnv* env, jthread thread, jlong* nanos_ptr) {
1034 return ERR(NOT_IMPLEMENTED);
1035 }
1036
1037 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001038 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001039 }
1040
1041 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001042 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001043 }
1044
1045 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001046 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001047 }
1048
1049 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001050 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001051 }
1052
1053 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001054 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001055 }
1056
1057 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001058 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001059 }
1060
1061 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001062 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001063 }
1064
1065 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001066 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001067 }
1068
1069 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1070 return ERR(NOT_IMPLEMENTED);
1071 }
1072
1073 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001074 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001075 delete env;
1076 return OK;
1077 }
1078
1079 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001080 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001081 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1082 return OK;
1083 }
1084
1085 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001086 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001087 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1088 return OK;
1089 }
1090
1091 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001092 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001093 *version_ptr = JVMTI_VERSION;
1094 return OK;
1095 }
1096
1097 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001098 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001099 switch (error) {
1100#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Alex Light41960712017-01-06 14:44:23 -08001101 jvmtiError res = CopyString(env, \
1102 "JVMTI_ERROR_"#e, \
1103 reinterpret_cast<unsigned char**>(name_ptr)); \
1104 if (res != OK) { \
1105 *name_ptr = nullptr; \
1106 return res; \
1107 } else { \
1108 return OK; \
1109 } \
Alex Light49948e92016-08-11 15:35:28 -07001110 } while (false)
1111 ERROR_CASE(NONE);
1112 ERROR_CASE(INVALID_THREAD);
1113 ERROR_CASE(INVALID_THREAD_GROUP);
1114 ERROR_CASE(INVALID_PRIORITY);
1115 ERROR_CASE(THREAD_NOT_SUSPENDED);
1116 ERROR_CASE(THREAD_NOT_ALIVE);
1117 ERROR_CASE(INVALID_OBJECT);
1118 ERROR_CASE(INVALID_CLASS);
1119 ERROR_CASE(CLASS_NOT_PREPARED);
1120 ERROR_CASE(INVALID_METHODID);
1121 ERROR_CASE(INVALID_LOCATION);
1122 ERROR_CASE(INVALID_FIELDID);
1123 ERROR_CASE(NO_MORE_FRAMES);
1124 ERROR_CASE(OPAQUE_FRAME);
1125 ERROR_CASE(TYPE_MISMATCH);
1126 ERROR_CASE(INVALID_SLOT);
1127 ERROR_CASE(DUPLICATE);
1128 ERROR_CASE(NOT_FOUND);
1129 ERROR_CASE(INVALID_MONITOR);
1130 ERROR_CASE(NOT_MONITOR_OWNER);
1131 ERROR_CASE(INTERRUPT);
1132 ERROR_CASE(INVALID_CLASS_FORMAT);
1133 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1134 ERROR_CASE(FAILS_VERIFICATION);
1135 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1136 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1137 ERROR_CASE(INVALID_TYPESTATE);
1138 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1139 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1140 ERROR_CASE(UNSUPPORTED_VERSION);
1141 ERROR_CASE(NAMES_DONT_MATCH);
1142 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1143 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1144 ERROR_CASE(UNMODIFIABLE_CLASS);
1145 ERROR_CASE(NOT_AVAILABLE);
1146 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1147 ERROR_CASE(NULL_POINTER);
1148 ERROR_CASE(ABSENT_INFORMATION);
1149 ERROR_CASE(INVALID_EVENT_TYPE);
1150 ERROR_CASE(ILLEGAL_ARGUMENT);
1151 ERROR_CASE(NATIVE_METHOD);
1152 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1153 ERROR_CASE(OUT_OF_MEMORY);
1154 ERROR_CASE(ACCESS_DENIED);
1155 ERROR_CASE(WRONG_PHASE);
1156 ERROR_CASE(INTERNAL);
1157 ERROR_CASE(UNATTACHED_THREAD);
1158 ERROR_CASE(INVALID_ENVIRONMENT);
1159#undef ERROR_CASE
1160 default: {
Alex Light41960712017-01-06 14:44:23 -08001161 jvmtiError res = CopyString(env,
1162 "JVMTI_ERROR_UNKNOWN",
1163 reinterpret_cast<unsigned char**>(name_ptr));
1164 if (res != OK) {
1165 *name_ptr = nullptr;
1166 return res;
1167 } else {
1168 return ERR(ILLEGAL_ARGUMENT);
1169 }
Alex Light49948e92016-08-11 15:35:28 -07001170 }
1171 }
1172 }
1173
1174 static jvmtiError SetVerboseFlag(jvmtiEnv* env, jvmtiVerboseFlag flag, jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001175 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1176 // OTHER is special, as it's 0, so can't do a bit check.
1177 bool val = (value == JNI_TRUE) ? true : false;
1178
1179 art::gLogVerbosity.collector = val;
1180 art::gLogVerbosity.compiler = val;
1181 art::gLogVerbosity.deopt = val;
1182 art::gLogVerbosity.heap = val;
1183 art::gLogVerbosity.jdwp = val;
1184 art::gLogVerbosity.jit = val;
1185 art::gLogVerbosity.monitor = val;
1186 art::gLogVerbosity.oat = val;
1187 art::gLogVerbosity.profiler = val;
1188 art::gLogVerbosity.signals = val;
1189 art::gLogVerbosity.simulator = val;
1190 art::gLogVerbosity.startup = val;
1191 art::gLogVerbosity.third_party_jni = val;
1192 art::gLogVerbosity.threads = val;
1193 art::gLogVerbosity.verifier = val;
1194 art::gLogVerbosity.image = val;
1195
1196 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1197
1198 art::gLogVerbosity.agents = val;
1199 } else {
1200 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1201 // semantics.
1202 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1203 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1204 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1205 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1206 if ((flag & ~kMask) != 0) {
1207 return ERR(ILLEGAL_ARGUMENT);
1208 }
1209
1210 bool val = (value == JNI_TRUE) ? true : false;
1211
1212 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1213 art::gLogVerbosity.gc = val;
1214 }
1215
1216 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1217 art::gLogVerbosity.class_linker = val;
1218 }
1219
1220 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1221 art::gLogVerbosity.jni = val;
1222 }
1223 }
1224
1225 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001226 }
1227
1228 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1229 return ERR(NOT_IMPLEMENTED);
1230 }
Alex Light9c20a142016-08-23 15:05:12 -07001231
1232 // TODO Remove this once events are working.
1233 static jvmtiError RetransformClassWithHook(jvmtiEnv* env,
1234 jclass klass,
1235 jvmtiEventClassFileLoadHook hook) {
1236 std::vector<jclass> classes;
1237 classes.push_back(klass);
1238 return RetransformClassesWithHook(reinterpret_cast<ArtJvmTiEnv*>(env), classes, hook);
1239 }
1240
1241 // TODO This will be called by the event handler for the art::ti Event Load Event
1242 static jvmtiError RetransformClassesWithHook(ArtJvmTiEnv* env,
1243 const std::vector<jclass>& classes,
1244 jvmtiEventClassFileLoadHook hook) {
1245 if (!IsValidEnv(env)) {
1246 return ERR(INVALID_ENVIRONMENT);
1247 }
Alex Lighta01de592016-11-15 10:43:06 -08001248 jvmtiError res = OK;
1249 std::string error;
Alex Light9c20a142016-08-23 15:05:12 -07001250 for (jclass klass : classes) {
1251 JNIEnv* jni_env = nullptr;
1252 jobject loader = nullptr;
1253 std::string name;
1254 jobject protection_domain = nullptr;
1255 jint data_len = 0;
1256 unsigned char* dex_data = nullptr;
1257 jvmtiError ret = OK;
1258 std::string location;
1259 if ((ret = GetTransformationData(env,
1260 klass,
1261 /*out*/&location,
1262 /*out*/&jni_env,
1263 /*out*/&loader,
1264 /*out*/&name,
1265 /*out*/&protection_domain,
1266 /*out*/&data_len,
1267 /*out*/&dex_data)) != OK) {
1268 // TODO Do something more here? Maybe give log statements?
1269 return ret;
1270 }
1271 jint new_data_len = 0;
1272 unsigned char* new_dex_data = nullptr;
1273 hook(env,
1274 jni_env,
1275 klass,
1276 loader,
1277 name.c_str(),
1278 protection_domain,
1279 data_len,
1280 dex_data,
1281 /*out*/&new_data_len,
1282 /*out*/&new_dex_data);
1283 // Check if anything actually changed.
1284 if ((new_data_len != 0 || new_dex_data != nullptr) && new_dex_data != dex_data) {
Alex Light0e692732017-01-10 15:00:05 -08001285 jvmtiClassDefinition def = { klass, new_data_len, new_dex_data };
1286 res = Redefiner::RedefineClasses(env,
1287 art::Runtime::Current(),
1288 art::Thread::Current(),
1289 1,
1290 &def,
1291 &error);
Alex Light9c20a142016-08-23 15:05:12 -07001292 env->Deallocate(new_dex_data);
1293 }
1294 // Deallocate the old dex data.
1295 env->Deallocate(dex_data);
Alex Lighta01de592016-11-15 10:43:06 -08001296 if (res != OK) {
1297 LOG(ERROR) << "FAILURE TO REDEFINE " << error;
1298 return res;
1299 }
Alex Light9c20a142016-08-23 15:05:12 -07001300 }
1301 return OK;
1302 }
Alex Light49948e92016-08-11 15:35:28 -07001303};
1304
1305static bool IsJvmtiVersion(jint version) {
1306 return version == JVMTI_VERSION_1 ||
1307 version == JVMTI_VERSION_1_0 ||
1308 version == JVMTI_VERSION_1_1 ||
1309 version == JVMTI_VERSION_1_2 ||
1310 version == JVMTI_VERSION;
1311}
1312
1313// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1314// is a pointer to the uninitialized memory for an art::ti::Env.
1315static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
1316 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm);
1317 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001318
1319 gEventHandler.RegisterArtJvmTiEnv(env);
Alex Light49948e92016-08-11 15:35:28 -07001320}
1321
1322// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1323// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1324// returns false and does not modify the 'env' pointer.
1325static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1326 if (IsJvmtiVersion(version)) {
1327 CreateArtJvmTiEnv(vm, env);
1328 return JNI_OK;
1329 } else {
1330 printf("version 0x%x is not valid!", version);
1331 return JNI_EVERSION;
1332 }
1333}
1334
1335// The plugin initialization function. This adds the jvmti environment.
1336extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001337 art::Runtime* runtime = art::Runtime::Current();
1338 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1339 runtime->AddSystemWeakHolder(&gObjectTagTable);
Alex Light49948e92016-08-11 15:35:28 -07001340 return true;
1341}
1342
1343// The actual struct holding all of the entrypoints into the jvmti interface.
1344const jvmtiInterface_1 gJvmtiInterface = {
Alex Light9c20a142016-08-23 15:05:12 -07001345 // SPECIAL FUNCTION: RetransformClassWithHook Is normally reserved1
1346 // TODO Remove once we have events working.
1347 reinterpret_cast<void*>(JvmtiFunctions::RetransformClassWithHook),
1348 // nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001349 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001350 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001351 JvmtiFunctions::GetAllThreads,
1352 JvmtiFunctions::SuspendThread,
1353 JvmtiFunctions::ResumeThread,
1354 JvmtiFunctions::StopThread,
1355 JvmtiFunctions::InterruptThread,
1356 JvmtiFunctions::GetThreadInfo,
1357 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1358 JvmtiFunctions::GetCurrentContendedMonitor,
1359 JvmtiFunctions::RunAgentThread,
1360 JvmtiFunctions::GetTopThreadGroups,
1361 JvmtiFunctions::GetThreadGroupInfo,
1362 JvmtiFunctions::GetThreadGroupChildren,
1363 JvmtiFunctions::GetFrameCount,
1364 JvmtiFunctions::GetThreadState,
1365 JvmtiFunctions::GetCurrentThread,
1366 JvmtiFunctions::GetFrameLocation,
1367 JvmtiFunctions::NotifyFramePop, // 20
1368 JvmtiFunctions::GetLocalObject,
1369 JvmtiFunctions::GetLocalInt,
1370 JvmtiFunctions::GetLocalLong,
1371 JvmtiFunctions::GetLocalFloat,
1372 JvmtiFunctions::GetLocalDouble,
1373 JvmtiFunctions::SetLocalObject,
1374 JvmtiFunctions::SetLocalInt,
1375 JvmtiFunctions::SetLocalLong,
1376 JvmtiFunctions::SetLocalFloat,
1377 JvmtiFunctions::SetLocalDouble, // 30
1378 JvmtiFunctions::CreateRawMonitor,
1379 JvmtiFunctions::DestroyRawMonitor,
1380 JvmtiFunctions::RawMonitorEnter,
1381 JvmtiFunctions::RawMonitorExit,
1382 JvmtiFunctions::RawMonitorWait,
1383 JvmtiFunctions::RawMonitorNotify,
1384 JvmtiFunctions::RawMonitorNotifyAll,
1385 JvmtiFunctions::SetBreakpoint,
1386 JvmtiFunctions::ClearBreakpoint,
1387 nullptr, // reserved40
1388 JvmtiFunctions::SetFieldAccessWatch,
1389 JvmtiFunctions::ClearFieldAccessWatch,
1390 JvmtiFunctions::SetFieldModificationWatch,
1391 JvmtiFunctions::ClearFieldModificationWatch,
1392 JvmtiFunctions::IsModifiableClass,
1393 JvmtiFunctions::Allocate,
1394 JvmtiFunctions::Deallocate,
1395 JvmtiFunctions::GetClassSignature,
1396 JvmtiFunctions::GetClassStatus,
1397 JvmtiFunctions::GetSourceFileName, // 50
1398 JvmtiFunctions::GetClassModifiers,
1399 JvmtiFunctions::GetClassMethods,
1400 JvmtiFunctions::GetClassFields,
1401 JvmtiFunctions::GetImplementedInterfaces,
1402 JvmtiFunctions::IsInterface,
1403 JvmtiFunctions::IsArrayClass,
1404 JvmtiFunctions::GetClassLoader,
1405 JvmtiFunctions::GetObjectHashCode,
1406 JvmtiFunctions::GetObjectMonitorUsage,
1407 JvmtiFunctions::GetFieldName, // 60
1408 JvmtiFunctions::GetFieldDeclaringClass,
1409 JvmtiFunctions::GetFieldModifiers,
1410 JvmtiFunctions::IsFieldSynthetic,
1411 JvmtiFunctions::GetMethodName,
1412 JvmtiFunctions::GetMethodDeclaringClass,
1413 JvmtiFunctions::GetMethodModifiers,
1414 nullptr, // reserved67
1415 JvmtiFunctions::GetMaxLocals,
1416 JvmtiFunctions::GetArgumentsSize,
1417 JvmtiFunctions::GetLineNumberTable, // 70
1418 JvmtiFunctions::GetMethodLocation,
1419 JvmtiFunctions::GetLocalVariableTable,
1420 JvmtiFunctions::SetNativeMethodPrefix,
1421 JvmtiFunctions::SetNativeMethodPrefixes,
1422 JvmtiFunctions::GetBytecodes,
1423 JvmtiFunctions::IsMethodNative,
1424 JvmtiFunctions::IsMethodSynthetic,
1425 JvmtiFunctions::GetLoadedClasses,
1426 JvmtiFunctions::GetClassLoaderClasses,
1427 JvmtiFunctions::PopFrame, // 80
1428 JvmtiFunctions::ForceEarlyReturnObject,
1429 JvmtiFunctions::ForceEarlyReturnInt,
1430 JvmtiFunctions::ForceEarlyReturnLong,
1431 JvmtiFunctions::ForceEarlyReturnFloat,
1432 JvmtiFunctions::ForceEarlyReturnDouble,
1433 JvmtiFunctions::ForceEarlyReturnVoid,
1434 JvmtiFunctions::RedefineClasses,
1435 JvmtiFunctions::GetVersionNumber,
1436 JvmtiFunctions::GetCapabilities,
1437 JvmtiFunctions::GetSourceDebugExtension, // 90
1438 JvmtiFunctions::IsMethodObsolete,
1439 JvmtiFunctions::SuspendThreadList,
1440 JvmtiFunctions::ResumeThreadList,
1441 nullptr, // reserved94
1442 nullptr, // reserved95
1443 nullptr, // reserved96
1444 nullptr, // reserved97
1445 nullptr, // reserved98
1446 nullptr, // reserved99
1447 JvmtiFunctions::GetAllStackTraces, // 100
1448 JvmtiFunctions::GetThreadListStackTraces,
1449 JvmtiFunctions::GetThreadLocalStorage,
1450 JvmtiFunctions::SetThreadLocalStorage,
1451 JvmtiFunctions::GetStackTrace,
1452 nullptr, // reserved105
1453 JvmtiFunctions::GetTag,
1454 JvmtiFunctions::SetTag,
1455 JvmtiFunctions::ForceGarbageCollection,
1456 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1457 JvmtiFunctions::IterateOverReachableObjects, // 110
1458 JvmtiFunctions::IterateOverHeap,
1459 JvmtiFunctions::IterateOverInstancesOfClass,
1460 nullptr, // reserved113
1461 JvmtiFunctions::GetObjectsWithTags,
1462 JvmtiFunctions::FollowReferences,
1463 JvmtiFunctions::IterateThroughHeap,
1464 nullptr, // reserved117
1465 nullptr, // reserved118
1466 nullptr, // reserved119
1467 JvmtiFunctions::SetJNIFunctionTable, // 120
1468 JvmtiFunctions::GetJNIFunctionTable,
1469 JvmtiFunctions::SetEventCallbacks,
1470 JvmtiFunctions::GenerateEvents,
1471 JvmtiFunctions::GetExtensionFunctions,
1472 JvmtiFunctions::GetExtensionEvents,
1473 JvmtiFunctions::SetExtensionEventCallback,
1474 JvmtiFunctions::DisposeEnvironment,
1475 JvmtiFunctions::GetErrorName,
1476 JvmtiFunctions::GetJLocationFormat,
1477 JvmtiFunctions::GetSystemProperties, // 130
1478 JvmtiFunctions::GetSystemProperty,
1479 JvmtiFunctions::SetSystemProperty,
1480 JvmtiFunctions::GetPhase,
1481 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1482 JvmtiFunctions::GetCurrentThreadCpuTime,
1483 JvmtiFunctions::GetThreadCpuTimerInfo,
1484 JvmtiFunctions::GetThreadCpuTime,
1485 JvmtiFunctions::GetTimerInfo,
1486 JvmtiFunctions::GetTime,
1487 JvmtiFunctions::GetPotentialCapabilities, // 140
1488 nullptr, // reserved141
1489 JvmtiFunctions::AddCapabilities,
1490 JvmtiFunctions::RelinquishCapabilities,
1491 JvmtiFunctions::GetAvailableProcessors,
1492 JvmtiFunctions::GetClassVersionNumbers,
1493 JvmtiFunctions::GetConstantPool,
1494 JvmtiFunctions::GetEnvironmentLocalStorage,
1495 JvmtiFunctions::SetEnvironmentLocalStorage,
1496 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1497 JvmtiFunctions::SetVerboseFlag, // 150
1498 JvmtiFunctions::AddToSystemClassLoaderSearch,
1499 JvmtiFunctions::RetransformClasses,
1500 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1501 JvmtiFunctions::GetObjectSize,
1502 JvmtiFunctions::GetLocalInstance,
1503};
1504
1505}; // namespace openjdkjvmti