blob: 1cca36ba2e16a658b4549d77a2e1ff7866de9f3d [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 Light6a3fd512017-02-27 14:34:32 -0800166 static jvmtiError StopThread(jvmtiEnv* env,
167 jthread thread ATTRIBUTE_UNUSED,
168 jobject exception ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700169 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800170 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700171 return ERR(NOT_IMPLEMENTED);
172 }
173
Alex Light6a3fd512017-02-27 14:34:32 -0800174 static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700175 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800176 ENSURE_HAS_CAP(env, can_signal_thread);
Alex Light49948e92016-08-11 15:35:28 -0700177 return ERR(NOT_IMPLEMENTED);
178 }
179
180 static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700181 ENSURE_VALID_ENV(env);
Andreas Gampeaf13ab92017-01-11 20:57:40 -0800182 return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700183 }
184
185 static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
Alex Light88e1ddd2017-08-21 13:09:55 -0700186 jthread thread,
187 jint* owned_monitor_count_ptr,
188 jobject** owned_monitors_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700189 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800190 ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
Alex Light88e1ddd2017-08-21 13:09:55 -0700191 return StackUtil::GetOwnedMonitorInfo(env,
192 thread,
193 owned_monitor_count_ptr,
194 owned_monitors_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700195 }
196
Alex Light88e1ddd2017-08-21 13:09:55 -0700197 static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
198 jthread thread,
199 jint* monitor_info_count_ptr,
200 jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700201 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800202 ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
Alex Light88e1ddd2017-08-21 13:09:55 -0700203 return StackUtil::GetOwnedMonitorStackDepthInfo(env,
204 thread,
205 monitor_info_count_ptr,
206 monitor_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700207 }
208
209 static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800210 jthread thread ATTRIBUTE_UNUSED,
211 jobject* monitor_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700212 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800213 ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
Alex Lighte6574242016-08-17 09:56:24 -0700214 return ERR(NOT_IMPLEMENTED);
Alex Light49948e92016-08-11 15:35:28 -0700215 }
216
217 static jvmtiError RunAgentThread(jvmtiEnv* env,
218 jthread thread,
219 jvmtiStartFunction proc,
220 const void* arg,
221 jint priority) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700222 ENSURE_VALID_ENV(env);
Andreas Gampe732b0ac2017-01-18 15:23:39 -0800223 return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
Alex Light49948e92016-08-11 15:35:28 -0700224 }
225
226 static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700227 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800228 return ThreadUtil::SetThreadLocalStorage(env, thread, data);
Alex Light49948e92016-08-11 15:35:28 -0700229 }
230
231 static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700232 ENSURE_VALID_ENV(env);
Andreas Gampe7b3b3262017-01-19 20:40:42 -0800233 return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700234 }
235
236 static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
237 jint* group_count_ptr,
238 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700239 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000240 return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700241 }
242
243 static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
244 jthreadGroup group,
245 jvmtiThreadGroupInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700246 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000247 return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700248 }
249
250 static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
251 jthreadGroup group,
252 jint* thread_count_ptr,
253 jthread** threads_ptr,
254 jint* group_count_ptr,
255 jthreadGroup** groups_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700256 ENSURE_VALID_ENV(env);
Andreas Gamped18d9e22017-01-16 16:08:45 +0000257 return ThreadGroupUtil::GetThreadGroupChildren(env,
258 group,
259 thread_count_ptr,
260 threads_ptr,
261 group_count_ptr,
262 groups_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700263 }
264
265 static jvmtiError GetStackTrace(jvmtiEnv* env,
266 jthread thread,
267 jint start_depth,
268 jint max_frame_count,
269 jvmtiFrameInfo* frame_buffer,
270 jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700271 ENSURE_VALID_ENV(env);
Andreas Gampeb5eb94a2016-10-27 19:23:09 -0700272 return StackUtil::GetStackTrace(env,
273 thread,
274 start_depth,
275 max_frame_count,
276 frame_buffer,
277 count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700278 }
279
280 static jvmtiError GetAllStackTraces(jvmtiEnv* env,
281 jint max_frame_count,
282 jvmtiStackInfo** stack_info_ptr,
283 jint* thread_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700284 ENSURE_VALID_ENV(env);
Andreas Gampea1a27c62017-01-11 16:37:16 -0800285 return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700286 }
287
288 static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
289 jint thread_count,
290 const jthread* thread_list,
291 jint max_frame_count,
292 jvmtiStackInfo** stack_info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700293 ENSURE_VALID_ENV(env);
Andreas Gampeeba32fb2017-01-12 17:40:05 -0800294 return StackUtil::GetThreadListStackTraces(env,
295 thread_count,
296 thread_list,
297 max_frame_count,
298 stack_info_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700299 }
300
301 static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700302 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800303 return StackUtil::GetFrameCount(env, thread, count_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700304 }
305
Alex Light6a3fd512017-02-27 14:34:32 -0800306 static jvmtiError PopFrame(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700307 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800308 ENSURE_HAS_CAP(env, can_pop_frame);
Alex Light49948e92016-08-11 15:35:28 -0700309 return ERR(NOT_IMPLEMENTED);
310 }
311
312 static jvmtiError GetFrameLocation(jvmtiEnv* env,
313 jthread thread,
314 jint depth,
315 jmethodID* method_ptr,
316 jlocation* location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700317 ENSURE_VALID_ENV(env);
Andreas Gampef6f3b5f2017-01-13 09:21:42 -0800318 return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700319 }
320
Alex Light6a3fd512017-02-27 14:34:32 -0800321 static jvmtiError NotifyFramePop(jvmtiEnv* env,
322 jthread thread ATTRIBUTE_UNUSED,
323 jint depth ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700324 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800325 ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
Alex Light49948e92016-08-11 15:35:28 -0700326 return ERR(NOT_IMPLEMENTED);
327 }
328
Alex Light6a3fd512017-02-27 14:34:32 -0800329 static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env,
330 jthread thread ATTRIBUTE_UNUSED,
331 jobject value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700332 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800333 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700334 return ERR(NOT_IMPLEMENTED);
335 }
336
Alex Light6a3fd512017-02-27 14:34:32 -0800337 static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env,
338 jthread thread ATTRIBUTE_UNUSED,
339 jint value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700340 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800341 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700342 return ERR(NOT_IMPLEMENTED);
343 }
344
Alex Light6a3fd512017-02-27 14:34:32 -0800345 static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env,
346 jthread thread ATTRIBUTE_UNUSED,
347 jlong value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700348 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800349 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700350 return ERR(NOT_IMPLEMENTED);
351 }
352
Alex Light6a3fd512017-02-27 14:34:32 -0800353 static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env,
354 jthread thread ATTRIBUTE_UNUSED,
355 jfloat value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700356 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800357 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700358 return ERR(NOT_IMPLEMENTED);
359 }
360
Alex Light6a3fd512017-02-27 14:34:32 -0800361 static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env,
362 jthread thread ATTRIBUTE_UNUSED,
363 jdouble value ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700364 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800365 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700366 return ERR(NOT_IMPLEMENTED);
367 }
368
Alex Light6a3fd512017-02-27 14:34:32 -0800369 static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700370 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800371 ENSURE_HAS_CAP(env, can_force_early_return);
Alex Light49948e92016-08-11 15:35:28 -0700372 return ERR(NOT_IMPLEMENTED);
373 }
374
375 static jvmtiError FollowReferences(jvmtiEnv* env,
376 jint heap_filter,
377 jclass klass,
378 jobject initial_object,
379 const jvmtiHeapCallbacks* callbacks,
380 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700381 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800382 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800383 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampe70bfc8a2016-11-03 11:04:15 -0700384 return heap_util.FollowReferences(env,
385 heap_filter,
386 klass,
387 initial_object,
388 callbacks,
389 user_data);
Alex Light49948e92016-08-11 15:35:28 -0700390 }
391
392 static jvmtiError IterateThroughHeap(jvmtiEnv* env,
393 jint heap_filter,
394 jclass klass,
395 const jvmtiHeapCallbacks* callbacks,
396 const void* user_data) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700397 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700398 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampede19eb92017-02-24 16:21:18 -0800399 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampee54d9922016-10-11 19:55:37 -0700400 return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
Alex Light49948e92016-08-11 15:35:28 -0700401 }
402
403 static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700404 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700405 ENSURE_HAS_CAP(env, can_tag_objects);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700406
407 JNIEnv* jni_env = GetJniEnv(env);
408 if (jni_env == nullptr) {
409 return ERR(INTERNAL);
410 }
411
412 art::ScopedObjectAccess soa(jni_env);
413 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800414 if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700415 *tag_ptr = 0;
416 }
417
418 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700419 }
420
421 static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700422 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700423 ENSURE_HAS_CAP(env, can_tag_objects);
424
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700425 if (object == nullptr) {
426 return ERR(NULL_POINTER);
427 }
428
429 JNIEnv* jni_env = GetJniEnv(env);
430 if (jni_env == nullptr) {
431 return ERR(INTERNAL);
432 }
433
434 art::ScopedObjectAccess soa(jni_env);
435 art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
Andreas Gampede19eb92017-02-24 16:21:18 -0800436 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
Andreas Gampe6dee92e2016-09-12 19:58:13 -0700437
438 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -0700439 }
440
441 static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
442 jint tag_count,
443 const jlong* tags,
444 jint* count_ptr,
445 jobject** object_result_ptr,
446 jlong** tag_result_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700447 ENSURE_VALID_ENV(env);
Alex Lighte6574242016-08-17 09:56:24 -0700448 ENSURE_HAS_CAP(env, can_tag_objects);
449
Andreas Gampe5e6046b2016-10-25 12:05:53 -0700450 JNIEnv* jni_env = GetJniEnv(env);
451 if (jni_env == nullptr) {
452 return ERR(INTERNAL);
453 }
454
455 art::ScopedObjectAccess soa(jni_env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800456 return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
457 tag_count,
458 tags,
459 count_ptr,
460 object_result_ptr,
461 tag_result_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700462 }
463
464 static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700465 ENSURE_VALID_ENV(env);
Andreas Gampe8da6d032016-10-31 19:31:03 -0700466 return HeapUtil::ForceGarbageCollection(env);
Alex Light49948e92016-08-11 15:35:28 -0700467 }
468
469 static jvmtiError IterateOverObjectsReachableFromObject(
470 jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800471 jobject object ATTRIBUTE_UNUSED,
472 jvmtiObjectReferenceCallback object_reference_callback ATTRIBUTE_UNUSED,
473 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700474 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800475 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700476 return ERR(NOT_IMPLEMENTED);
477 }
478
Alex Light6a3fd512017-02-27 14:34:32 -0800479 static jvmtiError IterateOverReachableObjects(
480 jvmtiEnv* env,
481 jvmtiHeapRootCallback heap_root_callback ATTRIBUTE_UNUSED,
482 jvmtiStackReferenceCallback stack_ref_callback ATTRIBUTE_UNUSED,
483 jvmtiObjectReferenceCallback object_ref_callback ATTRIBUTE_UNUSED,
484 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700485 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800486 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700487 return ERR(NOT_IMPLEMENTED);
488 }
489
490 static jvmtiError IterateOverHeap(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800491 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
492 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
493 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700494 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800495 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700496 return ERR(NOT_IMPLEMENTED);
497 }
498
Alex Light6a3fd512017-02-27 14:34:32 -0800499 static jvmtiError IterateOverInstancesOfClass(
500 jvmtiEnv* env,
501 jclass klass ATTRIBUTE_UNUSED,
502 jvmtiHeapObjectFilter object_filter ATTRIBUTE_UNUSED,
503 jvmtiHeapObjectCallback heap_object_callback ATTRIBUTE_UNUSED,
504 const void* user_data ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700505 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800506 ENSURE_HAS_CAP(env, can_tag_objects);
Alex Light49948e92016-08-11 15:35:28 -0700507 return ERR(NOT_IMPLEMENTED);
508 }
509
510 static jvmtiError GetLocalObject(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700511 jthread thread,
512 jint depth,
513 jint slot,
514 jobject* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700515 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800516 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700517 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700518 }
519
520 static jvmtiError GetLocalInstance(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700521 jthread thread,
522 jint depth,
523 jobject* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700524 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800525 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700526 return MethodUtil::GetLocalInstance(env, thread, depth, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700527 }
528
529 static jvmtiError GetLocalInt(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700530 jthread thread,
531 jint depth,
532 jint slot,
533 jint* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700534 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800535 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700536 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700537 }
538
539 static jvmtiError GetLocalLong(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700540 jthread thread,
541 jint depth,
542 jint slot,
543 jlong* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700544 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800545 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700546 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700547 }
548
549 static jvmtiError GetLocalFloat(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700550 jthread thread,
551 jint depth,
552 jint slot,
553 jfloat* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700554 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800555 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700556 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700557 }
558
559 static jvmtiError GetLocalDouble(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700560 jthread thread,
561 jint depth,
562 jint slot,
563 jdouble* value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700564 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800565 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700566 return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700567 }
568
569 static jvmtiError SetLocalObject(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700570 jthread thread,
571 jint depth,
572 jint slot,
573 jobject value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700574 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800575 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700576 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700577 }
578
579 static jvmtiError SetLocalInt(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700580 jthread thread,
581 jint depth,
582 jint slot,
583 jint value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700584 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800585 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700586 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700587 }
588
589 static jvmtiError SetLocalLong(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700590 jthread thread,
591 jint depth,
592 jint slot,
593 jlong value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700594 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800595 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700596 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700597 }
598
599 static jvmtiError SetLocalFloat(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700600 jthread thread,
601 jint depth,
602 jint slot,
603 jfloat value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700604 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800605 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700606 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700607 }
608
609 static jvmtiError SetLocalDouble(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700610 jthread thread,
611 jint depth,
612 jint slot,
613 jdouble value) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700614 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800615 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700616 return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
Alex Light49948e92016-08-11 15:35:28 -0700617 }
618
Alex Lighta26e3492017-06-27 17:55:37 -0700619
620 static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700621 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800622 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Lighta26e3492017-06-27 17:55:37 -0700623 return BreakpointUtil::SetBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700624 }
625
Alex Lighta26e3492017-06-27 17:55:37 -0700626 static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700627 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800628 ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
Alex Lighta26e3492017-06-27 17:55:37 -0700629 return BreakpointUtil::ClearBreakpoint(env, method, location);
Alex Light49948e92016-08-11 15:35:28 -0700630 }
631
Alex Light084fa372017-06-16 08:58:34 -0700632 static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700633 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800634 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700635 return FieldUtil::SetFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700636 }
637
Alex Light084fa372017-06-16 08:58:34 -0700638 static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700639 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800640 ENSURE_HAS_CAP(env, can_generate_field_access_events);
Alex Light084fa372017-06-16 08:58:34 -0700641 return FieldUtil::ClearFieldAccessWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700642 }
643
Alex Light084fa372017-06-16 08:58:34 -0700644 static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700645 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800646 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700647 return FieldUtil::SetFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700648 }
649
Alex Light084fa372017-06-16 08:58:34 -0700650 static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700651 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800652 ENSURE_HAS_CAP(env, can_generate_field_modification_events);
Alex Light084fa372017-06-16 08:58:34 -0700653 return FieldUtil::ClearFieldModificationWatch(env, klass, field);
Alex Light49948e92016-08-11 15:35:28 -0700654 }
655
656 static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700657 ENSURE_VALID_ENV(env);
Andreas Gampede19eb92017-02-24 16:21:18 -0800658 HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Andreas Gampeaa8b60c2016-10-12 12:51:25 -0700659 return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700660 }
661
662 static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
663 jobject initiating_loader,
664 jint* class_count_ptr,
665 jclass** classes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700666 ENSURE_VALID_ENV(env);
Andreas Gampe70f16392017-01-16 14:20:10 -0800667 return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700668 }
669
670 static jvmtiError GetClassSignature(jvmtiEnv* env,
671 jclass klass,
672 char** signature_ptr,
673 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700674 ENSURE_VALID_ENV(env);
Andreas Gampee492ae32016-10-28 19:34:57 -0700675 return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700676 }
677
678 static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700679 ENSURE_VALID_ENV(env);
Andreas Gampeff9d2092017-01-06 09:12:49 -0800680 return ClassUtil::GetClassStatus(env, klass, status_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700681 }
682
Alex Light6fa7b812017-06-16 09:04:29 -0700683 static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700684 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800685 ENSURE_HAS_CAP(env, can_get_source_file_name);
Alex Light6fa7b812017-06-16 09:04:29 -0700686 return ClassUtil::GetSourceFileName(env, klass, source_name_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700687 }
688
689 static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700690 ENSURE_VALID_ENV(env);
Andreas Gampe64013e52017-01-06 13:07:19 -0800691 return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700692 }
693
694 static jvmtiError GetClassMethods(jvmtiEnv* env,
695 jclass klass,
696 jint* method_count_ptr,
697 jmethodID** methods_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700698 ENSURE_VALID_ENV(env);
Andreas Gampe18fee4d2017-01-06 11:36:35 -0800699 return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700700 }
701
702 static jvmtiError GetClassFields(jvmtiEnv* env,
703 jclass klass,
704 jint* field_count_ptr,
705 jfieldID** fields_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700706 ENSURE_VALID_ENV(env);
Andreas Gampeac587272017-01-05 15:21:34 -0800707 return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700708 }
709
710 static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
711 jclass klass,
712 jint* interface_count_ptr,
713 jclass** interfaces_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700714 ENSURE_VALID_ENV(env);
Andreas Gampe8b07e472017-01-06 14:20:39 -0800715 return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700716 }
717
718 static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
719 jclass klass,
720 jint* minor_version_ptr,
721 jint* major_version_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700722 ENSURE_VALID_ENV(env);
Andreas Gampe812a2442017-01-19 22:04:46 -0800723 return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700724 }
725
726 static jvmtiError GetConstantPool(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800727 jclass klass ATTRIBUTE_UNUSED,
728 jint* constant_pool_count_ptr ATTRIBUTE_UNUSED,
729 jint* constant_pool_byte_count_ptr ATTRIBUTE_UNUSED,
730 unsigned char** constant_pool_bytes_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700731 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800732 ENSURE_HAS_CAP(env, can_get_constant_pool);
Alex Light49948e92016-08-11 15:35:28 -0700733 return ERR(NOT_IMPLEMENTED);
734 }
735
736 static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700737 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800738 return ClassUtil::IsInterface(env, klass, is_interface_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700739 }
740
741 static jvmtiError IsArrayClass(jvmtiEnv* env,
742 jclass klass,
743 jboolean* is_array_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700744 ENSURE_VALID_ENV(env);
Andreas Gampe4fd66ec2017-01-05 14:42:13 -0800745 return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700746 }
747
748 static jvmtiError IsModifiableClass(jvmtiEnv* env,
749 jclass klass,
750 jboolean* is_modifiable_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700751 ENSURE_VALID_ENV(env);
Alex Lighte4a88632017-01-10 07:41:24 -0800752 return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700753 }
754
755 static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700756 ENSURE_VALID_ENV(env);
Andreas Gampe8f5b6032017-01-06 15:50:55 -0800757 return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700758 }
759
760 static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
Alex Light6fa7b812017-06-16 09:04:29 -0700761 jclass klass,
762 char** source_debug_extension_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700763 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800764 ENSURE_HAS_CAP(env, can_get_source_debug_extension);
Alex Light6fa7b812017-06-16 09:04:29 -0700765 return ClassUtil::GetSourceDebugExtension(env, klass, source_debug_extension_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700766 }
767
768 static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700769 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800770 ENSURE_HAS_CAP(env, can_retransform_classes);
Alex Light6ac57502017-01-19 15:05:06 -0800771 std::string error_msg;
772 jvmtiError res = Transformer::RetransformClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800773 &gEventHandler,
Alex Light6ac57502017-01-19 15:05:06 -0800774 art::Runtime::Current(),
775 art::Thread::Current(),
776 class_count,
777 classes,
778 &error_msg);
779 if (res != OK) {
780 LOG(WARNING) << "FAILURE TO RETRANFORM " << error_msg;
781 }
782 return res;
Alex Light49948e92016-08-11 15:35:28 -0700783 }
784
785 static jvmtiError RedefineClasses(jvmtiEnv* env,
786 jint class_count,
787 const jvmtiClassDefinition* class_definitions) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700788 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800789 ENSURE_HAS_CAP(env, can_redefine_classes);
Alex Light0e692732017-01-10 15:00:05 -0800790 std::string error_msg;
791 jvmtiError res = Redefiner::RedefineClasses(ArtJvmTiEnv::AsArtJvmTiEnv(env),
Andreas Gampede19eb92017-02-24 16:21:18 -0800792 &gEventHandler,
Alex Light0e692732017-01-10 15:00:05 -0800793 art::Runtime::Current(),
794 art::Thread::Current(),
795 class_count,
796 class_definitions,
797 &error_msg);
798 if (res != OK) {
799 LOG(WARNING) << "FAILURE TO REDEFINE " << error_msg;
800 }
801 return res;
Alex Light49948e92016-08-11 15:35:28 -0700802 }
803
804 static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700805 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800806 return ObjectUtil::GetObjectSize(env, object, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700807 }
808
809 static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700810 ENSURE_VALID_ENV(env);
Andreas Gampe50a4e492017-01-06 18:00:20 -0800811 return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700812 }
813
814 static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -0800815 jobject object ATTRIBUTE_UNUSED,
816 jvmtiMonitorUsage* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700817 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800818 ENSURE_HAS_CAP(env, can_get_monitor_info);
Alex Light49948e92016-08-11 15:35:28 -0700819 return ERR(NOT_IMPLEMENTED);
820 }
821
822 static jvmtiError GetFieldName(jvmtiEnv* env,
823 jclass klass,
824 jfieldID field,
825 char** name_ptr,
826 char** signature_ptr,
827 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700828 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800829 return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700830 }
831
832 static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
833 jclass klass,
834 jfieldID field,
835 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700836 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800837 return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700838 }
839
840 static jvmtiError GetFieldModifiers(jvmtiEnv* env,
841 jclass klass,
842 jfieldID field,
843 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700844 ENSURE_VALID_ENV(env);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800845 return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700846 }
847
848 static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
849 jclass klass,
850 jfieldID field,
851 jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700852 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800853 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampeab2f0d02017-01-05 17:23:45 -0800854 return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700855 }
856
857 static jvmtiError GetMethodName(jvmtiEnv* env,
858 jmethodID method,
859 char** name_ptr,
860 char** signature_ptr,
861 char** generic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700862 ENSURE_VALID_ENV(env);
Andreas Gampe3c252f02016-10-27 18:25:17 -0700863 return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700864 }
865
866 static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
867 jmethodID method,
868 jclass* declaring_class_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700869 ENSURE_VALID_ENV(env);
Andreas Gampe368a2082016-10-28 17:33:13 -0700870 return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700871 }
872
873 static jvmtiError GetMethodModifiers(jvmtiEnv* env,
874 jmethodID method,
875 jint* modifiers_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700876 ENSURE_VALID_ENV(env);
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700877 return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700878 }
879
880 static jvmtiError GetMaxLocals(jvmtiEnv* env,
881 jmethodID method,
882 jint* max_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700883 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800884 return MethodUtil::GetMaxLocals(env, method, max_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700885 }
886
887 static jvmtiError GetArgumentsSize(jvmtiEnv* env,
888 jmethodID method,
889 jint* size_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700890 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800891 return MethodUtil::GetArgumentsSize(env, method, size_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700892 }
893
894 static jvmtiError GetLineNumberTable(jvmtiEnv* env,
895 jmethodID method,
896 jint* entry_count_ptr,
897 jvmtiLineNumberEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700898 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800899 ENSURE_HAS_CAP(env, can_get_line_numbers);
Andreas Gampeda3e5612016-12-13 19:00:53 -0800900 return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700901 }
902
903 static jvmtiError GetMethodLocation(jvmtiEnv* env,
904 jmethodID method,
905 jlocation* start_location_ptr,
906 jlocation* end_location_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700907 ENSURE_VALID_ENV(env);
Andreas Gampef71832e2017-01-09 11:38:04 -0800908 return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700909 }
910
911 static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
Alex Lightce68cc62017-07-26 10:30:38 -0700912 jmethodID method,
913 jint* entry_count_ptr,
914 jvmtiLocalVariableEntry** table_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700915 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800916 ENSURE_HAS_CAP(env, can_access_local_variables);
Alex Lightce68cc62017-07-26 10:30:38 -0700917 return MethodUtil::GetLocalVariableTable(env, method, entry_count_ptr, table_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700918 }
919
920 static jvmtiError GetBytecodes(jvmtiEnv* env,
Alex Light4c174282017-07-05 10:18:18 -0700921 jmethodID method,
922 jint* bytecode_count_ptr,
923 unsigned char** bytecodes_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700924 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800925 ENSURE_HAS_CAP(env, can_get_bytecodes);
Alex Light4c174282017-07-05 10:18:18 -0700926 return MethodUtil::GetBytecodes(env, method, bytecode_count_ptr, bytecodes_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700927 }
928
929 static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700930 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800931 return MethodUtil::IsMethodNative(env, method, is_native_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700932 }
933
934 static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700935 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800936 ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
Andreas Gampefdeef522017-01-09 14:40:25 -0800937 return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700938 }
939
940 static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700941 ENSURE_VALID_ENV(env);
Andreas Gampefdeef522017-01-09 14:40:25 -0800942 return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700943 }
944
Alex Light6a3fd512017-02-27 14:34:32 -0800945 static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, const char* prefix ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700946 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800947 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700948 return ERR(NOT_IMPLEMENTED);
949 }
950
Alex Light6a3fd512017-02-27 14:34:32 -0800951 static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
952 jint prefix_count ATTRIBUTE_UNUSED,
953 char** prefixes ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700954 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -0800955 ENSURE_HAS_CAP(env, can_set_native_method_prefix);
Alex Light49948e92016-08-11 15:35:28 -0700956 return ERR(NOT_IMPLEMENTED);
957 }
958
959 static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700960 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800961 return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
Alex Light49948e92016-08-11 15:35:28 -0700962 }
963
964 static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700965 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800966 return MonitorUtil::DestroyRawMonitor(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700967 }
968
969 static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700970 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800971 return MonitorUtil::RawMonitorEnter(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700972 }
973
974 static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700975 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800976 return MonitorUtil::RawMonitorExit(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700977 }
978
979 static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700980 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800981 return MonitorUtil::RawMonitorWait(env, monitor, millis);
Alex Light49948e92016-08-11 15:35:28 -0700982 }
983
984 static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700985 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800986 return MonitorUtil::RawMonitorNotify(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700987 }
988
989 static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700990 ENSURE_VALID_ENV(env);
Andreas Gampe319dbe82017-01-09 16:42:21 -0800991 return MonitorUtil::RawMonitorNotifyAll(env, monitor);
Alex Light49948e92016-08-11 15:35:28 -0700992 }
993
994 static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -0700995 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -0800996 return JNIUtil::SetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -0700997 }
998
999 static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001000 ENSURE_VALID_ENV(env);
Andreas Gampe6f8e4f02017-01-16 18:18:14 -08001001 return JNIUtil::GetJNIFunctionTable(env, function_table);
Alex Light49948e92016-08-11 15:35:28 -07001002 }
1003
Andreas Gampe77708d92016-10-07 11:48:21 -07001004 // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
1005 // an event.
Alex Light49948e92016-08-11 15:35:28 -07001006 static jvmtiError SetEventCallbacks(jvmtiEnv* env,
1007 const jvmtiEventCallbacks* callbacks,
1008 jint size_of_callbacks) {
Alex Lighte6574242016-08-17 09:56:24 -07001009 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001010 if (size_of_callbacks < 0) {
1011 return ERR(ILLEGAL_ARGUMENT);
1012 }
1013
1014 if (callbacks == nullptr) {
1015 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
1016 return ERR(NONE);
1017 }
1018
1019 std::unique_ptr<jvmtiEventCallbacks> tmp(new jvmtiEventCallbacks());
1020 memset(tmp.get(), 0, sizeof(jvmtiEventCallbacks));
1021 size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
1022 static_cast<size_t>(size_of_callbacks));
1023 copy_size = art::RoundDown(copy_size, sizeof(void*));
1024 memcpy(tmp.get(), callbacks, copy_size);
1025
1026 ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks = std::move(tmp);
1027
1028 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001029 }
1030
1031 static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
1032 jvmtiEventMode mode,
1033 jvmtiEvent event_type,
1034 jthread event_thread,
1035 ...) {
Alex Lighte6574242016-08-17 09:56:24 -07001036 ENSURE_VALID_ENV(env);
Andreas Gampe77708d92016-10-07 11:48:21 -07001037 art::Thread* art_thread = nullptr;
1038 if (event_thread != nullptr) {
1039 // TODO: Need non-aborting call here, to return JVMTI_ERROR_INVALID_THREAD.
1040 art::ScopedObjectAccess soa(art::Thread::Current());
1041 art::MutexLock mu(soa.Self(), *art::Locks::thread_list_lock_);
1042 art_thread = art::Thread::FromManagedThread(soa, event_thread);
1043
1044 if (art_thread == nullptr || // The thread hasn't been started or is already dead.
1045 art_thread->IsStillStarting()) {
1046 // TODO: We may want to let the EventHandler know, so it could clean up masks, potentially.
1047 return ERR(THREAD_NOT_ALIVE);
1048 }
1049 }
1050
Alex Light40d87f42017-01-18 10:27:06 -08001051 ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1052 return gEventHandler.SetEvent(art_env, art_thread, GetArtJvmtiEvent(art_env, event_type), mode);
Alex Light49948e92016-08-11 15:35:28 -07001053 }
1054
Alex Light1edc8cf2017-03-24 14:22:56 -07001055 static jvmtiError GenerateEvents(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001056 jvmtiEvent event_type ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001057 ENSURE_VALID_ENV(env);
Alex Light6a3fd512017-02-27 14:34:32 -08001058 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001059 }
1060
Alex Light1edc8cf2017-03-24 14:22:56 -07001061 static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001062 jint* extension_count_ptr,
1063 jvmtiExtensionFunctionInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001064 ENSURE_VALID_ENV(env);
Andreas Gamped73aba42017-05-03 21:40:26 -07001065 ENSURE_NON_NULL(extension_count_ptr);
1066 ENSURE_NON_NULL(extensions);
1067
1068 std::vector<jvmtiExtensionFunctionInfo> ext_vector;
1069
1070 // Holders for allocated values.
1071 std::vector<JvmtiUniquePtr<char[]>> char_buffers;
1072 std::vector<JvmtiUniquePtr<jvmtiParamInfo[]>> param_buffers;
1073 std::vector<JvmtiUniquePtr<jvmtiError[]>> error_buffers;
1074
1075 // Add a helper struct that takes an arbitrary const char*. add_extension will use Allocate
1076 // appropriately.
1077 struct CParamInfo {
1078 const char* name;
1079 jvmtiParamKind kind;
1080 jvmtiParamTypes base_type;
1081 jboolean null_ok;
1082 };
1083
1084 auto add_extension = [&](jvmtiExtensionFunction func,
1085 const char* id,
1086 const char* short_description,
1087 jint param_count,
1088 const std::vector<CParamInfo>& params,
1089 jint error_count,
1090 const std::vector<jvmtiError>& errors) {
1091 jvmtiExtensionFunctionInfo func_info;
1092 jvmtiError error;
1093
1094 func_info.func = func;
1095
1096 JvmtiUniquePtr<char[]> id_ptr = CopyString(env, id, &error);
1097 if (id_ptr == nullptr) {
1098 return error;
1099 }
1100 func_info.id = id_ptr.get();
1101 char_buffers.push_back(std::move(id_ptr));
1102
1103 JvmtiUniquePtr<char[]> descr = CopyString(env, short_description, &error);
1104 if (descr == nullptr) {
1105 return error;
1106 }
1107 func_info.short_description = descr.get();
1108 char_buffers.push_back(std::move(descr));
1109
1110 func_info.param_count = param_count;
1111 if (param_count > 0) {
1112 JvmtiUniquePtr<jvmtiParamInfo[]> params_ptr =
1113 AllocJvmtiUniquePtr<jvmtiParamInfo[]>(env, param_count, &error);
1114 if (params_ptr == nullptr) {
1115 return error;
1116 }
1117 func_info.params = params_ptr.get();
1118 param_buffers.push_back(std::move(params_ptr));
1119
1120 for (jint i = 0; i != param_count; ++i) {
1121 JvmtiUniquePtr<char[]> param_name = CopyString(env, params[i].name, &error);
1122 if (param_name == nullptr) {
1123 return error;
1124 }
1125 func_info.params[i].name = param_name.get();
1126 char_buffers.push_back(std::move(param_name));
1127
1128 func_info.params[i].kind = params[i].kind;
1129 func_info.params[i].base_type = params[i].base_type;
1130 func_info.params[i].null_ok = params[i].null_ok;
1131 }
1132 } else {
1133 func_info.params = nullptr;
1134 }
1135
1136 func_info.error_count = error_count;
1137 if (error_count > 0) {
1138 JvmtiUniquePtr<jvmtiError[]> errors_ptr =
1139 AllocJvmtiUniquePtr<jvmtiError[]>(env, error_count, &error);
1140 if (errors_ptr == nullptr) {
1141 return error;
1142 }
1143 func_info.errors = errors_ptr.get();
1144 error_buffers.push_back(std::move(errors_ptr));
1145
1146 for (jint i = 0; i != error_count; ++i) {
1147 func_info.errors[i] = errors[i];
1148 }
1149 } else {
1150 func_info.errors = nullptr;
1151 }
1152
1153 ext_vector.push_back(func_info);
1154
1155 return ERR(NONE);
1156 };
1157
1158 jvmtiError error;
1159
1160 // Heap extensions.
1161 error = add_extension(
1162 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetObjectHeapId),
1163 "com.android.art.heap.get_object_heap_id",
1164 "Retrieve the heap id of the the object tagged with the given argument. An "
1165 "arbitrary object is chosen if multiple objects exist with the same tag.",
1166 2,
1167 { // NOLINT [whitespace/braces] [4]
1168 { "tag", JVMTI_KIND_IN, JVMTI_TYPE_JLONG, false},
1169 { "heap_id", JVMTI_KIND_OUT, JVMTI_TYPE_JINT, false}
1170 },
1171 1,
1172 { JVMTI_ERROR_NOT_FOUND });
1173 if (error != ERR(NONE)) {
1174 return error;
1175 }
1176
1177 error = add_extension(
1178 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::GetHeapName),
1179 "com.android.art.heap.get_heap_name",
1180 "Retrieve the name of the heap with the given id.",
1181 2,
1182 { // NOLINT [whitespace/braces] [4]
1183 { "heap_id", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1184 { "heap_name", JVMTI_KIND_ALLOC_BUF, JVMTI_TYPE_CCHAR, false}
1185 },
1186 1,
1187 { JVMTI_ERROR_ILLEGAL_ARGUMENT });
1188 if (error != ERR(NONE)) {
1189 return error;
1190 }
1191
Andreas Gampe2eb25e42017-05-09 17:14:58 -07001192 error = add_extension(
1193 reinterpret_cast<jvmtiExtensionFunction>(HeapExtensions::IterateThroughHeapExt),
1194 "com.android.art.heap.iterate_through_heap_ext",
1195 "Iterate through a heap. This is equivalent to the standard IterateThroughHeap function,"
1196 " except for additionally passing the heap id of the current object. The jvmtiHeapCallbacks"
1197 " structure is reused, with the callbacks field overloaded to a signature of "
1198 "jint (*)(jlong, jlong, jlong*, jint length, void*, jint).",
1199 4,
1200 { // NOLINT [whitespace/braces] [4]
1201 { "heap_filter", JVMTI_KIND_IN, JVMTI_TYPE_JINT, false},
1202 { "klass", JVMTI_KIND_IN, JVMTI_TYPE_JCLASS, true},
1203 { "callbacks", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, false},
1204 { "user_data", JVMTI_KIND_IN_PTR, JVMTI_TYPE_CVOID, true}
1205 },
1206 3,
1207 { // NOLINT [whitespace/braces] [4]
1208 JVMTI_ERROR_MUST_POSSESS_CAPABILITY,
1209 JVMTI_ERROR_INVALID_CLASS,
1210 JVMTI_ERROR_NULL_POINTER
1211 });
1212 if (error != ERR(NONE)) {
1213 return error;
1214 }
1215
Alex Light8ddfd9f2017-07-05 16:33:46 -07001216 error = add_extension(
1217 reinterpret_cast<jvmtiExtensionFunction>(AllocUtil::GetGlobalJvmtiAllocationState),
1218 "com.android.art.alloc.get_global_jvmti_allocation_state",
1219 "Returns the total amount of memory currently allocated by all jvmtiEnvs through the"
1220 " 'Allocate' jvmti function. This does not include any memory that has been deallocated"
1221 " through the 'Deallocate' function. This number is approximate and might not correspond"
1222 " exactly to the sum of the sizes of all not freed allocations.",
1223 1,
1224 { // NOLINT [whitespace/braces] [4]
1225 { "currently_allocated", JVMTI_KIND_OUT, JVMTI_TYPE_JLONG, false},
1226 },
1227 1,
1228 { ERR(NULL_POINTER) });
1229 if (error != ERR(NONE)) {
1230 return error;
1231 }
1232
Andreas Gamped73aba42017-05-03 21:40:26 -07001233 // Copy into output buffer.
1234
1235 *extension_count_ptr = ext_vector.size();
1236 JvmtiUniquePtr<jvmtiExtensionFunctionInfo[]> out_data =
1237 AllocJvmtiUniquePtr<jvmtiExtensionFunctionInfo[]>(env, ext_vector.size(), &error);
1238 if (out_data == nullptr) {
1239 return error;
1240 }
1241 memcpy(out_data.get(),
1242 ext_vector.data(),
1243 ext_vector.size() * sizeof(jvmtiExtensionFunctionInfo));
1244 *extensions = out_data.release();
1245
1246 // Release all the buffer holders, we're OK now.
1247 for (auto& holder : char_buffers) {
1248 holder.release();
1249 }
1250 for (auto& holder : param_buffers) {
1251 holder.release();
1252 }
1253 for (auto& holder : error_buffers) {
1254 holder.release();
1255 }
Andreas Gampee4c33842017-01-09 10:50:17 -08001256
1257 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001258 }
1259
Alex Light1edc8cf2017-03-24 14:22:56 -07001260 static jvmtiError GetExtensionEvents(jvmtiEnv* env,
Alex Light49948e92016-08-11 15:35:28 -07001261 jint* extension_count_ptr,
1262 jvmtiExtensionEventInfo** extensions) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001263 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001264 // We do not have any extension events.
1265 *extension_count_ptr = 0;
1266 *extensions = nullptr;
1267
1268 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001269 }
1270
Alex Light1edc8cf2017-03-24 14:22:56 -07001271 static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001272 jint extension_event_index ATTRIBUTE_UNUSED,
1273 jvmtiExtensionEvent callback ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001274 ENSURE_VALID_ENV(env);
Andreas Gampee4c33842017-01-09 10:50:17 -08001275 // We do not have any extension events, so any call is illegal.
1276 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001277 }
1278
1279 static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001280 ENSURE_VALID_ENV(env);
1281 ENSURE_NON_NULL(capabilities_ptr);
1282 *capabilities_ptr = kPotentialCapabilities;
1283 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001284 }
1285
1286 static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001287 ENSURE_VALID_ENV(env);
1288 ENSURE_NON_NULL(capabilities_ptr);
1289 ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1290 jvmtiError ret = OK;
Alex Light34d8e082017-03-27 09:50:36 -07001291 jvmtiCapabilities changed = {};
1292 jvmtiCapabilities potential_capabilities = {};
Alex Light1d224962017-02-27 10:26:35 -08001293 ret = env->GetPotentialCapabilities(&potential_capabilities);
1294 if (ret != OK) {
1295 return ret;
1296 }
Alex Lighte6574242016-08-17 09:56:24 -07001297#define ADD_CAPABILITY(e) \
1298 do { \
1299 if (capabilities_ptr->e == 1) { \
Alex Light1d224962017-02-27 10:26:35 -08001300 if (potential_capabilities.e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001301 if (art_env->capabilities.e != 1) { \
1302 art_env->capabilities.e = 1; \
1303 changed.e = 1; \
1304 }\
Alex Lighte6574242016-08-17 09:56:24 -07001305 } else { \
1306 ret = ERR(NOT_AVAILABLE); \
1307 } \
1308 } \
1309 } while (false)
1310
1311 ADD_CAPABILITY(can_tag_objects);
1312 ADD_CAPABILITY(can_generate_field_modification_events);
1313 ADD_CAPABILITY(can_generate_field_access_events);
1314 ADD_CAPABILITY(can_get_bytecodes);
1315 ADD_CAPABILITY(can_get_synthetic_attribute);
1316 ADD_CAPABILITY(can_get_owned_monitor_info);
1317 ADD_CAPABILITY(can_get_current_contended_monitor);
1318 ADD_CAPABILITY(can_get_monitor_info);
1319 ADD_CAPABILITY(can_pop_frame);
1320 ADD_CAPABILITY(can_redefine_classes);
1321 ADD_CAPABILITY(can_signal_thread);
1322 ADD_CAPABILITY(can_get_source_file_name);
1323 ADD_CAPABILITY(can_get_line_numbers);
1324 ADD_CAPABILITY(can_get_source_debug_extension);
1325 ADD_CAPABILITY(can_access_local_variables);
1326 ADD_CAPABILITY(can_maintain_original_method_order);
1327 ADD_CAPABILITY(can_generate_single_step_events);
1328 ADD_CAPABILITY(can_generate_exception_events);
1329 ADD_CAPABILITY(can_generate_frame_pop_events);
1330 ADD_CAPABILITY(can_generate_breakpoint_events);
1331 ADD_CAPABILITY(can_suspend);
1332 ADD_CAPABILITY(can_redefine_any_class);
1333 ADD_CAPABILITY(can_get_current_thread_cpu_time);
1334 ADD_CAPABILITY(can_get_thread_cpu_time);
1335 ADD_CAPABILITY(can_generate_method_entry_events);
1336 ADD_CAPABILITY(can_generate_method_exit_events);
1337 ADD_CAPABILITY(can_generate_all_class_hook_events);
1338 ADD_CAPABILITY(can_generate_compiled_method_load_events);
1339 ADD_CAPABILITY(can_generate_monitor_events);
1340 ADD_CAPABILITY(can_generate_vm_object_alloc_events);
1341 ADD_CAPABILITY(can_generate_native_method_bind_events);
1342 ADD_CAPABILITY(can_generate_garbage_collection_events);
1343 ADD_CAPABILITY(can_generate_object_free_events);
1344 ADD_CAPABILITY(can_force_early_return);
1345 ADD_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1346 ADD_CAPABILITY(can_get_constant_pool);
1347 ADD_CAPABILITY(can_set_native_method_prefix);
1348 ADD_CAPABILITY(can_retransform_classes);
1349 ADD_CAPABILITY(can_retransform_any_class);
1350 ADD_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1351 ADD_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1352#undef ADD_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001353 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1354 changed,
1355 /*added*/true);
Alex Lighte6574242016-08-17 09:56:24 -07001356 return ret;
Alex Light49948e92016-08-11 15:35:28 -07001357 }
1358
1359 static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1360 const jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001361 ENSURE_VALID_ENV(env);
1362 ENSURE_NON_NULL(capabilities_ptr);
1363 ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
Alex Light34d8e082017-03-27 09:50:36 -07001364 jvmtiCapabilities changed = {};
Alex Lighte6574242016-08-17 09:56:24 -07001365#define DEL_CAPABILITY(e) \
1366 do { \
1367 if (capabilities_ptr->e == 1) { \
Alex Light73afd322017-01-18 11:17:47 -08001368 if (art_env->capabilities.e == 1) { \
1369 art_env->capabilities.e = 0;\
1370 changed.e = 1; \
1371 } \
Alex Lighte6574242016-08-17 09:56:24 -07001372 } \
1373 } while (false)
1374
1375 DEL_CAPABILITY(can_tag_objects);
1376 DEL_CAPABILITY(can_generate_field_modification_events);
1377 DEL_CAPABILITY(can_generate_field_access_events);
1378 DEL_CAPABILITY(can_get_bytecodes);
1379 DEL_CAPABILITY(can_get_synthetic_attribute);
1380 DEL_CAPABILITY(can_get_owned_monitor_info);
1381 DEL_CAPABILITY(can_get_current_contended_monitor);
1382 DEL_CAPABILITY(can_get_monitor_info);
1383 DEL_CAPABILITY(can_pop_frame);
1384 DEL_CAPABILITY(can_redefine_classes);
1385 DEL_CAPABILITY(can_signal_thread);
1386 DEL_CAPABILITY(can_get_source_file_name);
1387 DEL_CAPABILITY(can_get_line_numbers);
1388 DEL_CAPABILITY(can_get_source_debug_extension);
1389 DEL_CAPABILITY(can_access_local_variables);
1390 DEL_CAPABILITY(can_maintain_original_method_order);
1391 DEL_CAPABILITY(can_generate_single_step_events);
1392 DEL_CAPABILITY(can_generate_exception_events);
1393 DEL_CAPABILITY(can_generate_frame_pop_events);
1394 DEL_CAPABILITY(can_generate_breakpoint_events);
1395 DEL_CAPABILITY(can_suspend);
1396 DEL_CAPABILITY(can_redefine_any_class);
1397 DEL_CAPABILITY(can_get_current_thread_cpu_time);
1398 DEL_CAPABILITY(can_get_thread_cpu_time);
1399 DEL_CAPABILITY(can_generate_method_entry_events);
1400 DEL_CAPABILITY(can_generate_method_exit_events);
1401 DEL_CAPABILITY(can_generate_all_class_hook_events);
1402 DEL_CAPABILITY(can_generate_compiled_method_load_events);
1403 DEL_CAPABILITY(can_generate_monitor_events);
1404 DEL_CAPABILITY(can_generate_vm_object_alloc_events);
1405 DEL_CAPABILITY(can_generate_native_method_bind_events);
1406 DEL_CAPABILITY(can_generate_garbage_collection_events);
1407 DEL_CAPABILITY(can_generate_object_free_events);
1408 DEL_CAPABILITY(can_force_early_return);
1409 DEL_CAPABILITY(can_get_owned_monitor_stack_depth_info);
1410 DEL_CAPABILITY(can_get_constant_pool);
1411 DEL_CAPABILITY(can_set_native_method_prefix);
1412 DEL_CAPABILITY(can_retransform_classes);
1413 DEL_CAPABILITY(can_retransform_any_class);
1414 DEL_CAPABILITY(can_generate_resource_exhaustion_heap_events);
1415 DEL_CAPABILITY(can_generate_resource_exhaustion_threads_events);
1416#undef DEL_CAPABILITY
Alex Light73afd322017-01-18 11:17:47 -08001417 gEventHandler.HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1418 changed,
1419 /*added*/false);
Alex Lighte6574242016-08-17 09:56:24 -07001420 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001421 }
1422
1423 static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001424 ENSURE_VALID_ENV(env);
1425 ENSURE_NON_NULL(capabilities_ptr);
1426 ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1427 *capabilities_ptr = artenv->capabilities;
1428 return OK;
Alex Light49948e92016-08-11 15:35:28 -07001429 }
1430
Alex Light6a3fd512017-02-27 14:34:32 -08001431 static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1432 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001433 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001434 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001435 return ERR(NOT_IMPLEMENTED);
1436 }
1437
Alex Light6a3fd512017-02-27 14:34:32 -08001438 static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001439 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001440 ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001441 return ERR(NOT_IMPLEMENTED);
1442 }
1443
Alex Light6a3fd512017-02-27 14:34:32 -08001444 static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1445 jvmtiTimerInfo* info_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001446 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001447 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001448 return ERR(NOT_IMPLEMENTED);
1449 }
1450
Alex Light6a3fd512017-02-27 14:34:32 -08001451 static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1452 jthread thread ATTRIBUTE_UNUSED,
1453 jlong* nanos_ptr ATTRIBUTE_UNUSED) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001454 ENSURE_VALID_ENV(env);
Alex Light9db679d2017-01-25 15:28:04 -08001455 ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
Alex Light49948e92016-08-11 15:35:28 -07001456 return ERR(NOT_IMPLEMENTED);
1457 }
1458
1459 static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001460 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001461 return TimerUtil::GetTimerInfo(env, info_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001462 }
1463
1464 static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001465 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001466 return TimerUtil::GetTime(env, nanos_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001467 }
1468
1469 static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001470 ENSURE_VALID_ENV(env);
Andreas Gampe35bcf812017-01-13 16:24:17 -08001471 return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001472 }
1473
1474 static jvmtiError AddToBootstrapClassLoaderSearch(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::AddToBootstrapClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001477 }
1478
1479 static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001480 ENSURE_VALID_ENV(env);
Andreas Gampece7732b2017-01-17 15:50:26 -08001481 return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
Alex Light49948e92016-08-11 15:35:28 -07001482 }
1483
1484 static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001485 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001486 return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001487 }
1488
1489 static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001490 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001491 return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001492 }
1493
1494 static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001495 ENSURE_VALID_ENV(env);
Andreas Gampe1bdaf732017-01-09 19:21:06 -08001496 return PropertiesUtil::SetSystemProperty(env, property, value);
Alex Light49948e92016-08-11 15:35:28 -07001497 }
1498
1499 static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001500 ENSURE_VALID_ENV(env);
Andreas Gampe96eca782017-01-19 19:45:30 -08001501 return PhaseUtil::GetPhase(env, phase_ptr);
Alex Light49948e92016-08-11 15:35:28 -07001502 }
1503
1504 static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
Alex Lighte6574242016-08-17 09:56:24 -07001505 ENSURE_VALID_ENV(env);
Alex Light092a4042017-07-12 08:46:44 -07001506 ArtJvmTiEnv* tienv = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1507 gEventHandler.RemoveArtJvmTiEnv(tienv);
1508 art::Runtime::Current()->RemoveSystemWeakHolder(tienv->object_tag_table.get());
1509 ThreadUtil::RemoveEnvironment(tienv);
1510 delete tienv;
Alex Light49948e92016-08-11 15:35:28 -07001511 return OK;
1512 }
1513
1514 static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
Alex Lighte6574242016-08-17 09:56:24 -07001515 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001516 reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1517 return OK;
1518 }
1519
1520 static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001521 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001522 *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1523 return OK;
1524 }
1525
1526 static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001527 ENSURE_VALID_ENV(env);
Alex Light49948e92016-08-11 15:35:28 -07001528 *version_ptr = JVMTI_VERSION;
1529 return OK;
1530 }
1531
1532 static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
Alex Lighte6574242016-08-17 09:56:24 -07001533 ENSURE_NON_NULL(name_ptr);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001534 auto copy_fn = [&](const char* name_cstr) {
1535 jvmtiError res;
1536 JvmtiUniquePtr<char[]> copy = CopyString(env, name_cstr, &res);
1537 if (copy == nullptr) {
1538 *name_ptr = nullptr;
1539 return res;
1540 } else {
1541 *name_ptr = copy.release();
1542 return OK;
1543 }
1544 };
Alex Light49948e92016-08-11 15:35:28 -07001545 switch (error) {
Andreas Gampe95c466d2017-05-08 14:50:47 -07001546#define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : \
1547 return copy_fn("JVMTI_ERROR_"#e);
Alex Light49948e92016-08-11 15:35:28 -07001548 ERROR_CASE(NONE);
1549 ERROR_CASE(INVALID_THREAD);
1550 ERROR_CASE(INVALID_THREAD_GROUP);
1551 ERROR_CASE(INVALID_PRIORITY);
1552 ERROR_CASE(THREAD_NOT_SUSPENDED);
Andreas Gampe95c466d2017-05-08 14:50:47 -07001553 ERROR_CASE(THREAD_SUSPENDED);
Alex Light49948e92016-08-11 15:35:28 -07001554 ERROR_CASE(THREAD_NOT_ALIVE);
1555 ERROR_CASE(INVALID_OBJECT);
1556 ERROR_CASE(INVALID_CLASS);
1557 ERROR_CASE(CLASS_NOT_PREPARED);
1558 ERROR_CASE(INVALID_METHODID);
1559 ERROR_CASE(INVALID_LOCATION);
1560 ERROR_CASE(INVALID_FIELDID);
1561 ERROR_CASE(NO_MORE_FRAMES);
1562 ERROR_CASE(OPAQUE_FRAME);
1563 ERROR_CASE(TYPE_MISMATCH);
1564 ERROR_CASE(INVALID_SLOT);
1565 ERROR_CASE(DUPLICATE);
1566 ERROR_CASE(NOT_FOUND);
1567 ERROR_CASE(INVALID_MONITOR);
1568 ERROR_CASE(NOT_MONITOR_OWNER);
1569 ERROR_CASE(INTERRUPT);
1570 ERROR_CASE(INVALID_CLASS_FORMAT);
1571 ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1572 ERROR_CASE(FAILS_VERIFICATION);
1573 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1574 ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1575 ERROR_CASE(INVALID_TYPESTATE);
1576 ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1577 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1578 ERROR_CASE(UNSUPPORTED_VERSION);
1579 ERROR_CASE(NAMES_DONT_MATCH);
1580 ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1581 ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1582 ERROR_CASE(UNMODIFIABLE_CLASS);
1583 ERROR_CASE(NOT_AVAILABLE);
1584 ERROR_CASE(MUST_POSSESS_CAPABILITY);
1585 ERROR_CASE(NULL_POINTER);
1586 ERROR_CASE(ABSENT_INFORMATION);
1587 ERROR_CASE(INVALID_EVENT_TYPE);
1588 ERROR_CASE(ILLEGAL_ARGUMENT);
1589 ERROR_CASE(NATIVE_METHOD);
1590 ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1591 ERROR_CASE(OUT_OF_MEMORY);
1592 ERROR_CASE(ACCESS_DENIED);
1593 ERROR_CASE(WRONG_PHASE);
1594 ERROR_CASE(INTERNAL);
1595 ERROR_CASE(UNATTACHED_THREAD);
1596 ERROR_CASE(INVALID_ENVIRONMENT);
1597#undef ERROR_CASE
Alex Light49948e92016-08-11 15:35:28 -07001598 }
Andreas Gampe95c466d2017-05-08 14:50:47 -07001599
1600 return ERR(ILLEGAL_ARGUMENT);
Alex Light49948e92016-08-11 15:35:28 -07001601 }
1602
Alex Light1edc8cf2017-03-24 14:22:56 -07001603 static jvmtiError SetVerboseFlag(jvmtiEnv* env,
Alex Light6a3fd512017-02-27 14:34:32 -08001604 jvmtiVerboseFlag flag,
1605 jboolean value) {
Alex Light1edc8cf2017-03-24 14:22:56 -07001606 ENSURE_VALID_ENV(env);
Andreas Gampef37e3022017-01-13 17:54:46 -08001607 if (flag == jvmtiVerboseFlag::JVMTI_VERBOSE_OTHER) {
1608 // OTHER is special, as it's 0, so can't do a bit check.
1609 bool val = (value == JNI_TRUE) ? true : false;
1610
1611 art::gLogVerbosity.collector = val;
1612 art::gLogVerbosity.compiler = val;
1613 art::gLogVerbosity.deopt = val;
1614 art::gLogVerbosity.heap = val;
1615 art::gLogVerbosity.jdwp = val;
1616 art::gLogVerbosity.jit = val;
1617 art::gLogVerbosity.monitor = val;
1618 art::gLogVerbosity.oat = val;
1619 art::gLogVerbosity.profiler = val;
1620 art::gLogVerbosity.signals = val;
1621 art::gLogVerbosity.simulator = val;
1622 art::gLogVerbosity.startup = val;
1623 art::gLogVerbosity.third_party_jni = val;
1624 art::gLogVerbosity.threads = val;
1625 art::gLogVerbosity.verifier = val;
1626 art::gLogVerbosity.image = val;
1627
1628 // Note: can't switch systrace_lock_logging. That requires changing entrypoints.
1629
1630 art::gLogVerbosity.agents = val;
1631 } else {
1632 // Spec isn't clear whether "flag" is a mask or supposed to be single. We implement the mask
1633 // semantics.
1634 constexpr std::underlying_type<jvmtiVerboseFlag>::type kMask =
1635 jvmtiVerboseFlag::JVMTI_VERBOSE_GC |
1636 jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS |
1637 jvmtiVerboseFlag::JVMTI_VERBOSE_JNI;
1638 if ((flag & ~kMask) != 0) {
1639 return ERR(ILLEGAL_ARGUMENT);
1640 }
1641
1642 bool val = (value == JNI_TRUE) ? true : false;
1643
1644 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_GC) != 0) {
1645 art::gLogVerbosity.gc = val;
1646 }
1647
1648 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_CLASS) != 0) {
1649 art::gLogVerbosity.class_linker = val;
1650 }
1651
1652 if ((flag & jvmtiVerboseFlag::JVMTI_VERBOSE_JNI) != 0) {
1653 art::gLogVerbosity.jni = val;
1654 }
1655 }
1656
1657 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001658 }
1659
Alex Light1edc8cf2017-03-24 14:22:56 -07001660 static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1661 ENSURE_VALID_ENV(env);
Andreas Gampeacfc9572017-01-17 18:36:56 -08001662 // Report BCI as jlocation format. We report dex bytecode indices.
1663 if (format_ptr == nullptr) {
1664 return ERR(NULL_POINTER);
1665 }
1666 *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1667 return ERR(NONE);
Alex Light49948e92016-08-11 15:35:28 -07001668 }
1669};
1670
1671static bool IsJvmtiVersion(jint version) {
1672 return version == JVMTI_VERSION_1 ||
1673 version == JVMTI_VERSION_1_0 ||
1674 version == JVMTI_VERSION_1_1 ||
1675 version == JVMTI_VERSION_1_2 ||
1676 version == JVMTI_VERSION;
1677}
1678
Andreas Gampede19eb92017-02-24 16:21:18 -08001679extern const jvmtiInterface_1 gJvmtiInterface;
Alex Light092a4042017-07-12 08:46:44 -07001680
Andreas Gampede19eb92017-02-24 16:21:18 -08001681ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler)
1682 : art_vm(runtime),
1683 local_data(nullptr),
Andreas Gampea1705ea2017-03-28 20:12:13 -07001684 capabilities() {
1685 object_tag_table = std::unique_ptr<ObjectTagTable>(new ObjectTagTable(event_handler, this));
Andreas Gampede19eb92017-02-24 16:21:18 -08001686 functions = &gJvmtiInterface;
1687}
1688
Alex Light49948e92016-08-11 15:35:28 -07001689// Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1690// is a pointer to the uninitialized memory for an art::ti::Env.
1691static void CreateArtJvmTiEnv(art::JavaVMExt* vm, /*out*/void** new_jvmtiEnv) {
Andreas Gampede19eb92017-02-24 16:21:18 -08001692 struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, &gEventHandler);
Alex Light49948e92016-08-11 15:35:28 -07001693 *new_jvmtiEnv = env;
Andreas Gampe77708d92016-10-07 11:48:21 -07001694
1695 gEventHandler.RegisterArtJvmTiEnv(env);
Andreas Gampede19eb92017-02-24 16:21:18 -08001696
1697 art::Runtime::Current()->AddSystemWeakHolder(
1698 ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
Alex Light49948e92016-08-11 15:35:28 -07001699}
1700
1701// A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1702// places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1703// returns false and does not modify the 'env' pointer.
1704static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1705 if (IsJvmtiVersion(version)) {
1706 CreateArtJvmTiEnv(vm, env);
1707 return JNI_OK;
1708 } else {
1709 printf("version 0x%x is not valid!", version);
1710 return JNI_EVERSION;
1711 }
1712}
1713
1714// The plugin initialization function. This adds the jvmti environment.
1715extern "C" bool ArtPlugin_Initialize() {
Andreas Gampee08a2be2016-10-06 13:13:30 -07001716 art::Runtime* runtime = art::Runtime::Current();
Andreas Gampe96eca782017-01-19 19:45:30 -08001717
1718 if (runtime->IsStarted()) {
1719 PhaseUtil::SetToLive();
1720 } else {
1721 PhaseUtil::SetToOnLoad();
1722 }
Andreas Gampe3a7eb142017-01-19 21:59:22 -08001723 PhaseUtil::Register(&gEventHandler);
Andreas Gampeeafaf572017-01-20 12:34:15 -08001724 ThreadUtil::Register(&gEventHandler);
Andreas Gampee6377462017-01-20 17:37:50 -08001725 ClassUtil::Register(&gEventHandler);
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001726 DumpUtil::Register(&gEventHandler);
Alex Lightd78ddec2017-04-18 15:20:38 -07001727 MethodUtil::Register(&gEventHandler);
Andreas Gampecefaa142017-01-23 15:04:59 -08001728 SearchUtil::Register();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001729 HeapUtil::Register();
Andreas Gampe96eca782017-01-19 19:45:30 -08001730
Andreas Gampee08a2be2016-10-06 13:13:30 -07001731 runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
Andreas Gampe96eca782017-01-19 19:45:30 -08001732
Alex Light49948e92016-08-11 15:35:28 -07001733 return true;
1734}
1735
Andreas Gampeeafaf572017-01-20 12:34:15 -08001736extern "C" bool ArtPlugin_Deinitialize() {
Alex Lightb7edcda2017-04-27 13:20:31 -07001737 gEventHandler.Shutdown();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001738 PhaseUtil::Unregister();
1739 ThreadUtil::Unregister();
Andreas Gampee6377462017-01-20 17:37:50 -08001740 ClassUtil::Unregister();
Andreas Gampeeb0cea12017-01-23 08:50:04 -08001741 DumpUtil::Unregister();
Alex Lightd78ddec2017-04-18 15:20:38 -07001742 MethodUtil::Unregister();
Andreas Gampecefaa142017-01-23 15:04:59 -08001743 SearchUtil::Unregister();
Andreas Gampe9e38a502017-03-06 08:19:26 -08001744 HeapUtil::Unregister();
Andreas Gampeeafaf572017-01-20 12:34:15 -08001745
1746 return true;
1747}
1748
Alex Light49948e92016-08-11 15:35:28 -07001749// The actual struct holding all of the entrypoints into the jvmti interface.
1750const jvmtiInterface_1 gJvmtiInterface = {
Alex Light6ac57502017-01-19 15:05:06 -08001751 nullptr, // reserved1
Alex Light49948e92016-08-11 15:35:28 -07001752 JvmtiFunctions::SetEventNotificationMode,
Alex Light0e692732017-01-10 15:00:05 -08001753 nullptr, // reserved3
Alex Light49948e92016-08-11 15:35:28 -07001754 JvmtiFunctions::GetAllThreads,
1755 JvmtiFunctions::SuspendThread,
1756 JvmtiFunctions::ResumeThread,
1757 JvmtiFunctions::StopThread,
1758 JvmtiFunctions::InterruptThread,
1759 JvmtiFunctions::GetThreadInfo,
1760 JvmtiFunctions::GetOwnedMonitorInfo, // 10
1761 JvmtiFunctions::GetCurrentContendedMonitor,
1762 JvmtiFunctions::RunAgentThread,
1763 JvmtiFunctions::GetTopThreadGroups,
1764 JvmtiFunctions::GetThreadGroupInfo,
1765 JvmtiFunctions::GetThreadGroupChildren,
1766 JvmtiFunctions::GetFrameCount,
1767 JvmtiFunctions::GetThreadState,
1768 JvmtiFunctions::GetCurrentThread,
1769 JvmtiFunctions::GetFrameLocation,
1770 JvmtiFunctions::NotifyFramePop, // 20
1771 JvmtiFunctions::GetLocalObject,
1772 JvmtiFunctions::GetLocalInt,
1773 JvmtiFunctions::GetLocalLong,
1774 JvmtiFunctions::GetLocalFloat,
1775 JvmtiFunctions::GetLocalDouble,
1776 JvmtiFunctions::SetLocalObject,
1777 JvmtiFunctions::SetLocalInt,
1778 JvmtiFunctions::SetLocalLong,
1779 JvmtiFunctions::SetLocalFloat,
1780 JvmtiFunctions::SetLocalDouble, // 30
1781 JvmtiFunctions::CreateRawMonitor,
1782 JvmtiFunctions::DestroyRawMonitor,
1783 JvmtiFunctions::RawMonitorEnter,
1784 JvmtiFunctions::RawMonitorExit,
1785 JvmtiFunctions::RawMonitorWait,
1786 JvmtiFunctions::RawMonitorNotify,
1787 JvmtiFunctions::RawMonitorNotifyAll,
1788 JvmtiFunctions::SetBreakpoint,
1789 JvmtiFunctions::ClearBreakpoint,
1790 nullptr, // reserved40
1791 JvmtiFunctions::SetFieldAccessWatch,
1792 JvmtiFunctions::ClearFieldAccessWatch,
1793 JvmtiFunctions::SetFieldModificationWatch,
1794 JvmtiFunctions::ClearFieldModificationWatch,
1795 JvmtiFunctions::IsModifiableClass,
1796 JvmtiFunctions::Allocate,
1797 JvmtiFunctions::Deallocate,
1798 JvmtiFunctions::GetClassSignature,
1799 JvmtiFunctions::GetClassStatus,
1800 JvmtiFunctions::GetSourceFileName, // 50
1801 JvmtiFunctions::GetClassModifiers,
1802 JvmtiFunctions::GetClassMethods,
1803 JvmtiFunctions::GetClassFields,
1804 JvmtiFunctions::GetImplementedInterfaces,
1805 JvmtiFunctions::IsInterface,
1806 JvmtiFunctions::IsArrayClass,
1807 JvmtiFunctions::GetClassLoader,
1808 JvmtiFunctions::GetObjectHashCode,
1809 JvmtiFunctions::GetObjectMonitorUsage,
1810 JvmtiFunctions::GetFieldName, // 60
1811 JvmtiFunctions::GetFieldDeclaringClass,
1812 JvmtiFunctions::GetFieldModifiers,
1813 JvmtiFunctions::IsFieldSynthetic,
1814 JvmtiFunctions::GetMethodName,
1815 JvmtiFunctions::GetMethodDeclaringClass,
1816 JvmtiFunctions::GetMethodModifiers,
1817 nullptr, // reserved67
1818 JvmtiFunctions::GetMaxLocals,
1819 JvmtiFunctions::GetArgumentsSize,
1820 JvmtiFunctions::GetLineNumberTable, // 70
1821 JvmtiFunctions::GetMethodLocation,
1822 JvmtiFunctions::GetLocalVariableTable,
1823 JvmtiFunctions::SetNativeMethodPrefix,
1824 JvmtiFunctions::SetNativeMethodPrefixes,
1825 JvmtiFunctions::GetBytecodes,
1826 JvmtiFunctions::IsMethodNative,
1827 JvmtiFunctions::IsMethodSynthetic,
1828 JvmtiFunctions::GetLoadedClasses,
1829 JvmtiFunctions::GetClassLoaderClasses,
1830 JvmtiFunctions::PopFrame, // 80
1831 JvmtiFunctions::ForceEarlyReturnObject,
1832 JvmtiFunctions::ForceEarlyReturnInt,
1833 JvmtiFunctions::ForceEarlyReturnLong,
1834 JvmtiFunctions::ForceEarlyReturnFloat,
1835 JvmtiFunctions::ForceEarlyReturnDouble,
1836 JvmtiFunctions::ForceEarlyReturnVoid,
1837 JvmtiFunctions::RedefineClasses,
1838 JvmtiFunctions::GetVersionNumber,
1839 JvmtiFunctions::GetCapabilities,
1840 JvmtiFunctions::GetSourceDebugExtension, // 90
1841 JvmtiFunctions::IsMethodObsolete,
1842 JvmtiFunctions::SuspendThreadList,
1843 JvmtiFunctions::ResumeThreadList,
1844 nullptr, // reserved94
1845 nullptr, // reserved95
1846 nullptr, // reserved96
1847 nullptr, // reserved97
1848 nullptr, // reserved98
1849 nullptr, // reserved99
1850 JvmtiFunctions::GetAllStackTraces, // 100
1851 JvmtiFunctions::GetThreadListStackTraces,
1852 JvmtiFunctions::GetThreadLocalStorage,
1853 JvmtiFunctions::SetThreadLocalStorage,
1854 JvmtiFunctions::GetStackTrace,
1855 nullptr, // reserved105
1856 JvmtiFunctions::GetTag,
1857 JvmtiFunctions::SetTag,
1858 JvmtiFunctions::ForceGarbageCollection,
1859 JvmtiFunctions::IterateOverObjectsReachableFromObject,
1860 JvmtiFunctions::IterateOverReachableObjects, // 110
1861 JvmtiFunctions::IterateOverHeap,
1862 JvmtiFunctions::IterateOverInstancesOfClass,
1863 nullptr, // reserved113
1864 JvmtiFunctions::GetObjectsWithTags,
1865 JvmtiFunctions::FollowReferences,
1866 JvmtiFunctions::IterateThroughHeap,
1867 nullptr, // reserved117
1868 nullptr, // reserved118
1869 nullptr, // reserved119
1870 JvmtiFunctions::SetJNIFunctionTable, // 120
1871 JvmtiFunctions::GetJNIFunctionTable,
1872 JvmtiFunctions::SetEventCallbacks,
1873 JvmtiFunctions::GenerateEvents,
1874 JvmtiFunctions::GetExtensionFunctions,
1875 JvmtiFunctions::GetExtensionEvents,
1876 JvmtiFunctions::SetExtensionEventCallback,
1877 JvmtiFunctions::DisposeEnvironment,
1878 JvmtiFunctions::GetErrorName,
1879 JvmtiFunctions::GetJLocationFormat,
1880 JvmtiFunctions::GetSystemProperties, // 130
1881 JvmtiFunctions::GetSystemProperty,
1882 JvmtiFunctions::SetSystemProperty,
1883 JvmtiFunctions::GetPhase,
1884 JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1885 JvmtiFunctions::GetCurrentThreadCpuTime,
1886 JvmtiFunctions::GetThreadCpuTimerInfo,
1887 JvmtiFunctions::GetThreadCpuTime,
1888 JvmtiFunctions::GetTimerInfo,
1889 JvmtiFunctions::GetTime,
1890 JvmtiFunctions::GetPotentialCapabilities, // 140
1891 nullptr, // reserved141
1892 JvmtiFunctions::AddCapabilities,
1893 JvmtiFunctions::RelinquishCapabilities,
1894 JvmtiFunctions::GetAvailableProcessors,
1895 JvmtiFunctions::GetClassVersionNumbers,
1896 JvmtiFunctions::GetConstantPool,
1897 JvmtiFunctions::GetEnvironmentLocalStorage,
1898 JvmtiFunctions::SetEnvironmentLocalStorage,
1899 JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1900 JvmtiFunctions::SetVerboseFlag, // 150
1901 JvmtiFunctions::AddToSystemClassLoaderSearch,
1902 JvmtiFunctions::RetransformClasses,
1903 JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1904 JvmtiFunctions::GetObjectSize,
1905 JvmtiFunctions::GetLocalInstance,
1906};
1907
1908}; // namespace openjdkjvmti