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