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