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