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