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