blob: 5ca0381b48bf654b74cea00cc7725bd537d9838b [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
Andreas Gampe5e03a302017-03-13 13:10:00 -070038#include "jvmti.h"
Alex Light49948e92016-08-11 15:35:28 -070039
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 Gampeeb0cea12017-01-23 08:50:04 -080052#include "ti_dump.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080053#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070054#include "ti_heap.h"
Andreas Gampe6f8e4f02017-01-16 18:18:14 -080055#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070056#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080057#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080058#include "ti_object.h"
Andreas Gampe96eca782017-01-19 19:45:30 -080059#include "ti_phase.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080060#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080061#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080062#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070063#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080064#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000065#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080066#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070067#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070068
Alex Light49948e92016-08-11 15:35:28 -070069namespace openjdkjvmti {
70
Andreas Gampe77708d92016-10-07 11:48:21 -070071EventHandler gEventHandler;
Andreas Gampe6dee92e2016-09-12 19:58:13 -070072
Alex Lighte6574242016-08-17 09:56:24 -070073#define ENSURE_NON_NULL(n) \
74 do { \
75 if ((n) == nullptr) { \
76 return ERR(NULL_POINTER); \
77 } \
78 } while (false)
79
Alex Light49948e92016-08-11 15:35:28 -070080class JvmtiFunctions {
81 private:
82 static bool IsValidEnv(jvmtiEnv* env) {
83 return env != nullptr;
84 }
85
Alex Lighte6574242016-08-17 09:56:24 -070086#define ENSURE_VALID_ENV(env) \
87 do { \
88 if (!IsValidEnv(env)) { \
89 return ERR(INVALID_ENVIRONMENT); \
90 } \
91 } while (false)
92
93#define ENSURE_HAS_CAP(env, cap) \
94 do { \
95 ENSURE_VALID_ENV(env); \
96 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
97 return ERR(MUST_POSSESS_CAPABILITY); \
98 } \
99 } while (false)
100
Alex Light49948e92016-08-11 15:35:28 -0700101 public:
102 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700103 ENSURE_VALID_ENV(env);
104 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700105 if (size < 0) {
106 return ERR(ILLEGAL_ARGUMENT);
107 } else if (size == 0) {
108 *mem_ptr = nullptr;
109 return OK;
110 }
111 *mem_ptr = static_cast<unsigned char*>(malloc(size));
112 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
113 }
114
115 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700116 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700117 if (mem != nullptr) {
118 free(mem);
119 }
120 return OK;
121 }
122
123 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Andreas Gampe72c19832017-01-12 13:22:16 -0800124 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700125 }
126
127 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800128 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700129 }
130
131 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Andreas Gampe85807442017-01-13 14:40:58 -0800132 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700133 }
134
Alex Light6a3fd512017-02-27 14:34:32 -0800135 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800136 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700137 return ERR(NOT_IMPLEMENTED);
138 }
139
140 static jvmtiError SuspendThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800141 jint request_count ATTRIBUTE_UNUSED,
142 const jthread* request_list ATTRIBUTE_UNUSED,
143 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800144 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700145 return ERR(NOT_IMPLEMENTED);
146 }
147
Alex Light6a3fd512017-02-27 14:34:32 -0800148 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800149 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700150 return ERR(NOT_IMPLEMENTED);
151 }
152
153 static jvmtiError ResumeThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800154 jint request_count ATTRIBUTE_UNUSED,
155 const jthread* request_list ATTRIBUTE_UNUSED,
156 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800157 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700158 return ERR(NOT_IMPLEMENTED);
159 }
160
Alex Light6a3fd512017-02-27 14:34:32 -0800161 static jvmtiError StopThread(jvmtiEnv* env,
162 jthread thread ATTRIBUTE_UNUSED,
163 jobject exception ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800164 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700165 return ERR(NOT_IMPLEMENTED);
166 }
167
Alex Light6a3fd512017-02-27 14:34:32 -0800168 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800169 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700170 return ERR(NOT_IMPLEMENTED);
171 }
172
173 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800174 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700175 }
176
177 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800178 jthread thread ATTRIBUTE_UNUSED,
179 jint* owned_monitor_count_ptr ATTRIBUTE_UNUSED,
180 jobject** owned_monitors_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800181 ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700182 return ERR(NOT_IMPLEMENTED);
183 }
184
Alex Light6a3fd512017-02-27 14:34:32 -0800185 static jvmtiError GetOwnedMonitorStackDepthInfo(
186 jvmtiEnv* env,
187 jthread thread ATTRIBUTE_UNUSED,
188 jint* monitor_info_count_ptr ATTRIBUTE_UNUSED,
189 jvmtiMonitorStackDepthInfo** monitor_info_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800190 ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
Alex Light49948e92016-08-11 15:35:28 -0700191 return ERR(NOT_IMPLEMENTED);
192 }
193
194 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800195 jthread thread ATTRIBUTE_UNUSED,
196 jobject* monitor_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800197 ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
Alex Lighte6574242016-08-17 09:56:24 -0700198 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700199 }
200
201 static jvmtiError RunAgentThread(jvmtiEnv* env,
202 jthread thread,
203 jvmtiStartFunction proc,
204 const void* arg,
205 jint priority) {
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800206 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700207 }
208
209 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800210 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700211 }
212
213 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800214 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700215 }
216
217 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
218 jint* group_count_ptr,
219 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000220 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700221 }
222
223 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
224 jthreadGroup group,
225 jvmtiThreadGroupInfo* info_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000226 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700227 }
228
229 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
230 jthreadGroup group,
231 jint* thread_count_ptr,
232 jthread** threads_ptr,
233 jint* group_count_ptr,
234 jthreadGroup** groups_ptr) {
Andreas Gamped18d9e22017-01-16 16:08:45 +0000235 return ThreadGroupUtil::GetThreadGroupChildren(env,
236 group,
237 thread_count_ptr,
238 threads_ptr,
239 group_count_ptr,
240 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700241 }
242
243 static jvmtiError GetStackTrace(jvmtiEnv* env,
244 jthread thread,
245 jint start_depth,
246 jint max_frame_count,
247 jvmtiFrameInfo* frame_buffer,
248 jint* count_ptr) {
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700249 return StackUtil::GetStackTrace(env,
250 thread,
251 start_depth,
252 max_frame_count,
253 frame_buffer,
254 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700255 }
256
257 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
258 jint max_frame_count,
259 jvmtiStackInfo** stack_info_ptr,
260 jint* thread_count_ptr) {
Andreas Gampea1a27c62017-01-11 16:37:16 -0800261 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700262 }
263
264 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
265 jint thread_count,
266 const jthread* thread_list,
267 jint max_frame_count,
268 jvmtiStackInfo** stack_info_ptr) {
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800269 return StackUtil::GetThreadListStackTraces(env,
270 thread_count,
271 thread_list,
272 max_frame_count,
273 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700274 }
275
276 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800277 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700278 }
279
Alex Light6a3fd512017-02-27 14:34:32 -0800280 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800281 ENSURE_HAS_CAP(env, can_pop_frame);
Alex Light49948e92016-08-11 15:35:28 -0700282 return ERR(NOT_IMPLEMENTED);
283 }
284
285 static jvmtiError GetFrameLocation(jvmtiEnv* env,
286 jthread thread,
287 jint depth,
288 jmethodID* method_ptr,
289 jlocation* location_ptr) {
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800290 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700291 }
292
Alex Light6a3fd512017-02-27 14:34:32 -0800293 static jvmtiError NotifyFramePop(jvmtiEnv* env,
294 jthread thread ATTRIBUTE_UNUSED,
295 jint depth ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800296 ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
Alex Light49948e92016-08-11 15:35:28 -0700297 return ERR(NOT_IMPLEMENTED);
298 }
299
Alex Light6a3fd512017-02-27 14:34:32 -0800300 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env,
301 jthread thread ATTRIBUTE_UNUSED,
302 jobject value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800303 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700304 return ERR(NOT_IMPLEMENTED);
305 }
306
Alex Light6a3fd512017-02-27 14:34:32 -0800307 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env,
308 jthread thread ATTRIBUTE_UNUSED,
309 jint value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800310 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700311 return ERR(NOT_IMPLEMENTED);
312 }
313
Alex Light6a3fd512017-02-27 14:34:32 -0800314 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env,
315 jthread thread ATTRIBUTE_UNUSED,
316 jlong value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800317 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700318 return ERR(NOT_IMPLEMENTED);
319 }
320
Alex Light6a3fd512017-02-27 14:34:32 -0800321 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env,
322 jthread thread ATTRIBUTE_UNUSED,
323 jfloat value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800324 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700325 return ERR(NOT_IMPLEMENTED);
326 }
327
Alex Light6a3fd512017-02-27 14:34:32 -0800328 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env,
329 jthread thread ATTRIBUTE_UNUSED,
330 jdouble value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800331 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700332 return ERR(NOT_IMPLEMENTED);
333 }
334
Alex Light6a3fd512017-02-27 14:34:32 -0800335 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800336 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700337 return ERR(NOT_IMPLEMENTED);
338 }
339
340 static jvmtiError FollowReferences(jvmtiEnv* env,
341 jint heap_filter,
342 jclass klass,
343 jobject initial_object,
344 const jvmtiHeapCallbacks* callbacks,
345 const void* user_data) {
Alex Light9db679d2017-01-25 15:28:04 -0800346 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800347 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700348 return heap_util.FollowReferences(env,
349 heap_filter,
350 klass,
351 initial_object,
352 callbacks,
353 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700354 }
355
356 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
357 jint heap_filter,
358 jclass klass,
359 const jvmtiHeapCallbacks* callbacks,
360 const void* user_data) {
Alex Lighte6574242016-08-17 09:56:24 -0700361 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800362 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampee54d9922016-10-11 19:55:37 -0700363 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700364 }
365
366 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700367 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700368
369 JNIEnv* jni_env = GetJniEnv(env);
370 if (jni_env == nullptr) {
371 return ERR(INTERNAL);
372 }
373
374 art::ScopedObjectAccess soa(jni_env);
375 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800376 if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700377 *tag_ptr = 0;
378 }
379
380 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700381 }
382
383 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Lighte6574242016-08-17 09:56:24 -0700384 ENSURE_HAS_CAP(env, can_tag_objects);
385
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700386 if (object == nullptr) {
387 return ERR(NULL_POINTER);
388 }
389
390 JNIEnv* jni_env = GetJniEnv(env);
391 if (jni_env == nullptr) {
392 return ERR(INTERNAL);
393 }
394
395 art::ScopedObjectAccess soa(jni_env);
396 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800397 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700398
399 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700400 }
401
402 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
403 jint tag_count,
404 const jlong* tags,
405 jint* count_ptr,
406 jobject** object_result_ptr,
407 jlong** tag_result_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700408 ENSURE_HAS_CAP(env, can_tag_objects);
409
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700410 JNIEnv* jni_env = GetJniEnv(env);
411 if (jni_env == nullptr) {
412 return ERR(INTERNAL);
413 }
414
415 art::ScopedObjectAccess soa(jni_env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800416 return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
417 tag_count,
418 tags,
419 count_ptr,
420 object_result_ptr,
421 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700422 }
423
424 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Andreas Gampe8da6d032016-10-31 19:31:03 -0700425 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700426 }
427
428 static jvmtiError IterateOverObjectsReachableFromObject(
429 jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800430 jobject object ATTRIBUTE_UNUSED,
431 jvmtiObjectReferenceCallback object_reference_callback ATTRIBUTE_UNUSED,
432 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800433 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700434 return ERR(NOT_IMPLEMENTED);
435 }
436
Alex Light6a3fd512017-02-27 14:34:32 -0800437 static jvmtiError IterateOverReachableObjects(
438 jvmtiEnv* env,
439 jvmtiHeapRootCallback heap_root_callback ATTRIBUTE_UNUSED,
440 jvmtiStackReferenceCallback stack_ref_callback ATTRIBUTE_UNUSED,
441 jvmtiObjectReferenceCallback object_ref_callback ATTRIBUTE_UNUSED,
442 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800443 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700444 return ERR(NOT_IMPLEMENTED);
445 }
446
447 static jvmtiError IterateOverHeap(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800448 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
449 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
450 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800451 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700452 return ERR(NOT_IMPLEMENTED);
453 }
454
Alex Light6a3fd512017-02-27 14:34:32 -0800455 static jvmtiError IterateOverInstancesOfClass(
456 jvmtiEnv* env,
457 jclass klass ATTRIBUTE_UNUSED,
458 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
459 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
460 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800461 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700462 return ERR(NOT_IMPLEMENTED);
463 }
464
465 static jvmtiError GetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800466 jthread thread ATTRIBUTE_UNUSED,
467 jint depth ATTRIBUTE_UNUSED,
468 jint slot ATTRIBUTE_UNUSED,
469 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800470 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700471 return ERR(NOT_IMPLEMENTED);
472 }
473
474 static jvmtiError GetLocalInstance(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800475 jthread thread ATTRIBUTE_UNUSED,
476 jint depth ATTRIBUTE_UNUSED,
477 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800478 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700479 return ERR(NOT_IMPLEMENTED);
480 }
481
482 static jvmtiError GetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800483 jthread thread ATTRIBUTE_UNUSED,
484 jint depth ATTRIBUTE_UNUSED,
485 jint slot ATTRIBUTE_UNUSED,
486 jint* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800487 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700488 return ERR(NOT_IMPLEMENTED);
489 }
490
491 static jvmtiError GetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800492 jthread thread ATTRIBUTE_UNUSED,
493 jint depth ATTRIBUTE_UNUSED,
494 jint slot ATTRIBUTE_UNUSED,
495 jlong* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800496 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700497 return ERR(NOT_IMPLEMENTED);
498 }
499
500 static jvmtiError GetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800501 jthread thread ATTRIBUTE_UNUSED,
502 jint depth ATTRIBUTE_UNUSED,
503 jint slot ATTRIBUTE_UNUSED,
504 jfloat* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800505 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700506 return ERR(NOT_IMPLEMENTED);
507 }
508
509 static jvmtiError GetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800510 jthread thread ATTRIBUTE_UNUSED,
511 jint depth ATTRIBUTE_UNUSED,
512 jint slot ATTRIBUTE_UNUSED,
513 jdouble* value_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800514 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700515 return ERR(NOT_IMPLEMENTED);
516 }
517
518 static jvmtiError SetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800519 jthread thread ATTRIBUTE_UNUSED,
520 jint depth ATTRIBUTE_UNUSED,
521 jint slot ATTRIBUTE_UNUSED,
522 jobject value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800523 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700524 return ERR(NOT_IMPLEMENTED);
525 }
526
527 static jvmtiError SetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800528 jthread thread ATTRIBUTE_UNUSED,
529 jint depth ATTRIBUTE_UNUSED,
530 jint slot ATTRIBUTE_UNUSED,
531 jint value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800532 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700533 return ERR(NOT_IMPLEMENTED);
534 }
535
536 static jvmtiError SetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800537 jthread thread ATTRIBUTE_UNUSED,
538 jint depth ATTRIBUTE_UNUSED,
539 jint slot ATTRIBUTE_UNUSED,
540 jlong value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800541 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700542 return ERR(NOT_IMPLEMENTED);
543 }
544
545 static jvmtiError SetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800546 jthread thread ATTRIBUTE_UNUSED,
547 jint depth ATTRIBUTE_UNUSED,
548 jint slot ATTRIBUTE_UNUSED,
549 jfloat value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800550 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700551 return ERR(NOT_IMPLEMENTED);
552 }
553
554 static jvmtiError SetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800555 jthread thread ATTRIBUTE_UNUSED,
556 jint depth ATTRIBUTE_UNUSED,
557 jint slot ATTRIBUTE_UNUSED,
558 jdouble value ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800559 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700560 return ERR(NOT_IMPLEMENTED);
561 }
562
Alex Light6a3fd512017-02-27 14:34:32 -0800563 static jvmtiError SetBreakpoint(jvmtiEnv* env,
564 jmethodID method ATTRIBUTE_UNUSED,
565 jlocation location ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800566 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Light49948e92016-08-11 15:35:28 -0700567 return ERR(NOT_IMPLEMENTED);
568 }
569
Alex Light6a3fd512017-02-27 14:34:32 -0800570 static jvmtiError ClearBreakpoint(jvmtiEnv* env,
571 jmethodID method ATTRIBUTE_UNUSED,
572 jlocation location ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800573 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Light49948e92016-08-11 15:35:28 -0700574 return ERR(NOT_IMPLEMENTED);
575 }
576
Alex Light6a3fd512017-02-27 14:34:32 -0800577 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env,
578 jclass klass ATTRIBUTE_UNUSED,
579 jfieldID field ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800580 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light49948e92016-08-11 15:35:28 -0700581 return ERR(NOT_IMPLEMENTED);
582 }
583
Alex Light6a3fd512017-02-27 14:34:32 -0800584 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env,
585 jclass klass ATTRIBUTE_UNUSED,
586 jfieldID field ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800587 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light49948e92016-08-11 15:35:28 -0700588 return ERR(NOT_IMPLEMENTED);
589 }
590
Alex Light6a3fd512017-02-27 14:34:32 -0800591 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env,
592 jclass klass ATTRIBUTE_UNUSED,
593 jfieldID field ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800594 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light49948e92016-08-11 15:35:28 -0700595 return ERR(NOT_IMPLEMENTED);
596 }
597
Alex Light6a3fd512017-02-27 14:34:32 -0800598 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env,
599 jclass klass ATTRIBUTE_UNUSED,
600 jfieldID field ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800601 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light49948e92016-08-11 15:35:28 -0700602 return ERR(NOT_IMPLEMENTED);
603 }
604
605 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Andreas Gampede19eb92017-02-24 16:21:18 -0800606 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700607 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700608 }
609
610 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
611 jobject initiating_loader,
612 jint* class_count_ptr,
613 jclass** classes_ptr) {
Andreas Gampe70f16392017-01-16 14:20:10 -0800614 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700615 }
616
617 static jvmtiError GetClassSignature(jvmtiEnv* env,
618 jclass klass,
619 char** signature_ptr,
620 char** generic_ptr) {
Andreas Gampee492ae32016-10-28 19:34:57 -0700621 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700622 }
623
624 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Andreas Gampeff9d2092017-01-06 09:12:49 -0800625 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700626 }
627
Alex Light6a3fd512017-02-27 14:34:32 -0800628 static jvmtiError GetSourceFileName(jvmtiEnv* env,
629 jclass klass ATTRIBUTE_UNUSED,
630 char** source_name_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800631 ENSURE_HAS_CAP(env, can_get_source_file_name);
Alex Light49948e92016-08-11 15:35:28 -0700632 return ERR(NOT_IMPLEMENTED);
633 }
634
635 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Andreas Gampe64013e52017-01-06 13:07:19 -0800636 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700637 }
638
639 static jvmtiError GetClassMethods(jvmtiEnv* env,
640 jclass klass,
641 jint* method_count_ptr,
642 jmethodID** methods_ptr) {
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800643 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700644 }
645
646 static jvmtiError GetClassFields(jvmtiEnv* env,
647 jclass klass,
648 jint* field_count_ptr,
649 jfieldID** fields_ptr) {
Andreas Gampeac587272017-01-05 15:21:34 -0800650 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700651 }
652
653 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
654 jclass klass,
655 jint* interface_count_ptr,
656 jclass** interfaces_ptr) {
Andreas Gampe8b07e472017-01-06 14:20:39 -0800657 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700658 }
659
660 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
661 jclass klass,
662 jint* minor_version_ptr,
663 jint* major_version_ptr) {
Andreas Gampe812a2442017-01-19 22:04:46 -0800664 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700665 }
666
667 static jvmtiError GetConstantPool(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800668 jclass klass ATTRIBUTE_UNUSED,
669 jint* constant_pool_count_ptr ATTRIBUTE_UNUSED,
670 jint* constant_pool_byte_count_ptr ATTRIBUTE_UNUSED,
671 unsigned char** constant_pool_bytes_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800672 ENSURE_HAS_CAP(env, can_get_constant_pool);
Alex Light49948e92016-08-11 15:35:28 -0700673 return ERR(NOT_IMPLEMENTED);
674 }
675
676 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800677 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700678 }
679
680 static jvmtiError IsArrayClass(jvmtiEnv* env,
681 jclass klass,
682 jboolean* is_array_class_ptr) {
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800683 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700684 }
685
686 static jvmtiError IsModifiableClass(jvmtiEnv* env,
687 jclass klass,
688 jboolean* is_modifiable_class_ptr) {
Alex Lighte4a88632017-01-10 07:41:24 -0800689 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700690 }
691
692 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800693 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700694 }
695
696 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800697 jclass klass ATTRIBUTE_UNUSED,
698 char** source_debug_extension_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800699 ENSURE_HAS_CAP(env, can_get_source_debug_extension);
Alex Light49948e92016-08-11 15:35:28 -0700700 return ERR(NOT_IMPLEMENTED);
701 }
702
703 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light9db679d2017-01-25 15:28:04 -0800704 ENSURE_HAS_CAP(env, can_retransform_classes);
Alex Light6ac57502017-01-19 15:05:06 -0800705 std::string error_msg;
706 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800707 &gEventHandler,
Alex Light6ac57502017-01-19 15:05:06 -0800708 art::Runtime::Current(),
709 art::Thread::Current(),
710 class_count,
711 classes,
712 &error_msg);
713 if (res != OK) {
714 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
715 }
716 return res;
Alex Light49948e92016-08-11 15:35:28 -0700717 }
718
719 static jvmtiError RedefineClasses(jvmtiEnv* env,
720 jint class_count,
721 const jvmtiClassDefinition* class_definitions) {
Alex Light9db679d2017-01-25 15:28:04 -0800722 ENSURE_HAS_CAP(env, can_redefine_classes);
Alex Light0e692732017-01-10 15:00:05 -0800723 std::string error_msg;
724 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800725 &gEventHandler,
Alex Light0e692732017-01-10 15:00:05 -0800726 art::Runtime::Current(),
727 art::Thread::Current(),
728 class_count,
729 class_definitions,
730 &error_msg);
731 if (res != OK) {
732 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
733 }
734 return res;
Alex Light49948e92016-08-11 15:35:28 -0700735 }
736
737 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800738 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700739 }
740
741 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Andreas Gampe50a4e492017-01-06 18:00:20 -0800742 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700743 }
744
745 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800746 jobject object ATTRIBUTE_UNUSED,
747 jvmtiMonitorUsage* info_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800748 ENSURE_HAS_CAP(env, can_get_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700749 return ERR(NOT_IMPLEMENTED);
750 }
751
752 static jvmtiError GetFieldName(jvmtiEnv* env,
753 jclass klass,
754 jfieldID field,
755 char** name_ptr,
756 char** signature_ptr,
757 char** generic_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800758 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700759 }
760
761 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
762 jclass klass,
763 jfieldID field,
764 jclass* declaring_class_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800765 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700766 }
767
768 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
769 jclass klass,
770 jfieldID field,
771 jint* modifiers_ptr) {
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800772 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700773 }
774
775 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
776 jclass klass,
777 jfieldID field,
778 jboolean* is_synthetic_ptr) {
Alex Light9db679d2017-01-25 15:28:04 -0800779 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800780 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700781 }
782
783 static jvmtiError GetMethodName(jvmtiEnv* env,
784 jmethodID method,
785 char** name_ptr,
786 char** signature_ptr,
787 char** generic_ptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700788 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700789 }
790
791 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
792 jmethodID method,
793 jclass* declaring_class_ptr) {
Andreas Gampe368a2082016-10-28 17:33:13 -0700794 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700795 }
796
797 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
798 jmethodID method,
799 jint* modifiers_ptr) {
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700800 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700801 }
802
803 static jvmtiError GetMaxLocals(jvmtiEnv* env,
804 jmethodID method,
805 jint* max_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800806 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700807 }
808
809 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
810 jmethodID method,
811 jint* size_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800812 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700813 }
814
815 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
816 jmethodID method,
817 jint* entry_count_ptr,
818 jvmtiLineNumberEntry** table_ptr) {
Alex Light9db679d2017-01-25 15:28:04 -0800819 ENSURE_HAS_CAP(env, can_get_line_numbers);
Andreas Gampeda3e5612016-12-13 19:00:53 -0800820 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700821 }
822
823 static jvmtiError GetMethodLocation(jvmtiEnv* env,
824 jmethodID method,
825 jlocation* start_location_ptr,
826 jlocation* end_location_ptr) {
Andreas Gampef71832e2017-01-09 11:38:04 -0800827 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700828 }
829
830 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800831 jmethodID method ATTRIBUTE_UNUSED,
832 jint* entry_count_ptr ATTRIBUTE_UNUSED,
833 jvmtiLocalVariableEntry** table_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800834 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700835 return ERR(NOT_IMPLEMENTED);
836 }
837
838 static jvmtiError GetBytecodes(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800839 jmethodID method ATTRIBUTE_UNUSED,
840 jint* bytecode_count_ptr ATTRIBUTE_UNUSED,
841 unsigned char** bytecodes_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800842 ENSURE_HAS_CAP(env, can_get_bytecodes);
Alex Light49948e92016-08-11 15:35:28 -0700843 return ERR(NOT_IMPLEMENTED);
844 }
845
846 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800847 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700848 }
849
850 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Alex Light9db679d2017-01-25 15:28:04 -0800851 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampefdeef522017-01-09 14:40:25 -0800852 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700853 }
854
855 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Andreas Gampefdeef522017-01-09 14:40:25 -0800856 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700857 }
858
Alex Light6a3fd512017-02-27 14:34:32 -0800859 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800860 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700861 return ERR(NOT_IMPLEMENTED);
862 }
863
Alex Light6a3fd512017-02-27 14:34:32 -0800864 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
865 jint prefix_count ATTRIBUTE_UNUSED,
866 char** prefixes ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -0800867 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700868 return ERR(NOT_IMPLEMENTED);
869 }
870
871 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800872 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700873 }
874
875 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800876 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700877 }
878
879 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800880 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700881 }
882
883 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800884 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700885 }
886
887 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800888 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700889 }
890
891 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800892 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700893 }
894
895 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Andreas Gampe319dbe82017-01-09 16:42:21 -0800896 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700897 }
898
899 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800900 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700901 }
902
903 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800904 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700905 }
906
Andreas Gampe77708d92016-10-07 11:48:21 -0700907 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
908 // an event.
Alex Light49948e92016-08-11 15:35:28 -0700909 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
910 const jvmtiEventCallbacks* callbacks,
911 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -0700912 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700913 if (size_of_callbacks < 0) {
914 return ERR(ILLEGAL_ARGUMENT);
915 }
916
917 if (callbacks == nullptr) {
918 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
919 return ERR(NONE);
920 }
921
922 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
923 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
924 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
925 static_cast<size_t>(size_of_callbacks));
926 copy_size = art::RoundDown(copy_size, sizeof(void*));
927 memcpy(tmp.get(), callbacks, copy_size);
928
929 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
930
931 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700932 }
933
934 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
935 jvmtiEventMode mode,
936 jvmtiEvent event_type,
937 jthread event_thread,
938 ...) {
Alex Lighte6574242016-08-17 09:56:24 -0700939 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -0700940 art::Thread* art_thread = nullptr;
941 if (event_thread != nullptr) {
942 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
943 art::ScopedObjectAccess soa(art::Thread::Current());
944 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
945 art_thread = art::Thread::FromManagedThread(soa, event_thread);
946
947 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
948 art_thread->IsStillStarting()) {
949 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
950 return ERR(THREAD_NOT_ALIVE);
951 }
952 }
953
Alex Light40d87f42017-01-18 10:27:06 -0800954 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
955 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -0700956 }
957
Alex Light6a3fd512017-02-27 14:34:32 -0800958 static jvmtiError GenerateEvents(jvmtiEnv* env ATTRIBUTE_UNUSED,
959 jvmtiEvent event_type ATTRIBUTE_UNUSED) {
960 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700961 }
962
Alex Light6a3fd512017-02-27 14:34:32 -0800963 static jvmtiError GetExtensionFunctions(jvmtiEnv* env ATTRIBUTE_UNUSED,
Alex Light49948e92016-08-11 15:35:28 -0700964 jint* extension_count_ptr,
965 jvmtiExtensionFunctionInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800966 // We do not have any extension functions.
967 *extension_count_ptr = 0;
968 *extensions = nullptr;
969
970 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700971 }
972
Alex Light6a3fd512017-02-27 14:34:32 -0800973 static jvmtiError GetExtensionEvents(jvmtiEnv* env ATTRIBUTE_UNUSED,
Alex Light49948e92016-08-11 15:35:28 -0700974 jint* extension_count_ptr,
975 jvmtiExtensionEventInfo** extensions) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800976 // We do not have any extension events.
977 *extension_count_ptr = 0;
978 *extensions = nullptr;
979
980 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700981 }
982
Alex Light6a3fd512017-02-27 14:34:32 -0800983 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env ATTRIBUTE_UNUSED,
984 jint extension_event_index ATTRIBUTE_UNUSED,
985 jvmtiExtensionEvent callback ATTRIBUTE_UNUSED) {
Andreas Gampee4c33842017-01-09 10:50:17 -0800986 // We do not have any extension events, so any call is illegal.
987 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -0700988 }
989
990 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700991 ENSURE_VALID_ENV(env);
992 ENSURE_NON_NULL(capabilities_ptr);
993 *capabilities_ptr = kPotentialCapabilities;
994 return OK;
Alex Light49948e92016-08-11 15:35:28 -0700995 }
996
997 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700998 ENSURE_VALID_ENV(env);
999 ENSURE_NON_NULL(capabilities_ptr);
1000 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1001 jvmtiError ret = OK;
Alex Light34d8e082017-03-27 09:50:36 -07001002 jvmtiCapabilities changed = {};
1003 jvmtiCapabilities potential_capabilities = {};
Alex Light1d224962017-02-27 10:26:35 -08001004 ret = env->GetPotentialCapabilities(&potential_capabilities);
1005 if (ret != OK) {
1006 return ret;
1007 }
Alex Lighte6574242016-08-17 09:56:24 -07001008#define ADD_CAPABILITY(e) \
1009 do { \
1010 if (capabilities_ptr->e == 1) { \
Alex Light1d224962017-02-27 10:26:35 -08001011 if (potential_capabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001012 if (art_env->capabilities.e != 1) { \
1013 art_env->capabilities.e = 1; \
1014 changed.e = 1; \
1015 }\
Alex Lighte6574242016-08-17 09:56:24 -07001016 } else { \
1017 ret = ERR(NOT_AVAILABLE); \
1018 } \
1019 } \
1020 } while (false)
1021
1022 ADD_CAPABILITY(can_tag_objects);
1023 ADD_CAPABILITY(can_generate_field_modification_events);
1024 ADD_CAPABILITY(can_generate_field_access_events);
1025 ADD_CAPABILITY(can_get_bytecodes);
1026 ADD_CAPABILITY(can_get_synthetic_attribute);
1027 ADD_CAPABILITY(can_get_owned_monitor_info);
1028 ADD_CAPABILITY(can_get_current_contended_monitor);
1029 ADD_CAPABILITY(can_get_monitor_info);
1030 ADD_CAPABILITY(can_pop_frame);
1031 ADD_CAPABILITY(can_redefine_classes);
1032 ADD_CAPABILITY(can_signal_thread);
1033 ADD_CAPABILITY(can_get_source_file_name);
1034 ADD_CAPABILITY(can_get_line_numbers);
1035 ADD_CAPABILITY(can_get_source_debug_extension);
1036 ADD_CAPABILITY(can_access_local_variables);
1037 ADD_CAPABILITY(can_maintain_original_method_order);
1038 ADD_CAPABILITY(can_generate_single_step_events);
1039 ADD_CAPABILITY(can_generate_exception_events);
1040 ADD_CAPABILITY(can_generate_frame_pop_events);
1041 ADD_CAPABILITY(can_generate_breakpoint_events);
1042 ADD_CAPABILITY(can_suspend);
1043 ADD_CAPABILITY(can_redefine_any_class);
1044 ADD_CAPABILITY(can_get_current_thread_cpu_time);
1045 ADD_CAPABILITY(can_get_thread_cpu_time);
1046 ADD_CAPABILITY(can_generate_method_entry_events);
1047 ADD_CAPABILITY(can_generate_method_exit_events);
1048 ADD_CAPABILITY(can_generate_all_class_hook_events);
1049 ADD_CAPABILITY(can_generate_compiled_method_load_events);
1050 ADD_CAPABILITY(can_generate_monitor_events);
1051 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
1052 ADD_CAPABILITY(can_generate_native_method_bind_events);
1053 ADD_CAPABILITY(can_generate_garbage_collection_events);
1054 ADD_CAPABILITY(can_generate_object_free_events);
1055 ADD_CAPABILITY(can_force_early_return);
1056 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1057 ADD_CAPABILITY(can_get_constant_pool);
1058 ADD_CAPABILITY(can_set_native_method_prefix);
1059 ADD_CAPABILITY(can_retransform_classes);
1060 ADD_CAPABILITY(can_retransform_any_class);
1061 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1062 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1063#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001064 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1065 changed,
1066 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -07001067 return ret;
Alex Light49948e92016-08-11 15:35:28 -07001068 }
1069
1070 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1071 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001072 ENSURE_VALID_ENV(env);
1073 ENSURE_NON_NULL(capabilities_ptr);
1074 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light34d8e082017-03-27 09:50:36 -07001075 jvmtiCapabilities changed = {};
Alex Lighte6574242016-08-17 09:56:24 -07001076#define DEL_CAPABILITY(e) \
1077 do { \
1078 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001079 if (art_env->capabilities.e == 1) { \
1080 art_env->capabilities.e = 0;\
1081 changed.e = 1; \
1082 } \
Alex Lighte6574242016-08-17 09:56:24 -07001083 } \
1084 } while (false)
1085
1086 DEL_CAPABILITY(can_tag_objects);
1087 DEL_CAPABILITY(can_generate_field_modification_events);
1088 DEL_CAPABILITY(can_generate_field_access_events);
1089 DEL_CAPABILITY(can_get_bytecodes);
1090 DEL_CAPABILITY(can_get_synthetic_attribute);
1091 DEL_CAPABILITY(can_get_owned_monitor_info);
1092 DEL_CAPABILITY(can_get_current_contended_monitor);
1093 DEL_CAPABILITY(can_get_monitor_info);
1094 DEL_CAPABILITY(can_pop_frame);
1095 DEL_CAPABILITY(can_redefine_classes);
1096 DEL_CAPABILITY(can_signal_thread);
1097 DEL_CAPABILITY(can_get_source_file_name);
1098 DEL_CAPABILITY(can_get_line_numbers);
1099 DEL_CAPABILITY(can_get_source_debug_extension);
1100 DEL_CAPABILITY(can_access_local_variables);
1101 DEL_CAPABILITY(can_maintain_original_method_order);
1102 DEL_CAPABILITY(can_generate_single_step_events);
1103 DEL_CAPABILITY(can_generate_exception_events);
1104 DEL_CAPABILITY(can_generate_frame_pop_events);
1105 DEL_CAPABILITY(can_generate_breakpoint_events);
1106 DEL_CAPABILITY(can_suspend);
1107 DEL_CAPABILITY(can_redefine_any_class);
1108 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1109 DEL_CAPABILITY(can_get_thread_cpu_time);
1110 DEL_CAPABILITY(can_generate_method_entry_events);
1111 DEL_CAPABILITY(can_generate_method_exit_events);
1112 DEL_CAPABILITY(can_generate_all_class_hook_events);
1113 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1114 DEL_CAPABILITY(can_generate_monitor_events);
1115 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1116 DEL_CAPABILITY(can_generate_native_method_bind_events);
1117 DEL_CAPABILITY(can_generate_garbage_collection_events);
1118 DEL_CAPABILITY(can_generate_object_free_events);
1119 DEL_CAPABILITY(can_force_early_return);
1120 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1121 DEL_CAPABILITY(can_get_constant_pool);
1122 DEL_CAPABILITY(can_set_native_method_prefix);
1123 DEL_CAPABILITY(can_retransform_classes);
1124 DEL_CAPABILITY(can_retransform_any_class);
1125 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1126 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1127#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001128 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1129 changed,
1130 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001131 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001132 }
1133
1134 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001135 ENSURE_VALID_ENV(env);
1136 ENSURE_NON_NULL(capabilities_ptr);
1137 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1138 *capabilities_ptr = artenv->capabilities;
1139 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001140 }
1141
Alex Light6a3fd512017-02-27 14:34:32 -08001142 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1143 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -08001144 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001145 return ERR(NOT_IMPLEMENTED);
1146 }
1147
Alex Light6a3fd512017-02-27 14:34:32 -08001148 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -08001149 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001150 return ERR(NOT_IMPLEMENTED);
1151 }
1152
Alex Light6a3fd512017-02-27 14:34:32 -08001153 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1154 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -08001155 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001156 return ERR(NOT_IMPLEMENTED);
1157 }
1158
Alex Light6a3fd512017-02-27 14:34:32 -08001159 static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1160 jthread thread ATTRIBUTE_UNUSED,
1161 jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light9db679d2017-01-25 15:28:04 -08001162 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001163 return ERR(NOT_IMPLEMENTED);
1164 }
1165
1166 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001167 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001168 }
1169
1170 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001171 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001172 }
1173
1174 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Andreas Gampe35bcf812017-01-13 16:24:17 -08001175 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001176 }
1177
1178 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001179 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001180 }
1181
1182 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Andreas Gampece7732b2017-01-17 15:50:26 -08001183 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001184 }
1185
1186 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001187 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001188 }
1189
1190 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001191 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001192 }
1193
1194 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001195 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001196 }
1197
1198 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Andreas Gampe96eca782017-01-19 19:45:30 -08001199 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001200 }
1201
1202 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001203 ENSURE_VALID_ENV(env);
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001204 gEventHandler.RemoveArtJvmTiEnv(ArtJvmTiEnv::AsArtJvmTiEnv(env));
Andreas Gampede19eb92017-02-24 16:21:18 -08001205 art::Runtime::Current()->RemoveSystemWeakHolder(
1206 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001207 delete env;
1208 return OK;
1209 }
1210
1211 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001212 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001213 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1214 return OK;
1215 }
1216
1217 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001218 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001219 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1220 return OK;
1221 }
1222
1223 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001224 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001225 *version_ptr = JVMTI_VERSION;
1226 return OK;
1227 }
1228
1229 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001230 ENSURE_NON_NULL(name_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001231 switch (error) {
1232#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : do { \
Andreas Gampe54711412017-02-21 12:41:43 -08001233 jvmtiError res; \
1234 JvmtiUniquePtr<char[]> copy = CopyString(env, "JVMTI_ERROR_"#e, &res); \
1235 if (copy == nullptr) { \
Alex Light41960712017-01-06 14:44:23 -08001236 *name_ptr = nullptr; \
1237 return res; \
1238 } else { \
Andreas Gampe54711412017-02-21 12:41:43 -08001239 *name_ptr = copy.release(); \
Alex Light41960712017-01-06 14:44:23 -08001240 return OK; \
1241 } \
Alex Light49948e92016-08-11 15:35:28 -07001242 } while (false)
1243 ERROR_CASE(NONE);
1244 ERROR_CASE(INVALID_THREAD);
1245 ERROR_CASE(INVALID_THREAD_GROUP);
1246 ERROR_CASE(INVALID_PRIORITY);
1247 ERROR_CASE(THREAD_NOT_SUSPENDED);
1248 ERROR_CASE(THREAD_NOT_ALIVE);
1249 ERROR_CASE(INVALID_OBJECT);
1250 ERROR_CASE(INVALID_CLASS);
1251 ERROR_CASE(CLASS_NOT_PREPARED);
1252 ERROR_CASE(INVALID_METHODID);
1253 ERROR_CASE(INVALID_LOCATION);
1254 ERROR_CASE(INVALID_FIELDID);
1255 ERROR_CASE(NO_MORE_FRAMES);
1256 ERROR_CASE(OPAQUE_FRAME);
1257 ERROR_CASE(TYPE_MISMATCH);
1258 ERROR_CASE(INVALID_SLOT);
1259 ERROR_CASE(DUPLICATE);
1260 ERROR_CASE(NOT_FOUND);
1261 ERROR_CASE(INVALID_MONITOR);
1262 ERROR_CASE(NOT_MONITOR_OWNER);
1263 ERROR_CASE(INTERRUPT);
1264 ERROR_CASE(INVALID_CLASS_FORMAT);
1265 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1266 ERROR_CASE(FAILS_VERIFICATION);
1267 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1268 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1269 ERROR_CASE(INVALID_TYPESTATE);
1270 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1271 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1272 ERROR_CASE(UNSUPPORTED_VERSION);
1273 ERROR_CASE(NAMES_DONT_MATCH);
1274 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1275 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1276 ERROR_CASE(UNMODIFIABLE_CLASS);
1277 ERROR_CASE(NOT_AVAILABLE);
1278 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1279 ERROR_CASE(NULL_POINTER);
1280 ERROR_CASE(ABSENT_INFORMATION);
1281 ERROR_CASE(INVALID_EVENT_TYPE);
1282 ERROR_CASE(ILLEGAL_ARGUMENT);
1283 ERROR_CASE(NATIVE_METHOD);
1284 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1285 ERROR_CASE(OUT_OF_MEMORY);
1286 ERROR_CASE(ACCESS_DENIED);
1287 ERROR_CASE(WRONG_PHASE);
1288 ERROR_CASE(INTERNAL);
1289 ERROR_CASE(UNATTACHED_THREAD);
1290 ERROR_CASE(INVALID_ENVIRONMENT);
1291#undef ERROR_CASE
1292 default: {
Andreas Gampe54711412017-02-21 12:41:43 -08001293 jvmtiError res;
1294 JvmtiUniquePtr<char[]> copy = CopyString(env, "JVMTI_ERROR_UNKNOWN", &res);
1295 if (copy == nullptr) {
Alex Light41960712017-01-06 14:44:23 -08001296 *name_ptr = nullptr;
1297 return res;
1298 } else {
Andreas Gampe54711412017-02-21 12:41:43 -08001299 *name_ptr = copy.release();
Alex Light41960712017-01-06 14:44:23 -08001300 return ERR(ILLEGAL_ARGUMENT);
1301 }
Alex Light49948e92016-08-11 15:35:28 -07001302 }
1303 }
1304 }
1305
Alex Light6a3fd512017-02-27 14:34:32 -08001306 static jvmtiError SetVerboseFlag(jvmtiEnv* env ATTRIBUTE_UNUSED,
1307 jvmtiVerboseFlag flag,
1308 jboolean value) {
Andreas Gampef37e3022017-01-13 17:54:46 -08001309 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1310 // OTHER is special, as it's 0, so can't do a bit check.
1311 bool val = (value == JNI_TRUE) ? true : false;
1312
1313 art::gLogVerbosity.collector = val;
1314 art::gLogVerbosity.compiler = val;
1315 art::gLogVerbosity.deopt = val;
1316 art::gLogVerbosity.heap = val;
1317 art::gLogVerbosity.jdwp = val;
1318 art::gLogVerbosity.jit = val;
1319 art::gLogVerbosity.monitor = val;
1320 art::gLogVerbosity.oat = val;
1321 art::gLogVerbosity.profiler = val;
1322 art::gLogVerbosity.signals = val;
1323 art::gLogVerbosity.simulator = val;
1324 art::gLogVerbosity.startup = val;
1325 art::gLogVerbosity.third_party_jni = val;
1326 art::gLogVerbosity.threads = val;
1327 art::gLogVerbosity.verifier = val;
1328 art::gLogVerbosity.image = val;
1329
1330 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1331
1332 art::gLogVerbosity.agents = val;
1333 } else {
1334 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1335 // semantics.
1336 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1337 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1338 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1339 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1340 if ((flag & ~kMask) != 0) {
1341 return ERR(ILLEGAL_ARGUMENT);
1342 }
1343
1344 bool val = (value == JNI_TRUE) ? true : false;
1345
1346 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1347 art::gLogVerbosity.gc = val;
1348 }
1349
1350 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1351 art::gLogVerbosity.class_linker = val;
1352 }
1353
1354 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1355 art::gLogVerbosity.jni = val;
1356 }
1357 }
1358
1359 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001360 }
1361
Alex Light6a3fd512017-02-27 14:34:32 -08001362 static jvmtiError GetJLocationFormat(jvmtiEnv* env ATTRIBUTE_UNUSED,
1363 jvmtiJlocationFormat* format_ptr) {
Andreas Gampeacfc9572017-01-17 18:36:56 -08001364 // Report BCI as jlocation format. We report dex bytecode indices.
1365 if (format_ptr == nullptr) {
1366 return ERR(NULL_POINTER);
1367 }
1368 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1369 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001370 }
1371};
1372
1373static bool IsJvmtiVersion(jint version) {
1374 return version == JVMTI_VERSION_1 ||
1375 version == JVMTI_VERSION_1_0 ||
1376 version == JVMTI_VERSION_1_1 ||
1377 version == JVMTI_VERSION_1_2 ||
1378 version == JVMTI_VERSION;
1379}
1380
Andreas Gampede19eb92017-02-24 16:21:18 -08001381extern const jvmtiInterface_1 gJvmtiInterface;
1382ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler)
1383 : art_vm(runtime),
1384 local_data(nullptr),
1385 capabilities(),
1386 object_tag_table(new ObjectTagTable(event_handler)) {
1387 functions = &gJvmtiInterface;
1388}
1389
Alex Light49948e92016-08-11 15:35:28 -07001390// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1391// is a pointer to the uninitialized memory for an art::ti::Env.
1392static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
Andreas Gampede19eb92017-02-24 16:21:18 -08001393 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler);
Alex Light49948e92016-08-11 15:35:28 -07001394 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001395
1396 gEventHandler.RegisterArtJvmTiEnv(env);
Andreas Gampede19eb92017-02-24 16:21:18 -08001397
1398 art::Runtime::Current()->AddSystemWeakHolder(
1399 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001400}
1401
1402// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1403// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1404// returns false and does not modify the 'env' pointer.
1405static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1406 if (IsJvmtiVersion(version)) {
1407 CreateArtJvmTiEnv(vm, env);
1408 return JNI_OK;
1409 } else {
1410 printf("version 0x%x is not valid!", version);
1411 return JNI_EVERSION;
1412 }
1413}
1414
1415// The plugin initialization function. This adds the jvmti environment.
1416extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001417 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001418
1419 if (runtime->IsStarted()) {
1420 PhaseUtil::SetToLive();
1421 } else {
1422 PhaseUtil::SetToOnLoad();
1423 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001424 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001425 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001426 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001427 DumpUtil::Register(&gEventHandler);
Andreas Gampecefaa142017-01-23 15:04:59 -08001428 SearchUtil::Register();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001429 HeapUtil::Register();
Andreas Gampe96eca782017-01-19 19:45:30 -08001430
Andreas Gampee08a2be2016-10-06 13:13:30 -07001431 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001432
Alex Light49948e92016-08-11 15:35:28 -07001433 return true;
1434}
1435
Andreas Gampeeafaf572017-01-20 12:34:15 -08001436extern "C" bool ArtPlugin_Deinitialize() {
1437 PhaseUtil::Unregister();
1438 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001439 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001440 DumpUtil::Unregister();
Andreas Gampecefaa142017-01-23 15:04:59 -08001441 SearchUtil::Unregister();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001442 HeapUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001443
1444 return true;
1445}
1446
Alex Light49948e92016-08-11 15:35:28 -07001447// The actual struct holding all of the entrypoints into the jvmti interface.
1448const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001449 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001450 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001451 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001452 JvmtiFunctions::GetAllThreads,
1453 JvmtiFunctions::SuspendThread,
1454 JvmtiFunctions::ResumeThread,
1455 JvmtiFunctions::StopThread,
1456 JvmtiFunctions::InterruptThread,
1457 JvmtiFunctions::GetThreadInfo,
1458 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1459 JvmtiFunctions::GetCurrentContendedMonitor,
1460 JvmtiFunctions::RunAgentThread,
1461 JvmtiFunctions::GetTopThreadGroups,
1462 JvmtiFunctions::GetThreadGroupInfo,
1463 JvmtiFunctions::GetThreadGroupChildren,
1464 JvmtiFunctions::GetFrameCount,
1465 JvmtiFunctions::GetThreadState,
1466 JvmtiFunctions::GetCurrentThread,
1467 JvmtiFunctions::GetFrameLocation,
1468 JvmtiFunctions::NotifyFramePop, // 20
1469 JvmtiFunctions::GetLocalObject,
1470 JvmtiFunctions::GetLocalInt,
1471 JvmtiFunctions::GetLocalLong,
1472 JvmtiFunctions::GetLocalFloat,
1473 JvmtiFunctions::GetLocalDouble,
1474 JvmtiFunctions::SetLocalObject,
1475 JvmtiFunctions::SetLocalInt,
1476 JvmtiFunctions::SetLocalLong,
1477 JvmtiFunctions::SetLocalFloat,
1478 JvmtiFunctions::SetLocalDouble, // 30
1479 JvmtiFunctions::CreateRawMonitor,
1480 JvmtiFunctions::DestroyRawMonitor,
1481 JvmtiFunctions::RawMonitorEnter,
1482 JvmtiFunctions::RawMonitorExit,
1483 JvmtiFunctions::RawMonitorWait,
1484 JvmtiFunctions::RawMonitorNotify,
1485 JvmtiFunctions::RawMonitorNotifyAll,
1486 JvmtiFunctions::SetBreakpoint,
1487 JvmtiFunctions::ClearBreakpoint,
1488 nullptr, // reserved40
1489 JvmtiFunctions::SetFieldAccessWatch,
1490 JvmtiFunctions::ClearFieldAccessWatch,
1491 JvmtiFunctions::SetFieldModificationWatch,
1492 JvmtiFunctions::ClearFieldModificationWatch,
1493 JvmtiFunctions::IsModifiableClass,
1494 JvmtiFunctions::Allocate,
1495 JvmtiFunctions::Deallocate,
1496 JvmtiFunctions::GetClassSignature,
1497 JvmtiFunctions::GetClassStatus,
1498 JvmtiFunctions::GetSourceFileName, // 50
1499 JvmtiFunctions::GetClassModifiers,
1500 JvmtiFunctions::GetClassMethods,
1501 JvmtiFunctions::GetClassFields,
1502 JvmtiFunctions::GetImplementedInterfaces,
1503 JvmtiFunctions::IsInterface,
1504 JvmtiFunctions::IsArrayClass,
1505 JvmtiFunctions::GetClassLoader,
1506 JvmtiFunctions::GetObjectHashCode,
1507 JvmtiFunctions::GetObjectMonitorUsage,
1508 JvmtiFunctions::GetFieldName, // 60
1509 JvmtiFunctions::GetFieldDeclaringClass,
1510 JvmtiFunctions::GetFieldModifiers,
1511 JvmtiFunctions::IsFieldSynthetic,
1512 JvmtiFunctions::GetMethodName,
1513 JvmtiFunctions::GetMethodDeclaringClass,
1514 JvmtiFunctions::GetMethodModifiers,
1515 nullptr, // reserved67
1516 JvmtiFunctions::GetMaxLocals,
1517 JvmtiFunctions::GetArgumentsSize,
1518 JvmtiFunctions::GetLineNumberTable, // 70
1519 JvmtiFunctions::GetMethodLocation,
1520 JvmtiFunctions::GetLocalVariableTable,
1521 JvmtiFunctions::SetNativeMethodPrefix,
1522 JvmtiFunctions::SetNativeMethodPrefixes,
1523 JvmtiFunctions::GetBytecodes,
1524 JvmtiFunctions::IsMethodNative,
1525 JvmtiFunctions::IsMethodSynthetic,
1526 JvmtiFunctions::GetLoadedClasses,
1527 JvmtiFunctions::GetClassLoaderClasses,
1528 JvmtiFunctions::PopFrame, // 80
1529 JvmtiFunctions::ForceEarlyReturnObject,
1530 JvmtiFunctions::ForceEarlyReturnInt,
1531 JvmtiFunctions::ForceEarlyReturnLong,
1532 JvmtiFunctions::ForceEarlyReturnFloat,
1533 JvmtiFunctions::ForceEarlyReturnDouble,
1534 JvmtiFunctions::ForceEarlyReturnVoid,
1535 JvmtiFunctions::RedefineClasses,
1536 JvmtiFunctions::GetVersionNumber,
1537 JvmtiFunctions::GetCapabilities,
1538 JvmtiFunctions::GetSourceDebugExtension, // 90
1539 JvmtiFunctions::IsMethodObsolete,
1540 JvmtiFunctions::SuspendThreadList,
1541 JvmtiFunctions::ResumeThreadList,
1542 nullptr, // reserved94
1543 nullptr, // reserved95
1544 nullptr, // reserved96
1545 nullptr, // reserved97
1546 nullptr, // reserved98
1547 nullptr, // reserved99
1548 JvmtiFunctions::GetAllStackTraces, // 100
1549 JvmtiFunctions::GetThreadListStackTraces,
1550 JvmtiFunctions::GetThreadLocalStorage,
1551 JvmtiFunctions::SetThreadLocalStorage,
1552 JvmtiFunctions::GetStackTrace,
1553 nullptr, // reserved105
1554 JvmtiFunctions::GetTag,
1555 JvmtiFunctions::SetTag,
1556 JvmtiFunctions::ForceGarbageCollection,
1557 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1558 JvmtiFunctions::IterateOverReachableObjects, // 110
1559 JvmtiFunctions::IterateOverHeap,
1560 JvmtiFunctions::IterateOverInstancesOfClass,
1561 nullptr, // reserved113
1562 JvmtiFunctions::GetObjectsWithTags,
1563 JvmtiFunctions::FollowReferences,
1564 JvmtiFunctions::IterateThroughHeap,
1565 nullptr, // reserved117
1566 nullptr, // reserved118
1567 nullptr, // reserved119
1568 JvmtiFunctions::SetJNIFunctionTable, // 120
1569 JvmtiFunctions::GetJNIFunctionTable,
1570 JvmtiFunctions::SetEventCallbacks,
1571 JvmtiFunctions::GenerateEvents,
1572 JvmtiFunctions::GetExtensionFunctions,
1573 JvmtiFunctions::GetExtensionEvents,
1574 JvmtiFunctions::SetExtensionEventCallback,
1575 JvmtiFunctions::DisposeEnvironment,
1576 JvmtiFunctions::GetErrorName,
1577 JvmtiFunctions::GetJLocationFormat,
1578 JvmtiFunctions::GetSystemProperties, // 130
1579 JvmtiFunctions::GetSystemProperty,
1580 JvmtiFunctions::SetSystemProperty,
1581 JvmtiFunctions::GetPhase,
1582 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1583 JvmtiFunctions::GetCurrentThreadCpuTime,
1584 JvmtiFunctions::GetThreadCpuTimerInfo,
1585 JvmtiFunctions::GetThreadCpuTime,
1586 JvmtiFunctions::GetTimerInfo,
1587 JvmtiFunctions::GetTime,
1588 JvmtiFunctions::GetPotentialCapabilities, // 140
1589 nullptr, // reserved141
1590 JvmtiFunctions::AddCapabilities,
1591 JvmtiFunctions::RelinquishCapabilities,
1592 JvmtiFunctions::GetAvailableProcessors,
1593 JvmtiFunctions::GetClassVersionNumbers,
1594 JvmtiFunctions::GetConstantPool,
1595 JvmtiFunctions::GetEnvironmentLocalStorage,
1596 JvmtiFunctions::SetEnvironmentLocalStorage,
1597 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1598 JvmtiFunctions::SetVerboseFlag, // 150
1599 JvmtiFunctions::AddToSystemClassLoaderSearch,
1600 JvmtiFunctions::RetransformClasses,
1601 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1602 JvmtiFunctions::GetObjectSize,
1603 JvmtiFunctions::GetLocalInstance,
1604};
1605
1606}; // namespace openjdkjvmti