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