blob: df870bf7aeec6a7733e427386f58013a0746a172 [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"
Alex Lighta26e3492017-06-27 17:55:37 -070051#include "ti_breakpoint.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070052#include "ti_class.h"
Andreas Gampeeb0cea12017-01-23 08:50:04 -080053#include "ti_dump.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080054#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070055#include "ti_heap.h"
Andreas Gampe6f8e4f02017-01-16 18:18:14 -080056#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070057#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080058#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080059#include "ti_object.h"
Andreas Gampe96eca782017-01-19 19:45:30 -080060#include "ti_phase.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080061#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080062#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080063#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070064#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080065#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000066#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080067#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070068#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070069
Alex Light49948e92016-08-11 15:35:28 -070070namespace openjdkjvmti {
71
Andreas Gampe77708d92016-10-07 11:48:21 -070072EventHandler gEventHandler;
Andreas Gampe6dee92e2016-09-12 19:58:13 -070073
Alex Lighte6574242016-08-17 09:56:24 -070074#define ENSURE_NON_NULL(n) \
75 do { \
76 if ((n) == nullptr) { \
77 return ERR(NULL_POINTER); \
78 } \
79 } while (false)
80
Alex Light49948e92016-08-11 15:35:28 -070081class JvmtiFunctions {
82 private:
Alex Light1edc8cf2017-03-24 14:22:56 -070083 static jvmtiError getEnvironmentError(jvmtiEnv* env) {
84 if (env == nullptr) {
85 return ERR(INVALID_ENVIRONMENT);
86 } else if (art::Thread::Current() == nullptr) {
87 return ERR(UNATTACHED_THREAD);
88 } else {
89 return OK;
90 }
Alex Light49948e92016-08-11 15:35:28 -070091 }
92
Alex Light1edc8cf2017-03-24 14:22:56 -070093#define ENSURE_VALID_ENV(env) \
94 do { \
95 jvmtiError ensure_valid_env_ ## __LINE__ = getEnvironmentError(env); \
96 if (ensure_valid_env_ ## __LINE__ != OK) { \
97 return ensure_valid_env_ ## __LINE__ ; \
98 } \
Alex Lighte6574242016-08-17 09:56:24 -070099 } while (false)
100
101#define ENSURE_HAS_CAP(env, cap) \
102 do { \
Alex Lighte6574242016-08-17 09:56:24 -0700103 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
104 return ERR(MUST_POSSESS_CAPABILITY); \
105 } \
106 } while (false)
107
Alex Light49948e92016-08-11 15:35:28 -0700108 public:
109 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700110 ENSURE_VALID_ENV(env);
111 ENSURE_NON_NULL(mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700112 if (size < 0) {
113 return ERR(ILLEGAL_ARGUMENT);
114 } else if (size == 0) {
115 *mem_ptr = nullptr;
116 return OK;
117 }
118 *mem_ptr = static_cast<unsigned char*>(malloc(size));
119 return (*mem_ptr != nullptr) ? OK : ERR(OUT_OF_MEMORY);
120 }
121
122 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700123 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -0700124 if (mem != nullptr) {
125 free(mem);
126 }
127 return OK;
128 }
129
130 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700131 ENSURE_VALID_ENV(env);
Andreas Gampe72c19832017-01-12 13:22:16 -0800132 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700133 }
134
135 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700136 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800137 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700138 }
139
140 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700141 ENSURE_VALID_ENV(env);
Andreas Gampe85807442017-01-13 14:40:58 -0800142 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700143 }
144
Alex Light6a3fd512017-02-27 14:34:32 -0800145 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700146 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800147 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700148 return ERR(NOT_IMPLEMENTED);
149 }
150
151 static jvmtiError SuspendThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800152 jint request_count ATTRIBUTE_UNUSED,
153 const jthread* request_list ATTRIBUTE_UNUSED,
154 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700155 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800156 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700157 return ERR(NOT_IMPLEMENTED);
158 }
159
Alex Light6a3fd512017-02-27 14:34:32 -0800160 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700161 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800162 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700163 return ERR(NOT_IMPLEMENTED);
164 }
165
166 static jvmtiError ResumeThreadList(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800167 jint request_count ATTRIBUTE_UNUSED,
168 const jthread* request_list ATTRIBUTE_UNUSED,
169 jvmtiError* results ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700170 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800171 ENSURE_HAS_CAP(env, can_suspend);
Alex Light49948e92016-08-11 15:35:28 -0700172 return ERR(NOT_IMPLEMENTED);
173 }
174
Alex Light6a3fd512017-02-27 14:34:32 -0800175 static jvmtiError StopThread(jvmtiEnv* env,
176 jthread thread ATTRIBUTE_UNUSED,
177 jobject exception ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700178 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800179 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700180 return ERR(NOT_IMPLEMENTED);
181 }
182
Alex Light6a3fd512017-02-27 14:34:32 -0800183 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700184 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800185 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700186 return ERR(NOT_IMPLEMENTED);
187 }
188
189 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700190 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800191 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700192 }
193
194 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800195 jthread thread ATTRIBUTE_UNUSED,
196 jint* owned_monitor_count_ptr ATTRIBUTE_UNUSED,
197 jobject** owned_monitors_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700198 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800199 ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700200 return ERR(NOT_IMPLEMENTED);
201 }
202
Alex Light6a3fd512017-02-27 14:34:32 -0800203 static jvmtiError GetOwnedMonitorStackDepthInfo(
204 jvmtiEnv* env,
205 jthread thread ATTRIBUTE_UNUSED,
206 jint* monitor_info_count_ptr ATTRIBUTE_UNUSED,
207 jvmtiMonitorStackDepthInfo** monitor_info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700208 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800209 ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
Alex Light49948e92016-08-11 15:35:28 -0700210 return ERR(NOT_IMPLEMENTED);
211 }
212
213 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800214 jthread thread ATTRIBUTE_UNUSED,
215 jobject* monitor_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700216 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800217 ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
Alex Lighte6574242016-08-17 09:56:24 -0700218 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700219 }
220
221 static jvmtiError RunAgentThread(jvmtiEnv* env,
222 jthread thread,
223 jvmtiStartFunction proc,
224 const void* arg,
225 jint priority) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700226 ENSURE_VALID_ENV(env);
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800227 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700228 }
229
230 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700231 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800232 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700233 }
234
235 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700236 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800237 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700238 }
239
240 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
241 jint* group_count_ptr,
242 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700243 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000244 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700245 }
246
247 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
248 jthreadGroup group,
249 jvmtiThreadGroupInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700250 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000251 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700252 }
253
254 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
255 jthreadGroup group,
256 jint* thread_count_ptr,
257 jthread** threads_ptr,
258 jint* group_count_ptr,
259 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700260 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000261 return ThreadGroupUtil::GetThreadGroupChildren(env,
262 group,
263 thread_count_ptr,
264 threads_ptr,
265 group_count_ptr,
266 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700267 }
268
269 static jvmtiError GetStackTrace(jvmtiEnv* env,
270 jthread thread,
271 jint start_depth,
272 jint max_frame_count,
273 jvmtiFrameInfo* frame_buffer,
274 jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700275 ENSURE_VALID_ENV(env);
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700276 return StackUtil::GetStackTrace(env,
277 thread,
278 start_depth,
279 max_frame_count,
280 frame_buffer,
281 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700282 }
283
284 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
285 jint max_frame_count,
286 jvmtiStackInfo** stack_info_ptr,
287 jint* thread_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700288 ENSURE_VALID_ENV(env);
Andreas Gampea1a27c62017-01-11 16:37:16 -0800289 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700290 }
291
292 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
293 jint thread_count,
294 const jthread* thread_list,
295 jint max_frame_count,
296 jvmtiStackInfo** stack_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700297 ENSURE_VALID_ENV(env);
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800298 return StackUtil::GetThreadListStackTraces(env,
299 thread_count,
300 thread_list,
301 max_frame_count,
302 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700303 }
304
305 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700306 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800307 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700308 }
309
Alex Light6a3fd512017-02-27 14:34:32 -0800310 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700311 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800312 ENSURE_HAS_CAP(env, can_pop_frame);
Alex Light49948e92016-08-11 15:35:28 -0700313 return ERR(NOT_IMPLEMENTED);
314 }
315
316 static jvmtiError GetFrameLocation(jvmtiEnv* env,
317 jthread thread,
318 jint depth,
319 jmethodID* method_ptr,
320 jlocation* location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700321 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800322 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700323 }
324
Alex Light6a3fd512017-02-27 14:34:32 -0800325 static jvmtiError NotifyFramePop(jvmtiEnv* env,
326 jthread thread ATTRIBUTE_UNUSED,
327 jint depth ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700328 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800329 ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
Alex Light49948e92016-08-11 15:35:28 -0700330 return ERR(NOT_IMPLEMENTED);
331 }
332
Alex Light6a3fd512017-02-27 14:34:32 -0800333 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env,
334 jthread thread ATTRIBUTE_UNUSED,
335 jobject value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700336 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800337 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700338 return ERR(NOT_IMPLEMENTED);
339 }
340
Alex Light6a3fd512017-02-27 14:34:32 -0800341 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env,
342 jthread thread ATTRIBUTE_UNUSED,
343 jint value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700344 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800345 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700346 return ERR(NOT_IMPLEMENTED);
347 }
348
Alex Light6a3fd512017-02-27 14:34:32 -0800349 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env,
350 jthread thread ATTRIBUTE_UNUSED,
351 jlong value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700352 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800353 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700354 return ERR(NOT_IMPLEMENTED);
355 }
356
Alex Light6a3fd512017-02-27 14:34:32 -0800357 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env,
358 jthread thread ATTRIBUTE_UNUSED,
359 jfloat value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700360 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800361 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700362 return ERR(NOT_IMPLEMENTED);
363 }
364
Alex Light6a3fd512017-02-27 14:34:32 -0800365 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env,
366 jthread thread ATTRIBUTE_UNUSED,
367 jdouble value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700368 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800369 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700370 return ERR(NOT_IMPLEMENTED);
371 }
372
Alex Light6a3fd512017-02-27 14:34:32 -0800373 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700374 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800375 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700376 return ERR(NOT_IMPLEMENTED);
377 }
378
379 static jvmtiError FollowReferences(jvmtiEnv* env,
380 jint heap_filter,
381 jclass klass,
382 jobject initial_object,
383 const jvmtiHeapCallbacks* callbacks,
384 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700385 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800386 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800387 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700388 return heap_util.FollowReferences(env,
389 heap_filter,
390 klass,
391 initial_object,
392 callbacks,
393 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700394 }
395
396 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
397 jint heap_filter,
398 jclass klass,
399 const jvmtiHeapCallbacks* callbacks,
400 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700401 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700402 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800403 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampee54d9922016-10-11 19:55:37 -0700404 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700405 }
406
407 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700408 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700409 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700410
411 JNIEnv* jni_env = GetJniEnv(env);
412 if (jni_env == nullptr) {
413 return ERR(INTERNAL);
414 }
415
416 art::ScopedObjectAccess soa(jni_env);
417 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800418 if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700419 *tag_ptr = 0;
420 }
421
422 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700423 }
424
425 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700426 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700427 ENSURE_HAS_CAP(env, can_tag_objects);
428
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700429 if (object == nullptr) {
430 return ERR(NULL_POINTER);
431 }
432
433 JNIEnv* jni_env = GetJniEnv(env);
434 if (jni_env == nullptr) {
435 return ERR(INTERNAL);
436 }
437
438 art::ScopedObjectAccess soa(jni_env);
439 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800440 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700441
442 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700443 }
444
445 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
446 jint tag_count,
447 const jlong* tags,
448 jint* count_ptr,
449 jobject** object_result_ptr,
450 jlong** tag_result_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700451 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700452 ENSURE_HAS_CAP(env, can_tag_objects);
453
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700454 JNIEnv* jni_env = GetJniEnv(env);
455 if (jni_env == nullptr) {
456 return ERR(INTERNAL);
457 }
458
459 art::ScopedObjectAccess soa(jni_env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800460 return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
461 tag_count,
462 tags,
463 count_ptr,
464 object_result_ptr,
465 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700466 }
467
468 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700469 ENSURE_VALID_ENV(env);
Andreas Gampe8da6d032016-10-31 19:31:03 -0700470 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700471 }
472
473 static jvmtiError IterateOverObjectsReachableFromObject(
474 jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800475 jobject object ATTRIBUTE_UNUSED,
476 jvmtiObjectReferenceCallback object_reference_callback ATTRIBUTE_UNUSED,
477 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700478 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800479 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700480 return ERR(NOT_IMPLEMENTED);
481 }
482
Alex Light6a3fd512017-02-27 14:34:32 -0800483 static jvmtiError IterateOverReachableObjects(
484 jvmtiEnv* env,
485 jvmtiHeapRootCallback heap_root_callback ATTRIBUTE_UNUSED,
486 jvmtiStackReferenceCallback stack_ref_callback ATTRIBUTE_UNUSED,
487 jvmtiObjectReferenceCallback object_ref_callback ATTRIBUTE_UNUSED,
488 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700489 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800490 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700491 return ERR(NOT_IMPLEMENTED);
492 }
493
494 static jvmtiError IterateOverHeap(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800495 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
496 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
497 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700498 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800499 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700500 return ERR(NOT_IMPLEMENTED);
501 }
502
Alex Light6a3fd512017-02-27 14:34:32 -0800503 static jvmtiError IterateOverInstancesOfClass(
504 jvmtiEnv* env,
505 jclass klass ATTRIBUTE_UNUSED,
506 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
507 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
508 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700509 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800510 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700511 return ERR(NOT_IMPLEMENTED);
512 }
513
514 static jvmtiError GetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800515 jthread thread ATTRIBUTE_UNUSED,
516 jint depth ATTRIBUTE_UNUSED,
517 jint slot ATTRIBUTE_UNUSED,
518 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700519 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800520 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700521 return ERR(NOT_IMPLEMENTED);
522 }
523
524 static jvmtiError GetLocalInstance(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800525 jthread thread ATTRIBUTE_UNUSED,
526 jint depth ATTRIBUTE_UNUSED,
527 jobject* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700528 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800529 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700530 return ERR(NOT_IMPLEMENTED);
531 }
532
533 static jvmtiError GetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800534 jthread thread ATTRIBUTE_UNUSED,
535 jint depth ATTRIBUTE_UNUSED,
536 jint slot ATTRIBUTE_UNUSED,
537 jint* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700538 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800539 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700540 return ERR(NOT_IMPLEMENTED);
541 }
542
543 static jvmtiError GetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800544 jthread thread ATTRIBUTE_UNUSED,
545 jint depth ATTRIBUTE_UNUSED,
546 jint slot ATTRIBUTE_UNUSED,
547 jlong* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700548 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800549 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700550 return ERR(NOT_IMPLEMENTED);
551 }
552
553 static jvmtiError GetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800554 jthread thread ATTRIBUTE_UNUSED,
555 jint depth ATTRIBUTE_UNUSED,
556 jint slot ATTRIBUTE_UNUSED,
557 jfloat* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700558 ENSURE_VALID_ENV(env);
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
563 static jvmtiError GetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800564 jthread thread ATTRIBUTE_UNUSED,
565 jint depth ATTRIBUTE_UNUSED,
566 jint slot ATTRIBUTE_UNUSED,
567 jdouble* value_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700568 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800569 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700570 return ERR(NOT_IMPLEMENTED);
571 }
572
573 static jvmtiError SetLocalObject(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800574 jthread thread ATTRIBUTE_UNUSED,
575 jint depth ATTRIBUTE_UNUSED,
576 jint slot ATTRIBUTE_UNUSED,
577 jobject value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700578 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800579 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700580 return ERR(NOT_IMPLEMENTED);
581 }
582
583 static jvmtiError SetLocalInt(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800584 jthread thread ATTRIBUTE_UNUSED,
585 jint depth ATTRIBUTE_UNUSED,
586 jint slot ATTRIBUTE_UNUSED,
587 jint value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700588 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800589 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700590 return ERR(NOT_IMPLEMENTED);
591 }
592
593 static jvmtiError SetLocalLong(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800594 jthread thread ATTRIBUTE_UNUSED,
595 jint depth ATTRIBUTE_UNUSED,
596 jint slot ATTRIBUTE_UNUSED,
597 jlong value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700598 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800599 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700600 return ERR(NOT_IMPLEMENTED);
601 }
602
603 static jvmtiError SetLocalFloat(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800604 jthread thread ATTRIBUTE_UNUSED,
605 jint depth ATTRIBUTE_UNUSED,
606 jint slot ATTRIBUTE_UNUSED,
607 jfloat value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700608 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800609 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700610 return ERR(NOT_IMPLEMENTED);
611 }
612
613 static jvmtiError SetLocalDouble(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800614 jthread thread ATTRIBUTE_UNUSED,
615 jint depth ATTRIBUTE_UNUSED,
616 jint slot ATTRIBUTE_UNUSED,
617 jdouble value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700618 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800619 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700620 return ERR(NOT_IMPLEMENTED);
621 }
622
Alex Lighta26e3492017-06-27 17:55:37 -0700623
624 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
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 Lighta26e3492017-06-27 17:55:37 -0700627 return BreakpointUtil::SetBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700628 }
629
Alex Lighta26e3492017-06-27 17:55:37 -0700630 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700631 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800632 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Lighta26e3492017-06-27 17:55:37 -0700633 return BreakpointUtil::ClearBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700634 }
635
Alex Light084fa372017-06-16 08:58:34 -0700636 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700637 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800638 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700639 return FieldUtil::SetFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700640 }
641
Alex Light084fa372017-06-16 08:58:34 -0700642 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700643 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800644 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700645 return FieldUtil::ClearFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700646 }
647
Alex Light084fa372017-06-16 08:58:34 -0700648 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700649 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800650 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700651 return FieldUtil::SetFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700652 }
653
Alex Light084fa372017-06-16 08:58:34 -0700654 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700655 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800656 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700657 return FieldUtil::ClearFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700658 }
659
660 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700661 ENSURE_VALID_ENV(env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800662 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700663 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700664 }
665
666 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
667 jobject initiating_loader,
668 jint* class_count_ptr,
669 jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700670 ENSURE_VALID_ENV(env);
Andreas Gampe70f16392017-01-16 14:20:10 -0800671 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700672 }
673
674 static jvmtiError GetClassSignature(jvmtiEnv* env,
675 jclass klass,
676 char** signature_ptr,
677 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700678 ENSURE_VALID_ENV(env);
Andreas Gampee492ae32016-10-28 19:34:57 -0700679 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700680 }
681
682 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700683 ENSURE_VALID_ENV(env);
Andreas Gampeff9d2092017-01-06 09:12:49 -0800684 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700685 }
686
Alex Light6fa7b812017-06-16 09:04:29 -0700687 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700688 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800689 ENSURE_HAS_CAP(env, can_get_source_file_name);
Alex Light6fa7b812017-06-16 09:04:29 -0700690 return ClassUtil::GetSourceFileName(env, klass, source_name_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700691 }
692
693 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700694 ENSURE_VALID_ENV(env);
Andreas Gampe64013e52017-01-06 13:07:19 -0800695 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700696 }
697
698 static jvmtiError GetClassMethods(jvmtiEnv* env,
699 jclass klass,
700 jint* method_count_ptr,
701 jmethodID** methods_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700702 ENSURE_VALID_ENV(env);
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800703 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700704 }
705
706 static jvmtiError GetClassFields(jvmtiEnv* env,
707 jclass klass,
708 jint* field_count_ptr,
709 jfieldID** fields_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700710 ENSURE_VALID_ENV(env);
Andreas Gampeac587272017-01-05 15:21:34 -0800711 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700712 }
713
714 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
715 jclass klass,
716 jint* interface_count_ptr,
717 jclass** interfaces_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700718 ENSURE_VALID_ENV(env);
Andreas Gampe8b07e472017-01-06 14:20:39 -0800719 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700720 }
721
722 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
723 jclass klass,
724 jint* minor_version_ptr,
725 jint* major_version_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700726 ENSURE_VALID_ENV(env);
Andreas Gampe812a2442017-01-19 22:04:46 -0800727 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700728 }
729
730 static jvmtiError GetConstantPool(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800731 jclass klass ATTRIBUTE_UNUSED,
732 jint* constant_pool_count_ptr ATTRIBUTE_UNUSED,
733 jint* constant_pool_byte_count_ptr ATTRIBUTE_UNUSED,
734 unsigned char** constant_pool_bytes_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700735 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800736 ENSURE_HAS_CAP(env, can_get_constant_pool);
Alex Light49948e92016-08-11 15:35:28 -0700737 return ERR(NOT_IMPLEMENTED);
738 }
739
740 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700741 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800742 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700743 }
744
745 static jvmtiError IsArrayClass(jvmtiEnv* env,
746 jclass klass,
747 jboolean* is_array_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700748 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800749 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700750 }
751
752 static jvmtiError IsModifiableClass(jvmtiEnv* env,
753 jclass klass,
754 jboolean* is_modifiable_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700755 ENSURE_VALID_ENV(env);
Alex Lighte4a88632017-01-10 07:41:24 -0800756 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700757 }
758
759 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700760 ENSURE_VALID_ENV(env);
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800761 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700762 }
763
764 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
Alex Light6fa7b812017-06-16 09:04:29 -0700765 jclass klass,
766 char** source_debug_extension_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700767 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800768 ENSURE_HAS_CAP(env, can_get_source_debug_extension);
Alex Light6fa7b812017-06-16 09:04:29 -0700769 return ClassUtil::GetSourceDebugExtension(env, klass, source_debug_extension_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700770 }
771
772 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700773 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800774 ENSURE_HAS_CAP(env, can_retransform_classes);
Alex Light6ac57502017-01-19 15:05:06 -0800775 std::string error_msg;
776 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800777 &gEventHandler,
Alex Light6ac57502017-01-19 15:05:06 -0800778 art::Runtime::Current(),
779 art::Thread::Current(),
780 class_count,
781 classes,
782 &error_msg);
783 if (res != OK) {
784 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
785 }
786 return res;
Alex Light49948e92016-08-11 15:35:28 -0700787 }
788
789 static jvmtiError RedefineClasses(jvmtiEnv* env,
790 jint class_count,
791 const jvmtiClassDefinition* class_definitions) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700792 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800793 ENSURE_HAS_CAP(env, can_redefine_classes);
Alex Light0e692732017-01-10 15:00:05 -0800794 std::string error_msg;
795 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800796 &gEventHandler,
Alex Light0e692732017-01-10 15:00:05 -0800797 art::Runtime::Current(),
798 art::Thread::Current(),
799 class_count,
800 class_definitions,
801 &error_msg);
802 if (res != OK) {
803 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
804 }
805 return res;
Alex Light49948e92016-08-11 15:35:28 -0700806 }
807
808 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700809 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800810 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700811 }
812
813 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700814 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800815 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700816 }
817
818 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800819 jobject object ATTRIBUTE_UNUSED,
820 jvmtiMonitorUsage* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700821 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800822 ENSURE_HAS_CAP(env, can_get_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700823 return ERR(NOT_IMPLEMENTED);
824 }
825
826 static jvmtiError GetFieldName(jvmtiEnv* env,
827 jclass klass,
828 jfieldID field,
829 char** name_ptr,
830 char** signature_ptr,
831 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700832 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800833 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700834 }
835
836 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
837 jclass klass,
838 jfieldID field,
839 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700840 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800841 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700842 }
843
844 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
845 jclass klass,
846 jfieldID field,
847 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700848 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800849 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700850 }
851
852 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
853 jclass klass,
854 jfieldID field,
855 jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700856 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800857 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800858 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700859 }
860
861 static jvmtiError GetMethodName(jvmtiEnv* env,
862 jmethodID method,
863 char** name_ptr,
864 char** signature_ptr,
865 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700866 ENSURE_VALID_ENV(env);
Andreas Gampe3c252f02016-10-27 18:25:17 -0700867 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700868 }
869
870 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
871 jmethodID method,
872 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700873 ENSURE_VALID_ENV(env);
Andreas Gampe368a2082016-10-28 17:33:13 -0700874 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700875 }
876
877 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
878 jmethodID method,
879 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700880 ENSURE_VALID_ENV(env);
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700881 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700882 }
883
884 static jvmtiError GetMaxLocals(jvmtiEnv* env,
885 jmethodID method,
886 jint* max_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700887 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800888 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700889 }
890
891 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
892 jmethodID method,
893 jint* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700894 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800895 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700896 }
897
898 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
899 jmethodID method,
900 jint* entry_count_ptr,
901 jvmtiLineNumberEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700902 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800903 ENSURE_HAS_CAP(env, can_get_line_numbers);
Andreas Gampeda3e5612016-12-13 19:00:53 -0800904 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700905 }
906
907 static jvmtiError GetMethodLocation(jvmtiEnv* env,
908 jmethodID method,
909 jlocation* start_location_ptr,
910 jlocation* end_location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700911 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800912 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700913 }
914
915 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800916 jmethodID method ATTRIBUTE_UNUSED,
917 jint* entry_count_ptr ATTRIBUTE_UNUSED,
918 jvmtiLocalVariableEntry** table_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700919 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800920 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Light49948e92016-08-11 15:35:28 -0700921 return ERR(NOT_IMPLEMENTED);
922 }
923
924 static jvmtiError GetBytecodes(jvmtiEnv* env,
Alex Light4c174282017-07-05 10:18:18 -0700925 jmethodID method,
926 jint* bytecode_count_ptr,
927 unsigned char** bytecodes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700928 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800929 ENSURE_HAS_CAP(env, can_get_bytecodes);
Alex Light4c174282017-07-05 10:18:18 -0700930 return MethodUtil::GetBytecodes(env, method, bytecode_count_ptr, bytecodes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700931 }
932
933 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700934 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800935 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700936 }
937
938 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700939 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800940 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampefdeef522017-01-09 14:40:25 -0800941 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700942 }
943
944 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700945 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800946 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700947 }
948
Alex Light6a3fd512017-02-27 14:34:32 -0800949 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700950 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800951 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700952 return ERR(NOT_IMPLEMENTED);
953 }
954
Alex Light6a3fd512017-02-27 14:34:32 -0800955 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
956 jint prefix_count ATTRIBUTE_UNUSED,
957 char** prefixes ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700958 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800959 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700960 return ERR(NOT_IMPLEMENTED);
961 }
962
963 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700964 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800965 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700966 }
967
968 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700969 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800970 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700971 }
972
973 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700974 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800975 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700976 }
977
978 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700979 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800980 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700981 }
982
983 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700984 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800985 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700986 }
987
988 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700989 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800990 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700991 }
992
993 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700994 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800995 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700996 }
997
998 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700999 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -08001000 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -07001001 }
1002
1003 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001004 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -08001005 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -07001006 }
1007
Andreas Gampe77708d92016-10-07 11:48:21 -07001008 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
1009 // an event.
Alex Light49948e92016-08-11 15:35:28 -07001010 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
1011 const jvmtiEventCallbacks* callbacks,
1012 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -07001013 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001014 if (size_of_callbacks < 0) {
1015 return ERR(ILLEGAL_ARGUMENT);
1016 }
1017
1018 if (callbacks == nullptr) {
1019 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
1020 return ERR(NONE);
1021 }
1022
1023 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
1024 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
1025 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
1026 static_cast<size_t>(size_of_callbacks));
1027 copy_size = art::RoundDown(copy_size, sizeof(void*));
1028 memcpy(tmp.get(), callbacks, copy_size);
1029
1030 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
1031
1032 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001033 }
1034
1035 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
1036 jvmtiEventMode mode,
1037 jvmtiEvent event_type,
1038 jthread event_thread,
1039 ...) {
Alex Lighte6574242016-08-17 09:56:24 -07001040 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001041 art::Thread* art_thread = nullptr;
1042 if (event_thread != nullptr) {
1043 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
1044 art::ScopedObjectAccess soa(art::Thread::Current());
1045 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
1046 art_thread = art::Thread::FromManagedThread(soa, event_thread);
1047
1048 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
1049 art_thread->IsStillStarting()) {
1050 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
1051 return ERR(THREAD_NOT_ALIVE);
1052 }
1053 }
1054
Alex Light40d87f42017-01-18 10:27:06 -08001055 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1056 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -07001057 }
1058
Alex Light1edc8cf2017-03-24 14:22:56 -07001059 static jvmtiError GenerateEvents(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001060 jvmtiEvent event_type ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001061 ENSURE_VALID_ENV(env);
Alex Light6a3fd512017-02-27 14:34:32 -08001062 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001063 }
1064
Alex Light1edc8cf2017-03-24 14:22:56 -07001065 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001066 jint* extension_count_ptr,
1067 jvmtiExtensionFunctionInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001068 ENSURE_VALID_ENV(env);
Andreas Gamped73aba42017-05-03 21:40:26 -07001069 ENSURE_NON_NULL(extension_count_ptr);
1070 ENSURE_NON_NULL(extensions);
1071
1072 std::vector<jvmtiExtensionFunctionInfo> ext_vector;
1073
1074 // Holders for allocated values.
1075 std::vector<JvmtiUniquePtr<char[]>> char_buffers;
1076 std::vector<JvmtiUniquePtr<jvmtiParamInfo[]>> param_buffers;
1077 std::vector<JvmtiUniquePtr<jvmtiError[]>> error_buffers;
1078
1079 // Add a helper struct that takes an arbitrary const char*. add_extension will use Allocate
1080 // appropriately.
1081 struct CParamInfo {
1082 const char* name;
1083 jvmtiParamKind kind;
1084 jvmtiParamTypes base_type;
1085 jboolean null_ok;
1086 };
1087
1088 auto add_extension = [&](jvmtiExtensionFunction func,
1089 const char* id,
1090 const char* short_description,
1091 jint param_count,
1092 const std::vector<CParamInfo>& params,
1093 jint error_count,
1094 const std::vector<jvmtiError>& errors) {
1095 jvmtiExtensionFunctionInfo func_info;
1096 jvmtiError error;
1097
1098 func_info.func = func;
1099
1100 JvmtiUniquePtr<char[]> id_ptr = CopyString(env, id, &error);
1101 if (id_ptr == nullptr) {
1102 return error;
1103 }
1104 func_info.id = id_ptr.get();
1105 char_buffers.push_back(std::move(id_ptr));
1106
1107 JvmtiUniquePtr<char[]> descr = CopyString(env, short_description, &error);
1108 if (descr == nullptr) {
1109 return error;
1110 }
1111 func_info.short_description = descr.get();
1112 char_buffers.push_back(std::move(descr));
1113
1114 func_info.param_count = param_count;
1115 if (param_count > 0) {
1116 JvmtiUniquePtr<jvmtiParamInfo[]> params_ptr =
1117 AllocJvmtiUniquePtr<jvmtiParamInfo[]>(env, param_count, &error);
1118 if (params_ptr == nullptr) {
1119 return error;
1120 }
1121 func_info.params = params_ptr.get();
1122 param_buffers.push_back(std::move(params_ptr));
1123
1124 for (jint i = 0; i != param_count; ++i) {
1125 JvmtiUniquePtr<char[]> param_name = CopyString(env, params[i].name, &error);
1126 if (param_name == nullptr) {
1127 return error;
1128 }
1129 func_info.params[i].name = param_name.get();
1130 char_buffers.push_back(std::move(param_name));
1131
1132 func_info.params[i].kind = params[i].kind;
1133 func_info.params[i].base_type = params[i].base_type;
1134 func_info.params[i].null_ok = params[i].null_ok;
1135 }
1136 } else {
1137 func_info.params = nullptr;
1138 }
1139
1140 func_info.error_count = error_count;
1141 if (error_count > 0) {
1142 JvmtiUniquePtr<jvmtiError[]> errors_ptr =
1143 AllocJvmtiUniquePtr<jvmtiError[]>(env, error_count, &error);
1144 if (errors_ptr == nullptr) {
1145 return error;
1146 }
1147 func_info.errors = errors_ptr.get();
1148 error_buffers.push_back(std::move(errors_ptr));
1149
1150 for (jint i = 0; i != error_count; ++i) {
1151 func_info.errors[i] = errors[i];
1152 }
1153 } else {
1154 func_info.errors = nullptr;
1155 }
1156
1157 ext_vector.push_back(func_info);
1158
1159 return ERR(NONE);
1160 };
1161
1162 jvmtiError error;
1163
1164 // Heap extensions.
1165 error = add_extension(
1166 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetObjectHeapId),
1167 "com.android.art.heap.get_object_heap_id",
1168 "Retrieve the heap id of the the object tagged with the given argument. An "
1169 "arbitrary object is chosen if multiple objects exist with the same tag.",
1170 2,
1171 { // NOLINT [whitespace/braces] [4]
1172 { "tag", JVMTI_KIND_IN, JVMTI_TYPE_JLONG, false},
1173 { "heap_id", JVMTI_KIND_OUT, JVMTI_TYPE_JINT, false}
1174 },
1175 1,
1176 { JVMTI_ERROR_NOT_FOUND });
1177 if (error != ERR(NONE)) {
1178 return error;
1179 }
1180
1181 error = add_extension(
1182 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetHeapName),
1183 "com.android.art.heap.get_heap_name",
1184 "Retrieve the name of the heap with the given id.",
1185 2,
1186 { // NOLINT [whitespace/braces] [4]
1187 { "heap_id", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1188 { "heap_name", JVMTI_KIND_ALLOC_BUF, JVMTI_TYPE_CCHAR, false}
1189 },
1190 1,
1191 { JVMTI_ERROR_ILLEGAL_ARGUMENT });
1192 if (error != ERR(NONE)) {
1193 return error;
1194 }
1195
Andreas Gampe2eb25e42017-05-09 17:14:58 -07001196 error = add_extension(
1197 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::IterateThroughHeapExt),
1198 "com.android.art.heap.iterate_through_heap_ext",
1199 "Iterate through a heap. This is equivalent to the standard IterateThroughHeap function,"
1200 " except for additionally passing the heap id of the current object. The jvmtiHeapCallbacks"
1201 " structure is reused, with the callbacks field overloaded to a signature of "
1202 "jint (*)(jlong, jlong, jlong*, jint length, void*, jint).",
1203 4,
1204 { // NOLINT [whitespace/braces] [4]
1205 { "heap_filter", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1206 { "klass", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, true},
1207 { "callbacks", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, false},
1208 { "user_data", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, true}
1209 },
1210 3,
1211 { // NOLINT [whitespace/braces] [4]
1212 JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
1213 JVMTI_ERROR_INVALID_CLASS,
1214 JVMTI_ERROR_NULL_POINTER
1215 });
1216 if (error != ERR(NONE)) {
1217 return error;
1218 }
1219
Andreas Gamped73aba42017-05-03 21:40:26 -07001220 // Copy into output buffer.
1221
1222 *extension_count_ptr = ext_vector.size();
1223 JvmtiUniquePtr<jvmtiExtensionFunctionInfo[]> out_data =
1224 AllocJvmtiUniquePtr<jvmtiExtensionFunctionInfo[]>(env, ext_vector.size(), &error);
1225 if (out_data == nullptr) {
1226 return error;
1227 }
1228 memcpy(out_data.get(),
1229 ext_vector.data(),
1230 ext_vector.size() * sizeof(jvmtiExtensionFunctionInfo));
1231 *extensions = out_data.release();
1232
1233 // Release all the buffer holders, we're OK now.
1234 for (auto& holder : char_buffers) {
1235 holder.release();
1236 }
1237 for (auto& holder : param_buffers) {
1238 holder.release();
1239 }
1240 for (auto& holder : error_buffers) {
1241 holder.release();
1242 }
Andreas Gampee4c33842017-01-09 10:50:17 -08001243
1244 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001245 }
1246
Alex Light1edc8cf2017-03-24 14:22:56 -07001247 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001248 jint* extension_count_ptr,
1249 jvmtiExtensionEventInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001250 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001251 // We do not have any extension events.
1252 *extension_count_ptr = 0;
1253 *extensions = nullptr;
1254
1255 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001256 }
1257
Alex Light1edc8cf2017-03-24 14:22:56 -07001258 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001259 jint extension_event_index ATTRIBUTE_UNUSED,
1260 jvmtiExtensionEvent callback ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001261 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001262 // We do not have any extension events, so any call is illegal.
1263 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001264 }
1265
1266 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001267 ENSURE_VALID_ENV(env);
1268 ENSURE_NON_NULL(capabilities_ptr);
1269 *capabilities_ptr = kPotentialCapabilities;
1270 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001271 }
1272
1273 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001274 ENSURE_VALID_ENV(env);
1275 ENSURE_NON_NULL(capabilities_ptr);
1276 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1277 jvmtiError ret = OK;
Alex Light34d8e082017-03-27 09:50:36 -07001278 jvmtiCapabilities changed = {};
1279 jvmtiCapabilities potential_capabilities = {};
Alex Light1d224962017-02-27 10:26:35 -08001280 ret = env->GetPotentialCapabilities(&potential_capabilities);
1281 if (ret != OK) {
1282 return ret;
1283 }
Alex Lighte6574242016-08-17 09:56:24 -07001284#define ADD_CAPABILITY(e) \
1285 do { \
1286 if (capabilities_ptr->e == 1) { \
Alex Light1d224962017-02-27 10:26:35 -08001287 if (potential_capabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001288 if (art_env->capabilities.e != 1) { \
1289 art_env->capabilities.e = 1; \
1290 changed.e = 1; \
1291 }\
Alex Lighte6574242016-08-17 09:56:24 -07001292 } else { \
1293 ret = ERR(NOT_AVAILABLE); \
1294 } \
1295 } \
1296 } while (false)
1297
1298 ADD_CAPABILITY(can_tag_objects);
1299 ADD_CAPABILITY(can_generate_field_modification_events);
1300 ADD_CAPABILITY(can_generate_field_access_events);
1301 ADD_CAPABILITY(can_get_bytecodes);
1302 ADD_CAPABILITY(can_get_synthetic_attribute);
1303 ADD_CAPABILITY(can_get_owned_monitor_info);
1304 ADD_CAPABILITY(can_get_current_contended_monitor);
1305 ADD_CAPABILITY(can_get_monitor_info);
1306 ADD_CAPABILITY(can_pop_frame);
1307 ADD_CAPABILITY(can_redefine_classes);
1308 ADD_CAPABILITY(can_signal_thread);
1309 ADD_CAPABILITY(can_get_source_file_name);
1310 ADD_CAPABILITY(can_get_line_numbers);
1311 ADD_CAPABILITY(can_get_source_debug_extension);
1312 ADD_CAPABILITY(can_access_local_variables);
1313 ADD_CAPABILITY(can_maintain_original_method_order);
1314 ADD_CAPABILITY(can_generate_single_step_events);
1315 ADD_CAPABILITY(can_generate_exception_events);
1316 ADD_CAPABILITY(can_generate_frame_pop_events);
1317 ADD_CAPABILITY(can_generate_breakpoint_events);
1318 ADD_CAPABILITY(can_suspend);
1319 ADD_CAPABILITY(can_redefine_any_class);
1320 ADD_CAPABILITY(can_get_current_thread_cpu_time);
1321 ADD_CAPABILITY(can_get_thread_cpu_time);
1322 ADD_CAPABILITY(can_generate_method_entry_events);
1323 ADD_CAPABILITY(can_generate_method_exit_events);
1324 ADD_CAPABILITY(can_generate_all_class_hook_events);
1325 ADD_CAPABILITY(can_generate_compiled_method_load_events);
1326 ADD_CAPABILITY(can_generate_monitor_events);
1327 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
1328 ADD_CAPABILITY(can_generate_native_method_bind_events);
1329 ADD_CAPABILITY(can_generate_garbage_collection_events);
1330 ADD_CAPABILITY(can_generate_object_free_events);
1331 ADD_CAPABILITY(can_force_early_return);
1332 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1333 ADD_CAPABILITY(can_get_constant_pool);
1334 ADD_CAPABILITY(can_set_native_method_prefix);
1335 ADD_CAPABILITY(can_retransform_classes);
1336 ADD_CAPABILITY(can_retransform_any_class);
1337 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1338 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1339#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001340 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1341 changed,
1342 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -07001343 return ret;
Alex Light49948e92016-08-11 15:35:28 -07001344 }
1345
1346 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1347 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001348 ENSURE_VALID_ENV(env);
1349 ENSURE_NON_NULL(capabilities_ptr);
1350 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light34d8e082017-03-27 09:50:36 -07001351 jvmtiCapabilities changed = {};
Alex Lighte6574242016-08-17 09:56:24 -07001352#define DEL_CAPABILITY(e) \
1353 do { \
1354 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001355 if (art_env->capabilities.e == 1) { \
1356 art_env->capabilities.e = 0;\
1357 changed.e = 1; \
1358 } \
Alex Lighte6574242016-08-17 09:56:24 -07001359 } \
1360 } while (false)
1361
1362 DEL_CAPABILITY(can_tag_objects);
1363 DEL_CAPABILITY(can_generate_field_modification_events);
1364 DEL_CAPABILITY(can_generate_field_access_events);
1365 DEL_CAPABILITY(can_get_bytecodes);
1366 DEL_CAPABILITY(can_get_synthetic_attribute);
1367 DEL_CAPABILITY(can_get_owned_monitor_info);
1368 DEL_CAPABILITY(can_get_current_contended_monitor);
1369 DEL_CAPABILITY(can_get_monitor_info);
1370 DEL_CAPABILITY(can_pop_frame);
1371 DEL_CAPABILITY(can_redefine_classes);
1372 DEL_CAPABILITY(can_signal_thread);
1373 DEL_CAPABILITY(can_get_source_file_name);
1374 DEL_CAPABILITY(can_get_line_numbers);
1375 DEL_CAPABILITY(can_get_source_debug_extension);
1376 DEL_CAPABILITY(can_access_local_variables);
1377 DEL_CAPABILITY(can_maintain_original_method_order);
1378 DEL_CAPABILITY(can_generate_single_step_events);
1379 DEL_CAPABILITY(can_generate_exception_events);
1380 DEL_CAPABILITY(can_generate_frame_pop_events);
1381 DEL_CAPABILITY(can_generate_breakpoint_events);
1382 DEL_CAPABILITY(can_suspend);
1383 DEL_CAPABILITY(can_redefine_any_class);
1384 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1385 DEL_CAPABILITY(can_get_thread_cpu_time);
1386 DEL_CAPABILITY(can_generate_method_entry_events);
1387 DEL_CAPABILITY(can_generate_method_exit_events);
1388 DEL_CAPABILITY(can_generate_all_class_hook_events);
1389 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1390 DEL_CAPABILITY(can_generate_monitor_events);
1391 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1392 DEL_CAPABILITY(can_generate_native_method_bind_events);
1393 DEL_CAPABILITY(can_generate_garbage_collection_events);
1394 DEL_CAPABILITY(can_generate_object_free_events);
1395 DEL_CAPABILITY(can_force_early_return);
1396 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1397 DEL_CAPABILITY(can_get_constant_pool);
1398 DEL_CAPABILITY(can_set_native_method_prefix);
1399 DEL_CAPABILITY(can_retransform_classes);
1400 DEL_CAPABILITY(can_retransform_any_class);
1401 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1402 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1403#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001404 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1405 changed,
1406 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001407 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001408 }
1409
1410 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001411 ENSURE_VALID_ENV(env);
1412 ENSURE_NON_NULL(capabilities_ptr);
1413 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1414 *capabilities_ptr = artenv->capabilities;
1415 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001416 }
1417
Alex Light6a3fd512017-02-27 14:34:32 -08001418 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1419 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001420 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001421 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001422 return ERR(NOT_IMPLEMENTED);
1423 }
1424
Alex Light6a3fd512017-02-27 14:34:32 -08001425 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001426 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001427 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001428 return ERR(NOT_IMPLEMENTED);
1429 }
1430
Alex Light6a3fd512017-02-27 14:34:32 -08001431 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1432 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001433 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001434 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001435 return ERR(NOT_IMPLEMENTED);
1436 }
1437
Alex Light6a3fd512017-02-27 14:34:32 -08001438 static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1439 jthread thread ATTRIBUTE_UNUSED,
1440 jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001441 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001442 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001443 return ERR(NOT_IMPLEMENTED);
1444 }
1445
1446 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001447 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001448 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001449 }
1450
1451 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001452 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001453 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001454 }
1455
1456 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001457 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001458 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001459 }
1460
1461 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001462 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001463 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001464 }
1465
1466 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001467 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001468 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001469 }
1470
1471 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001472 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001473 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001474 }
1475
1476 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001477 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001478 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001479 }
1480
1481 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001482 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001483 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001484 }
1485
1486 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001487 ENSURE_VALID_ENV(env);
Andreas Gampe96eca782017-01-19 19:45:30 -08001488 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001489 }
1490
1491 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001492 ENSURE_VALID_ENV(env);
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001493 gEventHandler.RemoveArtJvmTiEnv(ArtJvmTiEnv::AsArtJvmTiEnv(env));
Andreas Gampede19eb92017-02-24 16:21:18 -08001494 art::Runtime::Current()->RemoveSystemWeakHolder(
1495 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001496 delete env;
1497 return OK;
1498 }
1499
1500 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001501 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001502 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1503 return OK;
1504 }
1505
1506 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001507 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001508 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1509 return OK;
1510 }
1511
1512 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001513 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001514 *version_ptr = JVMTI_VERSION;
1515 return OK;
1516 }
1517
1518 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001519 ENSURE_NON_NULL(name_ptr);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001520 auto copy_fn = [&](const char* name_cstr) {
1521 jvmtiError res;
1522 JvmtiUniquePtr<char[]> copy = CopyString(env, name_cstr, &res);
1523 if (copy == nullptr) {
1524 *name_ptr = nullptr;
1525 return res;
1526 } else {
1527 *name_ptr = copy.release();
1528 return OK;
1529 }
1530 };
Alex Light49948e92016-08-11 15:35:28 -07001531 switch (error) {
Andreas Gampe95c466d2017-05-08 14:50:47 -07001532#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : \
1533 return copy_fn("JVMTI_ERROR_"#e);
Alex Light49948e92016-08-11 15:35:28 -07001534 ERROR_CASE(NONE);
1535 ERROR_CASE(INVALID_THREAD);
1536 ERROR_CASE(INVALID_THREAD_GROUP);
1537 ERROR_CASE(INVALID_PRIORITY);
1538 ERROR_CASE(THREAD_NOT_SUSPENDED);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001539 ERROR_CASE(THREAD_SUSPENDED);
Alex Light49948e92016-08-11 15:35:28 -07001540 ERROR_CASE(THREAD_NOT_ALIVE);
1541 ERROR_CASE(INVALID_OBJECT);
1542 ERROR_CASE(INVALID_CLASS);
1543 ERROR_CASE(CLASS_NOT_PREPARED);
1544 ERROR_CASE(INVALID_METHODID);
1545 ERROR_CASE(INVALID_LOCATION);
1546 ERROR_CASE(INVALID_FIELDID);
1547 ERROR_CASE(NO_MORE_FRAMES);
1548 ERROR_CASE(OPAQUE_FRAME);
1549 ERROR_CASE(TYPE_MISMATCH);
1550 ERROR_CASE(INVALID_SLOT);
1551 ERROR_CASE(DUPLICATE);
1552 ERROR_CASE(NOT_FOUND);
1553 ERROR_CASE(INVALID_MONITOR);
1554 ERROR_CASE(NOT_MONITOR_OWNER);
1555 ERROR_CASE(INTERRUPT);
1556 ERROR_CASE(INVALID_CLASS_FORMAT);
1557 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1558 ERROR_CASE(FAILS_VERIFICATION);
1559 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1560 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1561 ERROR_CASE(INVALID_TYPESTATE);
1562 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1563 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1564 ERROR_CASE(UNSUPPORTED_VERSION);
1565 ERROR_CASE(NAMES_DONT_MATCH);
1566 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1567 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1568 ERROR_CASE(UNMODIFIABLE_CLASS);
1569 ERROR_CASE(NOT_AVAILABLE);
1570 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1571 ERROR_CASE(NULL_POINTER);
1572 ERROR_CASE(ABSENT_INFORMATION);
1573 ERROR_CASE(INVALID_EVENT_TYPE);
1574 ERROR_CASE(ILLEGAL_ARGUMENT);
1575 ERROR_CASE(NATIVE_METHOD);
1576 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1577 ERROR_CASE(OUT_OF_MEMORY);
1578 ERROR_CASE(ACCESS_DENIED);
1579 ERROR_CASE(WRONG_PHASE);
1580 ERROR_CASE(INTERNAL);
1581 ERROR_CASE(UNATTACHED_THREAD);
1582 ERROR_CASE(INVALID_ENVIRONMENT);
1583#undef ERROR_CASE
Alex Light49948e92016-08-11 15:35:28 -07001584 }
Andreas Gampe95c466d2017-05-08 14:50:47 -07001585
1586 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001587 }
1588
Alex Light1edc8cf2017-03-24 14:22:56 -07001589 static jvmtiError SetVerboseFlag(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001590 jvmtiVerboseFlag flag,
1591 jboolean value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001592 ENSURE_VALID_ENV(env);
Andreas Gampef37e3022017-01-13 17:54:46 -08001593 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1594 // OTHER is special, as it's 0, so can't do a bit check.
1595 bool val = (value == JNI_TRUE) ? true : false;
1596
1597 art::gLogVerbosity.collector = val;
1598 art::gLogVerbosity.compiler = val;
1599 art::gLogVerbosity.deopt = val;
1600 art::gLogVerbosity.heap = val;
1601 art::gLogVerbosity.jdwp = val;
1602 art::gLogVerbosity.jit = val;
1603 art::gLogVerbosity.monitor = val;
1604 art::gLogVerbosity.oat = val;
1605 art::gLogVerbosity.profiler = val;
1606 art::gLogVerbosity.signals = val;
1607 art::gLogVerbosity.simulator = val;
1608 art::gLogVerbosity.startup = val;
1609 art::gLogVerbosity.third_party_jni = val;
1610 art::gLogVerbosity.threads = val;
1611 art::gLogVerbosity.verifier = val;
1612 art::gLogVerbosity.image = val;
1613
1614 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1615
1616 art::gLogVerbosity.agents = val;
1617 } else {
1618 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1619 // semantics.
1620 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1621 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1622 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1623 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1624 if ((flag & ~kMask) != 0) {
1625 return ERR(ILLEGAL_ARGUMENT);
1626 }
1627
1628 bool val = (value == JNI_TRUE) ? true : false;
1629
1630 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1631 art::gLogVerbosity.gc = val;
1632 }
1633
1634 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1635 art::gLogVerbosity.class_linker = val;
1636 }
1637
1638 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1639 art::gLogVerbosity.jni = val;
1640 }
1641 }
1642
1643 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001644 }
1645
Alex Light1edc8cf2017-03-24 14:22:56 -07001646 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1647 ENSURE_VALID_ENV(env);
Andreas Gampeacfc9572017-01-17 18:36:56 -08001648 // Report BCI as jlocation format. We report dex bytecode indices.
1649 if (format_ptr == nullptr) {
1650 return ERR(NULL_POINTER);
1651 }
1652 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1653 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001654 }
1655};
1656
1657static bool IsJvmtiVersion(jint version) {
1658 return version == JVMTI_VERSION_1 ||
1659 version == JVMTI_VERSION_1_0 ||
1660 version == JVMTI_VERSION_1_1 ||
1661 version == JVMTI_VERSION_1_2 ||
1662 version == JVMTI_VERSION;
1663}
1664
Andreas Gampede19eb92017-02-24 16:21:18 -08001665extern const jvmtiInterface_1 gJvmtiInterface;
1666ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler)
1667 : art_vm(runtime),
1668 local_data(nullptr),
Andreas Gampea1705ea2017-03-28 20:12:13 -07001669 capabilities() {
1670 object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
Andreas Gampede19eb92017-02-24 16:21:18 -08001671 functions = &gJvmtiInterface;
1672}
1673
Alex Light49948e92016-08-11 15:35:28 -07001674// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1675// is a pointer to the uninitialized memory for an art::ti::Env.
1676static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
Andreas Gampede19eb92017-02-24 16:21:18 -08001677 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler);
Alex Light49948e92016-08-11 15:35:28 -07001678 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001679
1680 gEventHandler.RegisterArtJvmTiEnv(env);
Andreas Gampede19eb92017-02-24 16:21:18 -08001681
1682 art::Runtime::Current()->AddSystemWeakHolder(
1683 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001684}
1685
1686// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1687// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1688// returns false and does not modify the 'env' pointer.
1689static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1690 if (IsJvmtiVersion(version)) {
1691 CreateArtJvmTiEnv(vm, env);
1692 return JNI_OK;
1693 } else {
1694 printf("version 0x%x is not valid!", version);
1695 return JNI_EVERSION;
1696 }
1697}
1698
1699// The plugin initialization function. This adds the jvmti environment.
1700extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001701 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001702
1703 if (runtime->IsStarted()) {
1704 PhaseUtil::SetToLive();
1705 } else {
1706 PhaseUtil::SetToOnLoad();
1707 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001708 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001709 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001710 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001711 DumpUtil::Register(&gEventHandler);
Alex Lightd78ddec2017-04-18 15:20:38 -07001712 MethodUtil::Register(&gEventHandler);
Andreas Gampecefaa142017-01-23 15:04:59 -08001713 SearchUtil::Register();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001714 HeapUtil::Register();
Andreas Gampe96eca782017-01-19 19:45:30 -08001715
Andreas Gampee08a2be2016-10-06 13:13:30 -07001716 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001717
Alex Light49948e92016-08-11 15:35:28 -07001718 return true;
1719}
1720
Andreas Gampeeafaf572017-01-20 12:34:15 -08001721extern "C" bool ArtPlugin_Deinitialize() {
Alex Lightb7edcda2017-04-27 13:20:31 -07001722 gEventHandler.Shutdown();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001723 PhaseUtil::Unregister();
1724 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001725 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001726 DumpUtil::Unregister();
Alex Lightd78ddec2017-04-18 15:20:38 -07001727 MethodUtil::Unregister();
Andreas Gampecefaa142017-01-23 15:04:59 -08001728 SearchUtil::Unregister();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001729 HeapUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001730
1731 return true;
1732}
1733
Alex Light49948e92016-08-11 15:35:28 -07001734// The actual struct holding all of the entrypoints into the jvmti interface.
1735const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001736 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001737 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001738 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001739 JvmtiFunctions::GetAllThreads,
1740 JvmtiFunctions::SuspendThread,
1741 JvmtiFunctions::ResumeThread,
1742 JvmtiFunctions::StopThread,
1743 JvmtiFunctions::InterruptThread,
1744 JvmtiFunctions::GetThreadInfo,
1745 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1746 JvmtiFunctions::GetCurrentContendedMonitor,
1747 JvmtiFunctions::RunAgentThread,
1748 JvmtiFunctions::GetTopThreadGroups,
1749 JvmtiFunctions::GetThreadGroupInfo,
1750 JvmtiFunctions::GetThreadGroupChildren,
1751 JvmtiFunctions::GetFrameCount,
1752 JvmtiFunctions::GetThreadState,
1753 JvmtiFunctions::GetCurrentThread,
1754 JvmtiFunctions::GetFrameLocation,
1755 JvmtiFunctions::NotifyFramePop, // 20
1756 JvmtiFunctions::GetLocalObject,
1757 JvmtiFunctions::GetLocalInt,
1758 JvmtiFunctions::GetLocalLong,
1759 JvmtiFunctions::GetLocalFloat,
1760 JvmtiFunctions::GetLocalDouble,
1761 JvmtiFunctions::SetLocalObject,
1762 JvmtiFunctions::SetLocalInt,
1763 JvmtiFunctions::SetLocalLong,
1764 JvmtiFunctions::SetLocalFloat,
1765 JvmtiFunctions::SetLocalDouble, // 30
1766 JvmtiFunctions::CreateRawMonitor,
1767 JvmtiFunctions::DestroyRawMonitor,
1768 JvmtiFunctions::RawMonitorEnter,
1769 JvmtiFunctions::RawMonitorExit,
1770 JvmtiFunctions::RawMonitorWait,
1771 JvmtiFunctions::RawMonitorNotify,
1772 JvmtiFunctions::RawMonitorNotifyAll,
1773 JvmtiFunctions::SetBreakpoint,
1774 JvmtiFunctions::ClearBreakpoint,
1775 nullptr, // reserved40
1776 JvmtiFunctions::SetFieldAccessWatch,
1777 JvmtiFunctions::ClearFieldAccessWatch,
1778 JvmtiFunctions::SetFieldModificationWatch,
1779 JvmtiFunctions::ClearFieldModificationWatch,
1780 JvmtiFunctions::IsModifiableClass,
1781 JvmtiFunctions::Allocate,
1782 JvmtiFunctions::Deallocate,
1783 JvmtiFunctions::GetClassSignature,
1784 JvmtiFunctions::GetClassStatus,
1785 JvmtiFunctions::GetSourceFileName, // 50
1786 JvmtiFunctions::GetClassModifiers,
1787 JvmtiFunctions::GetClassMethods,
1788 JvmtiFunctions::GetClassFields,
1789 JvmtiFunctions::GetImplementedInterfaces,
1790 JvmtiFunctions::IsInterface,
1791 JvmtiFunctions::IsArrayClass,
1792 JvmtiFunctions::GetClassLoader,
1793 JvmtiFunctions::GetObjectHashCode,
1794 JvmtiFunctions::GetObjectMonitorUsage,
1795 JvmtiFunctions::GetFieldName, // 60
1796 JvmtiFunctions::GetFieldDeclaringClass,
1797 JvmtiFunctions::GetFieldModifiers,
1798 JvmtiFunctions::IsFieldSynthetic,
1799 JvmtiFunctions::GetMethodName,
1800 JvmtiFunctions::GetMethodDeclaringClass,
1801 JvmtiFunctions::GetMethodModifiers,
1802 nullptr, // reserved67
1803 JvmtiFunctions::GetMaxLocals,
1804 JvmtiFunctions::GetArgumentsSize,
1805 JvmtiFunctions::GetLineNumberTable, // 70
1806 JvmtiFunctions::GetMethodLocation,
1807 JvmtiFunctions::GetLocalVariableTable,
1808 JvmtiFunctions::SetNativeMethodPrefix,
1809 JvmtiFunctions::SetNativeMethodPrefixes,
1810 JvmtiFunctions::GetBytecodes,
1811 JvmtiFunctions::IsMethodNative,
1812 JvmtiFunctions::IsMethodSynthetic,
1813 JvmtiFunctions::GetLoadedClasses,
1814 JvmtiFunctions::GetClassLoaderClasses,
1815 JvmtiFunctions::PopFrame, // 80
1816 JvmtiFunctions::ForceEarlyReturnObject,
1817 JvmtiFunctions::ForceEarlyReturnInt,
1818 JvmtiFunctions::ForceEarlyReturnLong,
1819 JvmtiFunctions::ForceEarlyReturnFloat,
1820 JvmtiFunctions::ForceEarlyReturnDouble,
1821 JvmtiFunctions::ForceEarlyReturnVoid,
1822 JvmtiFunctions::RedefineClasses,
1823 JvmtiFunctions::GetVersionNumber,
1824 JvmtiFunctions::GetCapabilities,
1825 JvmtiFunctions::GetSourceDebugExtension, // 90
1826 JvmtiFunctions::IsMethodObsolete,
1827 JvmtiFunctions::SuspendThreadList,
1828 JvmtiFunctions::ResumeThreadList,
1829 nullptr, // reserved94
1830 nullptr, // reserved95
1831 nullptr, // reserved96
1832 nullptr, // reserved97
1833 nullptr, // reserved98
1834 nullptr, // reserved99
1835 JvmtiFunctions::GetAllStackTraces, // 100
1836 JvmtiFunctions::GetThreadListStackTraces,
1837 JvmtiFunctions::GetThreadLocalStorage,
1838 JvmtiFunctions::SetThreadLocalStorage,
1839 JvmtiFunctions::GetStackTrace,
1840 nullptr, // reserved105
1841 JvmtiFunctions::GetTag,
1842 JvmtiFunctions::SetTag,
1843 JvmtiFunctions::ForceGarbageCollection,
1844 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1845 JvmtiFunctions::IterateOverReachableObjects, // 110
1846 JvmtiFunctions::IterateOverHeap,
1847 JvmtiFunctions::IterateOverInstancesOfClass,
1848 nullptr, // reserved113
1849 JvmtiFunctions::GetObjectsWithTags,
1850 JvmtiFunctions::FollowReferences,
1851 JvmtiFunctions::IterateThroughHeap,
1852 nullptr, // reserved117
1853 nullptr, // reserved118
1854 nullptr, // reserved119
1855 JvmtiFunctions::SetJNIFunctionTable, // 120
1856 JvmtiFunctions::GetJNIFunctionTable,
1857 JvmtiFunctions::SetEventCallbacks,
1858 JvmtiFunctions::GenerateEvents,
1859 JvmtiFunctions::GetExtensionFunctions,
1860 JvmtiFunctions::GetExtensionEvents,
1861 JvmtiFunctions::SetExtensionEventCallback,
1862 JvmtiFunctions::DisposeEnvironment,
1863 JvmtiFunctions::GetErrorName,
1864 JvmtiFunctions::GetJLocationFormat,
1865 JvmtiFunctions::GetSystemProperties, // 130
1866 JvmtiFunctions::GetSystemProperty,
1867 JvmtiFunctions::SetSystemProperty,
1868 JvmtiFunctions::GetPhase,
1869 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1870 JvmtiFunctions::GetCurrentThreadCpuTime,
1871 JvmtiFunctions::GetThreadCpuTimerInfo,
1872 JvmtiFunctions::GetThreadCpuTime,
1873 JvmtiFunctions::GetTimerInfo,
1874 JvmtiFunctions::GetTime,
1875 JvmtiFunctions::GetPotentialCapabilities, // 140
1876 nullptr, // reserved141
1877 JvmtiFunctions::AddCapabilities,
1878 JvmtiFunctions::RelinquishCapabilities,
1879 JvmtiFunctions::GetAvailableProcessors,
1880 JvmtiFunctions::GetClassVersionNumbers,
1881 JvmtiFunctions::GetConstantPool,
1882 JvmtiFunctions::GetEnvironmentLocalStorage,
1883 JvmtiFunctions::SetEnvironmentLocalStorage,
1884 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1885 JvmtiFunctions::SetVerboseFlag, // 150
1886 JvmtiFunctions::AddToSystemClassLoaderSearch,
1887 JvmtiFunctions::RetransformClasses,
1888 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1889 JvmtiFunctions::GetObjectSize,
1890 JvmtiFunctions::GetLocalInstance,
1891};
1892
1893}; // namespace openjdkjvmti