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