blob: 0896210f1cfdb7c5e5c485fdcfd1529a5df4f2da [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 Gampeb486a982017-06-01 13:45:54 -070049#include "thread-current-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:
Alex Light1edc8cf2017-03-24 14:22:56 -070082 static jvmtiError getEnvironmentError(jvmtiEnv* env) {
83 if (env == nullptr) {
84 return ERR(INVALID_ENVIRONMENT);
85 } else if (art::Thread::Current() == nullptr) {
86 return ERR(UNATTACHED_THREAD);
87 } else {
88 return OK;
89 }
Alex Light49948e92016-08-11 15:35:28 -070090 }
91
Alex Light1edc8cf2017-03-24 14:22:56 -070092#define ENSURE_VALID_ENV(env) \
93 do { \
94 jvmtiError ensure_valid_env_ ## __LINE__ = getEnvironmentError(env); \
95 if (ensure_valid_env_ ## __LINE__ != OK) { \
96 return ensure_valid_env_ ## __LINE__ ; \
97 } \
Alex Lighte6574242016-08-17 09:56:24 -070098 } while (false)
99
100#define ENSURE_HAS_CAP(env, cap) \
101 do { \
Alex Lighte6574242016-08-17 09:56:24 -0700102 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
103 return ERR(MUST_POSSESS_CAPABILITY); \
104 } \
105 } while (false)
106
Alex Light49948e92016-08-11 15:35:28 -0700107 public:
108 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700109 ENSURE_VALID_ENV(env);
110 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700111 if (size < 0) {
112 return ERR(ILLEGAL_ARGUMENT);
113 } else if (size == 0) {
114 *mem_ptr = nullptr;
115 return OK;
116 }
117 *mem_ptr = static_cast<unsigned char*>(malloc(size));
118 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
119 }
120
121 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700122 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700123 if (mem != nullptr) {
124 free(mem);
125 }
126 return OK;
127 }
128
129 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700130 ENSURE_VALID_ENV(env);
Andreas Gampe72c19832017-01-12 13:22:16 -0800131 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700132 }
133
134 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700135 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800136 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700137 }
138
139 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700140 ENSURE_VALID_ENV(env);
Andreas Gampe85807442017-01-13 14:40:58 -0800141 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700142 }
143
Alex Light6a3fd512017-02-27 14:34:32 -0800144 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700145 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800146 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700147 return ERR(NOT_IMPLEMENTED);
148 }
149
150 static jvmtiError SuspendThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800151 jint request_count ATTRIBUTE_UNUSED,
152 const jthread* request_list ATTRIBUTE_UNUSED,
153 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700154 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800155 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700156 return ERR(NOT_IMPLEMENTED);
157 }
158
Alex Light6a3fd512017-02-27 14:34:32 -0800159 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700160 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800161 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700162 return ERR(NOT_IMPLEMENTED);
163 }
164
165 static jvmtiError ResumeThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800166 jint request_count ATTRIBUTE_UNUSED,
167 const jthread* request_list ATTRIBUTE_UNUSED,
168 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700169 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800170 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700171 return ERR(NOT_IMPLEMENTED);
172 }
173
Alex Light6a3fd512017-02-27 14:34:32 -0800174 static jvmtiError StopThread(jvmtiEnv* env,
175 jthread thread ATTRIBUTE_UNUSED,
176 jobject exception ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700177 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800178 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700179 return ERR(NOT_IMPLEMENTED);
180 }
181
Alex Light6a3fd512017-02-27 14:34:32 -0800182 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700183 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800184 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700185 return ERR(NOT_IMPLEMENTED);
186 }
187
188 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700189 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800190 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700191 }
192
193 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800194 jthread thread ATTRIBUTE_UNUSED,
195 jint* owned_monitor_count_ptr ATTRIBUTE_UNUSED,
196 jobject** owned_monitors_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700197 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800198 ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700199 return ERR(NOT_IMPLEMENTED);
200 }
201
Alex Light6a3fd512017-02-27 14:34:32 -0800202 static jvmtiError GetOwnedMonitorStackDepthInfo(
203 jvmtiEnv* env,
204 jthread thread ATTRIBUTE_UNUSED,
205 jint* monitor_info_count_ptr ATTRIBUTE_UNUSED,
206 jvmtiMonitorStackDepthInfo** monitor_info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700207 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800208 ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
Alex Light49948e92016-08-11 15:35:28 -0700209 return ERR(NOT_IMPLEMENTED);
210 }
211
212 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800213 jthread thread ATTRIBUTE_UNUSED,
214 jobject* monitor_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700215 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800216 ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
Alex Lighte6574242016-08-17 09:56:24 -0700217 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700218 }
219
220 static jvmtiError RunAgentThread(jvmtiEnv* env,
221 jthread thread,
222 jvmtiStartFunction proc,
223 const void* arg,
224 jint priority) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700225 ENSURE_VALID_ENV(env);
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800226 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700227 }
228
229 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700230 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800231 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700232 }
233
234 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700235 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800236 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700237 }
238
239 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
240 jint* group_count_ptr,
241 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700242 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000243 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700244 }
245
246 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
247 jthreadGroup group,
248 jvmtiThreadGroupInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700249 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000250 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700251 }
252
253 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
254 jthreadGroup group,
255 jint* thread_count_ptr,
256 jthread** threads_ptr,
257 jint* group_count_ptr,
258 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700259 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000260 return ThreadGroupUtil::GetThreadGroupChildren(env,
261 group,
262 thread_count_ptr,
263 threads_ptr,
264 group_count_ptr,
265 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700266 }
267
268 static jvmtiError GetStackTrace(jvmtiEnv* env,
269 jthread thread,
270 jint start_depth,
271 jint max_frame_count,
272 jvmtiFrameInfo* frame_buffer,
273 jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700274 ENSURE_VALID_ENV(env);
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700275 return StackUtil::GetStackTrace(env,
276 thread,
277 start_depth,
278 max_frame_count,
279 frame_buffer,
280 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700281 }
282
283 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
284 jint max_frame_count,
285 jvmtiStackInfo** stack_info_ptr,
286 jint* thread_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700287 ENSURE_VALID_ENV(env);
Andreas Gampea1a27c62017-01-11 16:37:16 -0800288 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700289 }
290
291 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
292 jint thread_count,
293 const jthread* thread_list,
294 jint max_frame_count,
295 jvmtiStackInfo** stack_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700296 ENSURE_VALID_ENV(env);
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800297 return StackUtil::GetThreadListStackTraces(env,
298 thread_count,
299 thread_list,
300 max_frame_count,
301 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700302 }
303
304 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700305 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800306 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700307 }
308
Alex Light6a3fd512017-02-27 14:34:32 -0800309 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700310 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800311 ENSURE_HAS_CAP(env, can_pop_frame);
Alex Light49948e92016-08-11 15:35:28 -0700312 return ERR(NOT_IMPLEMENTED);
313 }
314
315 static jvmtiError GetFrameLocation(jvmtiEnv* env,
316 jthread thread,
317 jint depth,
318 jmethodID* method_ptr,
319 jlocation* location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700320 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800321 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700322 }
323
Alex Light6a3fd512017-02-27 14:34:32 -0800324 static jvmtiError NotifyFramePop(jvmtiEnv* env,
325 jthread thread ATTRIBUTE_UNUSED,
326 jint depth ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700327 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800328 ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
Alex Light49948e92016-08-11 15:35:28 -0700329 return ERR(NOT_IMPLEMENTED);
330 }
331
Alex Light6a3fd512017-02-27 14:34:32 -0800332 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env,
333 jthread thread ATTRIBUTE_UNUSED,
334 jobject value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700335 ENSURE_VALID_ENV(env);
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
Alex Light6a3fd512017-02-27 14:34:32 -0800340 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env,
341 jthread thread ATTRIBUTE_UNUSED,
342 jint value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700343 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800344 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700345 return ERR(NOT_IMPLEMENTED);
346 }
347
Alex Light6a3fd512017-02-27 14:34:32 -0800348 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env,
349 jthread thread ATTRIBUTE_UNUSED,
350 jlong value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700351 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800352 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700353 return ERR(NOT_IMPLEMENTED);
354 }
355
Alex Light6a3fd512017-02-27 14:34:32 -0800356 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env,
357 jthread thread ATTRIBUTE_UNUSED,
358 jfloat value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700359 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800360 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700361 return ERR(NOT_IMPLEMENTED);
362 }
363
Alex Light6a3fd512017-02-27 14:34:32 -0800364 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env,
365 jthread thread ATTRIBUTE_UNUSED,
366 jdouble value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700367 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800368 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700369 return ERR(NOT_IMPLEMENTED);
370 }
371
Alex Light6a3fd512017-02-27 14:34:32 -0800372 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700373 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800374 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700375 return ERR(NOT_IMPLEMENTED);
376 }
377
378 static jvmtiError FollowReferences(jvmtiEnv* env,
379 jint heap_filter,
380 jclass klass,
381 jobject initial_object,
382 const jvmtiHeapCallbacks* callbacks,
383 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700384 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800385 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800386 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700387 return heap_util.FollowReferences(env,
388 heap_filter,
389 klass,
390 initial_object,
391 callbacks,
392 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700393 }
394
395 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
396 jint heap_filter,
397 jclass klass,
398 const jvmtiHeapCallbacks* callbacks,
399 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700400 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700401 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800402 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampee54d9922016-10-11 19:55:37 -0700403 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700404 }
405
406 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700407 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700408 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700409
410 JNIEnv* jni_env = GetJniEnv(env);
411 if (jni_env == nullptr) {
412 return ERR(INTERNAL);
413 }
414
415 art::ScopedObjectAccess soa(jni_env);
416 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800417 if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700418 *tag_ptr = 0;
419 }
420
421 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700422 }
423
424 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700425 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700426 ENSURE_HAS_CAP(env, can_tag_objects);
427
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700428 if (object == nullptr) {
429 return ERR(NULL_POINTER);
430 }
431
432 JNIEnv* jni_env = GetJniEnv(env);
433 if (jni_env == nullptr) {
434 return ERR(INTERNAL);
435 }
436
437 art::ScopedObjectAccess soa(jni_env);
438 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800439 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700440
441 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700442 }
443
444 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
445 jint tag_count,
446 const jlong* tags,
447 jint* count_ptr,
448 jobject** object_result_ptr,
449 jlong** tag_result_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700450 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700451 ENSURE_HAS_CAP(env, can_tag_objects);
452
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700453 JNIEnv* jni_env = GetJniEnv(env);
454 if (jni_env == nullptr) {
455 return ERR(INTERNAL);
456 }
457
458 art::ScopedObjectAccess soa(jni_env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800459 return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
460 tag_count,
461 tags,
462 count_ptr,
463 object_result_ptr,
464 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700465 }
466
467 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700468 ENSURE_VALID_ENV(env);
Andreas Gampe8da6d032016-10-31 19:31:03 -0700469 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700470 }
471
472 static jvmtiError IterateOverObjectsReachableFromObject(
473 jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800474 jobject object ATTRIBUTE_UNUSED,
475 jvmtiObjectReferenceCallback object_reference_callback ATTRIBUTE_UNUSED,
476 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700477 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800478 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700479 return ERR(NOT_IMPLEMENTED);
480 }
481
Alex Light6a3fd512017-02-27 14:34:32 -0800482 static jvmtiError IterateOverReachableObjects(
483 jvmtiEnv* env,
484 jvmtiHeapRootCallback heap_root_callback ATTRIBUTE_UNUSED,
485 jvmtiStackReferenceCallback stack_ref_callback ATTRIBUTE_UNUSED,
486 jvmtiObjectReferenceCallback object_ref_callback ATTRIBUTE_UNUSED,
487 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700488 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800489 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700490 return ERR(NOT_IMPLEMENTED);
491 }
492
493 static jvmtiError IterateOverHeap(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800494 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
495 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
496 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700497 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800498 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700499 return ERR(NOT_IMPLEMENTED);
500 }
501
Alex Light6a3fd512017-02-27 14:34:32 -0800502 static jvmtiError IterateOverInstancesOfClass(
503 jvmtiEnv* env,
504 jclass klass ATTRIBUTE_UNUSED,
505 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
506 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
507 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700508 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800509 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700510 return ERR(NOT_IMPLEMENTED);
511 }
512
513 static jvmtiError GetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800514 jthread thread ATTRIBUTE_UNUSED,
515 jint depth ATTRIBUTE_UNUSED,
516 jint slot ATTRIBUTE_UNUSED,
517 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700518 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800519 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700520 return ERR(NOT_IMPLEMENTED);
521 }
522
523 static jvmtiError GetLocalInstance(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800524 jthread thread ATTRIBUTE_UNUSED,
525 jint depth ATTRIBUTE_UNUSED,
526 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700527 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800528 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700529 return ERR(NOT_IMPLEMENTED);
530 }
531
532 static jvmtiError GetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800533 jthread thread ATTRIBUTE_UNUSED,
534 jint depth ATTRIBUTE_UNUSED,
535 jint slot ATTRIBUTE_UNUSED,
536 jint* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700537 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800538 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700539 return ERR(NOT_IMPLEMENTED);
540 }
541
542 static jvmtiError GetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800543 jthread thread ATTRIBUTE_UNUSED,
544 jint depth ATTRIBUTE_UNUSED,
545 jint slot ATTRIBUTE_UNUSED,
546 jlong* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700547 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800548 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700549 return ERR(NOT_IMPLEMENTED);
550 }
551
552 static jvmtiError GetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800553 jthread thread ATTRIBUTE_UNUSED,
554 jint depth ATTRIBUTE_UNUSED,
555 jint slot ATTRIBUTE_UNUSED,
556 jfloat* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700557 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800558 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700559 return ERR(NOT_IMPLEMENTED);
560 }
561
562 static jvmtiError GetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800563 jthread thread ATTRIBUTE_UNUSED,
564 jint depth ATTRIBUTE_UNUSED,
565 jint slot ATTRIBUTE_UNUSED,
566 jdouble* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700567 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800568 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700569 return ERR(NOT_IMPLEMENTED);
570 }
571
572 static jvmtiError SetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800573 jthread thread ATTRIBUTE_UNUSED,
574 jint depth ATTRIBUTE_UNUSED,
575 jint slot ATTRIBUTE_UNUSED,
576 jobject value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700577 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800578 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700579 return ERR(NOT_IMPLEMENTED);
580 }
581
582 static jvmtiError SetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800583 jthread thread ATTRIBUTE_UNUSED,
584 jint depth ATTRIBUTE_UNUSED,
585 jint slot ATTRIBUTE_UNUSED,
586 jint value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700587 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800588 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700589 return ERR(NOT_IMPLEMENTED);
590 }
591
592 static jvmtiError SetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800593 jthread thread ATTRIBUTE_UNUSED,
594 jint depth ATTRIBUTE_UNUSED,
595 jint slot ATTRIBUTE_UNUSED,
596 jlong value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700597 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800598 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700599 return ERR(NOT_IMPLEMENTED);
600 }
601
602 static jvmtiError SetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800603 jthread thread ATTRIBUTE_UNUSED,
604 jint depth ATTRIBUTE_UNUSED,
605 jint slot ATTRIBUTE_UNUSED,
606 jfloat value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700607 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800608 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700609 return ERR(NOT_IMPLEMENTED);
610 }
611
612 static jvmtiError SetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800613 jthread thread ATTRIBUTE_UNUSED,
614 jint depth ATTRIBUTE_UNUSED,
615 jint slot ATTRIBUTE_UNUSED,
616 jdouble value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700617 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800618 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700619 return ERR(NOT_IMPLEMENTED);
620 }
621
Alex Light6a3fd512017-02-27 14:34:32 -0800622 static jvmtiError SetBreakpoint(jvmtiEnv* env,
623 jmethodID method ATTRIBUTE_UNUSED,
624 jlocation location ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700625 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800626 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Light49948e92016-08-11 15:35:28 -0700627 return ERR(NOT_IMPLEMENTED);
628 }
629
Alex Light6a3fd512017-02-27 14:34:32 -0800630 static jvmtiError ClearBreakpoint(jvmtiEnv* env,
631 jmethodID method ATTRIBUTE_UNUSED,
632 jlocation location ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700633 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800634 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Light49948e92016-08-11 15:35:28 -0700635 return ERR(NOT_IMPLEMENTED);
636 }
637
Alex Light084fa372017-06-16 08:58:34 -0700638 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700639 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800640 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700641 return FieldUtil::SetFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700642 }
643
Alex Light084fa372017-06-16 08:58:34 -0700644 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700645 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800646 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700647 return FieldUtil::ClearFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700648 }
649
Alex Light084fa372017-06-16 08:58:34 -0700650 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700651 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800652 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700653 return FieldUtil::SetFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700654 }
655
Alex Light084fa372017-06-16 08:58:34 -0700656 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700657 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800658 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700659 return FieldUtil::ClearFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700660 }
661
662 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700663 ENSURE_VALID_ENV(env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800664 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700665 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700666 }
667
668 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
669 jobject initiating_loader,
670 jint* class_count_ptr,
671 jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700672 ENSURE_VALID_ENV(env);
Andreas Gampe70f16392017-01-16 14:20:10 -0800673 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700674 }
675
676 static jvmtiError GetClassSignature(jvmtiEnv* env,
677 jclass klass,
678 char** signature_ptr,
679 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700680 ENSURE_VALID_ENV(env);
Andreas Gampee492ae32016-10-28 19:34:57 -0700681 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700682 }
683
684 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700685 ENSURE_VALID_ENV(env);
Andreas Gampeff9d2092017-01-06 09:12:49 -0800686 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700687 }
688
Alex Light6fa7b812017-06-16 09:04:29 -0700689 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700690 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800691 ENSURE_HAS_CAP(env, can_get_source_file_name);
Alex Light6fa7b812017-06-16 09:04:29 -0700692 return ClassUtil::GetSourceFileName(env, klass, source_name_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700693 }
694
695 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700696 ENSURE_VALID_ENV(env);
Andreas Gampe64013e52017-01-06 13:07:19 -0800697 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700698 }
699
700 static jvmtiError GetClassMethods(jvmtiEnv* env,
701 jclass klass,
702 jint* method_count_ptr,
703 jmethodID** methods_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700704 ENSURE_VALID_ENV(env);
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800705 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700706 }
707
708 static jvmtiError GetClassFields(jvmtiEnv* env,
709 jclass klass,
710 jint* field_count_ptr,
711 jfieldID** fields_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700712 ENSURE_VALID_ENV(env);
Andreas Gampeac587272017-01-05 15:21:34 -0800713 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700714 }
715
716 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
717 jclass klass,
718 jint* interface_count_ptr,
719 jclass** interfaces_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700720 ENSURE_VALID_ENV(env);
Andreas Gampe8b07e472017-01-06 14:20:39 -0800721 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700722 }
723
724 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
725 jclass klass,
726 jint* minor_version_ptr,
727 jint* major_version_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700728 ENSURE_VALID_ENV(env);
Andreas Gampe812a2442017-01-19 22:04:46 -0800729 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700730 }
731
732 static jvmtiError GetConstantPool(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800733 jclass klass ATTRIBUTE_UNUSED,
734 jint* constant_pool_count_ptr ATTRIBUTE_UNUSED,
735 jint* constant_pool_byte_count_ptr ATTRIBUTE_UNUSED,
736 unsigned char** constant_pool_bytes_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700737 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800738 ENSURE_HAS_CAP(env, can_get_constant_pool);
Alex Light49948e92016-08-11 15:35:28 -0700739 return ERR(NOT_IMPLEMENTED);
740 }
741
742 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700743 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800744 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700745 }
746
747 static jvmtiError IsArrayClass(jvmtiEnv* env,
748 jclass klass,
749 jboolean* is_array_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700750 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800751 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700752 }
753
754 static jvmtiError IsModifiableClass(jvmtiEnv* env,
755 jclass klass,
756 jboolean* is_modifiable_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700757 ENSURE_VALID_ENV(env);
Alex Lighte4a88632017-01-10 07:41:24 -0800758 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700759 }
760
761 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700762 ENSURE_VALID_ENV(env);
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800763 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700764 }
765
766 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
Alex Light6fa7b812017-06-16 09:04:29 -0700767 jclass klass,
768 char** source_debug_extension_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700769 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800770 ENSURE_HAS_CAP(env, can_get_source_debug_extension);
Alex Light6fa7b812017-06-16 09:04:29 -0700771 return ClassUtil::GetSourceDebugExtension(env, klass, source_debug_extension_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700772 }
773
774 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700775 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800776 ENSURE_HAS_CAP(env, can_retransform_classes);
Alex Light6ac57502017-01-19 15:05:06 -0800777 std::string error_msg;
778 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800779 &gEventHandler,
Alex Light6ac57502017-01-19 15:05:06 -0800780 art::Runtime::Current(),
781 art::Thread::Current(),
782 class_count,
783 classes,
784 &error_msg);
785 if (res != OK) {
786 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
787 }
788 return res;
Alex Light49948e92016-08-11 15:35:28 -0700789 }
790
791 static jvmtiError RedefineClasses(jvmtiEnv* env,
792 jint class_count,
793 const jvmtiClassDefinition* class_definitions) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700794 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800795 ENSURE_HAS_CAP(env, can_redefine_classes);
Alex Light0e692732017-01-10 15:00:05 -0800796 std::string error_msg;
797 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800798 &gEventHandler,
Alex Light0e692732017-01-10 15:00:05 -0800799 art::Runtime::Current(),
800 art::Thread::Current(),
801 class_count,
802 class_definitions,
803 &error_msg);
804 if (res != OK) {
805 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
806 }
807 return res;
Alex Light49948e92016-08-11 15:35:28 -0700808 }
809
810 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700811 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800812 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700813 }
814
815 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700816 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800817 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700818 }
819
820 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800821 jobject object ATTRIBUTE_UNUSED,
822 jvmtiMonitorUsage* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700823 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800824 ENSURE_HAS_CAP(env, can_get_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700825 return ERR(NOT_IMPLEMENTED);
826 }
827
828 static jvmtiError GetFieldName(jvmtiEnv* env,
829 jclass klass,
830 jfieldID field,
831 char** name_ptr,
832 char** signature_ptr,
833 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700834 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800835 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700836 }
837
838 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
839 jclass klass,
840 jfieldID field,
841 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700842 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800843 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700844 }
845
846 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
847 jclass klass,
848 jfieldID field,
849 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700850 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800851 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700852 }
853
854 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
855 jclass klass,
856 jfieldID field,
857 jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700858 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800859 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800860 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700861 }
862
863 static jvmtiError GetMethodName(jvmtiEnv* env,
864 jmethodID method,
865 char** name_ptr,
866 char** signature_ptr,
867 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700868 ENSURE_VALID_ENV(env);
Andreas Gampe3c252f02016-10-27 18:25:17 -0700869 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700870 }
871
872 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
873 jmethodID method,
874 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700875 ENSURE_VALID_ENV(env);
Andreas Gampe368a2082016-10-28 17:33:13 -0700876 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700877 }
878
879 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
880 jmethodID method,
881 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700882 ENSURE_VALID_ENV(env);
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700883 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700884 }
885
886 static jvmtiError GetMaxLocals(jvmtiEnv* env,
887 jmethodID method,
888 jint* max_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700889 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800890 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700891 }
892
893 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
894 jmethodID method,
895 jint* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700896 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800897 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700898 }
899
900 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
901 jmethodID method,
902 jint* entry_count_ptr,
903 jvmtiLineNumberEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700904 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800905 ENSURE_HAS_CAP(env, can_get_line_numbers);
Andreas Gampeda3e5612016-12-13 19:00:53 -0800906 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700907 }
908
909 static jvmtiError GetMethodLocation(jvmtiEnv* env,
910 jmethodID method,
911 jlocation* start_location_ptr,
912 jlocation* end_location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700913 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800914 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700915 }
916
917 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800918 jmethodID method ATTRIBUTE_UNUSED,
919 jint* entry_count_ptr ATTRIBUTE_UNUSED,
920 jvmtiLocalVariableEntry** table_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700921 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800922 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700923 return ERR(NOT_IMPLEMENTED);
924 }
925
926 static jvmtiError GetBytecodes(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800927 jmethodID method ATTRIBUTE_UNUSED,
928 jint* bytecode_count_ptr ATTRIBUTE_UNUSED,
929 unsigned char** bytecodes_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700930 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800931 ENSURE_HAS_CAP(env, can_get_bytecodes);
Alex Light49948e92016-08-11 15:35:28 -0700932 return ERR(NOT_IMPLEMENTED);
933 }
934
935 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700936 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800937 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700938 }
939
940 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700941 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800942 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampefdeef522017-01-09 14:40:25 -0800943 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700944 }
945
946 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700947 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800948 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700949 }
950
Alex Light6a3fd512017-02-27 14:34:32 -0800951 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700952 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800953 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700954 return ERR(NOT_IMPLEMENTED);
955 }
956
Alex Light6a3fd512017-02-27 14:34:32 -0800957 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
958 jint prefix_count ATTRIBUTE_UNUSED,
959 char** prefixes ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700960 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800961 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700962 return ERR(NOT_IMPLEMENTED);
963 }
964
965 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700966 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800967 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700968 }
969
970 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700971 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800972 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700973 }
974
975 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700976 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800977 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700978 }
979
980 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700981 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800982 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700983 }
984
985 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700986 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800987 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700988 }
989
990 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700991 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800992 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700993 }
994
995 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700996 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800997 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700998 }
999
1000 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001001 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -08001002 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -07001003 }
1004
1005 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001006 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -08001007 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -07001008 }
1009
Andreas Gampe77708d92016-10-07 11:48:21 -07001010 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
1011 // an event.
Alex Light49948e92016-08-11 15:35:28 -07001012 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
1013 const jvmtiEventCallbacks* callbacks,
1014 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -07001015 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001016 if (size_of_callbacks < 0) {
1017 return ERR(ILLEGAL_ARGUMENT);
1018 }
1019
1020 if (callbacks == nullptr) {
1021 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
1022 return ERR(NONE);
1023 }
1024
1025 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
1026 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
1027 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
1028 static_cast<size_t>(size_of_callbacks));
1029 copy_size = art::RoundDown(copy_size, sizeof(void*));
1030 memcpy(tmp.get(), callbacks, copy_size);
1031
1032 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
1033
1034 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001035 }
1036
1037 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
1038 jvmtiEventMode mode,
1039 jvmtiEvent event_type,
1040 jthread event_thread,
1041 ...) {
Alex Lighte6574242016-08-17 09:56:24 -07001042 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001043 art::Thread* art_thread = nullptr;
1044 if (event_thread != nullptr) {
1045 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
1046 art::ScopedObjectAccess soa(art::Thread::Current());
1047 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
1048 art_thread = art::Thread::FromManagedThread(soa, event_thread);
1049
1050 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
1051 art_thread->IsStillStarting()) {
1052 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
1053 return ERR(THREAD_NOT_ALIVE);
1054 }
1055 }
1056
Alex Light40d87f42017-01-18 10:27:06 -08001057 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1058 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -07001059 }
1060
Alex Light1edc8cf2017-03-24 14:22:56 -07001061 static jvmtiError GenerateEvents(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001062 jvmtiEvent event_type ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001063 ENSURE_VALID_ENV(env);
Alex Light6a3fd512017-02-27 14:34:32 -08001064 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001065 }
1066
Alex Light1edc8cf2017-03-24 14:22:56 -07001067 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001068 jint* extension_count_ptr,
1069 jvmtiExtensionFunctionInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001070 ENSURE_VALID_ENV(env);
Andreas Gamped73aba42017-05-03 21:40:26 -07001071 ENSURE_NON_NULL(extension_count_ptr);
1072 ENSURE_NON_NULL(extensions);
1073
1074 std::vector<jvmtiExtensionFunctionInfo> ext_vector;
1075
1076 // Holders for allocated values.
1077 std::vector<JvmtiUniquePtr<char[]>> char_buffers;
1078 std::vector<JvmtiUniquePtr<jvmtiParamInfo[]>> param_buffers;
1079 std::vector<JvmtiUniquePtr<jvmtiError[]>> error_buffers;
1080
1081 // Add a helper struct that takes an arbitrary const char*. add_extension will use Allocate
1082 // appropriately.
1083 struct CParamInfo {
1084 const char* name;
1085 jvmtiParamKind kind;
1086 jvmtiParamTypes base_type;
1087 jboolean null_ok;
1088 };
1089
1090 auto add_extension = [&](jvmtiExtensionFunction func,
1091 const char* id,
1092 const char* short_description,
1093 jint param_count,
1094 const std::vector<CParamInfo>& params,
1095 jint error_count,
1096 const std::vector<jvmtiError>& errors) {
1097 jvmtiExtensionFunctionInfo func_info;
1098 jvmtiError error;
1099
1100 func_info.func = func;
1101
1102 JvmtiUniquePtr<char[]> id_ptr = CopyString(env, id, &error);
1103 if (id_ptr == nullptr) {
1104 return error;
1105 }
1106 func_info.id = id_ptr.get();
1107 char_buffers.push_back(std::move(id_ptr));
1108
1109 JvmtiUniquePtr<char[]> descr = CopyString(env, short_description, &error);
1110 if (descr == nullptr) {
1111 return error;
1112 }
1113 func_info.short_description = descr.get();
1114 char_buffers.push_back(std::move(descr));
1115
1116 func_info.param_count = param_count;
1117 if (param_count > 0) {
1118 JvmtiUniquePtr<jvmtiParamInfo[]> params_ptr =
1119 AllocJvmtiUniquePtr<jvmtiParamInfo[]>(env, param_count, &error);
1120 if (params_ptr == nullptr) {
1121 return error;
1122 }
1123 func_info.params = params_ptr.get();
1124 param_buffers.push_back(std::move(params_ptr));
1125
1126 for (jint i = 0; i != param_count; ++i) {
1127 JvmtiUniquePtr<char[]> param_name = CopyString(env, params[i].name, &error);
1128 if (param_name == nullptr) {
1129 return error;
1130 }
1131 func_info.params[i].name = param_name.get();
1132 char_buffers.push_back(std::move(param_name));
1133
1134 func_info.params[i].kind = params[i].kind;
1135 func_info.params[i].base_type = params[i].base_type;
1136 func_info.params[i].null_ok = params[i].null_ok;
1137 }
1138 } else {
1139 func_info.params = nullptr;
1140 }
1141
1142 func_info.error_count = error_count;
1143 if (error_count > 0) {
1144 JvmtiUniquePtr<jvmtiError[]> errors_ptr =
1145 AllocJvmtiUniquePtr<jvmtiError[]>(env, error_count, &error);
1146 if (errors_ptr == nullptr) {
1147 return error;
1148 }
1149 func_info.errors = errors_ptr.get();
1150 error_buffers.push_back(std::move(errors_ptr));
1151
1152 for (jint i = 0; i != error_count; ++i) {
1153 func_info.errors[i] = errors[i];
1154 }
1155 } else {
1156 func_info.errors = nullptr;
1157 }
1158
1159 ext_vector.push_back(func_info);
1160
1161 return ERR(NONE);
1162 };
1163
1164 jvmtiError error;
1165
1166 // Heap extensions.
1167 error = add_extension(
1168 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetObjectHeapId),
1169 "com.android.art.heap.get_object_heap_id",
1170 "Retrieve the heap id of the the object tagged with the given argument. An "
1171 "arbitrary object is chosen if multiple objects exist with the same tag.",
1172 2,
1173 { // NOLINT [whitespace/braces] [4]
1174 { "tag", JVMTI_KIND_IN, JVMTI_TYPE_JLONG, false},
1175 { "heap_id", JVMTI_KIND_OUT, JVMTI_TYPE_JINT, false}
1176 },
1177 1,
1178 { JVMTI_ERROR_NOT_FOUND });
1179 if (error != ERR(NONE)) {
1180 return error;
1181 }
1182
1183 error = add_extension(
1184 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetHeapName),
1185 "com.android.art.heap.get_heap_name",
1186 "Retrieve the name of the heap with the given id.",
1187 2,
1188 { // NOLINT [whitespace/braces] [4]
1189 { "heap_id", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1190 { "heap_name", JVMTI_KIND_ALLOC_BUF, JVMTI_TYPE_CCHAR, false}
1191 },
1192 1,
1193 { JVMTI_ERROR_ILLEGAL_ARGUMENT });
1194 if (error != ERR(NONE)) {
1195 return error;
1196 }
1197
Andreas Gampe2eb25e42017-05-09 17:14:58 -07001198 error = add_extension(
1199 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::IterateThroughHeapExt),
1200 "com.android.art.heap.iterate_through_heap_ext",
1201 "Iterate through a heap. This is equivalent to the standard IterateThroughHeap function,"
1202 " except for additionally passing the heap id of the current object. The jvmtiHeapCallbacks"
1203 " structure is reused, with the callbacks field overloaded to a signature of "
1204 "jint (*)(jlong, jlong, jlong*, jint length, void*, jint).",
1205 4,
1206 { // NOLINT [whitespace/braces] [4]
1207 { "heap_filter", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1208 { "klass", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, true},
1209 { "callbacks", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, false},
1210 { "user_data", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, true}
1211 },
1212 3,
1213 { // NOLINT [whitespace/braces] [4]
1214 JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
1215 JVMTI_ERROR_INVALID_CLASS,
1216 JVMTI_ERROR_NULL_POINTER
1217 });
1218 if (error != ERR(NONE)) {
1219 return error;
1220 }
1221
Andreas Gamped73aba42017-05-03 21:40:26 -07001222 // Copy into output buffer.
1223
1224 *extension_count_ptr = ext_vector.size();
1225 JvmtiUniquePtr<jvmtiExtensionFunctionInfo[]> out_data =
1226 AllocJvmtiUniquePtr<jvmtiExtensionFunctionInfo[]>(env, ext_vector.size(), &error);
1227 if (out_data == nullptr) {
1228 return error;
1229 }
1230 memcpy(out_data.get(),
1231 ext_vector.data(),
1232 ext_vector.size() * sizeof(jvmtiExtensionFunctionInfo));
1233 *extensions = out_data.release();
1234
1235 // Release all the buffer holders, we're OK now.
1236 for (auto& holder : char_buffers) {
1237 holder.release();
1238 }
1239 for (auto& holder : param_buffers) {
1240 holder.release();
1241 }
1242 for (auto& holder : error_buffers) {
1243 holder.release();
1244 }
Andreas Gampee4c33842017-01-09 10:50:17 -08001245
1246 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001247 }
1248
Alex Light1edc8cf2017-03-24 14:22:56 -07001249 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001250 jint* extension_count_ptr,
1251 jvmtiExtensionEventInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001252 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001253 // We do not have any extension events.
1254 *extension_count_ptr = 0;
1255 *extensions = nullptr;
1256
1257 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001258 }
1259
Alex Light1edc8cf2017-03-24 14:22:56 -07001260 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001261 jint extension_event_index ATTRIBUTE_UNUSED,
1262 jvmtiExtensionEvent callback ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001263 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001264 // We do not have any extension events, so any call is illegal.
1265 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001266 }
1267
1268 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001269 ENSURE_VALID_ENV(env);
1270 ENSURE_NON_NULL(capabilities_ptr);
1271 *capabilities_ptr = kPotentialCapabilities;
1272 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001273 }
1274
1275 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001276 ENSURE_VALID_ENV(env);
1277 ENSURE_NON_NULL(capabilities_ptr);
1278 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1279 jvmtiError ret = OK;
Alex Light34d8e082017-03-27 09:50:36 -07001280 jvmtiCapabilities changed = {};
1281 jvmtiCapabilities potential_capabilities = {};
Alex Light1d224962017-02-27 10:26:35 -08001282 ret = env->GetPotentialCapabilities(&potential_capabilities);
1283 if (ret != OK) {
1284 return ret;
1285 }
Alex Lighte6574242016-08-17 09:56:24 -07001286#define ADD_CAPABILITY(e) \
1287 do { \
1288 if (capabilities_ptr->e == 1) { \
Alex Light1d224962017-02-27 10:26:35 -08001289 if (potential_capabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001290 if (art_env->capabilities.e != 1) { \
1291 art_env->capabilities.e = 1; \
1292 changed.e = 1; \
1293 }\
Alex Lighte6574242016-08-17 09:56:24 -07001294 } else { \
1295 ret = ERR(NOT_AVAILABLE); \
1296 } \
1297 } \
1298 } while (false)
1299
1300 ADD_CAPABILITY(can_tag_objects);
1301 ADD_CAPABILITY(can_generate_field_modification_events);
1302 ADD_CAPABILITY(can_generate_field_access_events);
1303 ADD_CAPABILITY(can_get_bytecodes);
1304 ADD_CAPABILITY(can_get_synthetic_attribute);
1305 ADD_CAPABILITY(can_get_owned_monitor_info);
1306 ADD_CAPABILITY(can_get_current_contended_monitor);
1307 ADD_CAPABILITY(can_get_monitor_info);
1308 ADD_CAPABILITY(can_pop_frame);
1309 ADD_CAPABILITY(can_redefine_classes);
1310 ADD_CAPABILITY(can_signal_thread);
1311 ADD_CAPABILITY(can_get_source_file_name);
1312 ADD_CAPABILITY(can_get_line_numbers);
1313 ADD_CAPABILITY(can_get_source_debug_extension);
1314 ADD_CAPABILITY(can_access_local_variables);
1315 ADD_CAPABILITY(can_maintain_original_method_order);
1316 ADD_CAPABILITY(can_generate_single_step_events);
1317 ADD_CAPABILITY(can_generate_exception_events);
1318 ADD_CAPABILITY(can_generate_frame_pop_events);
1319 ADD_CAPABILITY(can_generate_breakpoint_events);
1320 ADD_CAPABILITY(can_suspend);
1321 ADD_CAPABILITY(can_redefine_any_class);
1322 ADD_CAPABILITY(can_get_current_thread_cpu_time);
1323 ADD_CAPABILITY(can_get_thread_cpu_time);
1324 ADD_CAPABILITY(can_generate_method_entry_events);
1325 ADD_CAPABILITY(can_generate_method_exit_events);
1326 ADD_CAPABILITY(can_generate_all_class_hook_events);
1327 ADD_CAPABILITY(can_generate_compiled_method_load_events);
1328 ADD_CAPABILITY(can_generate_monitor_events);
1329 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
1330 ADD_CAPABILITY(can_generate_native_method_bind_events);
1331 ADD_CAPABILITY(can_generate_garbage_collection_events);
1332 ADD_CAPABILITY(can_generate_object_free_events);
1333 ADD_CAPABILITY(can_force_early_return);
1334 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1335 ADD_CAPABILITY(can_get_constant_pool);
1336 ADD_CAPABILITY(can_set_native_method_prefix);
1337 ADD_CAPABILITY(can_retransform_classes);
1338 ADD_CAPABILITY(can_retransform_any_class);
1339 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1340 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1341#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001342 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1343 changed,
1344 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -07001345 return ret;
Alex Light49948e92016-08-11 15:35:28 -07001346 }
1347
1348 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1349 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001350 ENSURE_VALID_ENV(env);
1351 ENSURE_NON_NULL(capabilities_ptr);
1352 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light34d8e082017-03-27 09:50:36 -07001353 jvmtiCapabilities changed = {};
Alex Lighte6574242016-08-17 09:56:24 -07001354#define DEL_CAPABILITY(e) \
1355 do { \
1356 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001357 if (art_env->capabilities.e == 1) { \
1358 art_env->capabilities.e = 0;\
1359 changed.e = 1; \
1360 } \
Alex Lighte6574242016-08-17 09:56:24 -07001361 } \
1362 } while (false)
1363
1364 DEL_CAPABILITY(can_tag_objects);
1365 DEL_CAPABILITY(can_generate_field_modification_events);
1366 DEL_CAPABILITY(can_generate_field_access_events);
1367 DEL_CAPABILITY(can_get_bytecodes);
1368 DEL_CAPABILITY(can_get_synthetic_attribute);
1369 DEL_CAPABILITY(can_get_owned_monitor_info);
1370 DEL_CAPABILITY(can_get_current_contended_monitor);
1371 DEL_CAPABILITY(can_get_monitor_info);
1372 DEL_CAPABILITY(can_pop_frame);
1373 DEL_CAPABILITY(can_redefine_classes);
1374 DEL_CAPABILITY(can_signal_thread);
1375 DEL_CAPABILITY(can_get_source_file_name);
1376 DEL_CAPABILITY(can_get_line_numbers);
1377 DEL_CAPABILITY(can_get_source_debug_extension);
1378 DEL_CAPABILITY(can_access_local_variables);
1379 DEL_CAPABILITY(can_maintain_original_method_order);
1380 DEL_CAPABILITY(can_generate_single_step_events);
1381 DEL_CAPABILITY(can_generate_exception_events);
1382 DEL_CAPABILITY(can_generate_frame_pop_events);
1383 DEL_CAPABILITY(can_generate_breakpoint_events);
1384 DEL_CAPABILITY(can_suspend);
1385 DEL_CAPABILITY(can_redefine_any_class);
1386 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1387 DEL_CAPABILITY(can_get_thread_cpu_time);
1388 DEL_CAPABILITY(can_generate_method_entry_events);
1389 DEL_CAPABILITY(can_generate_method_exit_events);
1390 DEL_CAPABILITY(can_generate_all_class_hook_events);
1391 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1392 DEL_CAPABILITY(can_generate_monitor_events);
1393 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1394 DEL_CAPABILITY(can_generate_native_method_bind_events);
1395 DEL_CAPABILITY(can_generate_garbage_collection_events);
1396 DEL_CAPABILITY(can_generate_object_free_events);
1397 DEL_CAPABILITY(can_force_early_return);
1398 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1399 DEL_CAPABILITY(can_get_constant_pool);
1400 DEL_CAPABILITY(can_set_native_method_prefix);
1401 DEL_CAPABILITY(can_retransform_classes);
1402 DEL_CAPABILITY(can_retransform_any_class);
1403 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1404 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1405#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001406 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1407 changed,
1408 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001409 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001410 }
1411
1412 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001413 ENSURE_VALID_ENV(env);
1414 ENSURE_NON_NULL(capabilities_ptr);
1415 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1416 *capabilities_ptr = artenv->capabilities;
1417 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001418 }
1419
Alex Light6a3fd512017-02-27 14:34:32 -08001420 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1421 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001422 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001423 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001424 return ERR(NOT_IMPLEMENTED);
1425 }
1426
Alex Light6a3fd512017-02-27 14:34:32 -08001427 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001428 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001429 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001430 return ERR(NOT_IMPLEMENTED);
1431 }
1432
Alex Light6a3fd512017-02-27 14:34:32 -08001433 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1434 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001435 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001436 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001437 return ERR(NOT_IMPLEMENTED);
1438 }
1439
Alex Light6a3fd512017-02-27 14:34:32 -08001440 static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1441 jthread thread ATTRIBUTE_UNUSED,
1442 jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001443 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001444 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001445 return ERR(NOT_IMPLEMENTED);
1446 }
1447
1448 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001449 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001450 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001451 }
1452
1453 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001454 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001455 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001456 }
1457
1458 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001459 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001460 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001461 }
1462
1463 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001464 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001465 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001466 }
1467
1468 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001469 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001470 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001471 }
1472
1473 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001474 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001475 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001476 }
1477
1478 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001479 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001480 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001481 }
1482
1483 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001484 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001485 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001486 }
1487
1488 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001489 ENSURE_VALID_ENV(env);
Andreas Gampe96eca782017-01-19 19:45:30 -08001490 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001491 }
1492
1493 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001494 ENSURE_VALID_ENV(env);
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001495 gEventHandler.RemoveArtJvmTiEnv(ArtJvmTiEnv::AsArtJvmTiEnv(env));
Andreas Gampede19eb92017-02-24 16:21:18 -08001496 art::Runtime::Current()->RemoveSystemWeakHolder(
1497 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001498 delete env;
1499 return OK;
1500 }
1501
1502 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001503 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001504 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1505 return OK;
1506 }
1507
1508 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001509 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001510 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1511 return OK;
1512 }
1513
1514 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001515 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001516 *version_ptr = JVMTI_VERSION;
1517 return OK;
1518 }
1519
1520 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001521 ENSURE_NON_NULL(name_ptr);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001522 auto copy_fn = [&](const char* name_cstr) {
1523 jvmtiError res;
1524 JvmtiUniquePtr<char[]> copy = CopyString(env, name_cstr, &res);
1525 if (copy == nullptr) {
1526 *name_ptr = nullptr;
1527 return res;
1528 } else {
1529 *name_ptr = copy.release();
1530 return OK;
1531 }
1532 };
Alex Light49948e92016-08-11 15:35:28 -07001533 switch (error) {
Andreas Gampe95c466d2017-05-08 14:50:47 -07001534#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : \
1535 return copy_fn("JVMTI_ERROR_"#e);
Alex Light49948e92016-08-11 15:35:28 -07001536 ERROR_CASE(NONE);
1537 ERROR_CASE(INVALID_THREAD);
1538 ERROR_CASE(INVALID_THREAD_GROUP);
1539 ERROR_CASE(INVALID_PRIORITY);
1540 ERROR_CASE(THREAD_NOT_SUSPENDED);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001541 ERROR_CASE(THREAD_SUSPENDED);
Alex Light49948e92016-08-11 15:35:28 -07001542 ERROR_CASE(THREAD_NOT_ALIVE);
1543 ERROR_CASE(INVALID_OBJECT);
1544 ERROR_CASE(INVALID_CLASS);
1545 ERROR_CASE(CLASS_NOT_PREPARED);
1546 ERROR_CASE(INVALID_METHODID);
1547 ERROR_CASE(INVALID_LOCATION);
1548 ERROR_CASE(INVALID_FIELDID);
1549 ERROR_CASE(NO_MORE_FRAMES);
1550 ERROR_CASE(OPAQUE_FRAME);
1551 ERROR_CASE(TYPE_MISMATCH);
1552 ERROR_CASE(INVALID_SLOT);
1553 ERROR_CASE(DUPLICATE);
1554 ERROR_CASE(NOT_FOUND);
1555 ERROR_CASE(INVALID_MONITOR);
1556 ERROR_CASE(NOT_MONITOR_OWNER);
1557 ERROR_CASE(INTERRUPT);
1558 ERROR_CASE(INVALID_CLASS_FORMAT);
1559 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1560 ERROR_CASE(FAILS_VERIFICATION);
1561 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1562 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1563 ERROR_CASE(INVALID_TYPESTATE);
1564 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1565 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1566 ERROR_CASE(UNSUPPORTED_VERSION);
1567 ERROR_CASE(NAMES_DONT_MATCH);
1568 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1569 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1570 ERROR_CASE(UNMODIFIABLE_CLASS);
1571 ERROR_CASE(NOT_AVAILABLE);
1572 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1573 ERROR_CASE(NULL_POINTER);
1574 ERROR_CASE(ABSENT_INFORMATION);
1575 ERROR_CASE(INVALID_EVENT_TYPE);
1576 ERROR_CASE(ILLEGAL_ARGUMENT);
1577 ERROR_CASE(NATIVE_METHOD);
1578 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1579 ERROR_CASE(OUT_OF_MEMORY);
1580 ERROR_CASE(ACCESS_DENIED);
1581 ERROR_CASE(WRONG_PHASE);
1582 ERROR_CASE(INTERNAL);
1583 ERROR_CASE(UNATTACHED_THREAD);
1584 ERROR_CASE(INVALID_ENVIRONMENT);
1585#undef ERROR_CASE
Alex Light49948e92016-08-11 15:35:28 -07001586 }
Andreas Gampe95c466d2017-05-08 14:50:47 -07001587
1588 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001589 }
1590
Alex Light1edc8cf2017-03-24 14:22:56 -07001591 static jvmtiError SetVerboseFlag(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001592 jvmtiVerboseFlag flag,
1593 jboolean value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001594 ENSURE_VALID_ENV(env);
Andreas Gampef37e3022017-01-13 17:54:46 -08001595 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1596 // OTHER is special, as it's 0, so can't do a bit check.
1597 bool val = (value == JNI_TRUE) ? true : false;
1598
1599 art::gLogVerbosity.collector = val;
1600 art::gLogVerbosity.compiler = val;
1601 art::gLogVerbosity.deopt = val;
1602 art::gLogVerbosity.heap = val;
1603 art::gLogVerbosity.jdwp = val;
1604 art::gLogVerbosity.jit = val;
1605 art::gLogVerbosity.monitor = val;
1606 art::gLogVerbosity.oat = val;
1607 art::gLogVerbosity.profiler = val;
1608 art::gLogVerbosity.signals = val;
1609 art::gLogVerbosity.simulator = val;
1610 art::gLogVerbosity.startup = val;
1611 art::gLogVerbosity.third_party_jni = val;
1612 art::gLogVerbosity.threads = val;
1613 art::gLogVerbosity.verifier = val;
1614 art::gLogVerbosity.image = val;
1615
1616 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1617
1618 art::gLogVerbosity.agents = val;
1619 } else {
1620 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1621 // semantics.
1622 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1623 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1624 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1625 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1626 if ((flag & ~kMask) != 0) {
1627 return ERR(ILLEGAL_ARGUMENT);
1628 }
1629
1630 bool val = (value == JNI_TRUE) ? true : false;
1631
1632 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1633 art::gLogVerbosity.gc = val;
1634 }
1635
1636 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1637 art::gLogVerbosity.class_linker = val;
1638 }
1639
1640 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1641 art::gLogVerbosity.jni = val;
1642 }
1643 }
1644
1645 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001646 }
1647
Alex Light1edc8cf2017-03-24 14:22:56 -07001648 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1649 ENSURE_VALID_ENV(env);
Andreas Gampeacfc9572017-01-17 18:36:56 -08001650 // Report BCI as jlocation format. We report dex bytecode indices.
1651 if (format_ptr == nullptr) {
1652 return ERR(NULL_POINTER);
1653 }
1654 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1655 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001656 }
1657};
1658
1659static bool IsJvmtiVersion(jint version) {
1660 return version == JVMTI_VERSION_1 ||
1661 version == JVMTI_VERSION_1_0 ||
1662 version == JVMTI_VERSION_1_1 ||
1663 version == JVMTI_VERSION_1_2 ||
1664 version == JVMTI_VERSION;
1665}
1666
Andreas Gampede19eb92017-02-24 16:21:18 -08001667extern const jvmtiInterface_1 gJvmtiInterface;
1668ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler)
1669 : art_vm(runtime),
1670 local_data(nullptr),
Andreas Gampea1705ea2017-03-28 20:12:13 -07001671 capabilities() {
1672 object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
Andreas Gampede19eb92017-02-24 16:21:18 -08001673 functions = &gJvmtiInterface;
1674}
1675
Alex Light49948e92016-08-11 15:35:28 -07001676// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1677// is a pointer to the uninitialized memory for an art::ti::Env.
1678static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
Andreas Gampede19eb92017-02-24 16:21:18 -08001679 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler);
Alex Light49948e92016-08-11 15:35:28 -07001680 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001681
1682 gEventHandler.RegisterArtJvmTiEnv(env);
Andreas Gampede19eb92017-02-24 16:21:18 -08001683
1684 art::Runtime::Current()->AddSystemWeakHolder(
1685 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001686}
1687
1688// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1689// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1690// returns false and does not modify the 'env' pointer.
1691static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1692 if (IsJvmtiVersion(version)) {
1693 CreateArtJvmTiEnv(vm, env);
1694 return JNI_OK;
1695 } else {
1696 printf("version 0x%x is not valid!", version);
1697 return JNI_EVERSION;
1698 }
1699}
1700
1701// The plugin initialization function. This adds the jvmti environment.
1702extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001703 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001704
1705 if (runtime->IsStarted()) {
1706 PhaseUtil::SetToLive();
1707 } else {
1708 PhaseUtil::SetToOnLoad();
1709 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001710 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001711 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001712 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001713 DumpUtil::Register(&gEventHandler);
Alex Lightd78ddec2017-04-18 15:20:38 -07001714 MethodUtil::Register(&gEventHandler);
Andreas Gampecefaa142017-01-23 15:04:59 -08001715 SearchUtil::Register();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001716 HeapUtil::Register();
Andreas Gampe96eca782017-01-19 19:45:30 -08001717
Andreas Gampee08a2be2016-10-06 13:13:30 -07001718 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001719
Alex Light49948e92016-08-11 15:35:28 -07001720 return true;
1721}
1722
Andreas Gampeeafaf572017-01-20 12:34:15 -08001723extern "C" bool ArtPlugin_Deinitialize() {
Alex Lightb7edcda2017-04-27 13:20:31 -07001724 gEventHandler.Shutdown();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001725 PhaseUtil::Unregister();
1726 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001727 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001728 DumpUtil::Unregister();
Alex Lightd78ddec2017-04-18 15:20:38 -07001729 MethodUtil::Unregister();
Andreas Gampecefaa142017-01-23 15:04:59 -08001730 SearchUtil::Unregister();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001731 HeapUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001732
1733 return true;
1734}
1735
Alex Light49948e92016-08-11 15:35:28 -07001736// The actual struct holding all of the entrypoints into the jvmti interface.
1737const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001738 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001739 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001740 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001741 JvmtiFunctions::GetAllThreads,
1742 JvmtiFunctions::SuspendThread,
1743 JvmtiFunctions::ResumeThread,
1744 JvmtiFunctions::StopThread,
1745 JvmtiFunctions::InterruptThread,
1746 JvmtiFunctions::GetThreadInfo,
1747 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1748 JvmtiFunctions::GetCurrentContendedMonitor,
1749 JvmtiFunctions::RunAgentThread,
1750 JvmtiFunctions::GetTopThreadGroups,
1751 JvmtiFunctions::GetThreadGroupInfo,
1752 JvmtiFunctions::GetThreadGroupChildren,
1753 JvmtiFunctions::GetFrameCount,
1754 JvmtiFunctions::GetThreadState,
1755 JvmtiFunctions::GetCurrentThread,
1756 JvmtiFunctions::GetFrameLocation,
1757 JvmtiFunctions::NotifyFramePop, // 20
1758 JvmtiFunctions::GetLocalObject,
1759 JvmtiFunctions::GetLocalInt,
1760 JvmtiFunctions::GetLocalLong,
1761 JvmtiFunctions::GetLocalFloat,
1762 JvmtiFunctions::GetLocalDouble,
1763 JvmtiFunctions::SetLocalObject,
1764 JvmtiFunctions::SetLocalInt,
1765 JvmtiFunctions::SetLocalLong,
1766 JvmtiFunctions::SetLocalFloat,
1767 JvmtiFunctions::SetLocalDouble, // 30
1768 JvmtiFunctions::CreateRawMonitor,
1769 JvmtiFunctions::DestroyRawMonitor,
1770 JvmtiFunctions::RawMonitorEnter,
1771 JvmtiFunctions::RawMonitorExit,
1772 JvmtiFunctions::RawMonitorWait,
1773 JvmtiFunctions::RawMonitorNotify,
1774 JvmtiFunctions::RawMonitorNotifyAll,
1775 JvmtiFunctions::SetBreakpoint,
1776 JvmtiFunctions::ClearBreakpoint,
1777 nullptr, // reserved40
1778 JvmtiFunctions::SetFieldAccessWatch,
1779 JvmtiFunctions::ClearFieldAccessWatch,
1780 JvmtiFunctions::SetFieldModificationWatch,
1781 JvmtiFunctions::ClearFieldModificationWatch,
1782 JvmtiFunctions::IsModifiableClass,
1783 JvmtiFunctions::Allocate,
1784 JvmtiFunctions::Deallocate,
1785 JvmtiFunctions::GetClassSignature,
1786 JvmtiFunctions::GetClassStatus,
1787 JvmtiFunctions::GetSourceFileName, // 50
1788 JvmtiFunctions::GetClassModifiers,
1789 JvmtiFunctions::GetClassMethods,
1790 JvmtiFunctions::GetClassFields,
1791 JvmtiFunctions::GetImplementedInterfaces,
1792 JvmtiFunctions::IsInterface,
1793 JvmtiFunctions::IsArrayClass,
1794 JvmtiFunctions::GetClassLoader,
1795 JvmtiFunctions::GetObjectHashCode,
1796 JvmtiFunctions::GetObjectMonitorUsage,
1797 JvmtiFunctions::GetFieldName, // 60
1798 JvmtiFunctions::GetFieldDeclaringClass,
1799 JvmtiFunctions::GetFieldModifiers,
1800 JvmtiFunctions::IsFieldSynthetic,
1801 JvmtiFunctions::GetMethodName,
1802 JvmtiFunctions::GetMethodDeclaringClass,
1803 JvmtiFunctions::GetMethodModifiers,
1804 nullptr, // reserved67
1805 JvmtiFunctions::GetMaxLocals,
1806 JvmtiFunctions::GetArgumentsSize,
1807 JvmtiFunctions::GetLineNumberTable, // 70
1808 JvmtiFunctions::GetMethodLocation,
1809 JvmtiFunctions::GetLocalVariableTable,
1810 JvmtiFunctions::SetNativeMethodPrefix,
1811 JvmtiFunctions::SetNativeMethodPrefixes,
1812 JvmtiFunctions::GetBytecodes,
1813 JvmtiFunctions::IsMethodNative,
1814 JvmtiFunctions::IsMethodSynthetic,
1815 JvmtiFunctions::GetLoadedClasses,
1816 JvmtiFunctions::GetClassLoaderClasses,
1817 JvmtiFunctions::PopFrame, // 80
1818 JvmtiFunctions::ForceEarlyReturnObject,
1819 JvmtiFunctions::ForceEarlyReturnInt,
1820 JvmtiFunctions::ForceEarlyReturnLong,
1821 JvmtiFunctions::ForceEarlyReturnFloat,
1822 JvmtiFunctions::ForceEarlyReturnDouble,
1823 JvmtiFunctions::ForceEarlyReturnVoid,
1824 JvmtiFunctions::RedefineClasses,
1825 JvmtiFunctions::GetVersionNumber,
1826 JvmtiFunctions::GetCapabilities,
1827 JvmtiFunctions::GetSourceDebugExtension, // 90
1828 JvmtiFunctions::IsMethodObsolete,
1829 JvmtiFunctions::SuspendThreadList,
1830 JvmtiFunctions::ResumeThreadList,
1831 nullptr, // reserved94
1832 nullptr, // reserved95
1833 nullptr, // reserved96
1834 nullptr, // reserved97
1835 nullptr, // reserved98
1836 nullptr, // reserved99
1837 JvmtiFunctions::GetAllStackTraces, // 100
1838 JvmtiFunctions::GetThreadListStackTraces,
1839 JvmtiFunctions::GetThreadLocalStorage,
1840 JvmtiFunctions::SetThreadLocalStorage,
1841 JvmtiFunctions::GetStackTrace,
1842 nullptr, // reserved105
1843 JvmtiFunctions::GetTag,
1844 JvmtiFunctions::SetTag,
1845 JvmtiFunctions::ForceGarbageCollection,
1846 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1847 JvmtiFunctions::IterateOverReachableObjects, // 110
1848 JvmtiFunctions::IterateOverHeap,
1849 JvmtiFunctions::IterateOverInstancesOfClass,
1850 nullptr, // reserved113
1851 JvmtiFunctions::GetObjectsWithTags,
1852 JvmtiFunctions::FollowReferences,
1853 JvmtiFunctions::IterateThroughHeap,
1854 nullptr, // reserved117
1855 nullptr, // reserved118
1856 nullptr, // reserved119
1857 JvmtiFunctions::SetJNIFunctionTable, // 120
1858 JvmtiFunctions::GetJNIFunctionTable,
1859 JvmtiFunctions::SetEventCallbacks,
1860 JvmtiFunctions::GenerateEvents,
1861 JvmtiFunctions::GetExtensionFunctions,
1862 JvmtiFunctions::GetExtensionEvents,
1863 JvmtiFunctions::SetExtensionEventCallback,
1864 JvmtiFunctions::DisposeEnvironment,
1865 JvmtiFunctions::GetErrorName,
1866 JvmtiFunctions::GetJLocationFormat,
1867 JvmtiFunctions::GetSystemProperties, // 130
1868 JvmtiFunctions::GetSystemProperty,
1869 JvmtiFunctions::SetSystemProperty,
1870 JvmtiFunctions::GetPhase,
1871 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1872 JvmtiFunctions::GetCurrentThreadCpuTime,
1873 JvmtiFunctions::GetThreadCpuTimerInfo,
1874 JvmtiFunctions::GetThreadCpuTime,
1875 JvmtiFunctions::GetTimerInfo,
1876 JvmtiFunctions::GetTime,
1877 JvmtiFunctions::GetPotentialCapabilities, // 140
1878 nullptr, // reserved141
1879 JvmtiFunctions::AddCapabilities,
1880 JvmtiFunctions::RelinquishCapabilities,
1881 JvmtiFunctions::GetAvailableProcessors,
1882 JvmtiFunctions::GetClassVersionNumbers,
1883 JvmtiFunctions::GetConstantPool,
1884 JvmtiFunctions::GetEnvironmentLocalStorage,
1885 JvmtiFunctions::SetEnvironmentLocalStorage,
1886 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1887 JvmtiFunctions::SetVerboseFlag, // 150
1888 JvmtiFunctions::AddToSystemClassLoaderSearch,
1889 JvmtiFunctions::RetransformClasses,
1890 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1891 JvmtiFunctions::GetObjectSize,
1892 JvmtiFunctions::GetLocalInstance,
1893};
1894
1895}; // namespace openjdkjvmti