blob: b30d45ae8830cb6a3d5914c85b24222998736dae [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 Lightbf64a572017-07-05 10:34:49 -070051#include "ti_allocator.h"
Alex Lighta26e3492017-06-27 17:55:37 -070052#include "ti_breakpoint.h"
Andreas Gampee492ae32016-10-28 19:34:57 -070053#include "ti_class.h"
Andreas Gampeeb0cea12017-01-23 08:50:04 -080054#include "ti_dump.h"
Andreas Gampeab2f0d02017-01-05 17:23:45 -080055#include "ti_field.h"
Andreas Gampeba8df692016-11-01 10:30:44 -070056#include "ti_heap.h"
Andreas Gampe6f8e4f02017-01-16 18:18:14 -080057#include "ti_jni.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070058#include "ti_method.h"
Andreas Gampe319dbe82017-01-09 16:42:21 -080059#include "ti_monitor.h"
Andreas Gampe50a4e492017-01-06 18:00:20 -080060#include "ti_object.h"
Andreas Gampe96eca782017-01-19 19:45:30 -080061#include "ti_phase.h"
Andreas Gampe1bdaf732017-01-09 19:21:06 -080062#include "ti_properties.h"
Alex Lighta01de592016-11-15 10:43:06 -080063#include "ti_redefine.h"
Andreas Gampece7732b2017-01-17 15:50:26 -080064#include "ti_search.h"
Andreas Gampeb5eb94a2016-10-27 19:23:09 -070065#include "ti_stack.h"
Andreas Gampeaf13ab92017-01-11 20:57:40 -080066#include "ti_thread.h"
Andreas Gamped18d9e22017-01-16 16:08:45 +000067#include "ti_threadgroup.h"
Andreas Gampe35bcf812017-01-13 16:24:17 -080068#include "ti_timers.h"
Alex Light9c20a142016-08-23 15:05:12 -070069#include "transform.h"
Alex Light49948e92016-08-11 15:35:28 -070070
Alex Light49948e92016-08-11 15:35:28 -070071namespace openjdkjvmti {
72
Andreas Gampe77708d92016-10-07 11:48:21 -070073EventHandler gEventHandler;
Andreas Gampe6dee92e2016-09-12 19:58:13 -070074
Alex Lighte6574242016-08-17 09:56:24 -070075#define ENSURE_NON_NULL(n) \
76 do { \
77 if ((n) == nullptr) { \
78 return ERR(NULL_POINTER); \
79 } \
80 } while (false)
81
Alex Light49948e92016-08-11 15:35:28 -070082class JvmtiFunctions {
83 private:
Alex Light1edc8cf2017-03-24 14:22:56 -070084 static jvmtiError getEnvironmentError(jvmtiEnv* env) {
85 if (env == nullptr) {
86 return ERR(INVALID_ENVIRONMENT);
87 } else if (art::Thread::Current() == nullptr) {
88 return ERR(UNATTACHED_THREAD);
89 } else {
90 return OK;
91 }
Alex Light49948e92016-08-11 15:35:28 -070092 }
93
Alex Light1edc8cf2017-03-24 14:22:56 -070094#define ENSURE_VALID_ENV(env) \
95 do { \
96 jvmtiError ensure_valid_env_ ## __LINE__ = getEnvironmentError(env); \
97 if (ensure_valid_env_ ## __LINE__ != OK) { \
98 return ensure_valid_env_ ## __LINE__ ; \
99 } \
Alex Lighte6574242016-08-17 09:56:24 -0700100 } while (false)
101
102#define ENSURE_HAS_CAP(env, cap) \
103 do { \
Alex Lighte6574242016-08-17 09:56:24 -0700104 if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
105 return ERR(MUST_POSSESS_CAPABILITY); \
106 } \
107 } while (false)
108
Alex Light49948e92016-08-11 15:35:28 -0700109 public:
110 static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -0700111 ENSURE_VALID_ENV(env);
112 ENSURE_NON_NULL(mem_ptr);
Alex Lightbf64a572017-07-05 10:34:49 -0700113 return AllocUtil::Allocate(env, size, mem_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700114 }
115
116 static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
Alex Lighte6574242016-08-17 09:56:24 -0700117 ENSURE_VALID_ENV(env);
Alex Lightbf64a572017-07-05 10:34:49 -0700118 return AllocUtil::Deallocate(env, mem);
Alex Light49948e92016-08-11 15:35:28 -0700119 }
120
121 static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700122 ENSURE_VALID_ENV(env);
Andreas Gampe72c19832017-01-12 13:22:16 -0800123 return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700124 }
125
126 static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700127 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800128 return ThreadUtil::GetCurrentThread(env, thread_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700129 }
130
131 static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700132 ENSURE_VALID_ENV(env);
Andreas Gampe85807442017-01-13 14:40:58 -0800133 return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700134 }
135
Alex Light88fd7202017-06-30 08:31:59 -0700136 static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700137 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800138 ENSURE_HAS_CAP(env, can_suspend);
Alex Light88fd7202017-06-30 08:31:59 -0700139 return ThreadUtil::SuspendThread(env, thread);
Alex Light49948e92016-08-11 15:35:28 -0700140 }
141
142 static jvmtiError SuspendThreadList(jvmtiEnv* env,
Alex Light88fd7202017-06-30 08:31:59 -0700143 jint request_count,
144 const jthread* request_list,
145 jvmtiError* results) {
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 Light88fd7202017-06-30 08:31:59 -0700148 return ThreadUtil::SuspendThreadList(env, request_count, request_list, results);
Alex Light49948e92016-08-11 15:35:28 -0700149 }
150
Alex Light88fd7202017-06-30 08:31:59 -0700151 static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700152 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800153 ENSURE_HAS_CAP(env, can_suspend);
Alex Light88fd7202017-06-30 08:31:59 -0700154 return ThreadUtil::ResumeThread(env, thread);
Alex Light49948e92016-08-11 15:35:28 -0700155 }
156
157 static jvmtiError ResumeThreadList(jvmtiEnv* env,
Alex Light88fd7202017-06-30 08:31:59 -0700158 jint request_count,
159 const jthread* request_list,
160 jvmtiError* results) {
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 Light88fd7202017-06-30 08:31:59 -0700163 return ThreadUtil::ResumeThreadList(env, request_count, request_list, results);
Alex Light49948e92016-08-11 15:35:28 -0700164 }
165
Alex Light54d39dc2017-09-25 17:00:16 -0700166 static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700167 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800168 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light54d39dc2017-09-25 17:00:16 -0700169 return ThreadUtil::StopThread(env, thread, exception);
Alex Light49948e92016-08-11 15:35:28 -0700170 }
171
Alex Light54d39dc2017-09-25 17:00:16 -0700172 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700173 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800174 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light54d39dc2017-09-25 17:00:16 -0700175 return ThreadUtil::InterruptThread(env, thread);
Alex Light49948e92016-08-11 15:35:28 -0700176 }
177
178 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700179 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800180 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700181 }
182
183 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
Alex Light88e1ddd2017-08-21 13:09:55 -0700184 jthread thread,
185 jint* owned_monitor_count_ptr,
186 jobject** owned_monitors_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700187 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800188 ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
Alex Light88e1ddd2017-08-21 13:09:55 -0700189 return StackUtil::GetOwnedMonitorInfo(env,
190 thread,
191 owned_monitor_count_ptr,
192 owned_monitors_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700193 }
194
Alex Light88e1ddd2017-08-21 13:09:55 -0700195 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
196 jthread thread,
197 jint* monitor_info_count_ptr,
198 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700199 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800200 ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
Alex Light88e1ddd2017-08-21 13:09:55 -0700201 return StackUtil::GetOwnedMonitorStackDepthInfo(env,
202 thread,
203 monitor_info_count_ptr,
204 monitor_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700205 }
206
207 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
Alex Light41006c62017-09-14 09:51:14 -0700208 jthread thread,
209 jobject* monitor_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700210 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800211 ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
Alex Light41006c62017-09-14 09:51:14 -0700212 return MonitorUtil::GetCurrentContendedMonitor(env, thread, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700213 }
214
215 static jvmtiError RunAgentThread(jvmtiEnv* env,
216 jthread thread,
217 jvmtiStartFunction proc,
218 const void* arg,
219 jint priority) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700220 ENSURE_VALID_ENV(env);
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800221 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700222 }
223
224 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700225 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800226 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700227 }
228
229 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700230 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800231 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700232 }
233
234 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
235 jint* group_count_ptr,
236 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700237 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000238 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700239 }
240
241 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
242 jthreadGroup group,
243 jvmtiThreadGroupInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700244 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000245 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700246 }
247
248 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
249 jthreadGroup group,
250 jint* thread_count_ptr,
251 jthread** threads_ptr,
252 jint* group_count_ptr,
253 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700254 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000255 return ThreadGroupUtil::GetThreadGroupChildren(env,
256 group,
257 thread_count_ptr,
258 threads_ptr,
259 group_count_ptr,
260 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700261 }
262
263 static jvmtiError GetStackTrace(jvmtiEnv* env,
264 jthread thread,
265 jint start_depth,
266 jint max_frame_count,
267 jvmtiFrameInfo* frame_buffer,
268 jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700269 ENSURE_VALID_ENV(env);
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700270 return StackUtil::GetStackTrace(env,
271 thread,
272 start_depth,
273 max_frame_count,
274 frame_buffer,
275 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700276 }
277
278 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
279 jint max_frame_count,
280 jvmtiStackInfo** stack_info_ptr,
281 jint* thread_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700282 ENSURE_VALID_ENV(env);
Andreas Gampea1a27c62017-01-11 16:37:16 -0800283 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700284 }
285
286 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
287 jint thread_count,
288 const jthread* thread_list,
289 jint max_frame_count,
290 jvmtiStackInfo** stack_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700291 ENSURE_VALID_ENV(env);
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800292 return StackUtil::GetThreadListStackTraces(env,
293 thread_count,
294 thread_list,
295 max_frame_count,
296 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700297 }
298
299 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700300 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800301 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700302 }
303
Alex Light6a3fd512017-02-27 14:34:32 -0800304 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700305 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800306 ENSURE_HAS_CAP(env, can_pop_frame);
Alex Light49948e92016-08-11 15:35:28 -0700307 return ERR(NOT_IMPLEMENTED);
308 }
309
310 static jvmtiError GetFrameLocation(jvmtiEnv* env,
311 jthread thread,
312 jint depth,
313 jmethodID* method_ptr,
314 jlocation* location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700315 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800316 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700317 }
318
Alex Lighte814f9d2017-07-31 16:14:39 -0700319 static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700320 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800321 ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
Alex Lighte814f9d2017-07-31 16:14:39 -0700322 return StackUtil::NotifyFramePop(env, thread, depth);
Alex Light49948e92016-08-11 15:35:28 -0700323 }
324
Alex Light6a3fd512017-02-27 14:34:32 -0800325 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env,
326 jthread thread ATTRIBUTE_UNUSED,
327 jobject value 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_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700330 return ERR(NOT_IMPLEMENTED);
331 }
332
Alex Light6a3fd512017-02-27 14:34:32 -0800333 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env,
334 jthread thread ATTRIBUTE_UNUSED,
335 jint 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 ForceEarlyReturnLong(jvmtiEnv* env,
342 jthread thread ATTRIBUTE_UNUSED,
343 jlong 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 ForceEarlyReturnFloat(jvmtiEnv* env,
350 jthread thread ATTRIBUTE_UNUSED,
351 jfloat 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 ForceEarlyReturnDouble(jvmtiEnv* env,
358 jthread thread ATTRIBUTE_UNUSED,
359 jdouble 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 ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700366 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800367 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700368 return ERR(NOT_IMPLEMENTED);
369 }
370
371 static jvmtiError FollowReferences(jvmtiEnv* env,
372 jint heap_filter,
373 jclass klass,
374 jobject initial_object,
375 const jvmtiHeapCallbacks* callbacks,
376 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700377 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800378 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800379 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700380 return heap_util.FollowReferences(env,
381 heap_filter,
382 klass,
383 initial_object,
384 callbacks,
385 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700386 }
387
388 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
389 jint heap_filter,
390 jclass klass,
391 const jvmtiHeapCallbacks* callbacks,
392 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700393 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700394 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800395 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampee54d9922016-10-11 19:55:37 -0700396 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700397 }
398
399 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
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 Gampe6dee92e2016-09-12 19:58:13 -0700402
403 JNIEnv* jni_env = GetJniEnv(env);
404 if (jni_env == nullptr) {
405 return ERR(INTERNAL);
406 }
407
408 art::ScopedObjectAccess soa(jni_env);
409 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800410 if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700411 *tag_ptr = 0;
412 }
413
414 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700415 }
416
417 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700418 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700419 ENSURE_HAS_CAP(env, can_tag_objects);
420
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700421 if (object == nullptr) {
422 return ERR(NULL_POINTER);
423 }
424
425 JNIEnv* jni_env = GetJniEnv(env);
426 if (jni_env == nullptr) {
427 return ERR(INTERNAL);
428 }
429
430 art::ScopedObjectAccess soa(jni_env);
431 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800432 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700433
434 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700435 }
436
437 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
438 jint tag_count,
439 const jlong* tags,
440 jint* count_ptr,
441 jobject** object_result_ptr,
442 jlong** tag_result_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700443 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700444 ENSURE_HAS_CAP(env, can_tag_objects);
445
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700446 JNIEnv* jni_env = GetJniEnv(env);
447 if (jni_env == nullptr) {
448 return ERR(INTERNAL);
449 }
450
451 art::ScopedObjectAccess soa(jni_env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800452 return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
453 tag_count,
454 tags,
455 count_ptr,
456 object_result_ptr,
457 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700458 }
459
460 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700461 ENSURE_VALID_ENV(env);
Andreas Gampe8da6d032016-10-31 19:31:03 -0700462 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700463 }
464
465 static jvmtiError IterateOverObjectsReachableFromObject(
466 jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800467 jobject object ATTRIBUTE_UNUSED,
468 jvmtiObjectReferenceCallback object_reference_callback ATTRIBUTE_UNUSED,
469 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700470 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800471 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700472 return ERR(NOT_IMPLEMENTED);
473 }
474
Alex Light6a3fd512017-02-27 14:34:32 -0800475 static jvmtiError IterateOverReachableObjects(
476 jvmtiEnv* env,
477 jvmtiHeapRootCallback heap_root_callback ATTRIBUTE_UNUSED,
478 jvmtiStackReferenceCallback stack_ref_callback ATTRIBUTE_UNUSED,
479 jvmtiObjectReferenceCallback object_ref_callback ATTRIBUTE_UNUSED,
480 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700481 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800482 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700483 return ERR(NOT_IMPLEMENTED);
484 }
485
486 static jvmtiError IterateOverHeap(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800487 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
488 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
489 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700490 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800491 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700492 return ERR(NOT_IMPLEMENTED);
493 }
494
Alex Light6a3fd512017-02-27 14:34:32 -0800495 static jvmtiError IterateOverInstancesOfClass(
496 jvmtiEnv* env,
497 jclass klass ATTRIBUTE_UNUSED,
498 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
499 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
500 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700501 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800502 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700503 return ERR(NOT_IMPLEMENTED);
504 }
505
506 static jvmtiError GetLocalObject(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700507 jthread thread,
508 jint depth,
509 jint slot,
510 jobject* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700511 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800512 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700513 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700514 }
515
516 static jvmtiError GetLocalInstance(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700517 jthread thread,
518 jint depth,
519 jobject* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700520 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800521 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700522 return MethodUtil::GetLocalInstance(env, thread, depth, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700523 }
524
525 static jvmtiError GetLocalInt(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700526 jthread thread,
527 jint depth,
528 jint slot,
529 jint* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700530 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800531 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700532 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700533 }
534
535 static jvmtiError GetLocalLong(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700536 jthread thread,
537 jint depth,
538 jint slot,
539 jlong* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700540 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800541 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700542 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700543 }
544
545 static jvmtiError GetLocalFloat(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700546 jthread thread,
547 jint depth,
548 jint slot,
549 jfloat* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700550 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800551 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700552 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700553 }
554
555 static jvmtiError GetLocalDouble(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700556 jthread thread,
557 jint depth,
558 jint slot,
559 jdouble* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700560 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800561 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700562 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700563 }
564
565 static jvmtiError SetLocalObject(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700566 jthread thread,
567 jint depth,
568 jint slot,
569 jobject value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700570 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800571 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700572 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700573 }
574
575 static jvmtiError SetLocalInt(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700576 jthread thread,
577 jint depth,
578 jint slot,
579 jint value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700580 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800581 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700582 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700583 }
584
585 static jvmtiError SetLocalLong(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700586 jthread thread,
587 jint depth,
588 jint slot,
589 jlong value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700590 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800591 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700592 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700593 }
594
595 static jvmtiError SetLocalFloat(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700596 jthread thread,
597 jint depth,
598 jint slot,
599 jfloat value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700600 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800601 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700602 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700603 }
604
605 static jvmtiError SetLocalDouble(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700606 jthread thread,
607 jint depth,
608 jint slot,
609 jdouble value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700610 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800611 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700612 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700613 }
614
Alex Lighta26e3492017-06-27 17:55:37 -0700615
616 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
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_generate_breakpoint_events);
Alex Lighta26e3492017-06-27 17:55:37 -0700619 return BreakpointUtil::SetBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700620 }
621
Alex Lighta26e3492017-06-27 17:55:37 -0700622 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700623 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800624 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Lighta26e3492017-06-27 17:55:37 -0700625 return BreakpointUtil::ClearBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700626 }
627
Alex Light084fa372017-06-16 08:58:34 -0700628 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700629 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800630 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700631 return FieldUtil::SetFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700632 }
633
Alex Light084fa372017-06-16 08:58:34 -0700634 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700635 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800636 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700637 return FieldUtil::ClearFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700638 }
639
Alex Light084fa372017-06-16 08:58:34 -0700640 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700641 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800642 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700643 return FieldUtil::SetFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700644 }
645
Alex Light084fa372017-06-16 08:58:34 -0700646 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700647 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800648 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700649 return FieldUtil::ClearFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700650 }
651
652 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700653 ENSURE_VALID_ENV(env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800654 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700655 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700656 }
657
658 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
659 jobject initiating_loader,
660 jint* class_count_ptr,
661 jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700662 ENSURE_VALID_ENV(env);
Andreas Gampe70f16392017-01-16 14:20:10 -0800663 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700664 }
665
666 static jvmtiError GetClassSignature(jvmtiEnv* env,
667 jclass klass,
668 char** signature_ptr,
669 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700670 ENSURE_VALID_ENV(env);
Andreas Gampee492ae32016-10-28 19:34:57 -0700671 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700672 }
673
674 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700675 ENSURE_VALID_ENV(env);
Andreas Gampeff9d2092017-01-06 09:12:49 -0800676 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700677 }
678
Alex Light6fa7b812017-06-16 09:04:29 -0700679 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700680 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800681 ENSURE_HAS_CAP(env, can_get_source_file_name);
Alex Light6fa7b812017-06-16 09:04:29 -0700682 return ClassUtil::GetSourceFileName(env, klass, source_name_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700683 }
684
685 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700686 ENSURE_VALID_ENV(env);
Andreas Gampe64013e52017-01-06 13:07:19 -0800687 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700688 }
689
690 static jvmtiError GetClassMethods(jvmtiEnv* env,
691 jclass klass,
692 jint* method_count_ptr,
693 jmethodID** methods_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700694 ENSURE_VALID_ENV(env);
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800695 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700696 }
697
698 static jvmtiError GetClassFields(jvmtiEnv* env,
699 jclass klass,
700 jint* field_count_ptr,
701 jfieldID** fields_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700702 ENSURE_VALID_ENV(env);
Andreas Gampeac587272017-01-05 15:21:34 -0800703 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700704 }
705
706 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
707 jclass klass,
708 jint* interface_count_ptr,
709 jclass** interfaces_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700710 ENSURE_VALID_ENV(env);
Andreas Gampe8b07e472017-01-06 14:20:39 -0800711 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700712 }
713
714 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
715 jclass klass,
716 jint* minor_version_ptr,
717 jint* major_version_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700718 ENSURE_VALID_ENV(env);
Andreas Gampe812a2442017-01-19 22:04:46 -0800719 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700720 }
721
722 static jvmtiError GetConstantPool(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800723 jclass klass ATTRIBUTE_UNUSED,
724 jint* constant_pool_count_ptr ATTRIBUTE_UNUSED,
725 jint* constant_pool_byte_count_ptr ATTRIBUTE_UNUSED,
726 unsigned char** constant_pool_bytes_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700727 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800728 ENSURE_HAS_CAP(env, can_get_constant_pool);
Alex Light49948e92016-08-11 15:35:28 -0700729 return ERR(NOT_IMPLEMENTED);
730 }
731
732 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700733 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800734 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700735 }
736
737 static jvmtiError IsArrayClass(jvmtiEnv* env,
738 jclass klass,
739 jboolean* is_array_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700740 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800741 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700742 }
743
744 static jvmtiError IsModifiableClass(jvmtiEnv* env,
745 jclass klass,
746 jboolean* is_modifiable_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700747 ENSURE_VALID_ENV(env);
Alex Lighte4a88632017-01-10 07:41:24 -0800748 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700749 }
750
751 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700752 ENSURE_VALID_ENV(env);
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800753 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700754 }
755
756 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
Alex Light6fa7b812017-06-16 09:04:29 -0700757 jclass klass,
758 char** source_debug_extension_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700759 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800760 ENSURE_HAS_CAP(env, can_get_source_debug_extension);
Alex Light6fa7b812017-06-16 09:04:29 -0700761 return ClassUtil::GetSourceDebugExtension(env, klass, source_debug_extension_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700762 }
763
764 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700765 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800766 ENSURE_HAS_CAP(env, can_retransform_classes);
Alex Light6ac57502017-01-19 15:05:06 -0800767 std::string error_msg;
768 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800769 &gEventHandler,
Alex Light6ac57502017-01-19 15:05:06 -0800770 art::Runtime::Current(),
771 art::Thread::Current(),
772 class_count,
773 classes,
774 &error_msg);
775 if (res != OK) {
776 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
777 }
778 return res;
Alex Light49948e92016-08-11 15:35:28 -0700779 }
780
781 static jvmtiError RedefineClasses(jvmtiEnv* env,
782 jint class_count,
783 const jvmtiClassDefinition* class_definitions) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700784 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800785 ENSURE_HAS_CAP(env, can_redefine_classes);
Alex Light0e692732017-01-10 15:00:05 -0800786 std::string error_msg;
787 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800788 &gEventHandler,
Alex Light0e692732017-01-10 15:00:05 -0800789 art::Runtime::Current(),
790 art::Thread::Current(),
791 class_count,
792 class_definitions,
793 &error_msg);
794 if (res != OK) {
795 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
796 }
797 return res;
Alex Light49948e92016-08-11 15:35:28 -0700798 }
799
800 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700801 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800802 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700803 }
804
805 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700806 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800807 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700808 }
809
810 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
Alex Lightce568642017-09-05 16:54:25 -0700811 jobject object,
812 jvmtiMonitorUsage* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700813 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800814 ENSURE_HAS_CAP(env, can_get_monitor_info);
Alex Lightce568642017-09-05 16:54:25 -0700815 return ObjectUtil::GetObjectMonitorUsage(env, object, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700816 }
817
818 static jvmtiError GetFieldName(jvmtiEnv* env,
819 jclass klass,
820 jfieldID field,
821 char** name_ptr,
822 char** signature_ptr,
823 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700824 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800825 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700826 }
827
828 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
829 jclass klass,
830 jfieldID field,
831 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700832 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800833 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700834 }
835
836 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
837 jclass klass,
838 jfieldID field,
839 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700840 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800841 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700842 }
843
844 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
845 jclass klass,
846 jfieldID field,
847 jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700848 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800849 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800850 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700851 }
852
853 static jvmtiError GetMethodName(jvmtiEnv* env,
854 jmethodID method,
855 char** name_ptr,
856 char** signature_ptr,
857 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700858 ENSURE_VALID_ENV(env);
Andreas Gampe3c252f02016-10-27 18:25:17 -0700859 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700860 }
861
862 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
863 jmethodID method,
864 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700865 ENSURE_VALID_ENV(env);
Andreas Gampe368a2082016-10-28 17:33:13 -0700866 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700867 }
868
869 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
870 jmethodID method,
871 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700872 ENSURE_VALID_ENV(env);
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700873 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700874 }
875
876 static jvmtiError GetMaxLocals(jvmtiEnv* env,
877 jmethodID method,
878 jint* max_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700879 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800880 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700881 }
882
883 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
884 jmethodID method,
885 jint* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700886 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800887 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700888 }
889
890 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
891 jmethodID method,
892 jint* entry_count_ptr,
893 jvmtiLineNumberEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700894 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800895 ENSURE_HAS_CAP(env, can_get_line_numbers);
Andreas Gampeda3e5612016-12-13 19:00:53 -0800896 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700897 }
898
899 static jvmtiError GetMethodLocation(jvmtiEnv* env,
900 jmethodID method,
901 jlocation* start_location_ptr,
902 jlocation* end_location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700903 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800904 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700905 }
906
907 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
Alex Lightce68cc62017-07-26 10:30:38 -0700908 jmethodID method,
909 jint* entry_count_ptr,
910 jvmtiLocalVariableEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700911 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800912 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightce68cc62017-07-26 10:30:38 -0700913 return MethodUtil::GetLocalVariableTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700914 }
915
916 static jvmtiError GetBytecodes(jvmtiEnv* env,
Alex Light4c174282017-07-05 10:18:18 -0700917 jmethodID method,
918 jint* bytecode_count_ptr,
919 unsigned char** bytecodes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700920 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800921 ENSURE_HAS_CAP(env, can_get_bytecodes);
Alex Light4c174282017-07-05 10:18:18 -0700922 return MethodUtil::GetBytecodes(env, method, bytecode_count_ptr, bytecodes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700923 }
924
925 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700926 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800927 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700928 }
929
930 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700931 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800932 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampefdeef522017-01-09 14:40:25 -0800933 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700934 }
935
936 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700937 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800938 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700939 }
940
Alex Light6a3fd512017-02-27 14:34:32 -0800941 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700942 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800943 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700944 return ERR(NOT_IMPLEMENTED);
945 }
946
Alex Light6a3fd512017-02-27 14:34:32 -0800947 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
948 jint prefix_count ATTRIBUTE_UNUSED,
949 char** prefixes 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
955 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700956 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800957 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700958 }
959
960 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700961 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800962 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700963 }
964
965 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700966 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800967 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700968 }
969
970 static jvmtiError RawMonitorExit(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::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700973 }
974
975 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700976 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800977 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700978 }
979
980 static jvmtiError RawMonitorNotify(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::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700983 }
984
985 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700986 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800987 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700988 }
989
990 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700991 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800992 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700993 }
994
995 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700996 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800997 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700998 }
999
Andreas Gampe77708d92016-10-07 11:48:21 -07001000 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
1001 // an event.
Alex Light49948e92016-08-11 15:35:28 -07001002 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
1003 const jvmtiEventCallbacks* callbacks,
1004 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -07001005 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001006 if (size_of_callbacks < 0) {
1007 return ERR(ILLEGAL_ARGUMENT);
1008 }
1009
1010 if (callbacks == nullptr) {
1011 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
1012 return ERR(NONE);
1013 }
1014
1015 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
1016 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
1017 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
1018 static_cast<size_t>(size_of_callbacks));
1019 copy_size = art::RoundDown(copy_size, sizeof(void*));
1020 memcpy(tmp.get(), callbacks, copy_size);
1021
1022 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
1023
1024 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001025 }
1026
1027 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
1028 jvmtiEventMode mode,
1029 jvmtiEvent event_type,
1030 jthread event_thread,
1031 ...) {
Alex Lighte6574242016-08-17 09:56:24 -07001032 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001033 art::Thread* art_thread = nullptr;
1034 if (event_thread != nullptr) {
Alex Light7ddc23d2017-09-22 15:33:41 -07001035 // TODO The locking around this call is less then what we really want.
Andreas Gampe77708d92016-10-07 11:48:21 -07001036 art::ScopedObjectAccess soa(art::Thread::Current());
1037 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
Alex Light7ddc23d2017-09-22 15:33:41 -07001038 jvmtiError err = ERR(INTERNAL);
1039 if (!ThreadUtil::GetAliveNativeThread(event_thread, soa, &art_thread, &err)) {
1040 return err;
1041 } else if (art_thread->IsStillStarting()) {
Andreas Gampe77708d92016-10-07 11:48:21 -07001042 return ERR(THREAD_NOT_ALIVE);
1043 }
1044 }
1045
Alex Light40d87f42017-01-18 10:27:06 -08001046 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1047 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -07001048 }
1049
Alex Light1edc8cf2017-03-24 14:22:56 -07001050 static jvmtiError GenerateEvents(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001051 jvmtiEvent event_type ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001052 ENSURE_VALID_ENV(env);
Alex Light6a3fd512017-02-27 14:34:32 -08001053 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001054 }
1055
Alex Light1edc8cf2017-03-24 14:22:56 -07001056 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001057 jint* extension_count_ptr,
1058 jvmtiExtensionFunctionInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001059 ENSURE_VALID_ENV(env);
Andreas Gamped73aba42017-05-03 21:40:26 -07001060 ENSURE_NON_NULL(extension_count_ptr);
1061 ENSURE_NON_NULL(extensions);
1062
1063 std::vector<jvmtiExtensionFunctionInfo> ext_vector;
1064
1065 // Holders for allocated values.
1066 std::vector<JvmtiUniquePtr<char[]>> char_buffers;
1067 std::vector<JvmtiUniquePtr<jvmtiParamInfo[]>> param_buffers;
1068 std::vector<JvmtiUniquePtr<jvmtiError[]>> error_buffers;
1069
1070 // Add a helper struct that takes an arbitrary const char*. add_extension will use Allocate
1071 // appropriately.
1072 struct CParamInfo {
1073 const char* name;
1074 jvmtiParamKind kind;
1075 jvmtiParamTypes base_type;
1076 jboolean null_ok;
1077 };
1078
1079 auto add_extension = [&](jvmtiExtensionFunction func,
1080 const char* id,
1081 const char* short_description,
1082 jint param_count,
1083 const std::vector<CParamInfo>& params,
1084 jint error_count,
1085 const std::vector<jvmtiError>& errors) {
1086 jvmtiExtensionFunctionInfo func_info;
1087 jvmtiError error;
1088
1089 func_info.func = func;
1090
1091 JvmtiUniquePtr<char[]> id_ptr = CopyString(env, id, &error);
1092 if (id_ptr == nullptr) {
1093 return error;
1094 }
1095 func_info.id = id_ptr.get();
1096 char_buffers.push_back(std::move(id_ptr));
1097
1098 JvmtiUniquePtr<char[]> descr = CopyString(env, short_description, &error);
1099 if (descr == nullptr) {
1100 return error;
1101 }
1102 func_info.short_description = descr.get();
1103 char_buffers.push_back(std::move(descr));
1104
1105 func_info.param_count = param_count;
1106 if (param_count > 0) {
1107 JvmtiUniquePtr<jvmtiParamInfo[]> params_ptr =
1108 AllocJvmtiUniquePtr<jvmtiParamInfo[]>(env, param_count, &error);
1109 if (params_ptr == nullptr) {
1110 return error;
1111 }
1112 func_info.params = params_ptr.get();
1113 param_buffers.push_back(std::move(params_ptr));
1114
1115 for (jint i = 0; i != param_count; ++i) {
1116 JvmtiUniquePtr<char[]> param_name = CopyString(env, params[i].name, &error);
1117 if (param_name == nullptr) {
1118 return error;
1119 }
1120 func_info.params[i].name = param_name.get();
1121 char_buffers.push_back(std::move(param_name));
1122
1123 func_info.params[i].kind = params[i].kind;
1124 func_info.params[i].base_type = params[i].base_type;
1125 func_info.params[i].null_ok = params[i].null_ok;
1126 }
1127 } else {
1128 func_info.params = nullptr;
1129 }
1130
1131 func_info.error_count = error_count;
1132 if (error_count > 0) {
1133 JvmtiUniquePtr<jvmtiError[]> errors_ptr =
1134 AllocJvmtiUniquePtr<jvmtiError[]>(env, error_count, &error);
1135 if (errors_ptr == nullptr) {
1136 return error;
1137 }
1138 func_info.errors = errors_ptr.get();
1139 error_buffers.push_back(std::move(errors_ptr));
1140
1141 for (jint i = 0; i != error_count; ++i) {
1142 func_info.errors[i] = errors[i];
1143 }
1144 } else {
1145 func_info.errors = nullptr;
1146 }
1147
1148 ext_vector.push_back(func_info);
1149
1150 return ERR(NONE);
1151 };
1152
1153 jvmtiError error;
1154
1155 // Heap extensions.
1156 error = add_extension(
1157 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetObjectHeapId),
1158 "com.android.art.heap.get_object_heap_id",
1159 "Retrieve the heap id of the the object tagged with the given argument. An "
1160 "arbitrary object is chosen if multiple objects exist with the same tag.",
1161 2,
1162 { // NOLINT [whitespace/braces] [4]
1163 { "tag", JVMTI_KIND_IN, JVMTI_TYPE_JLONG, false},
1164 { "heap_id", JVMTI_KIND_OUT, JVMTI_TYPE_JINT, false}
1165 },
1166 1,
1167 { JVMTI_ERROR_NOT_FOUND });
1168 if (error != ERR(NONE)) {
1169 return error;
1170 }
1171
1172 error = add_extension(
1173 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetHeapName),
1174 "com.android.art.heap.get_heap_name",
1175 "Retrieve the name of the heap with the given id.",
1176 2,
1177 { // NOLINT [whitespace/braces] [4]
1178 { "heap_id", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1179 { "heap_name", JVMTI_KIND_ALLOC_BUF, JVMTI_TYPE_CCHAR, false}
1180 },
1181 1,
1182 { JVMTI_ERROR_ILLEGAL_ARGUMENT });
1183 if (error != ERR(NONE)) {
1184 return error;
1185 }
1186
Andreas Gampe2eb25e42017-05-09 17:14:58 -07001187 error = add_extension(
1188 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::IterateThroughHeapExt),
1189 "com.android.art.heap.iterate_through_heap_ext",
1190 "Iterate through a heap. This is equivalent to the standard IterateThroughHeap function,"
1191 " except for additionally passing the heap id of the current object. The jvmtiHeapCallbacks"
1192 " structure is reused, with the callbacks field overloaded to a signature of "
1193 "jint (*)(jlong, jlong, jlong*, jint length, void*, jint).",
1194 4,
1195 { // NOLINT [whitespace/braces] [4]
1196 { "heap_filter", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1197 { "klass", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, true},
1198 { "callbacks", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, false},
1199 { "user_data", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, true}
1200 },
1201 3,
1202 { // NOLINT [whitespace/braces] [4]
1203 JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
1204 JVMTI_ERROR_INVALID_CLASS,
1205 JVMTI_ERROR_NULL_POINTER
1206 });
1207 if (error != ERR(NONE)) {
1208 return error;
1209 }
1210
Alex Light8ddfd9f2017-07-05 16:33:46 -07001211 error = add_extension(
1212 reinterpret_cast<jvmtiExtensionFunction>(AllocUtil::GetGlobalJvmtiAllocationState),
1213 "com.android.art.alloc.get_global_jvmti_allocation_state",
1214 "Returns the total amount of memory currently allocated by all jvmtiEnvs through the"
1215 " 'Allocate' jvmti function. This does not include any memory that has been deallocated"
1216 " through the 'Deallocate' function. This number is approximate and might not correspond"
1217 " exactly to the sum of the sizes of all not freed allocations.",
1218 1,
1219 { // NOLINT [whitespace/braces] [4]
1220 { "currently_allocated", JVMTI_KIND_OUT, JVMTI_TYPE_JLONG, false},
1221 },
1222 1,
1223 { ERR(NULL_POINTER) });
1224 if (error != ERR(NONE)) {
1225 return error;
1226 }
1227
Andreas Gamped73aba42017-05-03 21:40:26 -07001228 // Copy into output buffer.
1229
1230 *extension_count_ptr = ext_vector.size();
1231 JvmtiUniquePtr<jvmtiExtensionFunctionInfo[]> out_data =
1232 AllocJvmtiUniquePtr<jvmtiExtensionFunctionInfo[]>(env, ext_vector.size(), &error);
1233 if (out_data == nullptr) {
1234 return error;
1235 }
1236 memcpy(out_data.get(),
1237 ext_vector.data(),
1238 ext_vector.size() * sizeof(jvmtiExtensionFunctionInfo));
1239 *extensions = out_data.release();
1240
1241 // Release all the buffer holders, we're OK now.
1242 for (auto& holder : char_buffers) {
1243 holder.release();
1244 }
1245 for (auto& holder : param_buffers) {
1246 holder.release();
1247 }
1248 for (auto& holder : error_buffers) {
1249 holder.release();
1250 }
Andreas Gampee4c33842017-01-09 10:50:17 -08001251
1252 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001253 }
1254
Alex Light1edc8cf2017-03-24 14:22:56 -07001255 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001256 jint* extension_count_ptr,
1257 jvmtiExtensionEventInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001258 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001259 // We do not have any extension events.
1260 *extension_count_ptr = 0;
1261 *extensions = nullptr;
1262
1263 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001264 }
1265
Alex Light1edc8cf2017-03-24 14:22:56 -07001266 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001267 jint extension_event_index ATTRIBUTE_UNUSED,
1268 jvmtiExtensionEvent callback ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001269 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001270 // We do not have any extension events, so any call is illegal.
1271 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001272 }
1273
1274 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001275 ENSURE_VALID_ENV(env);
1276 ENSURE_NON_NULL(capabilities_ptr);
1277 *capabilities_ptr = kPotentialCapabilities;
1278 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001279 }
1280
1281 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001282 ENSURE_VALID_ENV(env);
1283 ENSURE_NON_NULL(capabilities_ptr);
1284 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1285 jvmtiError ret = OK;
Alex Light34d8e082017-03-27 09:50:36 -07001286 jvmtiCapabilities changed = {};
1287 jvmtiCapabilities potential_capabilities = {};
Alex Light1d224962017-02-27 10:26:35 -08001288 ret = env->GetPotentialCapabilities(&potential_capabilities);
1289 if (ret != OK) {
1290 return ret;
1291 }
Alex Lighte6574242016-08-17 09:56:24 -07001292#define ADD_CAPABILITY(e) \
1293 do { \
1294 if (capabilities_ptr->e == 1) { \
Alex Light1d224962017-02-27 10:26:35 -08001295 if (potential_capabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001296 if (art_env->capabilities.e != 1) { \
1297 art_env->capabilities.e = 1; \
1298 changed.e = 1; \
1299 }\
Alex Lighte6574242016-08-17 09:56:24 -07001300 } else { \
1301 ret = ERR(NOT_AVAILABLE); \
1302 } \
1303 } \
1304 } while (false)
1305
1306 ADD_CAPABILITY(can_tag_objects);
1307 ADD_CAPABILITY(can_generate_field_modification_events);
1308 ADD_CAPABILITY(can_generate_field_access_events);
1309 ADD_CAPABILITY(can_get_bytecodes);
1310 ADD_CAPABILITY(can_get_synthetic_attribute);
1311 ADD_CAPABILITY(can_get_owned_monitor_info);
1312 ADD_CAPABILITY(can_get_current_contended_monitor);
1313 ADD_CAPABILITY(can_get_monitor_info);
1314 ADD_CAPABILITY(can_pop_frame);
1315 ADD_CAPABILITY(can_redefine_classes);
1316 ADD_CAPABILITY(can_signal_thread);
1317 ADD_CAPABILITY(can_get_source_file_name);
1318 ADD_CAPABILITY(can_get_line_numbers);
1319 ADD_CAPABILITY(can_get_source_debug_extension);
1320 ADD_CAPABILITY(can_access_local_variables);
1321 ADD_CAPABILITY(can_maintain_original_method_order);
1322 ADD_CAPABILITY(can_generate_single_step_events);
1323 ADD_CAPABILITY(can_generate_exception_events);
1324 ADD_CAPABILITY(can_generate_frame_pop_events);
1325 ADD_CAPABILITY(can_generate_breakpoint_events);
1326 ADD_CAPABILITY(can_suspend);
1327 ADD_CAPABILITY(can_redefine_any_class);
1328 ADD_CAPABILITY(can_get_current_thread_cpu_time);
1329 ADD_CAPABILITY(can_get_thread_cpu_time);
1330 ADD_CAPABILITY(can_generate_method_entry_events);
1331 ADD_CAPABILITY(can_generate_method_exit_events);
1332 ADD_CAPABILITY(can_generate_all_class_hook_events);
1333 ADD_CAPABILITY(can_generate_compiled_method_load_events);
1334 ADD_CAPABILITY(can_generate_monitor_events);
1335 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
1336 ADD_CAPABILITY(can_generate_native_method_bind_events);
1337 ADD_CAPABILITY(can_generate_garbage_collection_events);
1338 ADD_CAPABILITY(can_generate_object_free_events);
1339 ADD_CAPABILITY(can_force_early_return);
1340 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1341 ADD_CAPABILITY(can_get_constant_pool);
1342 ADD_CAPABILITY(can_set_native_method_prefix);
1343 ADD_CAPABILITY(can_retransform_classes);
1344 ADD_CAPABILITY(can_retransform_any_class);
1345 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1346 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1347#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001348 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1349 changed,
1350 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -07001351 return ret;
Alex Light49948e92016-08-11 15:35:28 -07001352 }
1353
1354 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1355 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001356 ENSURE_VALID_ENV(env);
1357 ENSURE_NON_NULL(capabilities_ptr);
1358 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light34d8e082017-03-27 09:50:36 -07001359 jvmtiCapabilities changed = {};
Alex Lighte6574242016-08-17 09:56:24 -07001360#define DEL_CAPABILITY(e) \
1361 do { \
1362 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001363 if (art_env->capabilities.e == 1) { \
1364 art_env->capabilities.e = 0;\
1365 changed.e = 1; \
1366 } \
Alex Lighte6574242016-08-17 09:56:24 -07001367 } \
1368 } while (false)
1369
1370 DEL_CAPABILITY(can_tag_objects);
1371 DEL_CAPABILITY(can_generate_field_modification_events);
1372 DEL_CAPABILITY(can_generate_field_access_events);
1373 DEL_CAPABILITY(can_get_bytecodes);
1374 DEL_CAPABILITY(can_get_synthetic_attribute);
1375 DEL_CAPABILITY(can_get_owned_monitor_info);
1376 DEL_CAPABILITY(can_get_current_contended_monitor);
1377 DEL_CAPABILITY(can_get_monitor_info);
1378 DEL_CAPABILITY(can_pop_frame);
1379 DEL_CAPABILITY(can_redefine_classes);
1380 DEL_CAPABILITY(can_signal_thread);
1381 DEL_CAPABILITY(can_get_source_file_name);
1382 DEL_CAPABILITY(can_get_line_numbers);
1383 DEL_CAPABILITY(can_get_source_debug_extension);
1384 DEL_CAPABILITY(can_access_local_variables);
1385 DEL_CAPABILITY(can_maintain_original_method_order);
1386 DEL_CAPABILITY(can_generate_single_step_events);
1387 DEL_CAPABILITY(can_generate_exception_events);
1388 DEL_CAPABILITY(can_generate_frame_pop_events);
1389 DEL_CAPABILITY(can_generate_breakpoint_events);
1390 DEL_CAPABILITY(can_suspend);
1391 DEL_CAPABILITY(can_redefine_any_class);
1392 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1393 DEL_CAPABILITY(can_get_thread_cpu_time);
1394 DEL_CAPABILITY(can_generate_method_entry_events);
1395 DEL_CAPABILITY(can_generate_method_exit_events);
1396 DEL_CAPABILITY(can_generate_all_class_hook_events);
1397 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1398 DEL_CAPABILITY(can_generate_monitor_events);
1399 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1400 DEL_CAPABILITY(can_generate_native_method_bind_events);
1401 DEL_CAPABILITY(can_generate_garbage_collection_events);
1402 DEL_CAPABILITY(can_generate_object_free_events);
1403 DEL_CAPABILITY(can_force_early_return);
1404 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1405 DEL_CAPABILITY(can_get_constant_pool);
1406 DEL_CAPABILITY(can_set_native_method_prefix);
1407 DEL_CAPABILITY(can_retransform_classes);
1408 DEL_CAPABILITY(can_retransform_any_class);
1409 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1410 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1411#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001412 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1413 changed,
1414 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001415 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001416 }
1417
1418 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001419 ENSURE_VALID_ENV(env);
1420 ENSURE_NON_NULL(capabilities_ptr);
1421 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1422 *capabilities_ptr = artenv->capabilities;
1423 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001424 }
1425
Alex Light6a3fd512017-02-27 14:34:32 -08001426 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1427 jvmtiTimerInfo* info_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 GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001434 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001435 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001436 return ERR(NOT_IMPLEMENTED);
1437 }
1438
Alex Light6a3fd512017-02-27 14:34:32 -08001439 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1440 jvmtiTimerInfo* info_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
Alex Light6a3fd512017-02-27 14:34:32 -08001446 static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1447 jthread thread ATTRIBUTE_UNUSED,
1448 jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001449 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001450 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001451 return ERR(NOT_IMPLEMENTED);
1452 }
1453
1454 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001455 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001456 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001457 }
1458
1459 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001460 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001461 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001462 }
1463
1464 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001465 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001466 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001467 }
1468
1469 static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001470 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001471 return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001472 }
1473
1474 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001475 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001476 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001477 }
1478
1479 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001480 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001481 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001482 }
1483
1484 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001485 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001486 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001487 }
1488
1489 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001490 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001491 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001492 }
1493
1494 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001495 ENSURE_VALID_ENV(env);
Andreas Gampe96eca782017-01-19 19:45:30 -08001496 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001497 }
1498
1499 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001500 ENSURE_VALID_ENV(env);
Alex Light092a4042017-07-12 08:46:44 -07001501 ArtJvmTiEnv* tienv = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1502 gEventHandler.RemoveArtJvmTiEnv(tienv);
1503 art::Runtime::Current()->RemoveSystemWeakHolder(tienv->object_tag_table.get());
1504 ThreadUtil::RemoveEnvironment(tienv);
1505 delete tienv;
Alex Light49948e92016-08-11 15:35:28 -07001506 return OK;
1507 }
1508
1509 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001510 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001511 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1512 return OK;
1513 }
1514
1515 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001516 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001517 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1518 return OK;
1519 }
1520
1521 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001522 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001523 *version_ptr = JVMTI_VERSION;
1524 return OK;
1525 }
1526
1527 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001528 ENSURE_NON_NULL(name_ptr);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001529 auto copy_fn = [&](const char* name_cstr) {
1530 jvmtiError res;
1531 JvmtiUniquePtr<char[]> copy = CopyString(env, name_cstr, &res);
1532 if (copy == nullptr) {
1533 *name_ptr = nullptr;
1534 return res;
1535 } else {
1536 *name_ptr = copy.release();
1537 return OK;
1538 }
1539 };
Alex Light49948e92016-08-11 15:35:28 -07001540 switch (error) {
Andreas Gampe95c466d2017-05-08 14:50:47 -07001541#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : \
1542 return copy_fn("JVMTI_ERROR_"#e);
Alex Light49948e92016-08-11 15:35:28 -07001543 ERROR_CASE(NONE);
1544 ERROR_CASE(INVALID_THREAD);
1545 ERROR_CASE(INVALID_THREAD_GROUP);
1546 ERROR_CASE(INVALID_PRIORITY);
1547 ERROR_CASE(THREAD_NOT_SUSPENDED);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001548 ERROR_CASE(THREAD_SUSPENDED);
Alex Light49948e92016-08-11 15:35:28 -07001549 ERROR_CASE(THREAD_NOT_ALIVE);
1550 ERROR_CASE(INVALID_OBJECT);
1551 ERROR_CASE(INVALID_CLASS);
1552 ERROR_CASE(CLASS_NOT_PREPARED);
1553 ERROR_CASE(INVALID_METHODID);
1554 ERROR_CASE(INVALID_LOCATION);
1555 ERROR_CASE(INVALID_FIELDID);
1556 ERROR_CASE(NO_MORE_FRAMES);
1557 ERROR_CASE(OPAQUE_FRAME);
1558 ERROR_CASE(TYPE_MISMATCH);
1559 ERROR_CASE(INVALID_SLOT);
1560 ERROR_CASE(DUPLICATE);
1561 ERROR_CASE(NOT_FOUND);
1562 ERROR_CASE(INVALID_MONITOR);
1563 ERROR_CASE(NOT_MONITOR_OWNER);
1564 ERROR_CASE(INTERRUPT);
1565 ERROR_CASE(INVALID_CLASS_FORMAT);
1566 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1567 ERROR_CASE(FAILS_VERIFICATION);
1568 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1569 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1570 ERROR_CASE(INVALID_TYPESTATE);
1571 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1572 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1573 ERROR_CASE(UNSUPPORTED_VERSION);
1574 ERROR_CASE(NAMES_DONT_MATCH);
1575 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1576 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1577 ERROR_CASE(UNMODIFIABLE_CLASS);
1578 ERROR_CASE(NOT_AVAILABLE);
1579 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1580 ERROR_CASE(NULL_POINTER);
1581 ERROR_CASE(ABSENT_INFORMATION);
1582 ERROR_CASE(INVALID_EVENT_TYPE);
1583 ERROR_CASE(ILLEGAL_ARGUMENT);
1584 ERROR_CASE(NATIVE_METHOD);
1585 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1586 ERROR_CASE(OUT_OF_MEMORY);
1587 ERROR_CASE(ACCESS_DENIED);
1588 ERROR_CASE(WRONG_PHASE);
1589 ERROR_CASE(INTERNAL);
1590 ERROR_CASE(UNATTACHED_THREAD);
1591 ERROR_CASE(INVALID_ENVIRONMENT);
1592#undef ERROR_CASE
Alex Light49948e92016-08-11 15:35:28 -07001593 }
Andreas Gampe95c466d2017-05-08 14:50:47 -07001594
1595 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001596 }
1597
Alex Light1edc8cf2017-03-24 14:22:56 -07001598 static jvmtiError SetVerboseFlag(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001599 jvmtiVerboseFlag flag,
1600 jboolean value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001601 ENSURE_VALID_ENV(env);
Andreas Gampef37e3022017-01-13 17:54:46 -08001602 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1603 // OTHER is special, as it's 0, so can't do a bit check.
1604 bool val = (value == JNI_TRUE) ? true : false;
1605
1606 art::gLogVerbosity.collector = val;
1607 art::gLogVerbosity.compiler = val;
1608 art::gLogVerbosity.deopt = val;
1609 art::gLogVerbosity.heap = val;
1610 art::gLogVerbosity.jdwp = val;
1611 art::gLogVerbosity.jit = val;
1612 art::gLogVerbosity.monitor = val;
1613 art::gLogVerbosity.oat = val;
1614 art::gLogVerbosity.profiler = val;
1615 art::gLogVerbosity.signals = val;
1616 art::gLogVerbosity.simulator = val;
1617 art::gLogVerbosity.startup = val;
1618 art::gLogVerbosity.third_party_jni = val;
1619 art::gLogVerbosity.threads = val;
1620 art::gLogVerbosity.verifier = val;
1621 art::gLogVerbosity.image = val;
1622
1623 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1624
1625 art::gLogVerbosity.agents = val;
1626 } else {
1627 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1628 // semantics.
1629 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1630 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1631 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1632 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1633 if ((flag & ~kMask) != 0) {
1634 return ERR(ILLEGAL_ARGUMENT);
1635 }
1636
1637 bool val = (value == JNI_TRUE) ? true : false;
1638
1639 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1640 art::gLogVerbosity.gc = val;
1641 }
1642
1643 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1644 art::gLogVerbosity.class_linker = val;
1645 }
1646
1647 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1648 art::gLogVerbosity.jni = val;
1649 }
1650 }
1651
1652 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001653 }
1654
Alex Light1edc8cf2017-03-24 14:22:56 -07001655 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1656 ENSURE_VALID_ENV(env);
Andreas Gampeacfc9572017-01-17 18:36:56 -08001657 // Report BCI as jlocation format. We report dex bytecode indices.
1658 if (format_ptr == nullptr) {
1659 return ERR(NULL_POINTER);
1660 }
1661 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1662 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001663 }
1664};
1665
1666static bool IsJvmtiVersion(jint version) {
1667 return version == JVMTI_VERSION_1 ||
1668 version == JVMTI_VERSION_1_0 ||
1669 version == JVMTI_VERSION_1_1 ||
1670 version == JVMTI_VERSION_1_2 ||
1671 version == JVMTI_VERSION;
1672}
1673
Andreas Gampede19eb92017-02-24 16:21:18 -08001674extern const jvmtiInterface_1 gJvmtiInterface;
Alex Light092a4042017-07-12 08:46:44 -07001675
Andreas Gampede19eb92017-02-24 16:21:18 -08001676ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler)
1677 : art_vm(runtime),
1678 local_data(nullptr),
Andreas Gampea1705ea2017-03-28 20:12:13 -07001679 capabilities() {
1680 object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
Andreas Gampede19eb92017-02-24 16:21:18 -08001681 functions = &gJvmtiInterface;
1682}
1683
Alex Light49948e92016-08-11 15:35:28 -07001684// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1685// is a pointer to the uninitialized memory for an art::ti::Env.
1686static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
Andreas Gampede19eb92017-02-24 16:21:18 -08001687 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler);
Alex Light49948e92016-08-11 15:35:28 -07001688 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001689
1690 gEventHandler.RegisterArtJvmTiEnv(env);
Andreas Gampede19eb92017-02-24 16:21:18 -08001691
1692 art::Runtime::Current()->AddSystemWeakHolder(
1693 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001694}
1695
1696// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1697// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1698// returns false and does not modify the 'env' pointer.
1699static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1700 if (IsJvmtiVersion(version)) {
1701 CreateArtJvmTiEnv(vm, env);
1702 return JNI_OK;
1703 } else {
1704 printf("version 0x%x is not valid!", version);
1705 return JNI_EVERSION;
1706 }
1707}
1708
1709// The plugin initialization function. This adds the jvmti environment.
1710extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001711 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001712
1713 if (runtime->IsStarted()) {
1714 PhaseUtil::SetToLive();
1715 } else {
1716 PhaseUtil::SetToOnLoad();
1717 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001718 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001719 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001720 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001721 DumpUtil::Register(&gEventHandler);
Alex Lightd78ddec2017-04-18 15:20:38 -07001722 MethodUtil::Register(&gEventHandler);
Andreas Gampecefaa142017-01-23 15:04:59 -08001723 SearchUtil::Register();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001724 HeapUtil::Register();
Andreas Gampe96eca782017-01-19 19:45:30 -08001725
Andreas Gampee08a2be2016-10-06 13:13:30 -07001726 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001727
Alex Light49948e92016-08-11 15:35:28 -07001728 return true;
1729}
1730
Andreas Gampeeafaf572017-01-20 12:34:15 -08001731extern "C" bool ArtPlugin_Deinitialize() {
Alex Lightb7edcda2017-04-27 13:20:31 -07001732 gEventHandler.Shutdown();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001733 PhaseUtil::Unregister();
1734 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001735 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001736 DumpUtil::Unregister();
Alex Lightd78ddec2017-04-18 15:20:38 -07001737 MethodUtil::Unregister();
Andreas Gampecefaa142017-01-23 15:04:59 -08001738 SearchUtil::Unregister();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001739 HeapUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001740
1741 return true;
1742}
1743
Alex Light49948e92016-08-11 15:35:28 -07001744// The actual struct holding all of the entrypoints into the jvmti interface.
1745const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001746 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001747 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001748 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001749 JvmtiFunctions::GetAllThreads,
1750 JvmtiFunctions::SuspendThread,
1751 JvmtiFunctions::ResumeThread,
1752 JvmtiFunctions::StopThread,
1753 JvmtiFunctions::InterruptThread,
1754 JvmtiFunctions::GetThreadInfo,
1755 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1756 JvmtiFunctions::GetCurrentContendedMonitor,
1757 JvmtiFunctions::RunAgentThread,
1758 JvmtiFunctions::GetTopThreadGroups,
1759 JvmtiFunctions::GetThreadGroupInfo,
1760 JvmtiFunctions::GetThreadGroupChildren,
1761 JvmtiFunctions::GetFrameCount,
1762 JvmtiFunctions::GetThreadState,
1763 JvmtiFunctions::GetCurrentThread,
1764 JvmtiFunctions::GetFrameLocation,
1765 JvmtiFunctions::NotifyFramePop, // 20
1766 JvmtiFunctions::GetLocalObject,
1767 JvmtiFunctions::GetLocalInt,
1768 JvmtiFunctions::GetLocalLong,
1769 JvmtiFunctions::GetLocalFloat,
1770 JvmtiFunctions::GetLocalDouble,
1771 JvmtiFunctions::SetLocalObject,
1772 JvmtiFunctions::SetLocalInt,
1773 JvmtiFunctions::SetLocalLong,
1774 JvmtiFunctions::SetLocalFloat,
1775 JvmtiFunctions::SetLocalDouble, // 30
1776 JvmtiFunctions::CreateRawMonitor,
1777 JvmtiFunctions::DestroyRawMonitor,
1778 JvmtiFunctions::RawMonitorEnter,
1779 JvmtiFunctions::RawMonitorExit,
1780 JvmtiFunctions::RawMonitorWait,
1781 JvmtiFunctions::RawMonitorNotify,
1782 JvmtiFunctions::RawMonitorNotifyAll,
1783 JvmtiFunctions::SetBreakpoint,
1784 JvmtiFunctions::ClearBreakpoint,
1785 nullptr, // reserved40
1786 JvmtiFunctions::SetFieldAccessWatch,
1787 JvmtiFunctions::ClearFieldAccessWatch,
1788 JvmtiFunctions::SetFieldModificationWatch,
1789 JvmtiFunctions::ClearFieldModificationWatch,
1790 JvmtiFunctions::IsModifiableClass,
1791 JvmtiFunctions::Allocate,
1792 JvmtiFunctions::Deallocate,
1793 JvmtiFunctions::GetClassSignature,
1794 JvmtiFunctions::GetClassStatus,
1795 JvmtiFunctions::GetSourceFileName, // 50
1796 JvmtiFunctions::GetClassModifiers,
1797 JvmtiFunctions::GetClassMethods,
1798 JvmtiFunctions::GetClassFields,
1799 JvmtiFunctions::GetImplementedInterfaces,
1800 JvmtiFunctions::IsInterface,
1801 JvmtiFunctions::IsArrayClass,
1802 JvmtiFunctions::GetClassLoader,
1803 JvmtiFunctions::GetObjectHashCode,
1804 JvmtiFunctions::GetObjectMonitorUsage,
1805 JvmtiFunctions::GetFieldName, // 60
1806 JvmtiFunctions::GetFieldDeclaringClass,
1807 JvmtiFunctions::GetFieldModifiers,
1808 JvmtiFunctions::IsFieldSynthetic,
1809 JvmtiFunctions::GetMethodName,
1810 JvmtiFunctions::GetMethodDeclaringClass,
1811 JvmtiFunctions::GetMethodModifiers,
1812 nullptr, // reserved67
1813 JvmtiFunctions::GetMaxLocals,
1814 JvmtiFunctions::GetArgumentsSize,
1815 JvmtiFunctions::GetLineNumberTable, // 70
1816 JvmtiFunctions::GetMethodLocation,
1817 JvmtiFunctions::GetLocalVariableTable,
1818 JvmtiFunctions::SetNativeMethodPrefix,
1819 JvmtiFunctions::SetNativeMethodPrefixes,
1820 JvmtiFunctions::GetBytecodes,
1821 JvmtiFunctions::IsMethodNative,
1822 JvmtiFunctions::IsMethodSynthetic,
1823 JvmtiFunctions::GetLoadedClasses,
1824 JvmtiFunctions::GetClassLoaderClasses,
1825 JvmtiFunctions::PopFrame, // 80
1826 JvmtiFunctions::ForceEarlyReturnObject,
1827 JvmtiFunctions::ForceEarlyReturnInt,
1828 JvmtiFunctions::ForceEarlyReturnLong,
1829 JvmtiFunctions::ForceEarlyReturnFloat,
1830 JvmtiFunctions::ForceEarlyReturnDouble,
1831 JvmtiFunctions::ForceEarlyReturnVoid,
1832 JvmtiFunctions::RedefineClasses,
1833 JvmtiFunctions::GetVersionNumber,
1834 JvmtiFunctions::GetCapabilities,
1835 JvmtiFunctions::GetSourceDebugExtension, // 90
1836 JvmtiFunctions::IsMethodObsolete,
1837 JvmtiFunctions::SuspendThreadList,
1838 JvmtiFunctions::ResumeThreadList,
1839 nullptr, // reserved94
1840 nullptr, // reserved95
1841 nullptr, // reserved96
1842 nullptr, // reserved97
1843 nullptr, // reserved98
1844 nullptr, // reserved99
1845 JvmtiFunctions::GetAllStackTraces, // 100
1846 JvmtiFunctions::GetThreadListStackTraces,
1847 JvmtiFunctions::GetThreadLocalStorage,
1848 JvmtiFunctions::SetThreadLocalStorage,
1849 JvmtiFunctions::GetStackTrace,
1850 nullptr, // reserved105
1851 JvmtiFunctions::GetTag,
1852 JvmtiFunctions::SetTag,
1853 JvmtiFunctions::ForceGarbageCollection,
1854 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1855 JvmtiFunctions::IterateOverReachableObjects, // 110
1856 JvmtiFunctions::IterateOverHeap,
1857 JvmtiFunctions::IterateOverInstancesOfClass,
1858 nullptr, // reserved113
1859 JvmtiFunctions::GetObjectsWithTags,
1860 JvmtiFunctions::FollowReferences,
1861 JvmtiFunctions::IterateThroughHeap,
1862 nullptr, // reserved117
1863 nullptr, // reserved118
1864 nullptr, // reserved119
1865 JvmtiFunctions::SetJNIFunctionTable, // 120
1866 JvmtiFunctions::GetJNIFunctionTable,
1867 JvmtiFunctions::SetEventCallbacks,
1868 JvmtiFunctions::GenerateEvents,
1869 JvmtiFunctions::GetExtensionFunctions,
1870 JvmtiFunctions::GetExtensionEvents,
1871 JvmtiFunctions::SetExtensionEventCallback,
1872 JvmtiFunctions::DisposeEnvironment,
1873 JvmtiFunctions::GetErrorName,
1874 JvmtiFunctions::GetJLocationFormat,
1875 JvmtiFunctions::GetSystemProperties, // 130
1876 JvmtiFunctions::GetSystemProperty,
1877 JvmtiFunctions::SetSystemProperty,
1878 JvmtiFunctions::GetPhase,
1879 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1880 JvmtiFunctions::GetCurrentThreadCpuTime,
1881 JvmtiFunctions::GetThreadCpuTimerInfo,
1882 JvmtiFunctions::GetThreadCpuTime,
1883 JvmtiFunctions::GetTimerInfo,
1884 JvmtiFunctions::GetTime,
1885 JvmtiFunctions::GetPotentialCapabilities, // 140
1886 nullptr, // reserved141
1887 JvmtiFunctions::AddCapabilities,
1888 JvmtiFunctions::RelinquishCapabilities,
1889 JvmtiFunctions::GetAvailableProcessors,
1890 JvmtiFunctions::GetClassVersionNumbers,
1891 JvmtiFunctions::GetConstantPool,
1892 JvmtiFunctions::GetEnvironmentLocalStorage,
1893 JvmtiFunctions::SetEnvironmentLocalStorage,
1894 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1895 JvmtiFunctions::SetVerboseFlag, // 150
1896 JvmtiFunctions::AddToSystemClassLoaderSearch,
1897 JvmtiFunctions::RetransformClasses,
1898 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1899 JvmtiFunctions::GetObjectSize,
1900 JvmtiFunctions::GetLocalInstance,
1901};
1902
1903}; // namespace openjdkjvmti