1*795d594fSAndroid Build Coastguard Worker /* Copyright (C) 2016 The Android Open Source Project
2*795d594fSAndroid Build Coastguard Worker * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * This file implements interfaces from the file jvmti.h. This implementation
5*795d594fSAndroid Build Coastguard Worker * is licensed under the same terms as the file jvmti.h. The
6*795d594fSAndroid Build Coastguard Worker * copyright and license information for the file jvmti.h follows.
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9*795d594fSAndroid Build Coastguard Worker * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10*795d594fSAndroid Build Coastguard Worker *
11*795d594fSAndroid Build Coastguard Worker * This code is free software; you can redistribute it and/or modify it
12*795d594fSAndroid Build Coastguard Worker * under the terms of the GNU General Public License version 2 only, as
13*795d594fSAndroid Build Coastguard Worker * published by the Free Software Foundation. Oracle designates this
14*795d594fSAndroid Build Coastguard Worker * particular file as subject to the "Classpath" exception as provided
15*795d594fSAndroid Build Coastguard Worker * by Oracle in the LICENSE file that accompanied this code.
16*795d594fSAndroid Build Coastguard Worker *
17*795d594fSAndroid Build Coastguard Worker * This code is distributed in the hope that it will be useful, but WITHOUT
18*795d594fSAndroid Build Coastguard Worker * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19*795d594fSAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20*795d594fSAndroid Build Coastguard Worker * version 2 for more details (a copy is included in the LICENSE file that
21*795d594fSAndroid Build Coastguard Worker * accompanied this code).
22*795d594fSAndroid Build Coastguard Worker *
23*795d594fSAndroid Build Coastguard Worker * You should have received a copy of the GNU General Public License version
24*795d594fSAndroid Build Coastguard Worker * 2 along with this work; if not, write to the Free Software Foundation,
25*795d594fSAndroid Build Coastguard Worker * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26*795d594fSAndroid Build Coastguard Worker *
27*795d594fSAndroid Build Coastguard Worker * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28*795d594fSAndroid Build Coastguard Worker * or visit www.oracle.com if you need additional information or have any
29*795d594fSAndroid Build Coastguard Worker * questions.
30*795d594fSAndroid Build Coastguard Worker */
31*795d594fSAndroid Build Coastguard Worker
32*795d594fSAndroid Build Coastguard Worker #include <memory>
33*795d594fSAndroid Build Coastguard Worker #include <string>
34*795d594fSAndroid Build Coastguard Worker #include <type_traits>
35*795d594fSAndroid Build Coastguard Worker #include <vector>
36*795d594fSAndroid Build Coastguard Worker
37*795d594fSAndroid Build Coastguard Worker #include <android-base/logging.h>
38*795d594fSAndroid Build Coastguard Worker
39*795d594fSAndroid Build Coastguard Worker #include <jni.h>
40*795d594fSAndroid Build Coastguard Worker
41*795d594fSAndroid Build Coastguard Worker #include "jvmti.h"
42*795d594fSAndroid Build Coastguard Worker
43*795d594fSAndroid Build Coastguard Worker #include "alloc_manager.h"
44*795d594fSAndroid Build Coastguard Worker #include "art_jvmti.h"
45*795d594fSAndroid Build Coastguard Worker #include "base/logging.h" // For gLogVerbosity.
46*795d594fSAndroid Build Coastguard Worker #include "base/mutex.h"
47*795d594fSAndroid Build Coastguard Worker #include "events-inl.h"
48*795d594fSAndroid Build Coastguard Worker #include "jni/jni_env_ext-inl.h"
49*795d594fSAndroid Build Coastguard Worker #include "obj_ptr-inl.h"
50*795d594fSAndroid Build Coastguard Worker #include "object_tagging.h"
51*795d594fSAndroid Build Coastguard Worker #include "runtime.h"
52*795d594fSAndroid Build Coastguard Worker #include "scoped_thread_state_change-inl.h"
53*795d594fSAndroid Build Coastguard Worker #include "thread-current-inl.h"
54*795d594fSAndroid Build Coastguard Worker #include "thread_list.h"
55*795d594fSAndroid Build Coastguard Worker #include "ti_allocator.h"
56*795d594fSAndroid Build Coastguard Worker #include "ti_breakpoint.h"
57*795d594fSAndroid Build Coastguard Worker #include "ti_class.h"
58*795d594fSAndroid Build Coastguard Worker #include "ti_dump.h"
59*795d594fSAndroid Build Coastguard Worker #include "ti_extension.h"
60*795d594fSAndroid Build Coastguard Worker #include "ti_field.h"
61*795d594fSAndroid Build Coastguard Worker #include "ti_heap.h"
62*795d594fSAndroid Build Coastguard Worker #include "ti_jni.h"
63*795d594fSAndroid Build Coastguard Worker #include "ti_logging.h"
64*795d594fSAndroid Build Coastguard Worker #include "ti_method.h"
65*795d594fSAndroid Build Coastguard Worker #include "ti_monitor.h"
66*795d594fSAndroid Build Coastguard Worker #include "ti_object.h"
67*795d594fSAndroid Build Coastguard Worker #include "ti_phase.h"
68*795d594fSAndroid Build Coastguard Worker #include "ti_properties.h"
69*795d594fSAndroid Build Coastguard Worker #include "ti_redefine.h"
70*795d594fSAndroid Build Coastguard Worker #include "ti_search.h"
71*795d594fSAndroid Build Coastguard Worker #include "ti_stack.h"
72*795d594fSAndroid Build Coastguard Worker #include "ti_thread.h"
73*795d594fSAndroid Build Coastguard Worker #include "ti_threadgroup.h"
74*795d594fSAndroid Build Coastguard Worker #include "ti_timers.h"
75*795d594fSAndroid Build Coastguard Worker #include "transform.h"
76*795d594fSAndroid Build Coastguard Worker
77*795d594fSAndroid Build Coastguard Worker namespace openjdkjvmti {
78*795d594fSAndroid Build Coastguard Worker
79*795d594fSAndroid Build Coastguard Worker // NB These are heap allocated to avoid the static destructors being run if an agent calls exit(3).
80*795d594fSAndroid Build Coastguard Worker // These should never be null.
81*795d594fSAndroid Build Coastguard Worker EventHandler* gEventHandler;
82*795d594fSAndroid Build Coastguard Worker DeoptManager* gDeoptManager;
83*795d594fSAndroid Build Coastguard Worker AllocationManager* gAllocManager;
84*795d594fSAndroid Build Coastguard Worker
85*795d594fSAndroid Build Coastguard Worker #define ENSURE_NON_NULL(n) \
86*795d594fSAndroid Build Coastguard Worker do { \
87*795d594fSAndroid Build Coastguard Worker if ((n) == nullptr) { \
88*795d594fSAndroid Build Coastguard Worker return ERR(NULL_POINTER); \
89*795d594fSAndroid Build Coastguard Worker } \
90*795d594fSAndroid Build Coastguard Worker } while (false)
91*795d594fSAndroid Build Coastguard Worker
92*795d594fSAndroid Build Coastguard Worker class JvmtiFunctions {
93*795d594fSAndroid Build Coastguard Worker private:
getEnvironmentError(jvmtiEnv * env)94*795d594fSAndroid Build Coastguard Worker static jvmtiError getEnvironmentError(jvmtiEnv* env) {
95*795d594fSAndroid Build Coastguard Worker if (env == nullptr) {
96*795d594fSAndroid Build Coastguard Worker return ERR(INVALID_ENVIRONMENT);
97*795d594fSAndroid Build Coastguard Worker } else if (art::Thread::Current() == nullptr) {
98*795d594fSAndroid Build Coastguard Worker return ERR(UNATTACHED_THREAD);
99*795d594fSAndroid Build Coastguard Worker } else {
100*795d594fSAndroid Build Coastguard Worker return OK;
101*795d594fSAndroid Build Coastguard Worker }
102*795d594fSAndroid Build Coastguard Worker }
103*795d594fSAndroid Build Coastguard Worker
104*795d594fSAndroid Build Coastguard Worker #define ENSURE_VALID_ENV(env) \
105*795d594fSAndroid Build Coastguard Worker do { \
106*795d594fSAndroid Build Coastguard Worker jvmtiError ensure_valid_env_ ## __LINE__ = getEnvironmentError(env); \
107*795d594fSAndroid Build Coastguard Worker if (ensure_valid_env_ ## __LINE__ != OK) { \
108*795d594fSAndroid Build Coastguard Worker return ensure_valid_env_ ## __LINE__ ; \
109*795d594fSAndroid Build Coastguard Worker } \
110*795d594fSAndroid Build Coastguard Worker } while (false)
111*795d594fSAndroid Build Coastguard Worker
112*795d594fSAndroid Build Coastguard Worker #define ENSURE_HAS_CAP(env, cap) \
113*795d594fSAndroid Build Coastguard Worker do { \
114*795d594fSAndroid Build Coastguard Worker if (ArtJvmTiEnv::AsArtJvmTiEnv(env)->capabilities.cap != 1) { \
115*795d594fSAndroid Build Coastguard Worker return ERR(MUST_POSSESS_CAPABILITY); \
116*795d594fSAndroid Build Coastguard Worker } \
117*795d594fSAndroid Build Coastguard Worker } while (false)
118*795d594fSAndroid Build Coastguard Worker
119*795d594fSAndroid Build Coastguard Worker public:
Allocate(jvmtiEnv * env,jlong size,unsigned char ** mem_ptr)120*795d594fSAndroid Build Coastguard Worker static jvmtiError Allocate(jvmtiEnv* env, jlong size, unsigned char** mem_ptr) {
121*795d594fSAndroid Build Coastguard Worker jvmtiError err = getEnvironmentError(env);
122*795d594fSAndroid Build Coastguard Worker // Allow UNATTACHED_THREAD since we don't really care about that for this function.
123*795d594fSAndroid Build Coastguard Worker if (err != OK && err != ERR(UNATTACHED_THREAD)) {
124*795d594fSAndroid Build Coastguard Worker return err;
125*795d594fSAndroid Build Coastguard Worker }
126*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(mem_ptr);
127*795d594fSAndroid Build Coastguard Worker return AllocUtil::Allocate(env, size, mem_ptr);
128*795d594fSAndroid Build Coastguard Worker }
129*795d594fSAndroid Build Coastguard Worker
Deallocate(jvmtiEnv * env,unsigned char * mem)130*795d594fSAndroid Build Coastguard Worker static jvmtiError Deallocate(jvmtiEnv* env, unsigned char* mem) {
131*795d594fSAndroid Build Coastguard Worker jvmtiError err = getEnvironmentError(env);
132*795d594fSAndroid Build Coastguard Worker // Allow UNATTACHED_THREAD since we don't really care about that for this function.
133*795d594fSAndroid Build Coastguard Worker if (err != OK && err != ERR(UNATTACHED_THREAD)) {
134*795d594fSAndroid Build Coastguard Worker return err;
135*795d594fSAndroid Build Coastguard Worker }
136*795d594fSAndroid Build Coastguard Worker return AllocUtil::Deallocate(env, mem);
137*795d594fSAndroid Build Coastguard Worker }
138*795d594fSAndroid Build Coastguard Worker
GetThreadState(jvmtiEnv * env,jthread thread,jint * thread_state_ptr)139*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadState(jvmtiEnv* env, jthread thread, jint* thread_state_ptr) {
140*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
141*795d594fSAndroid Build Coastguard Worker return ThreadUtil::GetThreadState(env, thread, thread_state_ptr);
142*795d594fSAndroid Build Coastguard Worker }
143*795d594fSAndroid Build Coastguard Worker
GetCurrentThread(jvmtiEnv * env,jthread * thread_ptr)144*795d594fSAndroid Build Coastguard Worker static jvmtiError GetCurrentThread(jvmtiEnv* env, jthread* thread_ptr) {
145*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
146*795d594fSAndroid Build Coastguard Worker return ThreadUtil::GetCurrentThread(env, thread_ptr);
147*795d594fSAndroid Build Coastguard Worker }
148*795d594fSAndroid Build Coastguard Worker
GetAllThreads(jvmtiEnv * env,jint * threads_count_ptr,jthread ** threads_ptr)149*795d594fSAndroid Build Coastguard Worker static jvmtiError GetAllThreads(jvmtiEnv* env, jint* threads_count_ptr, jthread** threads_ptr) {
150*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
151*795d594fSAndroid Build Coastguard Worker return ThreadUtil::GetAllThreads(env, threads_count_ptr, threads_ptr);
152*795d594fSAndroid Build Coastguard Worker }
153*795d594fSAndroid Build Coastguard Worker
SuspendThread(jvmtiEnv * env,jthread thread)154*795d594fSAndroid Build Coastguard Worker static jvmtiError SuspendThread(jvmtiEnv* env, jthread thread) {
155*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
156*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_suspend);
157*795d594fSAndroid Build Coastguard Worker return ThreadUtil::SuspendThread(env, thread);
158*795d594fSAndroid Build Coastguard Worker }
159*795d594fSAndroid Build Coastguard Worker
SuspendThreadList(jvmtiEnv * env,jint request_count,const jthread * request_list,jvmtiError * results)160*795d594fSAndroid Build Coastguard Worker static jvmtiError SuspendThreadList(jvmtiEnv* env,
161*795d594fSAndroid Build Coastguard Worker jint request_count,
162*795d594fSAndroid Build Coastguard Worker const jthread* request_list,
163*795d594fSAndroid Build Coastguard Worker jvmtiError* results) {
164*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
165*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_suspend);
166*795d594fSAndroid Build Coastguard Worker return ThreadUtil::SuspendThreadList(env, request_count, request_list, results);
167*795d594fSAndroid Build Coastguard Worker }
168*795d594fSAndroid Build Coastguard Worker
ResumeThread(jvmtiEnv * env,jthread thread)169*795d594fSAndroid Build Coastguard Worker static jvmtiError ResumeThread(jvmtiEnv* env, jthread thread) {
170*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
171*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_suspend);
172*795d594fSAndroid Build Coastguard Worker return ThreadUtil::ResumeThread(env, thread);
173*795d594fSAndroid Build Coastguard Worker }
174*795d594fSAndroid Build Coastguard Worker
ResumeThreadList(jvmtiEnv * env,jint request_count,const jthread * request_list,jvmtiError * results)175*795d594fSAndroid Build Coastguard Worker static jvmtiError ResumeThreadList(jvmtiEnv* env,
176*795d594fSAndroid Build Coastguard Worker jint request_count,
177*795d594fSAndroid Build Coastguard Worker const jthread* request_list,
178*795d594fSAndroid Build Coastguard Worker jvmtiError* results) {
179*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
180*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_suspend);
181*795d594fSAndroid Build Coastguard Worker return ThreadUtil::ResumeThreadList(env, request_count, request_list, results);
182*795d594fSAndroid Build Coastguard Worker }
183*795d594fSAndroid Build Coastguard Worker
StopThread(jvmtiEnv * env,jthread thread,jobject exception)184*795d594fSAndroid Build Coastguard Worker static jvmtiError StopThread(jvmtiEnv* env, jthread thread, jobject exception) {
185*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
186*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_signal_thread);
187*795d594fSAndroid Build Coastguard Worker return ThreadUtil::StopThread(env, thread, exception);
188*795d594fSAndroid Build Coastguard Worker }
189*795d594fSAndroid Build Coastguard Worker
InterruptThread(jvmtiEnv * env,jthread thread)190*795d594fSAndroid Build Coastguard Worker static jvmtiError InterruptThread(jvmtiEnv* env, jthread thread) {
191*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
192*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_signal_thread);
193*795d594fSAndroid Build Coastguard Worker return ThreadUtil::InterruptThread(env, thread);
194*795d594fSAndroid Build Coastguard Worker }
195*795d594fSAndroid Build Coastguard Worker
GetThreadInfo(jvmtiEnv * env,jthread thread,jvmtiThreadInfo * info_ptr)196*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadInfo(jvmtiEnv* env, jthread thread, jvmtiThreadInfo* info_ptr) {
197*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
198*795d594fSAndroid Build Coastguard Worker return ThreadUtil::GetThreadInfo(env, thread, info_ptr);
199*795d594fSAndroid Build Coastguard Worker }
200*795d594fSAndroid Build Coastguard Worker
GetOwnedMonitorInfo(jvmtiEnv * env,jthread thread,jint * owned_monitor_count_ptr,jobject ** owned_monitors_ptr)201*795d594fSAndroid Build Coastguard Worker static jvmtiError GetOwnedMonitorInfo(jvmtiEnv* env,
202*795d594fSAndroid Build Coastguard Worker jthread thread,
203*795d594fSAndroid Build Coastguard Worker jint* owned_monitor_count_ptr,
204*795d594fSAndroid Build Coastguard Worker jobject** owned_monitors_ptr) {
205*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
206*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_owned_monitor_info);
207*795d594fSAndroid Build Coastguard Worker return StackUtil::GetOwnedMonitorInfo(env,
208*795d594fSAndroid Build Coastguard Worker thread,
209*795d594fSAndroid Build Coastguard Worker owned_monitor_count_ptr,
210*795d594fSAndroid Build Coastguard Worker owned_monitors_ptr);
211*795d594fSAndroid Build Coastguard Worker }
212*795d594fSAndroid Build Coastguard Worker
GetOwnedMonitorStackDepthInfo(jvmtiEnv * env,jthread thread,jint * monitor_info_count_ptr,jvmtiMonitorStackDepthInfo ** monitor_info_ptr)213*795d594fSAndroid Build Coastguard Worker static jvmtiError GetOwnedMonitorStackDepthInfo(jvmtiEnv* env,
214*795d594fSAndroid Build Coastguard Worker jthread thread,
215*795d594fSAndroid Build Coastguard Worker jint* monitor_info_count_ptr,
216*795d594fSAndroid Build Coastguard Worker jvmtiMonitorStackDepthInfo** monitor_info_ptr) {
217*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
218*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_owned_monitor_stack_depth_info);
219*795d594fSAndroid Build Coastguard Worker return StackUtil::GetOwnedMonitorStackDepthInfo(env,
220*795d594fSAndroid Build Coastguard Worker thread,
221*795d594fSAndroid Build Coastguard Worker monitor_info_count_ptr,
222*795d594fSAndroid Build Coastguard Worker monitor_info_ptr);
223*795d594fSAndroid Build Coastguard Worker }
224*795d594fSAndroid Build Coastguard Worker
GetCurrentContendedMonitor(jvmtiEnv * env,jthread thread,jobject * monitor_ptr)225*795d594fSAndroid Build Coastguard Worker static jvmtiError GetCurrentContendedMonitor(jvmtiEnv* env,
226*795d594fSAndroid Build Coastguard Worker jthread thread,
227*795d594fSAndroid Build Coastguard Worker jobject* monitor_ptr) {
228*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
229*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_current_contended_monitor);
230*795d594fSAndroid Build Coastguard Worker return MonitorUtil::GetCurrentContendedMonitor(env, thread, monitor_ptr);
231*795d594fSAndroid Build Coastguard Worker }
232*795d594fSAndroid Build Coastguard Worker
RunAgentThread(jvmtiEnv * env,jthread thread,jvmtiStartFunction proc,const void * arg,jint priority)233*795d594fSAndroid Build Coastguard Worker static jvmtiError RunAgentThread(jvmtiEnv* env,
234*795d594fSAndroid Build Coastguard Worker jthread thread,
235*795d594fSAndroid Build Coastguard Worker jvmtiStartFunction proc,
236*795d594fSAndroid Build Coastguard Worker const void* arg,
237*795d594fSAndroid Build Coastguard Worker jint priority) {
238*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
239*795d594fSAndroid Build Coastguard Worker return ThreadUtil::RunAgentThread(env, thread, proc, arg, priority);
240*795d594fSAndroid Build Coastguard Worker }
241*795d594fSAndroid Build Coastguard Worker
SetThreadLocalStorage(jvmtiEnv * env,jthread thread,const void * data)242*795d594fSAndroid Build Coastguard Worker static jvmtiError SetThreadLocalStorage(jvmtiEnv* env, jthread thread, const void* data) {
243*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
244*795d594fSAndroid Build Coastguard Worker return ThreadUtil::SetThreadLocalStorage(env, thread, data);
245*795d594fSAndroid Build Coastguard Worker }
246*795d594fSAndroid Build Coastguard Worker
GetThreadLocalStorage(jvmtiEnv * env,jthread thread,void ** data_ptr)247*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadLocalStorage(jvmtiEnv* env, jthread thread, void** data_ptr) {
248*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
249*795d594fSAndroid Build Coastguard Worker return ThreadUtil::GetThreadLocalStorage(env, thread, data_ptr);
250*795d594fSAndroid Build Coastguard Worker }
251*795d594fSAndroid Build Coastguard Worker
GetTopThreadGroups(jvmtiEnv * env,jint * group_count_ptr,jthreadGroup ** groups_ptr)252*795d594fSAndroid Build Coastguard Worker static jvmtiError GetTopThreadGroups(jvmtiEnv* env,
253*795d594fSAndroid Build Coastguard Worker jint* group_count_ptr,
254*795d594fSAndroid Build Coastguard Worker jthreadGroup** groups_ptr) {
255*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
256*795d594fSAndroid Build Coastguard Worker return ThreadGroupUtil::GetTopThreadGroups(env, group_count_ptr, groups_ptr);
257*795d594fSAndroid Build Coastguard Worker }
258*795d594fSAndroid Build Coastguard Worker
GetThreadGroupInfo(jvmtiEnv * env,jthreadGroup group,jvmtiThreadGroupInfo * info_ptr)259*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadGroupInfo(jvmtiEnv* env,
260*795d594fSAndroid Build Coastguard Worker jthreadGroup group,
261*795d594fSAndroid Build Coastguard Worker jvmtiThreadGroupInfo* info_ptr) {
262*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
263*795d594fSAndroid Build Coastguard Worker return ThreadGroupUtil::GetThreadGroupInfo(env, group, info_ptr);
264*795d594fSAndroid Build Coastguard Worker }
265*795d594fSAndroid Build Coastguard Worker
GetThreadGroupChildren(jvmtiEnv * env,jthreadGroup group,jint * thread_count_ptr,jthread ** threads_ptr,jint * group_count_ptr,jthreadGroup ** groups_ptr)266*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadGroupChildren(jvmtiEnv* env,
267*795d594fSAndroid Build Coastguard Worker jthreadGroup group,
268*795d594fSAndroid Build Coastguard Worker jint* thread_count_ptr,
269*795d594fSAndroid Build Coastguard Worker jthread** threads_ptr,
270*795d594fSAndroid Build Coastguard Worker jint* group_count_ptr,
271*795d594fSAndroid Build Coastguard Worker jthreadGroup** groups_ptr) {
272*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
273*795d594fSAndroid Build Coastguard Worker return ThreadGroupUtil::GetThreadGroupChildren(env,
274*795d594fSAndroid Build Coastguard Worker group,
275*795d594fSAndroid Build Coastguard Worker thread_count_ptr,
276*795d594fSAndroid Build Coastguard Worker threads_ptr,
277*795d594fSAndroid Build Coastguard Worker group_count_ptr,
278*795d594fSAndroid Build Coastguard Worker groups_ptr);
279*795d594fSAndroid Build Coastguard Worker }
280*795d594fSAndroid Build Coastguard Worker
GetStackTrace(jvmtiEnv * env,jthread thread,jint start_depth,jint max_frame_count,jvmtiFrameInfo * frame_buffer,jint * count_ptr)281*795d594fSAndroid Build Coastguard Worker static jvmtiError GetStackTrace(jvmtiEnv* env,
282*795d594fSAndroid Build Coastguard Worker jthread thread,
283*795d594fSAndroid Build Coastguard Worker jint start_depth,
284*795d594fSAndroid Build Coastguard Worker jint max_frame_count,
285*795d594fSAndroid Build Coastguard Worker jvmtiFrameInfo* frame_buffer,
286*795d594fSAndroid Build Coastguard Worker jint* count_ptr) {
287*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
288*795d594fSAndroid Build Coastguard Worker return StackUtil::GetStackTrace(env,
289*795d594fSAndroid Build Coastguard Worker thread,
290*795d594fSAndroid Build Coastguard Worker start_depth,
291*795d594fSAndroid Build Coastguard Worker max_frame_count,
292*795d594fSAndroid Build Coastguard Worker frame_buffer,
293*795d594fSAndroid Build Coastguard Worker count_ptr);
294*795d594fSAndroid Build Coastguard Worker }
295*795d594fSAndroid Build Coastguard Worker
GetAllStackTraces(jvmtiEnv * env,jint max_frame_count,jvmtiStackInfo ** stack_info_ptr,jint * thread_count_ptr)296*795d594fSAndroid Build Coastguard Worker static jvmtiError GetAllStackTraces(jvmtiEnv* env,
297*795d594fSAndroid Build Coastguard Worker jint max_frame_count,
298*795d594fSAndroid Build Coastguard Worker jvmtiStackInfo** stack_info_ptr,
299*795d594fSAndroid Build Coastguard Worker jint* thread_count_ptr) {
300*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
301*795d594fSAndroid Build Coastguard Worker return StackUtil::GetAllStackTraces(env, max_frame_count, stack_info_ptr, thread_count_ptr);
302*795d594fSAndroid Build Coastguard Worker }
303*795d594fSAndroid Build Coastguard Worker
GetThreadListStackTraces(jvmtiEnv * env,jint thread_count,const jthread * thread_list,jint max_frame_count,jvmtiStackInfo ** stack_info_ptr)304*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadListStackTraces(jvmtiEnv* env,
305*795d594fSAndroid Build Coastguard Worker jint thread_count,
306*795d594fSAndroid Build Coastguard Worker const jthread* thread_list,
307*795d594fSAndroid Build Coastguard Worker jint max_frame_count,
308*795d594fSAndroid Build Coastguard Worker jvmtiStackInfo** stack_info_ptr) {
309*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
310*795d594fSAndroid Build Coastguard Worker return StackUtil::GetThreadListStackTraces(env,
311*795d594fSAndroid Build Coastguard Worker thread_count,
312*795d594fSAndroid Build Coastguard Worker thread_list,
313*795d594fSAndroid Build Coastguard Worker max_frame_count,
314*795d594fSAndroid Build Coastguard Worker stack_info_ptr);
315*795d594fSAndroid Build Coastguard Worker }
316*795d594fSAndroid Build Coastguard Worker
GetFrameCount(jvmtiEnv * env,jthread thread,jint * count_ptr)317*795d594fSAndroid Build Coastguard Worker static jvmtiError GetFrameCount(jvmtiEnv* env, jthread thread, jint* count_ptr) {
318*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
319*795d594fSAndroid Build Coastguard Worker return StackUtil::GetFrameCount(env, thread, count_ptr);
320*795d594fSAndroid Build Coastguard Worker }
321*795d594fSAndroid Build Coastguard Worker
PopFrame(jvmtiEnv * env,jthread thread)322*795d594fSAndroid Build Coastguard Worker static jvmtiError PopFrame(jvmtiEnv* env, jthread thread) {
323*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
324*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_pop_frame);
325*795d594fSAndroid Build Coastguard Worker return StackUtil::PopFrame(env, thread);
326*795d594fSAndroid Build Coastguard Worker }
327*795d594fSAndroid Build Coastguard Worker
GetFrameLocation(jvmtiEnv * env,jthread thread,jint depth,jmethodID * method_ptr,jlocation * location_ptr)328*795d594fSAndroid Build Coastguard Worker static jvmtiError GetFrameLocation(jvmtiEnv* env,
329*795d594fSAndroid Build Coastguard Worker jthread thread,
330*795d594fSAndroid Build Coastguard Worker jint depth,
331*795d594fSAndroid Build Coastguard Worker jmethodID* method_ptr,
332*795d594fSAndroid Build Coastguard Worker jlocation* location_ptr) {
333*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
334*795d594fSAndroid Build Coastguard Worker return StackUtil::GetFrameLocation(env, thread, depth, method_ptr, location_ptr);
335*795d594fSAndroid Build Coastguard Worker }
336*795d594fSAndroid Build Coastguard Worker
NotifyFramePop(jvmtiEnv * env,jthread thread,jint depth)337*795d594fSAndroid Build Coastguard Worker static jvmtiError NotifyFramePop(jvmtiEnv* env, jthread thread, jint depth) {
338*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
339*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_frame_pop_events);
340*795d594fSAndroid Build Coastguard Worker return StackUtil::NotifyFramePop(env, thread, depth);
341*795d594fSAndroid Build Coastguard Worker }
342*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnObject(jvmtiEnv * env,jthread thread,jobject value)343*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnObject(jvmtiEnv* env, jthread thread, jobject value) {
344*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
345*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
346*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn(env, gEventHandler, thread, value);
347*795d594fSAndroid Build Coastguard Worker }
348*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnInt(jvmtiEnv * env,jthread thread,jint value)349*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnInt(jvmtiEnv* env, jthread thread, jint value) {
350*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
351*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
352*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn(env, gEventHandler, thread, value);
353*795d594fSAndroid Build Coastguard Worker }
354*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnLong(jvmtiEnv * env,jthread thread,jlong value)355*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnLong(jvmtiEnv* env, jthread thread, jlong value) {
356*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
357*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
358*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn(env, gEventHandler, thread, value);
359*795d594fSAndroid Build Coastguard Worker }
360*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnFloat(jvmtiEnv * env,jthread thread,jfloat value)361*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnFloat(jvmtiEnv* env, jthread thread, jfloat value) {
362*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
363*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
364*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn(env, gEventHandler, thread, value);
365*795d594fSAndroid Build Coastguard Worker }
366*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnDouble(jvmtiEnv * env,jthread thread,jdouble value)367*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnDouble(jvmtiEnv* env, jthread thread, jdouble value) {
368*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
369*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
370*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn(env, gEventHandler, thread, value);
371*795d594fSAndroid Build Coastguard Worker }
372*795d594fSAndroid Build Coastguard Worker
ForceEarlyReturnVoid(jvmtiEnv * env,jthread thread)373*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceEarlyReturnVoid(jvmtiEnv* env, jthread thread) {
374*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
375*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_force_early_return);
376*795d594fSAndroid Build Coastguard Worker return StackUtil::ForceEarlyReturn<nullptr_t>(env, gEventHandler, thread, nullptr);
377*795d594fSAndroid Build Coastguard Worker }
378*795d594fSAndroid Build Coastguard Worker
FollowReferences(jvmtiEnv * env,jint heap_filter,jclass klass,jobject initial_object,const jvmtiHeapCallbacks * callbacks,const void * user_data)379*795d594fSAndroid Build Coastguard Worker static jvmtiError FollowReferences(jvmtiEnv* env,
380*795d594fSAndroid Build Coastguard Worker jint heap_filter,
381*795d594fSAndroid Build Coastguard Worker jclass klass,
382*795d594fSAndroid Build Coastguard Worker jobject initial_object,
383*795d594fSAndroid Build Coastguard Worker const jvmtiHeapCallbacks* callbacks,
384*795d594fSAndroid Build Coastguard Worker const void* user_data) {
385*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
386*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
387*795d594fSAndroid Build Coastguard Worker HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
388*795d594fSAndroid Build Coastguard Worker return heap_util.FollowReferences(env,
389*795d594fSAndroid Build Coastguard Worker heap_filter,
390*795d594fSAndroid Build Coastguard Worker klass,
391*795d594fSAndroid Build Coastguard Worker initial_object,
392*795d594fSAndroid Build Coastguard Worker callbacks,
393*795d594fSAndroid Build Coastguard Worker user_data);
394*795d594fSAndroid Build Coastguard Worker }
395*795d594fSAndroid Build Coastguard Worker
IterateThroughHeap(jvmtiEnv * env,jint heap_filter,jclass klass,const jvmtiHeapCallbacks * callbacks,const void * user_data)396*795d594fSAndroid Build Coastguard Worker static jvmtiError IterateThroughHeap(jvmtiEnv* env,
397*795d594fSAndroid Build Coastguard Worker jint heap_filter,
398*795d594fSAndroid Build Coastguard Worker jclass klass,
399*795d594fSAndroid Build Coastguard Worker const jvmtiHeapCallbacks* callbacks,
400*795d594fSAndroid Build Coastguard Worker const void* user_data) {
401*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
402*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
403*795d594fSAndroid Build Coastguard Worker HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
404*795d594fSAndroid Build Coastguard Worker return heap_util.IterateThroughHeap(env, heap_filter, klass, callbacks, user_data);
405*795d594fSAndroid Build Coastguard Worker }
406*795d594fSAndroid Build Coastguard Worker
GetTag(jvmtiEnv * env,jobject object,jlong * tag_ptr)407*795d594fSAndroid Build Coastguard Worker static jvmtiError GetTag(jvmtiEnv* env, jobject object, jlong* tag_ptr) {
408*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
409*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
410*795d594fSAndroid Build Coastguard Worker
411*795d594fSAndroid Build Coastguard Worker JNIEnv* jni_env = GetJniEnv(env);
412*795d594fSAndroid Build Coastguard Worker if (jni_env == nullptr) {
413*795d594fSAndroid Build Coastguard Worker return ERR(INTERNAL);
414*795d594fSAndroid Build Coastguard Worker }
415*795d594fSAndroid Build Coastguard Worker
416*795d594fSAndroid Build Coastguard Worker art::ScopedObjectAccess soa(jni_env);
417*795d594fSAndroid Build Coastguard Worker art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
418*795d594fSAndroid Build Coastguard Worker if (!ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTag(obj.Ptr(), tag_ptr)) {
419*795d594fSAndroid Build Coastguard Worker *tag_ptr = 0;
420*795d594fSAndroid Build Coastguard Worker }
421*795d594fSAndroid Build Coastguard Worker
422*795d594fSAndroid Build Coastguard Worker return ERR(NONE);
423*795d594fSAndroid Build Coastguard Worker }
424*795d594fSAndroid Build Coastguard Worker
SetTag(jvmtiEnv * env,jobject object,jlong tag)425*795d594fSAndroid Build Coastguard Worker static jvmtiError SetTag(jvmtiEnv* env, jobject object, jlong tag) {
426*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
427*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
428*795d594fSAndroid Build Coastguard Worker
429*795d594fSAndroid Build Coastguard Worker if (object == nullptr) {
430*795d594fSAndroid Build Coastguard Worker return ERR(NULL_POINTER);
431*795d594fSAndroid Build Coastguard Worker }
432*795d594fSAndroid Build Coastguard Worker
433*795d594fSAndroid Build Coastguard Worker JNIEnv* jni_env = GetJniEnv(env);
434*795d594fSAndroid Build Coastguard Worker if (jni_env == nullptr) {
435*795d594fSAndroid Build Coastguard Worker return ERR(INTERNAL);
436*795d594fSAndroid Build Coastguard Worker }
437*795d594fSAndroid Build Coastguard Worker
438*795d594fSAndroid Build Coastguard Worker art::ScopedObjectAccess soa(jni_env);
439*795d594fSAndroid Build Coastguard Worker art::ObjPtr<art::mirror::Object> obj = soa.Decode<art::mirror::Object>(object);
440*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->Set(obj.Ptr(), tag);
441*795d594fSAndroid Build Coastguard Worker
442*795d594fSAndroid Build Coastguard Worker return ERR(NONE);
443*795d594fSAndroid Build Coastguard Worker }
444*795d594fSAndroid Build Coastguard Worker
GetObjectsWithTags(jvmtiEnv * env,jint tag_count,const jlong * tags,jint * count_ptr,jobject ** object_result_ptr,jlong ** tag_result_ptr)445*795d594fSAndroid Build Coastguard Worker static jvmtiError GetObjectsWithTags(jvmtiEnv* env,
446*795d594fSAndroid Build Coastguard Worker jint tag_count,
447*795d594fSAndroid Build Coastguard Worker const jlong* tags,
448*795d594fSAndroid Build Coastguard Worker jint* count_ptr,
449*795d594fSAndroid Build Coastguard Worker jobject** object_result_ptr,
450*795d594fSAndroid Build Coastguard Worker jlong** tag_result_ptr) {
451*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
452*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
453*795d594fSAndroid Build Coastguard Worker
454*795d594fSAndroid Build Coastguard Worker JNIEnv* jni_env = GetJniEnv(env);
455*795d594fSAndroid Build Coastguard Worker if (jni_env == nullptr) {
456*795d594fSAndroid Build Coastguard Worker return ERR(INTERNAL);
457*795d594fSAndroid Build Coastguard Worker }
458*795d594fSAndroid Build Coastguard Worker
459*795d594fSAndroid Build Coastguard Worker art::ScopedObjectAccess soa(jni_env);
460*795d594fSAndroid Build Coastguard Worker return ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table->GetTaggedObjects(env,
461*795d594fSAndroid Build Coastguard Worker tag_count,
462*795d594fSAndroid Build Coastguard Worker tags,
463*795d594fSAndroid Build Coastguard Worker count_ptr,
464*795d594fSAndroid Build Coastguard Worker object_result_ptr,
465*795d594fSAndroid Build Coastguard Worker tag_result_ptr);
466*795d594fSAndroid Build Coastguard Worker }
467*795d594fSAndroid Build Coastguard Worker
ForceGarbageCollection(jvmtiEnv * env)468*795d594fSAndroid Build Coastguard Worker static jvmtiError ForceGarbageCollection(jvmtiEnv* env) {
469*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
470*795d594fSAndroid Build Coastguard Worker return HeapUtil::ForceGarbageCollection(env);
471*795d594fSAndroid Build Coastguard Worker }
472*795d594fSAndroid Build Coastguard Worker
IterateOverObjectsReachableFromObject(jvmtiEnv * env,jobject object,jvmtiObjectReferenceCallback object_reference_callback,const void * user_data)473*795d594fSAndroid Build Coastguard Worker static jvmtiError IterateOverObjectsReachableFromObject(
474*795d594fSAndroid Build Coastguard Worker jvmtiEnv* env,
475*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jobject object,
476*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiObjectReferenceCallback object_reference_callback,
477*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] const void* user_data) {
478*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
479*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
480*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
481*795d594fSAndroid Build Coastguard Worker }
482*795d594fSAndroid Build Coastguard Worker
IterateOverReachableObjects(jvmtiEnv * env,jvmtiHeapRootCallback heap_root_callback,jvmtiStackReferenceCallback stack_ref_callback,jvmtiObjectReferenceCallback object_ref_callback,const void * user_data)483*795d594fSAndroid Build Coastguard Worker static jvmtiError IterateOverReachableObjects(
484*795d594fSAndroid Build Coastguard Worker jvmtiEnv* env,
485*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiHeapRootCallback heap_root_callback,
486*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiStackReferenceCallback stack_ref_callback,
487*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiObjectReferenceCallback object_ref_callback,
488*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] const void* user_data) {
489*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
490*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
491*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
492*795d594fSAndroid Build Coastguard Worker }
493*795d594fSAndroid Build Coastguard Worker
IterateOverHeap(jvmtiEnv * env,jvmtiHeapObjectFilter object_filter,jvmtiHeapObjectCallback heap_object_callback,const void * user_data)494*795d594fSAndroid Build Coastguard Worker static jvmtiError IterateOverHeap(jvmtiEnv* env,
495*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiHeapObjectFilter object_filter,
496*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiHeapObjectCallback heap_object_callback,
497*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] const void* user_data) {
498*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
499*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
500*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
501*795d594fSAndroid Build Coastguard Worker }
502*795d594fSAndroid Build Coastguard Worker
IterateOverInstancesOfClass(jvmtiEnv * env,jclass klass,jvmtiHeapObjectFilter object_filter,jvmtiHeapObjectCallback heap_object_callback,const void * user_data)503*795d594fSAndroid Build Coastguard Worker static jvmtiError IterateOverInstancesOfClass(
504*795d594fSAndroid Build Coastguard Worker jvmtiEnv* env,
505*795d594fSAndroid Build Coastguard Worker jclass klass,
506*795d594fSAndroid Build Coastguard Worker jvmtiHeapObjectFilter object_filter,
507*795d594fSAndroid Build Coastguard Worker jvmtiHeapObjectCallback heap_object_callback,
508*795d594fSAndroid Build Coastguard Worker const void* user_data) {
509*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
510*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_tag_objects);
511*795d594fSAndroid Build Coastguard Worker HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
512*795d594fSAndroid Build Coastguard Worker return heap_util.IterateOverInstancesOfClass(
513*795d594fSAndroid Build Coastguard Worker env, klass, object_filter, heap_object_callback, user_data);
514*795d594fSAndroid Build Coastguard Worker }
515*795d594fSAndroid Build Coastguard Worker
GetLocalObject(jvmtiEnv * env,jthread thread,jint depth,jint slot,jobject * value_ptr)516*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalObject(jvmtiEnv* env,
517*795d594fSAndroid Build Coastguard Worker jthread thread,
518*795d594fSAndroid Build Coastguard Worker jint depth,
519*795d594fSAndroid Build Coastguard Worker jint slot,
520*795d594fSAndroid Build Coastguard Worker jobject* value_ptr) {
521*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
522*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
523*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
524*795d594fSAndroid Build Coastguard Worker }
525*795d594fSAndroid Build Coastguard Worker
GetLocalInstance(jvmtiEnv * env,jthread thread,jint depth,jobject * value_ptr)526*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalInstance(jvmtiEnv* env,
527*795d594fSAndroid Build Coastguard Worker jthread thread,
528*795d594fSAndroid Build Coastguard Worker jint depth,
529*795d594fSAndroid Build Coastguard Worker jobject* value_ptr) {
530*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
531*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
532*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalInstance(env, thread, depth, value_ptr);
533*795d594fSAndroid Build Coastguard Worker }
534*795d594fSAndroid Build Coastguard Worker
GetLocalInt(jvmtiEnv * env,jthread thread,jint depth,jint slot,jint * value_ptr)535*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalInt(jvmtiEnv* env,
536*795d594fSAndroid Build Coastguard Worker jthread thread,
537*795d594fSAndroid Build Coastguard Worker jint depth,
538*795d594fSAndroid Build Coastguard Worker jint slot,
539*795d594fSAndroid Build Coastguard Worker jint* value_ptr) {
540*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
541*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
542*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
543*795d594fSAndroid Build Coastguard Worker }
544*795d594fSAndroid Build Coastguard Worker
GetLocalLong(jvmtiEnv * env,jthread thread,jint depth,jint slot,jlong * value_ptr)545*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalLong(jvmtiEnv* env,
546*795d594fSAndroid Build Coastguard Worker jthread thread,
547*795d594fSAndroid Build Coastguard Worker jint depth,
548*795d594fSAndroid Build Coastguard Worker jint slot,
549*795d594fSAndroid Build Coastguard Worker jlong* value_ptr) {
550*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
551*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
552*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
553*795d594fSAndroid Build Coastguard Worker }
554*795d594fSAndroid Build Coastguard Worker
GetLocalFloat(jvmtiEnv * env,jthread thread,jint depth,jint slot,jfloat * value_ptr)555*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalFloat(jvmtiEnv* env,
556*795d594fSAndroid Build Coastguard Worker jthread thread,
557*795d594fSAndroid Build Coastguard Worker jint depth,
558*795d594fSAndroid Build Coastguard Worker jint slot,
559*795d594fSAndroid Build Coastguard Worker jfloat* value_ptr) {
560*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
561*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
562*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
563*795d594fSAndroid Build Coastguard Worker }
564*795d594fSAndroid Build Coastguard Worker
GetLocalDouble(jvmtiEnv * env,jthread thread,jint depth,jint slot,jdouble * value_ptr)565*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalDouble(jvmtiEnv* env,
566*795d594fSAndroid Build Coastguard Worker jthread thread,
567*795d594fSAndroid Build Coastguard Worker jint depth,
568*795d594fSAndroid Build Coastguard Worker jint slot,
569*795d594fSAndroid Build Coastguard Worker jdouble* value_ptr) {
570*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
571*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
572*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariable(env, thread, depth, slot, value_ptr);
573*795d594fSAndroid Build Coastguard Worker }
574*795d594fSAndroid Build Coastguard Worker
SetLocalObject(jvmtiEnv * env,jthread thread,jint depth,jint slot,jobject value)575*795d594fSAndroid Build Coastguard Worker static jvmtiError SetLocalObject(jvmtiEnv* env,
576*795d594fSAndroid Build Coastguard Worker jthread thread,
577*795d594fSAndroid Build Coastguard Worker jint depth,
578*795d594fSAndroid Build Coastguard Worker jint slot,
579*795d594fSAndroid Build Coastguard Worker jobject value) {
580*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
581*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
582*795d594fSAndroid Build Coastguard Worker return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
583*795d594fSAndroid Build Coastguard Worker }
584*795d594fSAndroid Build Coastguard Worker
SetLocalInt(jvmtiEnv * env,jthread thread,jint depth,jint slot,jint value)585*795d594fSAndroid Build Coastguard Worker static jvmtiError SetLocalInt(jvmtiEnv* env,
586*795d594fSAndroid Build Coastguard Worker jthread thread,
587*795d594fSAndroid Build Coastguard Worker jint depth,
588*795d594fSAndroid Build Coastguard Worker jint slot,
589*795d594fSAndroid Build Coastguard Worker jint value) {
590*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
591*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
592*795d594fSAndroid Build Coastguard Worker return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
593*795d594fSAndroid Build Coastguard Worker }
594*795d594fSAndroid Build Coastguard Worker
SetLocalLong(jvmtiEnv * env,jthread thread,jint depth,jint slot,jlong value)595*795d594fSAndroid Build Coastguard Worker static jvmtiError SetLocalLong(jvmtiEnv* env,
596*795d594fSAndroid Build Coastguard Worker jthread thread,
597*795d594fSAndroid Build Coastguard Worker jint depth,
598*795d594fSAndroid Build Coastguard Worker jint slot,
599*795d594fSAndroid Build Coastguard Worker jlong value) {
600*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
601*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
602*795d594fSAndroid Build Coastguard Worker return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
603*795d594fSAndroid Build Coastguard Worker }
604*795d594fSAndroid Build Coastguard Worker
SetLocalFloat(jvmtiEnv * env,jthread thread,jint depth,jint slot,jfloat value)605*795d594fSAndroid Build Coastguard Worker static jvmtiError SetLocalFloat(jvmtiEnv* env,
606*795d594fSAndroid Build Coastguard Worker jthread thread,
607*795d594fSAndroid Build Coastguard Worker jint depth,
608*795d594fSAndroid Build Coastguard Worker jint slot,
609*795d594fSAndroid Build Coastguard Worker jfloat value) {
610*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
611*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
612*795d594fSAndroid Build Coastguard Worker return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
613*795d594fSAndroid Build Coastguard Worker }
614*795d594fSAndroid Build Coastguard Worker
SetLocalDouble(jvmtiEnv * env,jthread thread,jint depth,jint slot,jdouble value)615*795d594fSAndroid Build Coastguard Worker static jvmtiError SetLocalDouble(jvmtiEnv* env,
616*795d594fSAndroid Build Coastguard Worker jthread thread,
617*795d594fSAndroid Build Coastguard Worker jint depth,
618*795d594fSAndroid Build Coastguard Worker jint slot,
619*795d594fSAndroid Build Coastguard Worker jdouble value) {
620*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
621*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
622*795d594fSAndroid Build Coastguard Worker return MethodUtil::SetLocalVariable(env, thread, depth, slot, value);
623*795d594fSAndroid Build Coastguard Worker }
624*795d594fSAndroid Build Coastguard Worker
625*795d594fSAndroid Build Coastguard Worker
SetBreakpoint(jvmtiEnv * env,jmethodID method,jlocation location)626*795d594fSAndroid Build Coastguard Worker static jvmtiError SetBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
627*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
628*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
629*795d594fSAndroid Build Coastguard Worker return BreakpointUtil::SetBreakpoint(env, method, location);
630*795d594fSAndroid Build Coastguard Worker }
631*795d594fSAndroid Build Coastguard Worker
ClearBreakpoint(jvmtiEnv * env,jmethodID method,jlocation location)632*795d594fSAndroid Build Coastguard Worker static jvmtiError ClearBreakpoint(jvmtiEnv* env, jmethodID method, jlocation location) {
633*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
634*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_breakpoint_events);
635*795d594fSAndroid Build Coastguard Worker return BreakpointUtil::ClearBreakpoint(env, method, location);
636*795d594fSAndroid Build Coastguard Worker }
637*795d594fSAndroid Build Coastguard Worker
SetFieldAccessWatch(jvmtiEnv * env,jclass klass,jfieldID field)638*795d594fSAndroid Build Coastguard Worker static jvmtiError SetFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
639*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
640*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_field_access_events);
641*795d594fSAndroid Build Coastguard Worker return FieldUtil::SetFieldAccessWatch(env, klass, field);
642*795d594fSAndroid Build Coastguard Worker }
643*795d594fSAndroid Build Coastguard Worker
ClearFieldAccessWatch(jvmtiEnv * env,jclass klass,jfieldID field)644*795d594fSAndroid Build Coastguard Worker static jvmtiError ClearFieldAccessWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
645*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
646*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_field_access_events);
647*795d594fSAndroid Build Coastguard Worker return FieldUtil::ClearFieldAccessWatch(env, klass, field);
648*795d594fSAndroid Build Coastguard Worker }
649*795d594fSAndroid Build Coastguard Worker
SetFieldModificationWatch(jvmtiEnv * env,jclass klass,jfieldID field)650*795d594fSAndroid Build Coastguard Worker static jvmtiError SetFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
651*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
652*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_field_modification_events);
653*795d594fSAndroid Build Coastguard Worker return FieldUtil::SetFieldModificationWatch(env, klass, field);
654*795d594fSAndroid Build Coastguard Worker }
655*795d594fSAndroid Build Coastguard Worker
ClearFieldModificationWatch(jvmtiEnv * env,jclass klass,jfieldID field)656*795d594fSAndroid Build Coastguard Worker static jvmtiError ClearFieldModificationWatch(jvmtiEnv* env, jclass klass, jfieldID field) {
657*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
658*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_generate_field_modification_events);
659*795d594fSAndroid Build Coastguard Worker return FieldUtil::ClearFieldModificationWatch(env, klass, field);
660*795d594fSAndroid Build Coastguard Worker }
661*795d594fSAndroid Build Coastguard Worker
GetLoadedClasses(jvmtiEnv * env,jint * class_count_ptr,jclass ** classes_ptr)662*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLoadedClasses(jvmtiEnv* env, jint* class_count_ptr, jclass** classes_ptr) {
663*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
664*795d594fSAndroid Build Coastguard Worker HeapUtil heap_util(ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
665*795d594fSAndroid Build Coastguard Worker return heap_util.GetLoadedClasses(env, class_count_ptr, classes_ptr);
666*795d594fSAndroid Build Coastguard Worker }
667*795d594fSAndroid Build Coastguard Worker
GetClassLoaderClasses(jvmtiEnv * env,jobject initiating_loader,jint * class_count_ptr,jclass ** classes_ptr)668*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassLoaderClasses(jvmtiEnv* env,
669*795d594fSAndroid Build Coastguard Worker jobject initiating_loader,
670*795d594fSAndroid Build Coastguard Worker jint* class_count_ptr,
671*795d594fSAndroid Build Coastguard Worker jclass** classes_ptr) {
672*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
673*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassLoaderClasses(env, initiating_loader, class_count_ptr, classes_ptr);
674*795d594fSAndroid Build Coastguard Worker }
675*795d594fSAndroid Build Coastguard Worker
GetClassSignature(jvmtiEnv * env,jclass klass,char ** signature_ptr,char ** generic_ptr)676*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassSignature(jvmtiEnv* env,
677*795d594fSAndroid Build Coastguard Worker jclass klass,
678*795d594fSAndroid Build Coastguard Worker char** signature_ptr,
679*795d594fSAndroid Build Coastguard Worker char** generic_ptr) {
680*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
681*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassSignature(env, klass, signature_ptr, generic_ptr);
682*795d594fSAndroid Build Coastguard Worker }
683*795d594fSAndroid Build Coastguard Worker
GetClassStatus(jvmtiEnv * env,jclass klass,jint * status_ptr)684*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassStatus(jvmtiEnv* env, jclass klass, jint* status_ptr) {
685*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
686*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassStatus(env, klass, status_ptr);
687*795d594fSAndroid Build Coastguard Worker }
688*795d594fSAndroid Build Coastguard Worker
GetSourceFileName(jvmtiEnv * env,jclass klass,char ** source_name_ptr)689*795d594fSAndroid Build Coastguard Worker static jvmtiError GetSourceFileName(jvmtiEnv* env, jclass klass, char** source_name_ptr) {
690*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
691*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_source_file_name);
692*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetSourceFileName(env, klass, source_name_ptr);
693*795d594fSAndroid Build Coastguard Worker }
694*795d594fSAndroid Build Coastguard Worker
GetClassModifiers(jvmtiEnv * env,jclass klass,jint * modifiers_ptr)695*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassModifiers(jvmtiEnv* env, jclass klass, jint* modifiers_ptr) {
696*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
697*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassModifiers(env, klass, modifiers_ptr);
698*795d594fSAndroid Build Coastguard Worker }
699*795d594fSAndroid Build Coastguard Worker
GetClassMethods(jvmtiEnv * env,jclass klass,jint * method_count_ptr,jmethodID ** methods_ptr)700*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassMethods(jvmtiEnv* env,
701*795d594fSAndroid Build Coastguard Worker jclass klass,
702*795d594fSAndroid Build Coastguard Worker jint* method_count_ptr,
703*795d594fSAndroid Build Coastguard Worker jmethodID** methods_ptr) {
704*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
705*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassMethods(env, klass, method_count_ptr, methods_ptr);
706*795d594fSAndroid Build Coastguard Worker }
707*795d594fSAndroid Build Coastguard Worker
GetClassFields(jvmtiEnv * env,jclass klass,jint * field_count_ptr,jfieldID ** fields_ptr)708*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassFields(jvmtiEnv* env,
709*795d594fSAndroid Build Coastguard Worker jclass klass,
710*795d594fSAndroid Build Coastguard Worker jint* field_count_ptr,
711*795d594fSAndroid Build Coastguard Worker jfieldID** fields_ptr) {
712*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
713*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassFields(env, klass, field_count_ptr, fields_ptr);
714*795d594fSAndroid Build Coastguard Worker }
715*795d594fSAndroid Build Coastguard Worker
GetImplementedInterfaces(jvmtiEnv * env,jclass klass,jint * interface_count_ptr,jclass ** interfaces_ptr)716*795d594fSAndroid Build Coastguard Worker static jvmtiError GetImplementedInterfaces(jvmtiEnv* env,
717*795d594fSAndroid Build Coastguard Worker jclass klass,
718*795d594fSAndroid Build Coastguard Worker jint* interface_count_ptr,
719*795d594fSAndroid Build Coastguard Worker jclass** interfaces_ptr) {
720*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
721*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetImplementedInterfaces(env, klass, interface_count_ptr, interfaces_ptr);
722*795d594fSAndroid Build Coastguard Worker }
723*795d594fSAndroid Build Coastguard Worker
GetClassVersionNumbers(jvmtiEnv * env,jclass klass,jint * minor_version_ptr,jint * major_version_ptr)724*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassVersionNumbers(jvmtiEnv* env,
725*795d594fSAndroid Build Coastguard Worker jclass klass,
726*795d594fSAndroid Build Coastguard Worker jint* minor_version_ptr,
727*795d594fSAndroid Build Coastguard Worker jint* major_version_ptr) {
728*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
729*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassVersionNumbers(env, klass, minor_version_ptr, major_version_ptr);
730*795d594fSAndroid Build Coastguard Worker }
731*795d594fSAndroid Build Coastguard Worker
GetConstantPool(jvmtiEnv * env,jclass klass,jint * constant_pool_count_ptr,jint * constant_pool_byte_count_ptr,unsigned char ** constant_pool_bytes_ptr)732*795d594fSAndroid Build Coastguard Worker static jvmtiError GetConstantPool(jvmtiEnv* env,
733*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jclass klass,
734*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jint* constant_pool_count_ptr,
735*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jint* constant_pool_byte_count_ptr,
736*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] unsigned char** constant_pool_bytes_ptr) {
737*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
738*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_constant_pool);
739*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
740*795d594fSAndroid Build Coastguard Worker }
741*795d594fSAndroid Build Coastguard Worker
IsInterface(jvmtiEnv * env,jclass klass,jboolean * is_interface_ptr)742*795d594fSAndroid Build Coastguard Worker static jvmtiError IsInterface(jvmtiEnv* env, jclass klass, jboolean* is_interface_ptr) {
743*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
744*795d594fSAndroid Build Coastguard Worker return ClassUtil::IsInterface(env, klass, is_interface_ptr);
745*795d594fSAndroid Build Coastguard Worker }
746*795d594fSAndroid Build Coastguard Worker
IsArrayClass(jvmtiEnv * env,jclass klass,jboolean * is_array_class_ptr)747*795d594fSAndroid Build Coastguard Worker static jvmtiError IsArrayClass(jvmtiEnv* env,
748*795d594fSAndroid Build Coastguard Worker jclass klass,
749*795d594fSAndroid Build Coastguard Worker jboolean* is_array_class_ptr) {
750*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
751*795d594fSAndroid Build Coastguard Worker return ClassUtil::IsArrayClass(env, klass, is_array_class_ptr);
752*795d594fSAndroid Build Coastguard Worker }
753*795d594fSAndroid Build Coastguard Worker
IsModifiableClass(jvmtiEnv * env,jclass klass,jboolean * is_modifiable_class_ptr)754*795d594fSAndroid Build Coastguard Worker static jvmtiError IsModifiableClass(jvmtiEnv* env,
755*795d594fSAndroid Build Coastguard Worker jclass klass,
756*795d594fSAndroid Build Coastguard Worker jboolean* is_modifiable_class_ptr) {
757*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
758*795d594fSAndroid Build Coastguard Worker return Redefiner::IsModifiableClass(env, klass, is_modifiable_class_ptr);
759*795d594fSAndroid Build Coastguard Worker }
760*795d594fSAndroid Build Coastguard Worker
GetClassLoader(jvmtiEnv * env,jclass klass,jobject * classloader_ptr)761*795d594fSAndroid Build Coastguard Worker static jvmtiError GetClassLoader(jvmtiEnv* env, jclass klass, jobject* classloader_ptr) {
762*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
763*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetClassLoader(env, klass, classloader_ptr);
764*795d594fSAndroid Build Coastguard Worker }
765*795d594fSAndroid Build Coastguard Worker
GetSourceDebugExtension(jvmtiEnv * env,jclass klass,char ** source_debug_extension_ptr)766*795d594fSAndroid Build Coastguard Worker static jvmtiError GetSourceDebugExtension(jvmtiEnv* env,
767*795d594fSAndroid Build Coastguard Worker jclass klass,
768*795d594fSAndroid Build Coastguard Worker char** source_debug_extension_ptr) {
769*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
770*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_source_debug_extension);
771*795d594fSAndroid Build Coastguard Worker return ClassUtil::GetSourceDebugExtension(env, klass, source_debug_extension_ptr);
772*795d594fSAndroid Build Coastguard Worker }
773*795d594fSAndroid Build Coastguard Worker
RetransformClasses(jvmtiEnv * env,jint class_count,const jclass * classes)774*795d594fSAndroid Build Coastguard Worker static jvmtiError RetransformClasses(jvmtiEnv* env, jint class_count, const jclass* classes) {
775*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
776*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_retransform_classes);
777*795d594fSAndroid Build Coastguard Worker return Transformer::RetransformClasses(env, class_count, classes);
778*795d594fSAndroid Build Coastguard Worker }
779*795d594fSAndroid Build Coastguard Worker
RedefineClasses(jvmtiEnv * env,jint class_count,const jvmtiClassDefinition * class_definitions)780*795d594fSAndroid Build Coastguard Worker static jvmtiError RedefineClasses(jvmtiEnv* env,
781*795d594fSAndroid Build Coastguard Worker jint class_count,
782*795d594fSAndroid Build Coastguard Worker const jvmtiClassDefinition* class_definitions) {
783*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
784*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_redefine_classes);
785*795d594fSAndroid Build Coastguard Worker return Redefiner::RedefineClasses(env, class_count, class_definitions);
786*795d594fSAndroid Build Coastguard Worker }
787*795d594fSAndroid Build Coastguard Worker
GetObjectSize(jvmtiEnv * env,jobject object,jlong * size_ptr)788*795d594fSAndroid Build Coastguard Worker static jvmtiError GetObjectSize(jvmtiEnv* env, jobject object, jlong* size_ptr) {
789*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
790*795d594fSAndroid Build Coastguard Worker return ObjectUtil::GetObjectSize(env, object, size_ptr);
791*795d594fSAndroid Build Coastguard Worker }
792*795d594fSAndroid Build Coastguard Worker
GetObjectHashCode(jvmtiEnv * env,jobject object,jint * hash_code_ptr)793*795d594fSAndroid Build Coastguard Worker static jvmtiError GetObjectHashCode(jvmtiEnv* env, jobject object, jint* hash_code_ptr) {
794*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
795*795d594fSAndroid Build Coastguard Worker return ObjectUtil::GetObjectHashCode(env, object, hash_code_ptr);
796*795d594fSAndroid Build Coastguard Worker }
797*795d594fSAndroid Build Coastguard Worker
GetObjectMonitorUsage(jvmtiEnv * env,jobject object,jvmtiMonitorUsage * info_ptr)798*795d594fSAndroid Build Coastguard Worker static jvmtiError GetObjectMonitorUsage(jvmtiEnv* env,
799*795d594fSAndroid Build Coastguard Worker jobject object,
800*795d594fSAndroid Build Coastguard Worker jvmtiMonitorUsage* info_ptr) {
801*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
802*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_monitor_info);
803*795d594fSAndroid Build Coastguard Worker return ObjectUtil::GetObjectMonitorUsage(env, object, info_ptr);
804*795d594fSAndroid Build Coastguard Worker }
805*795d594fSAndroid Build Coastguard Worker
GetFieldName(jvmtiEnv * env,jclass klass,jfieldID field,char ** name_ptr,char ** signature_ptr,char ** generic_ptr)806*795d594fSAndroid Build Coastguard Worker static jvmtiError GetFieldName(jvmtiEnv* env,
807*795d594fSAndroid Build Coastguard Worker jclass klass,
808*795d594fSAndroid Build Coastguard Worker jfieldID field,
809*795d594fSAndroid Build Coastguard Worker char** name_ptr,
810*795d594fSAndroid Build Coastguard Worker char** signature_ptr,
811*795d594fSAndroid Build Coastguard Worker char** generic_ptr) {
812*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
813*795d594fSAndroid Build Coastguard Worker return FieldUtil::GetFieldName(env, klass, field, name_ptr, signature_ptr, generic_ptr);
814*795d594fSAndroid Build Coastguard Worker }
815*795d594fSAndroid Build Coastguard Worker
GetFieldDeclaringClass(jvmtiEnv * env,jclass klass,jfieldID field,jclass * declaring_class_ptr)816*795d594fSAndroid Build Coastguard Worker static jvmtiError GetFieldDeclaringClass(jvmtiEnv* env,
817*795d594fSAndroid Build Coastguard Worker jclass klass,
818*795d594fSAndroid Build Coastguard Worker jfieldID field,
819*795d594fSAndroid Build Coastguard Worker jclass* declaring_class_ptr) {
820*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
821*795d594fSAndroid Build Coastguard Worker return FieldUtil::GetFieldDeclaringClass(env, klass, field, declaring_class_ptr);
822*795d594fSAndroid Build Coastguard Worker }
823*795d594fSAndroid Build Coastguard Worker
GetFieldModifiers(jvmtiEnv * env,jclass klass,jfieldID field,jint * modifiers_ptr)824*795d594fSAndroid Build Coastguard Worker static jvmtiError GetFieldModifiers(jvmtiEnv* env,
825*795d594fSAndroid Build Coastguard Worker jclass klass,
826*795d594fSAndroid Build Coastguard Worker jfieldID field,
827*795d594fSAndroid Build Coastguard Worker jint* modifiers_ptr) {
828*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
829*795d594fSAndroid Build Coastguard Worker return FieldUtil::GetFieldModifiers(env, klass, field, modifiers_ptr);
830*795d594fSAndroid Build Coastguard Worker }
831*795d594fSAndroid Build Coastguard Worker
IsFieldSynthetic(jvmtiEnv * env,jclass klass,jfieldID field,jboolean * is_synthetic_ptr)832*795d594fSAndroid Build Coastguard Worker static jvmtiError IsFieldSynthetic(jvmtiEnv* env,
833*795d594fSAndroid Build Coastguard Worker jclass klass,
834*795d594fSAndroid Build Coastguard Worker jfieldID field,
835*795d594fSAndroid Build Coastguard Worker jboolean* is_synthetic_ptr) {
836*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
837*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
838*795d594fSAndroid Build Coastguard Worker return FieldUtil::IsFieldSynthetic(env, klass, field, is_synthetic_ptr);
839*795d594fSAndroid Build Coastguard Worker }
840*795d594fSAndroid Build Coastguard Worker
GetMethodName(jvmtiEnv * env,jmethodID method,char ** name_ptr,char ** signature_ptr,char ** generic_ptr)841*795d594fSAndroid Build Coastguard Worker static jvmtiError GetMethodName(jvmtiEnv* env,
842*795d594fSAndroid Build Coastguard Worker jmethodID method,
843*795d594fSAndroid Build Coastguard Worker char** name_ptr,
844*795d594fSAndroid Build Coastguard Worker char** signature_ptr,
845*795d594fSAndroid Build Coastguard Worker char** generic_ptr) {
846*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
847*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetMethodName(env, method, name_ptr, signature_ptr, generic_ptr);
848*795d594fSAndroid Build Coastguard Worker }
849*795d594fSAndroid Build Coastguard Worker
GetMethodDeclaringClass(jvmtiEnv * env,jmethodID method,jclass * declaring_class_ptr)850*795d594fSAndroid Build Coastguard Worker static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
851*795d594fSAndroid Build Coastguard Worker jmethodID method,
852*795d594fSAndroid Build Coastguard Worker jclass* declaring_class_ptr) {
853*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
854*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetMethodDeclaringClass(env, method, declaring_class_ptr);
855*795d594fSAndroid Build Coastguard Worker }
856*795d594fSAndroid Build Coastguard Worker
GetMethodModifiers(jvmtiEnv * env,jmethodID method,jint * modifiers_ptr)857*795d594fSAndroid Build Coastguard Worker static jvmtiError GetMethodModifiers(jvmtiEnv* env,
858*795d594fSAndroid Build Coastguard Worker jmethodID method,
859*795d594fSAndroid Build Coastguard Worker jint* modifiers_ptr) {
860*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
861*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetMethodModifiers(env, method, modifiers_ptr);
862*795d594fSAndroid Build Coastguard Worker }
863*795d594fSAndroid Build Coastguard Worker
GetMaxLocals(jvmtiEnv * env,jmethodID method,jint * max_ptr)864*795d594fSAndroid Build Coastguard Worker static jvmtiError GetMaxLocals(jvmtiEnv* env,
865*795d594fSAndroid Build Coastguard Worker jmethodID method,
866*795d594fSAndroid Build Coastguard Worker jint* max_ptr) {
867*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
868*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetMaxLocals(env, method, max_ptr);
869*795d594fSAndroid Build Coastguard Worker }
870*795d594fSAndroid Build Coastguard Worker
GetArgumentsSize(jvmtiEnv * env,jmethodID method,jint * size_ptr)871*795d594fSAndroid Build Coastguard Worker static jvmtiError GetArgumentsSize(jvmtiEnv* env,
872*795d594fSAndroid Build Coastguard Worker jmethodID method,
873*795d594fSAndroid Build Coastguard Worker jint* size_ptr) {
874*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
875*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetArgumentsSize(env, method, size_ptr);
876*795d594fSAndroid Build Coastguard Worker }
877*795d594fSAndroid Build Coastguard Worker
GetLineNumberTable(jvmtiEnv * env,jmethodID method,jint * entry_count_ptr,jvmtiLineNumberEntry ** table_ptr)878*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLineNumberTable(jvmtiEnv* env,
879*795d594fSAndroid Build Coastguard Worker jmethodID method,
880*795d594fSAndroid Build Coastguard Worker jint* entry_count_ptr,
881*795d594fSAndroid Build Coastguard Worker jvmtiLineNumberEntry** table_ptr) {
882*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
883*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_line_numbers);
884*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLineNumberTable(env, method, entry_count_ptr, table_ptr);
885*795d594fSAndroid Build Coastguard Worker }
886*795d594fSAndroid Build Coastguard Worker
GetMethodLocation(jvmtiEnv * env,jmethodID method,jlocation * start_location_ptr,jlocation * end_location_ptr)887*795d594fSAndroid Build Coastguard Worker static jvmtiError GetMethodLocation(jvmtiEnv* env,
888*795d594fSAndroid Build Coastguard Worker jmethodID method,
889*795d594fSAndroid Build Coastguard Worker jlocation* start_location_ptr,
890*795d594fSAndroid Build Coastguard Worker jlocation* end_location_ptr) {
891*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
892*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetMethodLocation(env, method, start_location_ptr, end_location_ptr);
893*795d594fSAndroid Build Coastguard Worker }
894*795d594fSAndroid Build Coastguard Worker
GetLocalVariableTable(jvmtiEnv * env,jmethodID method,jint * entry_count_ptr,jvmtiLocalVariableEntry ** table_ptr)895*795d594fSAndroid Build Coastguard Worker static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
896*795d594fSAndroid Build Coastguard Worker jmethodID method,
897*795d594fSAndroid Build Coastguard Worker jint* entry_count_ptr,
898*795d594fSAndroid Build Coastguard Worker jvmtiLocalVariableEntry** table_ptr) {
899*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
900*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_access_local_variables);
901*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetLocalVariableTable(env, method, entry_count_ptr, table_ptr);
902*795d594fSAndroid Build Coastguard Worker }
903*795d594fSAndroid Build Coastguard Worker
GetBytecodes(jvmtiEnv * env,jmethodID method,jint * bytecode_count_ptr,unsigned char ** bytecodes_ptr)904*795d594fSAndroid Build Coastguard Worker static jvmtiError GetBytecodes(jvmtiEnv* env,
905*795d594fSAndroid Build Coastguard Worker jmethodID method,
906*795d594fSAndroid Build Coastguard Worker jint* bytecode_count_ptr,
907*795d594fSAndroid Build Coastguard Worker unsigned char** bytecodes_ptr) {
908*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
909*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_bytecodes);
910*795d594fSAndroid Build Coastguard Worker return MethodUtil::GetBytecodes(env, method, bytecode_count_ptr, bytecodes_ptr);
911*795d594fSAndroid Build Coastguard Worker }
912*795d594fSAndroid Build Coastguard Worker
IsMethodNative(jvmtiEnv * env,jmethodID method,jboolean * is_native_ptr)913*795d594fSAndroid Build Coastguard Worker static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr) {
914*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
915*795d594fSAndroid Build Coastguard Worker return MethodUtil::IsMethodNative(env, method, is_native_ptr);
916*795d594fSAndroid Build Coastguard Worker }
917*795d594fSAndroid Build Coastguard Worker
IsMethodSynthetic(jvmtiEnv * env,jmethodID method,jboolean * is_synthetic_ptr)918*795d594fSAndroid Build Coastguard Worker static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr) {
919*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
920*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_synthetic_attribute);
921*795d594fSAndroid Build Coastguard Worker return MethodUtil::IsMethodSynthetic(env, method, is_synthetic_ptr);
922*795d594fSAndroid Build Coastguard Worker }
923*795d594fSAndroid Build Coastguard Worker
IsMethodObsolete(jvmtiEnv * env,jmethodID method,jboolean * is_obsolete_ptr)924*795d594fSAndroid Build Coastguard Worker static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr) {
925*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
926*795d594fSAndroid Build Coastguard Worker return MethodUtil::IsMethodObsolete(env, method, is_obsolete_ptr);
927*795d594fSAndroid Build Coastguard Worker }
928*795d594fSAndroid Build Coastguard Worker
SetNativeMethodPrefix(jvmtiEnv * env,const char * prefix)929*795d594fSAndroid Build Coastguard Worker static jvmtiError SetNativeMethodPrefix(jvmtiEnv* env, [[maybe_unused]] const char* prefix) {
930*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
931*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_set_native_method_prefix);
932*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
933*795d594fSAndroid Build Coastguard Worker }
934*795d594fSAndroid Build Coastguard Worker
SetNativeMethodPrefixes(jvmtiEnv * env,jint prefix_count,char ** prefixes)935*795d594fSAndroid Build Coastguard Worker static jvmtiError SetNativeMethodPrefixes(jvmtiEnv* env,
936*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jint prefix_count,
937*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] char** prefixes) {
938*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
939*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_set_native_method_prefix);
940*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
941*795d594fSAndroid Build Coastguard Worker }
942*795d594fSAndroid Build Coastguard Worker
CreateRawMonitor(jvmtiEnv * env,const char * name,jrawMonitorID * monitor_ptr)943*795d594fSAndroid Build Coastguard Worker static jvmtiError CreateRawMonitor(jvmtiEnv* env, const char* name, jrawMonitorID* monitor_ptr) {
944*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
945*795d594fSAndroid Build Coastguard Worker return MonitorUtil::CreateRawMonitor(env, name, monitor_ptr);
946*795d594fSAndroid Build Coastguard Worker }
947*795d594fSAndroid Build Coastguard Worker
DestroyRawMonitor(jvmtiEnv * env,jrawMonitorID monitor)948*795d594fSAndroid Build Coastguard Worker static jvmtiError DestroyRawMonitor(jvmtiEnv* env, jrawMonitorID monitor) {
949*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
950*795d594fSAndroid Build Coastguard Worker return MonitorUtil::DestroyRawMonitor(env, monitor);
951*795d594fSAndroid Build Coastguard Worker }
952*795d594fSAndroid Build Coastguard Worker
RawMonitorEnter(jvmtiEnv * env,jrawMonitorID monitor)953*795d594fSAndroid Build Coastguard Worker static jvmtiError RawMonitorEnter(jvmtiEnv* env, jrawMonitorID monitor) {
954*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
955*795d594fSAndroid Build Coastguard Worker return MonitorUtil::RawMonitorEnter(env, monitor);
956*795d594fSAndroid Build Coastguard Worker }
957*795d594fSAndroid Build Coastguard Worker
RawMonitorExit(jvmtiEnv * env,jrawMonitorID monitor)958*795d594fSAndroid Build Coastguard Worker static jvmtiError RawMonitorExit(jvmtiEnv* env, jrawMonitorID monitor) {
959*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
960*795d594fSAndroid Build Coastguard Worker return MonitorUtil::RawMonitorExit(env, monitor);
961*795d594fSAndroid Build Coastguard Worker }
962*795d594fSAndroid Build Coastguard Worker
RawMonitorWait(jvmtiEnv * env,jrawMonitorID monitor,jlong millis)963*795d594fSAndroid Build Coastguard Worker static jvmtiError RawMonitorWait(jvmtiEnv* env, jrawMonitorID monitor, jlong millis) {
964*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
965*795d594fSAndroid Build Coastguard Worker return MonitorUtil::RawMonitorWait(env, monitor, millis);
966*795d594fSAndroid Build Coastguard Worker }
967*795d594fSAndroid Build Coastguard Worker
RawMonitorNotify(jvmtiEnv * env,jrawMonitorID monitor)968*795d594fSAndroid Build Coastguard Worker static jvmtiError RawMonitorNotify(jvmtiEnv* env, jrawMonitorID monitor) {
969*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
970*795d594fSAndroid Build Coastguard Worker return MonitorUtil::RawMonitorNotify(env, monitor);
971*795d594fSAndroid Build Coastguard Worker }
972*795d594fSAndroid Build Coastguard Worker
RawMonitorNotifyAll(jvmtiEnv * env,jrawMonitorID monitor)973*795d594fSAndroid Build Coastguard Worker static jvmtiError RawMonitorNotifyAll(jvmtiEnv* env, jrawMonitorID monitor) {
974*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
975*795d594fSAndroid Build Coastguard Worker return MonitorUtil::RawMonitorNotifyAll(env, monitor);
976*795d594fSAndroid Build Coastguard Worker }
977*795d594fSAndroid Build Coastguard Worker
SetJNIFunctionTable(jvmtiEnv * env,const jniNativeInterface * function_table)978*795d594fSAndroid Build Coastguard Worker static jvmtiError SetJNIFunctionTable(jvmtiEnv* env, const jniNativeInterface* function_table) {
979*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
980*795d594fSAndroid Build Coastguard Worker return JNIUtil::SetJNIFunctionTable(env, function_table);
981*795d594fSAndroid Build Coastguard Worker }
982*795d594fSAndroid Build Coastguard Worker
GetJNIFunctionTable(jvmtiEnv * env,jniNativeInterface ** function_table)983*795d594fSAndroid Build Coastguard Worker static jvmtiError GetJNIFunctionTable(jvmtiEnv* env, jniNativeInterface** function_table) {
984*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
985*795d594fSAndroid Build Coastguard Worker return JNIUtil::GetJNIFunctionTable(env, function_table);
986*795d594fSAndroid Build Coastguard Worker }
987*795d594fSAndroid Build Coastguard Worker
988*795d594fSAndroid Build Coastguard Worker // TODO: This will require locking, so that an agent can't remove callbacks when we're dispatching
989*795d594fSAndroid Build Coastguard Worker // an event.
SetEventCallbacks(jvmtiEnv * env,const jvmtiEventCallbacks * callbacks,jint size_of_callbacks)990*795d594fSAndroid Build Coastguard Worker static jvmtiError SetEventCallbacks(jvmtiEnv* env,
991*795d594fSAndroid Build Coastguard Worker const jvmtiEventCallbacks* callbacks,
992*795d594fSAndroid Build Coastguard Worker jint size_of_callbacks) {
993*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
994*795d594fSAndroid Build Coastguard Worker if (size_of_callbacks < 0) {
995*795d594fSAndroid Build Coastguard Worker return ERR(ILLEGAL_ARGUMENT);
996*795d594fSAndroid Build Coastguard Worker }
997*795d594fSAndroid Build Coastguard Worker
998*795d594fSAndroid Build Coastguard Worker if (callbacks == nullptr) {
999*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv::AsArtJvmTiEnv(env)->event_callbacks.reset();
1000*795d594fSAndroid Build Coastguard Worker return ERR(NONE);
1001*795d594fSAndroid Build Coastguard Worker }
1002*795d594fSAndroid Build Coastguard Worker
1003*795d594fSAndroid Build Coastguard Worker // Lock the event_info_mutex_ while we replace the callbacks.
1004*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1005*795d594fSAndroid Build Coastguard Worker art::WriterMutexLock lk(art::Thread::Current(), art_env->event_info_mutex_);
1006*795d594fSAndroid Build Coastguard Worker std::unique_ptr<ArtJvmtiEventCallbacks> tmp(new ArtJvmtiEventCallbacks());
1007*795d594fSAndroid Build Coastguard Worker // Copy over the extension events.
1008*795d594fSAndroid Build Coastguard Worker tmp->CopyExtensionsFrom(art_env->event_callbacks.get());
1009*795d594fSAndroid Build Coastguard Worker // Never overwrite the extension events.
1010*795d594fSAndroid Build Coastguard Worker size_t copy_size = std::min(sizeof(jvmtiEventCallbacks),
1011*795d594fSAndroid Build Coastguard Worker static_cast<size_t>(size_of_callbacks));
1012*795d594fSAndroid Build Coastguard Worker copy_size = art::RoundDown(copy_size, sizeof(void*));
1013*795d594fSAndroid Build Coastguard Worker // Copy non-extension events.
1014*795d594fSAndroid Build Coastguard Worker memcpy(tmp.get(), callbacks, copy_size);
1015*795d594fSAndroid Build Coastguard Worker
1016*795d594fSAndroid Build Coastguard Worker // replace the event table.
1017*795d594fSAndroid Build Coastguard Worker art_env->event_callbacks = std::move(tmp);
1018*795d594fSAndroid Build Coastguard Worker
1019*795d594fSAndroid Build Coastguard Worker return ERR(NONE);
1020*795d594fSAndroid Build Coastguard Worker }
1021*795d594fSAndroid Build Coastguard Worker
SetEventNotificationMode(jvmtiEnv * env,jvmtiEventMode mode,jvmtiEvent event_type,jthread event_thread,...)1022*795d594fSAndroid Build Coastguard Worker static jvmtiError SetEventNotificationMode(jvmtiEnv* env,
1023*795d594fSAndroid Build Coastguard Worker jvmtiEventMode mode,
1024*795d594fSAndroid Build Coastguard Worker jvmtiEvent event_type,
1025*795d594fSAndroid Build Coastguard Worker jthread event_thread,
1026*795d594fSAndroid Build Coastguard Worker ...) {
1027*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1028*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* art_env = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1029*795d594fSAndroid Build Coastguard Worker return gEventHandler->SetEvent(art_env,
1030*795d594fSAndroid Build Coastguard Worker event_thread,
1031*795d594fSAndroid Build Coastguard Worker GetArtJvmtiEvent(art_env, event_type),
1032*795d594fSAndroid Build Coastguard Worker mode);
1033*795d594fSAndroid Build Coastguard Worker }
1034*795d594fSAndroid Build Coastguard Worker
GenerateEvents(jvmtiEnv * env,jvmtiEvent event_type)1035*795d594fSAndroid Build Coastguard Worker static jvmtiError GenerateEvents(jvmtiEnv* env, [[maybe_unused]] jvmtiEvent event_type) {
1036*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1037*795d594fSAndroid Build Coastguard Worker return OK;
1038*795d594fSAndroid Build Coastguard Worker }
1039*795d594fSAndroid Build Coastguard Worker
GetExtensionFunctions(jvmtiEnv * env,jint * extension_count_ptr,jvmtiExtensionFunctionInfo ** extensions)1040*795d594fSAndroid Build Coastguard Worker static jvmtiError GetExtensionFunctions(jvmtiEnv* env,
1041*795d594fSAndroid Build Coastguard Worker jint* extension_count_ptr,
1042*795d594fSAndroid Build Coastguard Worker jvmtiExtensionFunctionInfo** extensions) {
1043*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1044*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(extension_count_ptr);
1045*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(extensions);
1046*795d594fSAndroid Build Coastguard Worker return ExtensionUtil::GetExtensionFunctions(env, extension_count_ptr, extensions);
1047*795d594fSAndroid Build Coastguard Worker }
1048*795d594fSAndroid Build Coastguard Worker
GetExtensionEvents(jvmtiEnv * env,jint * extension_count_ptr,jvmtiExtensionEventInfo ** extensions)1049*795d594fSAndroid Build Coastguard Worker static jvmtiError GetExtensionEvents(jvmtiEnv* env,
1050*795d594fSAndroid Build Coastguard Worker jint* extension_count_ptr,
1051*795d594fSAndroid Build Coastguard Worker jvmtiExtensionEventInfo** extensions) {
1052*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1053*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(extension_count_ptr);
1054*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(extensions);
1055*795d594fSAndroid Build Coastguard Worker return ExtensionUtil::GetExtensionEvents(env, extension_count_ptr, extensions);
1056*795d594fSAndroid Build Coastguard Worker }
1057*795d594fSAndroid Build Coastguard Worker
SetExtensionEventCallback(jvmtiEnv * env,jint extension_event_index,jvmtiExtensionEvent callback)1058*795d594fSAndroid Build Coastguard Worker static jvmtiError SetExtensionEventCallback(jvmtiEnv* env,
1059*795d594fSAndroid Build Coastguard Worker jint extension_event_index,
1060*795d594fSAndroid Build Coastguard Worker jvmtiExtensionEvent callback) {
1061*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1062*795d594fSAndroid Build Coastguard Worker return ExtensionUtil::SetExtensionEventCallback(env,
1063*795d594fSAndroid Build Coastguard Worker extension_event_index,
1064*795d594fSAndroid Build Coastguard Worker callback,
1065*795d594fSAndroid Build Coastguard Worker gEventHandler);
1066*795d594fSAndroid Build Coastguard Worker }
1067*795d594fSAndroid Build Coastguard Worker
1068*795d594fSAndroid Build Coastguard Worker #define FOR_ALL_CAPABILITIES(FUN) \
1069*795d594fSAndroid Build Coastguard Worker FUN(can_tag_objects) \
1070*795d594fSAndroid Build Coastguard Worker FUN(can_generate_field_modification_events) \
1071*795d594fSAndroid Build Coastguard Worker FUN(can_generate_field_access_events) \
1072*795d594fSAndroid Build Coastguard Worker FUN(can_get_bytecodes) \
1073*795d594fSAndroid Build Coastguard Worker FUN(can_get_synthetic_attribute) \
1074*795d594fSAndroid Build Coastguard Worker FUN(can_get_owned_monitor_info) \
1075*795d594fSAndroid Build Coastguard Worker FUN(can_get_current_contended_monitor) \
1076*795d594fSAndroid Build Coastguard Worker FUN(can_get_monitor_info) \
1077*795d594fSAndroid Build Coastguard Worker FUN(can_pop_frame) \
1078*795d594fSAndroid Build Coastguard Worker FUN(can_redefine_classes) \
1079*795d594fSAndroid Build Coastguard Worker FUN(can_signal_thread) \
1080*795d594fSAndroid Build Coastguard Worker FUN(can_get_source_file_name) \
1081*795d594fSAndroid Build Coastguard Worker FUN(can_get_line_numbers) \
1082*795d594fSAndroid Build Coastguard Worker FUN(can_get_source_debug_extension) \
1083*795d594fSAndroid Build Coastguard Worker FUN(can_access_local_variables) \
1084*795d594fSAndroid Build Coastguard Worker FUN(can_maintain_original_method_order) \
1085*795d594fSAndroid Build Coastguard Worker FUN(can_generate_single_step_events) \
1086*795d594fSAndroid Build Coastguard Worker FUN(can_generate_exception_events) \
1087*795d594fSAndroid Build Coastguard Worker FUN(can_generate_frame_pop_events) \
1088*795d594fSAndroid Build Coastguard Worker FUN(can_generate_breakpoint_events) \
1089*795d594fSAndroid Build Coastguard Worker FUN(can_suspend) \
1090*795d594fSAndroid Build Coastguard Worker FUN(can_redefine_any_class) \
1091*795d594fSAndroid Build Coastguard Worker FUN(can_get_current_thread_cpu_time) \
1092*795d594fSAndroid Build Coastguard Worker FUN(can_get_thread_cpu_time) \
1093*795d594fSAndroid Build Coastguard Worker FUN(can_generate_method_entry_events) \
1094*795d594fSAndroid Build Coastguard Worker FUN(can_generate_method_exit_events) \
1095*795d594fSAndroid Build Coastguard Worker FUN(can_generate_all_class_hook_events) \
1096*795d594fSAndroid Build Coastguard Worker FUN(can_generate_compiled_method_load_events) \
1097*795d594fSAndroid Build Coastguard Worker FUN(can_generate_monitor_events) \
1098*795d594fSAndroid Build Coastguard Worker FUN(can_generate_vm_object_alloc_events) \
1099*795d594fSAndroid Build Coastguard Worker FUN(can_generate_native_method_bind_events) \
1100*795d594fSAndroid Build Coastguard Worker FUN(can_generate_garbage_collection_events) \
1101*795d594fSAndroid Build Coastguard Worker FUN(can_generate_object_free_events) \
1102*795d594fSAndroid Build Coastguard Worker FUN(can_force_early_return) \
1103*795d594fSAndroid Build Coastguard Worker FUN(can_get_owned_monitor_stack_depth_info) \
1104*795d594fSAndroid Build Coastguard Worker FUN(can_get_constant_pool) \
1105*795d594fSAndroid Build Coastguard Worker FUN(can_set_native_method_prefix) \
1106*795d594fSAndroid Build Coastguard Worker FUN(can_retransform_classes) \
1107*795d594fSAndroid Build Coastguard Worker FUN(can_retransform_any_class) \
1108*795d594fSAndroid Build Coastguard Worker FUN(can_generate_resource_exhaustion_heap_events) \
1109*795d594fSAndroid Build Coastguard Worker FUN(can_generate_resource_exhaustion_threads_events)
1110*795d594fSAndroid Build Coastguard Worker
GetPotentialCapabilities(jvmtiEnv * env,jvmtiCapabilities * capabilities_ptr)1111*795d594fSAndroid Build Coastguard Worker static jvmtiError GetPotentialCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
1112*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1113*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(capabilities_ptr);
1114*795d594fSAndroid Build Coastguard Worker *capabilities_ptr = kPotentialCapabilities;
1115*795d594fSAndroid Build Coastguard Worker if (UNLIKELY(!IsFullJvmtiAvailable())) {
1116*795d594fSAndroid Build Coastguard Worker #define REMOVE_NONDEBUGGABLE_UNSUPPORTED(e) \
1117*795d594fSAndroid Build Coastguard Worker do { \
1118*795d594fSAndroid Build Coastguard Worker if (kNonDebuggableUnsupportedCapabilities.e == 1) { \
1119*795d594fSAndroid Build Coastguard Worker capabilities_ptr->e = 0; \
1120*795d594fSAndroid Build Coastguard Worker } \
1121*795d594fSAndroid Build Coastguard Worker } while (false);
1122*795d594fSAndroid Build Coastguard Worker
1123*795d594fSAndroid Build Coastguard Worker FOR_ALL_CAPABILITIES(REMOVE_NONDEBUGGABLE_UNSUPPORTED);
1124*795d594fSAndroid Build Coastguard Worker #undef REMOVE_NONDEBUGGABLE_UNSUPPORTED
1125*795d594fSAndroid Build Coastguard Worker }
1126*795d594fSAndroid Build Coastguard Worker return OK;
1127*795d594fSAndroid Build Coastguard Worker }
1128*795d594fSAndroid Build Coastguard Worker
AddCapabilities(jvmtiEnv * env,const jvmtiCapabilities * capabilities_ptr)1129*795d594fSAndroid Build Coastguard Worker static jvmtiError AddCapabilities(jvmtiEnv* env, const jvmtiCapabilities* capabilities_ptr) {
1130*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1131*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(capabilities_ptr);
1132*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* art_env = static_cast<ArtJvmTiEnv*>(env);
1133*795d594fSAndroid Build Coastguard Worker jvmtiError ret = OK;
1134*795d594fSAndroid Build Coastguard Worker jvmtiCapabilities changed = {};
1135*795d594fSAndroid Build Coastguard Worker jvmtiCapabilities potential_capabilities = {};
1136*795d594fSAndroid Build Coastguard Worker ret = env->GetPotentialCapabilities(&potential_capabilities);
1137*795d594fSAndroid Build Coastguard Worker if (ret != OK) {
1138*795d594fSAndroid Build Coastguard Worker return ret;
1139*795d594fSAndroid Build Coastguard Worker }
1140*795d594fSAndroid Build Coastguard Worker #define ADD_CAPABILITY(e) \
1141*795d594fSAndroid Build Coastguard Worker do { \
1142*795d594fSAndroid Build Coastguard Worker if (capabilities_ptr->e == 1) { \
1143*795d594fSAndroid Build Coastguard Worker if (potential_capabilities.e == 1) { \
1144*795d594fSAndroid Build Coastguard Worker if (art_env->capabilities.e != 1) { \
1145*795d594fSAndroid Build Coastguard Worker art_env->capabilities.e = 1; \
1146*795d594fSAndroid Build Coastguard Worker changed.e = 1; \
1147*795d594fSAndroid Build Coastguard Worker }\
1148*795d594fSAndroid Build Coastguard Worker } else { \
1149*795d594fSAndroid Build Coastguard Worker ret = ERR(NOT_AVAILABLE); \
1150*795d594fSAndroid Build Coastguard Worker } \
1151*795d594fSAndroid Build Coastguard Worker } \
1152*795d594fSAndroid Build Coastguard Worker } while (false);
1153*795d594fSAndroid Build Coastguard Worker
1154*795d594fSAndroid Build Coastguard Worker FOR_ALL_CAPABILITIES(ADD_CAPABILITY);
1155*795d594fSAndroid Build Coastguard Worker #undef ADD_CAPABILITY
1156*795d594fSAndroid Build Coastguard Worker gEventHandler->HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1157*795d594fSAndroid Build Coastguard Worker changed,
1158*795d594fSAndroid Build Coastguard Worker /*added=*/true);
1159*795d594fSAndroid Build Coastguard Worker return ret;
1160*795d594fSAndroid Build Coastguard Worker }
1161*795d594fSAndroid Build Coastguard Worker
RelinquishCapabilities(jvmtiEnv * env,const jvmtiCapabilities * capabilities_ptr)1162*795d594fSAndroid Build Coastguard Worker static jvmtiError RelinquishCapabilities(jvmtiEnv* env,
1163*795d594fSAndroid Build Coastguard Worker const jvmtiCapabilities* capabilities_ptr) {
1164*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1165*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(capabilities_ptr);
1166*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* art_env = reinterpret_cast<ArtJvmTiEnv*>(env);
1167*795d594fSAndroid Build Coastguard Worker jvmtiCapabilities changed = {};
1168*795d594fSAndroid Build Coastguard Worker #define DEL_CAPABILITY(e) \
1169*795d594fSAndroid Build Coastguard Worker do { \
1170*795d594fSAndroid Build Coastguard Worker if (capabilities_ptr->e == 1) { \
1171*795d594fSAndroid Build Coastguard Worker if (art_env->capabilities.e == 1) { \
1172*795d594fSAndroid Build Coastguard Worker art_env->capabilities.e = 0;\
1173*795d594fSAndroid Build Coastguard Worker changed.e = 1; \
1174*795d594fSAndroid Build Coastguard Worker } \
1175*795d594fSAndroid Build Coastguard Worker } \
1176*795d594fSAndroid Build Coastguard Worker } while (false);
1177*795d594fSAndroid Build Coastguard Worker
1178*795d594fSAndroid Build Coastguard Worker FOR_ALL_CAPABILITIES(DEL_CAPABILITY);
1179*795d594fSAndroid Build Coastguard Worker #undef DEL_CAPABILITY
1180*795d594fSAndroid Build Coastguard Worker gEventHandler->HandleChangedCapabilities(ArtJvmTiEnv::AsArtJvmTiEnv(env),
1181*795d594fSAndroid Build Coastguard Worker changed,
1182*795d594fSAndroid Build Coastguard Worker /*added=*/false);
1183*795d594fSAndroid Build Coastguard Worker return OK;
1184*795d594fSAndroid Build Coastguard Worker }
1185*795d594fSAndroid Build Coastguard Worker
1186*795d594fSAndroid Build Coastguard Worker #undef FOR_ALL_CAPABILITIES
1187*795d594fSAndroid Build Coastguard Worker
GetCapabilities(jvmtiEnv * env,jvmtiCapabilities * capabilities_ptr)1188*795d594fSAndroid Build Coastguard Worker static jvmtiError GetCapabilities(jvmtiEnv* env, jvmtiCapabilities* capabilities_ptr) {
1189*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1190*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(capabilities_ptr);
1191*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* artenv = reinterpret_cast<ArtJvmTiEnv*>(env);
1192*795d594fSAndroid Build Coastguard Worker *capabilities_ptr = artenv->capabilities;
1193*795d594fSAndroid Build Coastguard Worker return OK;
1194*795d594fSAndroid Build Coastguard Worker }
1195*795d594fSAndroid Build Coastguard Worker
GetCurrentThreadCpuTimerInfo(jvmtiEnv * env,jvmtiTimerInfo * info_ptr)1196*795d594fSAndroid Build Coastguard Worker static jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiEnv* env,
1197*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiTimerInfo* info_ptr) {
1198*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1199*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
1200*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
1201*795d594fSAndroid Build Coastguard Worker }
1202*795d594fSAndroid Build Coastguard Worker
GetCurrentThreadCpuTime(jvmtiEnv * env,jlong * nanos_ptr)1203*795d594fSAndroid Build Coastguard Worker static jvmtiError GetCurrentThreadCpuTime(jvmtiEnv* env, [[maybe_unused]] jlong* nanos_ptr) {
1204*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1205*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_current_thread_cpu_time);
1206*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
1207*795d594fSAndroid Build Coastguard Worker }
1208*795d594fSAndroid Build Coastguard Worker
GetThreadCpuTimerInfo(jvmtiEnv * env,jvmtiTimerInfo * info_ptr)1209*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadCpuTimerInfo(jvmtiEnv* env,
1210*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jvmtiTimerInfo* info_ptr) {
1211*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1212*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
1213*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
1214*795d594fSAndroid Build Coastguard Worker }
1215*795d594fSAndroid Build Coastguard Worker
GetThreadCpuTime(jvmtiEnv * env,jthread thread,jlong * nanos_ptr)1216*795d594fSAndroid Build Coastguard Worker static jvmtiError GetThreadCpuTime(jvmtiEnv* env,
1217*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jthread thread,
1218*795d594fSAndroid Build Coastguard Worker [[maybe_unused]] jlong* nanos_ptr) {
1219*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1220*795d594fSAndroid Build Coastguard Worker ENSURE_HAS_CAP(env, can_get_thread_cpu_time);
1221*795d594fSAndroid Build Coastguard Worker return ERR(NOT_IMPLEMENTED);
1222*795d594fSAndroid Build Coastguard Worker }
1223*795d594fSAndroid Build Coastguard Worker
GetTimerInfo(jvmtiEnv * env,jvmtiTimerInfo * info_ptr)1224*795d594fSAndroid Build Coastguard Worker static jvmtiError GetTimerInfo(jvmtiEnv* env, jvmtiTimerInfo* info_ptr) {
1225*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1226*795d594fSAndroid Build Coastguard Worker return TimerUtil::GetTimerInfo(env, info_ptr);
1227*795d594fSAndroid Build Coastguard Worker }
1228*795d594fSAndroid Build Coastguard Worker
GetTime(jvmtiEnv * env,jlong * nanos_ptr)1229*795d594fSAndroid Build Coastguard Worker static jvmtiError GetTime(jvmtiEnv* env, jlong* nanos_ptr) {
1230*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1231*795d594fSAndroid Build Coastguard Worker return TimerUtil::GetTime(env, nanos_ptr);
1232*795d594fSAndroid Build Coastguard Worker }
1233*795d594fSAndroid Build Coastguard Worker
GetAvailableProcessors(jvmtiEnv * env,jint * processor_count_ptr)1234*795d594fSAndroid Build Coastguard Worker static jvmtiError GetAvailableProcessors(jvmtiEnv* env, jint* processor_count_ptr) {
1235*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1236*795d594fSAndroid Build Coastguard Worker return TimerUtil::GetAvailableProcessors(env, processor_count_ptr);
1237*795d594fSAndroid Build Coastguard Worker }
1238*795d594fSAndroid Build Coastguard Worker
AddToBootstrapClassLoaderSearch(jvmtiEnv * env,const char * segment)1239*795d594fSAndroid Build Coastguard Worker static jvmtiError AddToBootstrapClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1240*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1241*795d594fSAndroid Build Coastguard Worker return SearchUtil::AddToBootstrapClassLoaderSearch(env, segment);
1242*795d594fSAndroid Build Coastguard Worker }
1243*795d594fSAndroid Build Coastguard Worker
AddToSystemClassLoaderSearch(jvmtiEnv * env,const char * segment)1244*795d594fSAndroid Build Coastguard Worker static jvmtiError AddToSystemClassLoaderSearch(jvmtiEnv* env, const char* segment) {
1245*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1246*795d594fSAndroid Build Coastguard Worker return SearchUtil::AddToSystemClassLoaderSearch(env, segment);
1247*795d594fSAndroid Build Coastguard Worker }
1248*795d594fSAndroid Build Coastguard Worker
GetSystemProperties(jvmtiEnv * env,jint * count_ptr,char *** property_ptr)1249*795d594fSAndroid Build Coastguard Worker static jvmtiError GetSystemProperties(jvmtiEnv* env, jint* count_ptr, char*** property_ptr) {
1250*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1251*795d594fSAndroid Build Coastguard Worker return PropertiesUtil::GetSystemProperties(env, count_ptr, property_ptr);
1252*795d594fSAndroid Build Coastguard Worker }
1253*795d594fSAndroid Build Coastguard Worker
GetSystemProperty(jvmtiEnv * env,const char * property,char ** value_ptr)1254*795d594fSAndroid Build Coastguard Worker static jvmtiError GetSystemProperty(jvmtiEnv* env, const char* property, char** value_ptr) {
1255*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1256*795d594fSAndroid Build Coastguard Worker return PropertiesUtil::GetSystemProperty(env, property, value_ptr);
1257*795d594fSAndroid Build Coastguard Worker }
1258*795d594fSAndroid Build Coastguard Worker
SetSystemProperty(jvmtiEnv * env,const char * property,const char * value)1259*795d594fSAndroid Build Coastguard Worker static jvmtiError SetSystemProperty(jvmtiEnv* env, const char* property, const char* value) {
1260*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1261*795d594fSAndroid Build Coastguard Worker return PropertiesUtil::SetSystemProperty(env, property, value);
1262*795d594fSAndroid Build Coastguard Worker }
1263*795d594fSAndroid Build Coastguard Worker
GetPhase(jvmtiEnv * env,jvmtiPhase * phase_ptr)1264*795d594fSAndroid Build Coastguard Worker static jvmtiError GetPhase(jvmtiEnv* env, jvmtiPhase* phase_ptr) {
1265*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1266*795d594fSAndroid Build Coastguard Worker return PhaseUtil::GetPhase(env, phase_ptr);
1267*795d594fSAndroid Build Coastguard Worker }
1268*795d594fSAndroid Build Coastguard Worker
DisposeEnvironment(jvmtiEnv * env)1269*795d594fSAndroid Build Coastguard Worker static jvmtiError DisposeEnvironment(jvmtiEnv* env) {
1270*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1271*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv* tienv = ArtJvmTiEnv::AsArtJvmTiEnv(env);
1272*795d594fSAndroid Build Coastguard Worker gEventHandler->RemoveArtJvmTiEnv(tienv);
1273*795d594fSAndroid Build Coastguard Worker art::Runtime::Current()->RemoveSystemWeakHolder(tienv->object_tag_table.get());
1274*795d594fSAndroid Build Coastguard Worker ThreadUtil::RemoveEnvironment(tienv);
1275*795d594fSAndroid Build Coastguard Worker delete tienv;
1276*795d594fSAndroid Build Coastguard Worker return OK;
1277*795d594fSAndroid Build Coastguard Worker }
1278*795d594fSAndroid Build Coastguard Worker
SetEnvironmentLocalStorage(jvmtiEnv * env,const void * data)1279*795d594fSAndroid Build Coastguard Worker static jvmtiError SetEnvironmentLocalStorage(jvmtiEnv* env, const void* data) {
1280*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1281*795d594fSAndroid Build Coastguard Worker reinterpret_cast<ArtJvmTiEnv*>(env)->local_data = const_cast<void*>(data);
1282*795d594fSAndroid Build Coastguard Worker return OK;
1283*795d594fSAndroid Build Coastguard Worker }
1284*795d594fSAndroid Build Coastguard Worker
GetEnvironmentLocalStorage(jvmtiEnv * env,void ** data_ptr)1285*795d594fSAndroid Build Coastguard Worker static jvmtiError GetEnvironmentLocalStorage(jvmtiEnv* env, void** data_ptr) {
1286*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1287*795d594fSAndroid Build Coastguard Worker *data_ptr = reinterpret_cast<ArtJvmTiEnv*>(env)->local_data;
1288*795d594fSAndroid Build Coastguard Worker return OK;
1289*795d594fSAndroid Build Coastguard Worker }
1290*795d594fSAndroid Build Coastguard Worker
GetVersionNumber(jvmtiEnv * env,jint * version_ptr)1291*795d594fSAndroid Build Coastguard Worker static jvmtiError GetVersionNumber(jvmtiEnv* env, jint* version_ptr) {
1292*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1293*795d594fSAndroid Build Coastguard Worker *version_ptr = ArtJvmTiEnv::AsArtJvmTiEnv(env)->ti_version;
1294*795d594fSAndroid Build Coastguard Worker return OK;
1295*795d594fSAndroid Build Coastguard Worker }
1296*795d594fSAndroid Build Coastguard Worker
GetErrorName(jvmtiEnv * env,jvmtiError error,char ** name_ptr)1297*795d594fSAndroid Build Coastguard Worker static jvmtiError GetErrorName(jvmtiEnv* env, jvmtiError error, char** name_ptr) {
1298*795d594fSAndroid Build Coastguard Worker ENSURE_NON_NULL(name_ptr);
1299*795d594fSAndroid Build Coastguard Worker auto copy_fn = [&](const char* name_cstr) {
1300*795d594fSAndroid Build Coastguard Worker jvmtiError res;
1301*795d594fSAndroid Build Coastguard Worker JvmtiUniquePtr<char[]> copy = CopyString(env, name_cstr, &res);
1302*795d594fSAndroid Build Coastguard Worker if (copy == nullptr) {
1303*795d594fSAndroid Build Coastguard Worker *name_ptr = nullptr;
1304*795d594fSAndroid Build Coastguard Worker return res;
1305*795d594fSAndroid Build Coastguard Worker } else {
1306*795d594fSAndroid Build Coastguard Worker *name_ptr = copy.release();
1307*795d594fSAndroid Build Coastguard Worker return OK;
1308*795d594fSAndroid Build Coastguard Worker }
1309*795d594fSAndroid Build Coastguard Worker };
1310*795d594fSAndroid Build Coastguard Worker switch (error) {
1311*795d594fSAndroid Build Coastguard Worker #define ERROR_CASE(e) case (JVMTI_ERROR_ ## e) : \
1312*795d594fSAndroid Build Coastguard Worker return copy_fn("JVMTI_ERROR_"#e);
1313*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NONE);
1314*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_THREAD);
1315*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_THREAD_GROUP);
1316*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_PRIORITY);
1317*795d594fSAndroid Build Coastguard Worker ERROR_CASE(THREAD_NOT_SUSPENDED);
1318*795d594fSAndroid Build Coastguard Worker ERROR_CASE(THREAD_SUSPENDED);
1319*795d594fSAndroid Build Coastguard Worker ERROR_CASE(THREAD_NOT_ALIVE);
1320*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_OBJECT);
1321*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_CLASS);
1322*795d594fSAndroid Build Coastguard Worker ERROR_CASE(CLASS_NOT_PREPARED);
1323*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_METHODID);
1324*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_LOCATION);
1325*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_FIELDID);
1326*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NO_MORE_FRAMES);
1327*795d594fSAndroid Build Coastguard Worker ERROR_CASE(OPAQUE_FRAME);
1328*795d594fSAndroid Build Coastguard Worker ERROR_CASE(TYPE_MISMATCH);
1329*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_SLOT);
1330*795d594fSAndroid Build Coastguard Worker ERROR_CASE(DUPLICATE);
1331*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NOT_FOUND);
1332*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_MONITOR);
1333*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NOT_MONITOR_OWNER);
1334*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INTERRUPT);
1335*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_CLASS_FORMAT);
1336*795d594fSAndroid Build Coastguard Worker ERROR_CASE(CIRCULAR_CLASS_DEFINITION);
1337*795d594fSAndroid Build Coastguard Worker ERROR_CASE(FAILS_VERIFICATION);
1338*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_ADDED);
1339*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED);
1340*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_TYPESTATE);
1341*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED);
1342*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_DELETED);
1343*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_VERSION);
1344*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NAMES_DONT_MATCH);
1345*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED);
1346*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED);
1347*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNMODIFIABLE_CLASS);
1348*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NOT_AVAILABLE);
1349*795d594fSAndroid Build Coastguard Worker ERROR_CASE(MUST_POSSESS_CAPABILITY);
1350*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NULL_POINTER);
1351*795d594fSAndroid Build Coastguard Worker ERROR_CASE(ABSENT_INFORMATION);
1352*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_EVENT_TYPE);
1353*795d594fSAndroid Build Coastguard Worker ERROR_CASE(ILLEGAL_ARGUMENT);
1354*795d594fSAndroid Build Coastguard Worker ERROR_CASE(NATIVE_METHOD);
1355*795d594fSAndroid Build Coastguard Worker ERROR_CASE(CLASS_LOADER_UNSUPPORTED);
1356*795d594fSAndroid Build Coastguard Worker ERROR_CASE(OUT_OF_MEMORY);
1357*795d594fSAndroid Build Coastguard Worker ERROR_CASE(ACCESS_DENIED);
1358*795d594fSAndroid Build Coastguard Worker ERROR_CASE(WRONG_PHASE);
1359*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INTERNAL);
1360*795d594fSAndroid Build Coastguard Worker ERROR_CASE(UNATTACHED_THREAD);
1361*795d594fSAndroid Build Coastguard Worker ERROR_CASE(INVALID_ENVIRONMENT);
1362*795d594fSAndroid Build Coastguard Worker #undef ERROR_CASE
1363*795d594fSAndroid Build Coastguard Worker }
1364*795d594fSAndroid Build Coastguard Worker
1365*795d594fSAndroid Build Coastguard Worker return ERR(ILLEGAL_ARGUMENT);
1366*795d594fSAndroid Build Coastguard Worker }
1367*795d594fSAndroid Build Coastguard Worker
SetVerboseFlag(jvmtiEnv * env,jvmtiVerboseFlag flag,jboolean value)1368*795d594fSAndroid Build Coastguard Worker static jvmtiError SetVerboseFlag(jvmtiEnv* env,
1369*795d594fSAndroid Build Coastguard Worker jvmtiVerboseFlag flag,
1370*795d594fSAndroid Build Coastguard Worker jboolean value) {
1371*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1372*795d594fSAndroid Build Coastguard Worker return LogUtil::SetVerboseFlag(env, flag, value);
1373*795d594fSAndroid Build Coastguard Worker }
1374*795d594fSAndroid Build Coastguard Worker
GetJLocationFormat(jvmtiEnv * env,jvmtiJlocationFormat * format_ptr)1375*795d594fSAndroid Build Coastguard Worker static jvmtiError GetJLocationFormat(jvmtiEnv* env, jvmtiJlocationFormat* format_ptr) {
1376*795d594fSAndroid Build Coastguard Worker ENSURE_VALID_ENV(env);
1377*795d594fSAndroid Build Coastguard Worker // Report BCI as jlocation format. We report dex bytecode indices.
1378*795d594fSAndroid Build Coastguard Worker if (format_ptr == nullptr) {
1379*795d594fSAndroid Build Coastguard Worker return ERR(NULL_POINTER);
1380*795d594fSAndroid Build Coastguard Worker }
1381*795d594fSAndroid Build Coastguard Worker *format_ptr = jvmtiJlocationFormat::JVMTI_JLOCATION_JVMBCI;
1382*795d594fSAndroid Build Coastguard Worker return ERR(NONE);
1383*795d594fSAndroid Build Coastguard Worker }
1384*795d594fSAndroid Build Coastguard Worker };
1385*795d594fSAndroid Build Coastguard Worker
IsJvmtiVersion(jint version)1386*795d594fSAndroid Build Coastguard Worker static bool IsJvmtiVersion(jint version) {
1387*795d594fSAndroid Build Coastguard Worker return version == JVMTI_VERSION_1 ||
1388*795d594fSAndroid Build Coastguard Worker version == JVMTI_VERSION_1_0 ||
1389*795d594fSAndroid Build Coastguard Worker version == JVMTI_VERSION_1_1 ||
1390*795d594fSAndroid Build Coastguard Worker version == JVMTI_VERSION_1_2 ||
1391*795d594fSAndroid Build Coastguard Worker version == JVMTI_VERSION;
1392*795d594fSAndroid Build Coastguard Worker }
1393*795d594fSAndroid Build Coastguard Worker
1394*795d594fSAndroid Build Coastguard Worker extern const jvmtiInterface_1 gJvmtiInterface;
1395*795d594fSAndroid Build Coastguard Worker
ArtJvmTiEnv(art::JavaVMExt * runtime,EventHandler * event_handler,jint version)1396*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv::ArtJvmTiEnv(art::JavaVMExt* runtime, EventHandler* event_handler, jint version)
1397*795d594fSAndroid Build Coastguard Worker : art_vm(runtime),
1398*795d594fSAndroid Build Coastguard Worker local_data(nullptr),
1399*795d594fSAndroid Build Coastguard Worker ti_version(version),
1400*795d594fSAndroid Build Coastguard Worker capabilities(),
1401*795d594fSAndroid Build Coastguard Worker event_info_mutex_("jvmtiEnv_EventInfoMutex"),
1402*795d594fSAndroid Build Coastguard Worker last_error_mutex_("jvmtiEnv_LastErrorMutex", art::LockLevel::kGenericBottomLock) {
1403*795d594fSAndroid Build Coastguard Worker object_tag_table = std::make_unique<ObjectTagTable>(event_handler, this);
1404*795d594fSAndroid Build Coastguard Worker functions = &gJvmtiInterface;
1405*795d594fSAndroid Build Coastguard Worker }
1406*795d594fSAndroid Build Coastguard Worker
1407*795d594fSAndroid Build Coastguard Worker // Creates a jvmtiEnv and returns it with the art::ti::Env that is associated with it. new_art_ti
1408*795d594fSAndroid Build Coastguard Worker // is a pointer to the uninitialized memory for an art::ti::Env.
CreateArtJvmTiEnv(art::JavaVMExt * vm,jint version,void ** new_jvmtiEnv)1409*795d594fSAndroid Build Coastguard Worker static void CreateArtJvmTiEnv(art::JavaVMExt* vm, jint version, /*out*/void** new_jvmtiEnv) {
1410*795d594fSAndroid Build Coastguard Worker struct ArtJvmTiEnv* env = new ArtJvmTiEnv(vm, gEventHandler, version);
1411*795d594fSAndroid Build Coastguard Worker *new_jvmtiEnv = env;
1412*795d594fSAndroid Build Coastguard Worker
1413*795d594fSAndroid Build Coastguard Worker gEventHandler->RegisterArtJvmTiEnv(env);
1414*795d594fSAndroid Build Coastguard Worker
1415*795d594fSAndroid Build Coastguard Worker art::Runtime::Current()->AddSystemWeakHolder(
1416*795d594fSAndroid Build Coastguard Worker ArtJvmTiEnv::AsArtJvmTiEnv(env)->object_tag_table.get());
1417*795d594fSAndroid Build Coastguard Worker }
1418*795d594fSAndroid Build Coastguard Worker
1419*795d594fSAndroid Build Coastguard Worker // A hook that the runtime uses to allow plugins to handle GetEnv calls. It returns true and
1420*795d594fSAndroid Build Coastguard Worker // places the return value in 'env' if this library can handle the GetEnv request. Otherwise
1421*795d594fSAndroid Build Coastguard Worker // returns false and does not modify the 'env' pointer.
GetEnvHandler(art::JavaVMExt * vm,void ** env,jint version)1422*795d594fSAndroid Build Coastguard Worker static jint GetEnvHandler(art::JavaVMExt* vm, /*out*/void** env, jint version) {
1423*795d594fSAndroid Build Coastguard Worker // JavaDebuggable will either be set by the runtime as it is starting up or the plugin if it's
1424*795d594fSAndroid Build Coastguard Worker // loaded early enough. If this is false we cannot guarantee conformance to all JVMTI behaviors
1425*795d594fSAndroid Build Coastguard Worker // due to optimizations. We will only allow agents to get ArtTiEnvs using the kArtTiVersion.
1426*795d594fSAndroid Build Coastguard Worker if (IsFullJvmtiAvailable() && IsJvmtiVersion(version)) {
1427*795d594fSAndroid Build Coastguard Worker CreateArtJvmTiEnv(vm, JVMTI_VERSION, env);
1428*795d594fSAndroid Build Coastguard Worker return JNI_OK;
1429*795d594fSAndroid Build Coastguard Worker } else if (version == kArtTiVersion) {
1430*795d594fSAndroid Build Coastguard Worker CreateArtJvmTiEnv(vm, kArtTiVersion, env);
1431*795d594fSAndroid Build Coastguard Worker return JNI_OK;
1432*795d594fSAndroid Build Coastguard Worker } else {
1433*795d594fSAndroid Build Coastguard Worker printf("version 0x%x is not valid!", version);
1434*795d594fSAndroid Build Coastguard Worker if (IsJvmtiVersion(version)) {
1435*795d594fSAndroid Build Coastguard Worker LOG(ERROR) << "JVMTI Version 0x" << std::hex << version << " requested but the runtime is not"
1436*795d594fSAndroid Build Coastguard Worker << " debuggable! Only limited, best effort kArtTiVersion"
1437*795d594fSAndroid Build Coastguard Worker << " (0x" << std::hex << kArtTiVersion << ") environments are available. If"
1438*795d594fSAndroid Build Coastguard Worker << " possible, rebuild your apk in debuggable mode or start the runtime with"
1439*795d594fSAndroid Build Coastguard Worker << " the `-Xcompiler-option --debuggable` flags.";
1440*795d594fSAndroid Build Coastguard Worker }
1441*795d594fSAndroid Build Coastguard Worker return JNI_EVERSION;
1442*795d594fSAndroid Build Coastguard Worker }
1443*795d594fSAndroid Build Coastguard Worker }
1444*795d594fSAndroid Build Coastguard Worker
1445*795d594fSAndroid Build Coastguard Worker // The plugin initialization function. This adds the jvmti environment.
ArtPlugin_Initialize()1446*795d594fSAndroid Build Coastguard Worker extern "C" bool ArtPlugin_Initialize() {
1447*795d594fSAndroid Build Coastguard Worker art::Runtime* runtime = art::Runtime::Current();
1448*795d594fSAndroid Build Coastguard Worker
1449*795d594fSAndroid Build Coastguard Worker gAllocManager = new AllocationManager;
1450*795d594fSAndroid Build Coastguard Worker gDeoptManager = new DeoptManager;
1451*795d594fSAndroid Build Coastguard Worker gEventHandler = new EventHandler;
1452*795d594fSAndroid Build Coastguard Worker
1453*795d594fSAndroid Build Coastguard Worker gDeoptManager->Setup();
1454*795d594fSAndroid Build Coastguard Worker if (runtime->IsStarted()) {
1455*795d594fSAndroid Build Coastguard Worker PhaseUtil::SetToLive();
1456*795d594fSAndroid Build Coastguard Worker } else {
1457*795d594fSAndroid Build Coastguard Worker PhaseUtil::SetToOnLoad();
1458*795d594fSAndroid Build Coastguard Worker }
1459*795d594fSAndroid Build Coastguard Worker PhaseUtil::Register(gEventHandler);
1460*795d594fSAndroid Build Coastguard Worker ThreadUtil::Register(gEventHandler);
1461*795d594fSAndroid Build Coastguard Worker ClassUtil::Register(gEventHandler);
1462*795d594fSAndroid Build Coastguard Worker DumpUtil::Register(gEventHandler);
1463*795d594fSAndroid Build Coastguard Worker MethodUtil::Register(gEventHandler);
1464*795d594fSAndroid Build Coastguard Worker HeapExtensions::Register(gEventHandler);
1465*795d594fSAndroid Build Coastguard Worker SearchUtil::Register();
1466*795d594fSAndroid Build Coastguard Worker HeapUtil::Register();
1467*795d594fSAndroid Build Coastguard Worker FieldUtil::Register(gEventHandler);
1468*795d594fSAndroid Build Coastguard Worker BreakpointUtil::Register(gEventHandler);
1469*795d594fSAndroid Build Coastguard Worker Transformer::Register(gEventHandler);
1470*795d594fSAndroid Build Coastguard Worker gDeoptManager->FinishSetup();
1471*795d594fSAndroid Build Coastguard Worker runtime->GetJavaVM()->AddEnvironmentHook(GetEnvHandler);
1472*795d594fSAndroid Build Coastguard Worker
1473*795d594fSAndroid Build Coastguard Worker return true;
1474*795d594fSAndroid Build Coastguard Worker }
1475*795d594fSAndroid Build Coastguard Worker
ArtPlugin_Deinitialize()1476*795d594fSAndroid Build Coastguard Worker extern "C" bool ArtPlugin_Deinitialize() {
1477*795d594fSAndroid Build Coastguard Worker // When runtime is shutting down, it is not necessary to unregister callbacks or update
1478*795d594fSAndroid Build Coastguard Worker // instrumentation levels. Removing callbacks require a GC critical section in some cases and
1479*795d594fSAndroid Build Coastguard Worker // when runtime is shutting down we already stop GC and hence it is not safe to request to
1480*795d594fSAndroid Build Coastguard Worker // enter a GC critical section.
1481*795d594fSAndroid Build Coastguard Worker if (art::Runtime::Current()->IsShuttingDown(art::Thread::Current())) {
1482*795d594fSAndroid Build Coastguard Worker return true;
1483*795d594fSAndroid Build Coastguard Worker }
1484*795d594fSAndroid Build Coastguard Worker
1485*795d594fSAndroid Build Coastguard Worker gEventHandler->Shutdown();
1486*795d594fSAndroid Build Coastguard Worker gDeoptManager->Shutdown();
1487*795d594fSAndroid Build Coastguard Worker PhaseUtil::Unregister();
1488*795d594fSAndroid Build Coastguard Worker ThreadUtil::Unregister();
1489*795d594fSAndroid Build Coastguard Worker ClassUtil::Unregister();
1490*795d594fSAndroid Build Coastguard Worker DumpUtil::Unregister();
1491*795d594fSAndroid Build Coastguard Worker MethodUtil::Unregister();
1492*795d594fSAndroid Build Coastguard Worker SearchUtil::Unregister();
1493*795d594fSAndroid Build Coastguard Worker HeapUtil::Unregister();
1494*795d594fSAndroid Build Coastguard Worker FieldUtil::Unregister();
1495*795d594fSAndroid Build Coastguard Worker BreakpointUtil::Unregister();
1496*795d594fSAndroid Build Coastguard Worker
1497*795d594fSAndroid Build Coastguard Worker // TODO It would be good to delete the gEventHandler and gDeoptManager here but we cannot since
1498*795d594fSAndroid Build Coastguard Worker // daemon threads might be suspended and we want to make sure that even if they wake up briefly
1499*795d594fSAndroid Build Coastguard Worker // they won't hit deallocated memory. By this point none of the functions will do anything since
1500*795d594fSAndroid Build Coastguard Worker // they have already shutdown.
1501*795d594fSAndroid Build Coastguard Worker
1502*795d594fSAndroid Build Coastguard Worker return true;
1503*795d594fSAndroid Build Coastguard Worker }
1504*795d594fSAndroid Build Coastguard Worker
1505*795d594fSAndroid Build Coastguard Worker // The actual struct holding all of the entrypoints into the jvmti interface.
1506*795d594fSAndroid Build Coastguard Worker const jvmtiInterface_1 gJvmtiInterface = {
1507*795d594fSAndroid Build Coastguard Worker nullptr, // reserved1
1508*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetEventNotificationMode,
1509*795d594fSAndroid Build Coastguard Worker nullptr, // reserved3
1510*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetAllThreads,
1511*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SuspendThread,
1512*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ResumeThread,
1513*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::StopThread,
1514*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::InterruptThread,
1515*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadInfo,
1516*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetOwnedMonitorInfo, // 10
1517*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetCurrentContendedMonitor,
1518*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RunAgentThread,
1519*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetTopThreadGroups,
1520*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadGroupInfo,
1521*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadGroupChildren,
1522*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetFrameCount,
1523*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadState,
1524*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetCurrentThread,
1525*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetFrameLocation,
1526*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::NotifyFramePop, // 20
1527*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalObject,
1528*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalInt,
1529*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalLong,
1530*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalFloat,
1531*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalDouble,
1532*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetLocalObject,
1533*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetLocalInt,
1534*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetLocalLong,
1535*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetLocalFloat,
1536*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetLocalDouble, // 30
1537*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::CreateRawMonitor,
1538*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::DestroyRawMonitor,
1539*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RawMonitorEnter,
1540*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RawMonitorExit,
1541*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RawMonitorWait,
1542*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RawMonitorNotify,
1543*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RawMonitorNotifyAll,
1544*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetBreakpoint,
1545*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ClearBreakpoint,
1546*795d594fSAndroid Build Coastguard Worker nullptr, // reserved40
1547*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetFieldAccessWatch,
1548*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ClearFieldAccessWatch,
1549*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetFieldModificationWatch,
1550*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ClearFieldModificationWatch,
1551*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsModifiableClass,
1552*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::Allocate,
1553*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::Deallocate,
1554*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassSignature,
1555*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassStatus,
1556*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetSourceFileName, // 50
1557*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassModifiers,
1558*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassMethods,
1559*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassFields,
1560*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetImplementedInterfaces,
1561*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsInterface,
1562*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsArrayClass,
1563*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassLoader,
1564*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetObjectHashCode,
1565*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetObjectMonitorUsage,
1566*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetFieldName, // 60
1567*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetFieldDeclaringClass,
1568*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetFieldModifiers,
1569*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsFieldSynthetic,
1570*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetMethodName,
1571*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetMethodDeclaringClass,
1572*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetMethodModifiers,
1573*795d594fSAndroid Build Coastguard Worker nullptr, // reserved67
1574*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetMaxLocals,
1575*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetArgumentsSize,
1576*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLineNumberTable, // 70
1577*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetMethodLocation,
1578*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalVariableTable,
1579*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetNativeMethodPrefix,
1580*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetNativeMethodPrefixes,
1581*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetBytecodes,
1582*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsMethodNative,
1583*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsMethodSynthetic,
1584*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLoadedClasses,
1585*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassLoaderClasses,
1586*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::PopFrame, // 80
1587*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnObject,
1588*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnInt,
1589*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnLong,
1590*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnFloat,
1591*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnDouble,
1592*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceEarlyReturnVoid,
1593*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RedefineClasses,
1594*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetVersionNumber,
1595*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetCapabilities,
1596*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetSourceDebugExtension, // 90
1597*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IsMethodObsolete,
1598*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SuspendThreadList,
1599*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ResumeThreadList,
1600*795d594fSAndroid Build Coastguard Worker nullptr, // reserved94
1601*795d594fSAndroid Build Coastguard Worker nullptr, // reserved95
1602*795d594fSAndroid Build Coastguard Worker nullptr, // reserved96
1603*795d594fSAndroid Build Coastguard Worker nullptr, // reserved97
1604*795d594fSAndroid Build Coastguard Worker nullptr, // reserved98
1605*795d594fSAndroid Build Coastguard Worker nullptr, // reserved99
1606*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetAllStackTraces, // 100
1607*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadListStackTraces,
1608*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadLocalStorage,
1609*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetThreadLocalStorage,
1610*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetStackTrace,
1611*795d594fSAndroid Build Coastguard Worker nullptr, // reserved105
1612*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetTag,
1613*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetTag,
1614*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::ForceGarbageCollection,
1615*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IterateOverObjectsReachableFromObject,
1616*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IterateOverReachableObjects, // 110
1617*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IterateOverHeap,
1618*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IterateOverInstancesOfClass,
1619*795d594fSAndroid Build Coastguard Worker nullptr, // reserved113
1620*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetObjectsWithTags,
1621*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::FollowReferences,
1622*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::IterateThroughHeap,
1623*795d594fSAndroid Build Coastguard Worker nullptr, // reserved117
1624*795d594fSAndroid Build Coastguard Worker nullptr, // reserved118
1625*795d594fSAndroid Build Coastguard Worker nullptr, // reserved119
1626*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetJNIFunctionTable, // 120
1627*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetJNIFunctionTable,
1628*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetEventCallbacks,
1629*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GenerateEvents,
1630*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetExtensionFunctions,
1631*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetExtensionEvents,
1632*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetExtensionEventCallback,
1633*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::DisposeEnvironment,
1634*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetErrorName,
1635*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetJLocationFormat,
1636*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetSystemProperties, // 130
1637*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetSystemProperty,
1638*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetSystemProperty,
1639*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetPhase,
1640*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetCurrentThreadCpuTimerInfo,
1641*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetCurrentThreadCpuTime,
1642*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadCpuTimerInfo,
1643*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetThreadCpuTime,
1644*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetTimerInfo,
1645*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetTime,
1646*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetPotentialCapabilities, // 140
1647*795d594fSAndroid Build Coastguard Worker nullptr, // reserved141
1648*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::AddCapabilities,
1649*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RelinquishCapabilities,
1650*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetAvailableProcessors,
1651*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetClassVersionNumbers,
1652*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetConstantPool,
1653*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetEnvironmentLocalStorage,
1654*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetEnvironmentLocalStorage,
1655*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::AddToBootstrapClassLoaderSearch,
1656*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::SetVerboseFlag, // 150
1657*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::AddToSystemClassLoaderSearch,
1658*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::RetransformClasses,
1659*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetOwnedMonitorStackDepthInfo,
1660*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetObjectSize,
1661*795d594fSAndroid Build Coastguard Worker JvmtiFunctions::GetLocalInstance,
1662*795d594fSAndroid Build Coastguard Worker };
1663*795d594fSAndroid Build Coastguard Worker
1664*795d594fSAndroid Build Coastguard Worker }; // namespace openjdkjvmti
1665