Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -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 | |
| 32 | #include "ti_method.h" |
| 33 | |
Andreas Gampe | 49fc60e | 2017-08-24 13:19:59 -0700 | [diff] [blame] | 34 | #include <type_traits> |
| 35 | |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 36 | #include "art_jvmti.h" |
| 37 | #include "art_method-inl.h" |
| 38 | #include "base/enums.h" |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 39 | #include "base/mutex-inl.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 40 | #include "dex/code_item_accessors-inl.h" |
| 41 | #include "dex/dex_file_annotations.h" |
| 42 | #include "dex/dex_file_types.h" |
David Sehr | 8c0961f | 2018-01-23 16:11:38 -0800 | [diff] [blame] | 43 | #include "dex/modifiers.h" |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 44 | #include "events-inl.h" |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 45 | #include "gc_root-inl.h" |
Alex Light | 0a5ec3d | 2017-07-25 16:50:26 -0700 | [diff] [blame] | 46 | #include "jit/jit.h" |
Vladimir Marko | a3ad0cd | 2018-05-04 10:06:38 +0100 | [diff] [blame] | 47 | #include "jni/jni_internal.h" |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 48 | #include "mirror/class-inl.h" |
| 49 | #include "mirror/class_loader.h" |
| 50 | #include "mirror/object-inl.h" |
Andreas Gampe | 27dfa05 | 2017-02-16 15:04:36 -0800 | [diff] [blame] | 51 | #include "mirror/object_array-inl.h" |
Andreas Gampe | 373a9b5 | 2017-10-18 09:01:57 -0700 | [diff] [blame] | 52 | #include "nativehelper/scoped_local_ref.h" |
Nicolas Geoffray | 58cc1cb | 2017-11-20 13:27:29 +0000 | [diff] [blame] | 53 | #include "oat_file.h" |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 54 | #include "runtime_callbacks.h" |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 55 | #include "scoped_thread_state_change-inl.h" |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 56 | #include "stack.h" |
Andreas Gampe | b486a98 | 2017-06-01 13:45:54 -0700 | [diff] [blame] | 57 | #include "thread-current-inl.h" |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 58 | #include "thread_list.h" |
Alex Light | e814f9d | 2017-07-31 16:14:39 -0700 | [diff] [blame] | 59 | #include "ti_stack.h" |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 60 | #include "ti_thread.h" |
Alex Light | 0af8cde | 2017-04-20 13:35:05 -0700 | [diff] [blame] | 61 | #include "ti_phase.h" |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 62 | |
| 63 | namespace openjdkjvmti { |
| 64 | |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 65 | struct TiMethodCallback : public art::MethodCallback { |
| 66 | void RegisterNativeMethod(art::ArtMethod* method, |
| 67 | const void* cur_method, |
| 68 | /*out*/void** new_method) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 69 | override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 70 | if (event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kNativeMethodBind)) { |
| 71 | art::Thread* thread = art::Thread::Current(); |
Alex Light | 0af8cde | 2017-04-20 13:35:05 -0700 | [diff] [blame] | 72 | art::JNIEnvExt* jnienv = thread->GetJniEnv(); |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 73 | ScopedLocalRef<jthread> thread_jni( |
Alex Light | 0af8cde | 2017-04-20 13:35:05 -0700 | [diff] [blame] | 74 | jnienv, PhaseUtil::IsLivePhase() ? jnienv->AddLocalReference<jthread>(thread->GetPeer()) |
| 75 | : nullptr); |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 76 | art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative); |
| 77 | event_handler->DispatchEvent<ArtJvmtiEvent::kNativeMethodBind>( |
| 78 | thread, |
Alex Light | 0af8cde | 2017-04-20 13:35:05 -0700 | [diff] [blame] | 79 | static_cast<JNIEnv*>(jnienv), |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 80 | thread_jni.get(), |
| 81 | art::jni::EncodeArtMethod(method), |
| 82 | const_cast<void*>(cur_method), |
| 83 | new_method); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | EventHandler* event_handler = nullptr; |
| 88 | }; |
| 89 | |
| 90 | TiMethodCallback gMethodCallback; |
| 91 | |
| 92 | void MethodUtil::Register(EventHandler* handler) { |
| 93 | gMethodCallback.event_handler = handler; |
| 94 | art::ScopedThreadStateChange stsc(art::Thread::Current(), |
| 95 | art::ThreadState::kWaitingForDebuggerToAttach); |
| 96 | art::ScopedSuspendAll ssa("Add method callback"); |
Alex Light | 2161193 | 2017-09-26 13:07:39 -0700 | [diff] [blame] | 97 | art::RuntimeCallbacks* callbacks = art::Runtime::Current()->GetRuntimeCallbacks(); |
| 98 | callbacks->AddMethodCallback(&gMethodCallback); |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | void MethodUtil::Unregister() { |
| 102 | art::ScopedThreadStateChange stsc(art::Thread::Current(), |
| 103 | art::ThreadState::kWaitingForDebuggerToAttach); |
| 104 | art::ScopedSuspendAll ssa("Remove method callback"); |
Alex Light | 2161193 | 2017-09-26 13:07:39 -0700 | [diff] [blame] | 105 | art::RuntimeCallbacks* callbacks = art::Runtime::Current()->GetRuntimeCallbacks(); |
| 106 | callbacks->RemoveMethodCallback(&gMethodCallback); |
Alex Light | d78ddec | 2017-04-18 15:20:38 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Alex Light | 4c17428 | 2017-07-05 10:18:18 -0700 | [diff] [blame] | 109 | jvmtiError MethodUtil::GetBytecodes(jvmtiEnv* env, |
| 110 | jmethodID method, |
| 111 | jint* size_ptr, |
| 112 | unsigned char** bytecode_ptr) { |
| 113 | if (method == nullptr) { |
| 114 | return ERR(INVALID_METHODID); |
| 115 | } |
| 116 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 117 | |
| 118 | if (art_method->IsNative()) { |
| 119 | return ERR(NATIVE_METHOD); |
| 120 | } |
| 121 | |
| 122 | if (size_ptr == nullptr || bytecode_ptr == nullptr) { |
| 123 | return ERR(NULL_POINTER); |
| 124 | } |
| 125 | |
| 126 | art::ScopedObjectAccess soa(art::Thread::Current()); |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 127 | art::CodeItemInstructionAccessor accessor(art_method->DexInstructions()); |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 128 | if (!accessor.HasCodeItem()) { |
Alex Light | 4c17428 | 2017-07-05 10:18:18 -0700 | [diff] [blame] | 129 | *size_ptr = 0; |
| 130 | *bytecode_ptr = nullptr; |
| 131 | return OK; |
| 132 | } |
| 133 | // 2 bytes per instruction for dex code. |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 134 | *size_ptr = accessor.InsnsSizeInCodeUnits() * 2; |
Alex Light | 4c17428 | 2017-07-05 10:18:18 -0700 | [diff] [blame] | 135 | jvmtiError err = env->Allocate(*size_ptr, bytecode_ptr); |
| 136 | if (err != OK) { |
| 137 | return err; |
| 138 | } |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 139 | memcpy(*bytecode_ptr, accessor.Insns(), *size_ptr); |
Alex Light | 4c17428 | 2017-07-05 10:18:18 -0700 | [diff] [blame] | 140 | return OK; |
| 141 | } |
| 142 | |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 143 | jvmtiError MethodUtil::GetArgumentsSize(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 144 | jmethodID method, |
| 145 | jint* size_ptr) { |
| 146 | if (method == nullptr) { |
| 147 | return ERR(INVALID_METHODID); |
| 148 | } |
| 149 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 150 | |
| 151 | if (art_method->IsNative()) { |
| 152 | return ERR(NATIVE_METHOD); |
| 153 | } |
| 154 | |
| 155 | if (size_ptr == nullptr) { |
| 156 | return ERR(NULL_POINTER); |
| 157 | } |
| 158 | |
| 159 | art::ScopedObjectAccess soa(art::Thread::Current()); |
| 160 | if (art_method->IsProxyMethod() || art_method->IsAbstract()) { |
Andreas Gampe | e1f79b6 | 2017-04-12 21:11:28 -0700 | [diff] [blame] | 161 | // Use the shorty. |
| 162 | art::ArtMethod* base_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize); |
| 163 | size_t arg_count = art::ArtMethod::NumArgRegisters(base_method->GetShorty()); |
| 164 | if (!base_method->IsStatic()) { |
| 165 | arg_count++; |
| 166 | } |
| 167 | *size_ptr = static_cast<jint>(arg_count); |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 168 | return ERR(NONE); |
| 169 | } |
| 170 | |
| 171 | DCHECK_NE(art_method->GetCodeItemOffset(), 0u); |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 172 | *size_ptr = art_method->DexInstructionData().InsSize(); |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 173 | |
| 174 | return ERR(NONE); |
| 175 | } |
| 176 | |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 177 | jvmtiError MethodUtil::GetLocalVariableTable(jvmtiEnv* env, |
| 178 | jmethodID method, |
| 179 | jint* entry_count_ptr, |
| 180 | jvmtiLocalVariableEntry** table_ptr) { |
| 181 | if (method == nullptr) { |
| 182 | return ERR(INVALID_METHODID); |
| 183 | } |
| 184 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 185 | |
| 186 | if (art_method->IsNative()) { |
| 187 | return ERR(NATIVE_METHOD); |
| 188 | } |
| 189 | |
| 190 | if (entry_count_ptr == nullptr || table_ptr == nullptr) { |
| 191 | return ERR(NULL_POINTER); |
| 192 | } |
| 193 | |
| 194 | art::ScopedObjectAccess soa(art::Thread::Current()); |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 195 | |
| 196 | const art::DexFile* const dex_file = art_method->GetDexFile(); |
| 197 | if (dex_file == nullptr) { |
| 198 | return ERR(ABSENT_INFORMATION); |
| 199 | } |
| 200 | |
| 201 | // TODO HasCodeItem == false means that the method is abstract (or native, but we check that |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 202 | // earlier). We should check what is returned by the RI in this situation since it's not clear |
| 203 | // what the appropriate return value is from the spec. |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 204 | art::CodeItemDebugInfoAccessor accessor(art_method->DexInstructionDebugInfo()); |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 205 | if (!accessor.HasCodeItem()) { |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 206 | return ERR(ABSENT_INFORMATION); |
| 207 | } |
| 208 | |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 209 | std::vector<jvmtiLocalVariableEntry> variables; |
| 210 | jvmtiError err = OK; |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 211 | |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 212 | auto release = [&](jint* out_entry_count_ptr, jvmtiLocalVariableEntry** out_table_ptr) { |
| 213 | jlong table_size = sizeof(jvmtiLocalVariableEntry) * variables.size(); |
| 214 | if (err != OK || |
| 215 | (err = env->Allocate(table_size, |
| 216 | reinterpret_cast<unsigned char**>(out_table_ptr))) != OK) { |
| 217 | for (jvmtiLocalVariableEntry& e : variables) { |
| 218 | env->Deallocate(reinterpret_cast<unsigned char*>(e.name)); |
| 219 | env->Deallocate(reinterpret_cast<unsigned char*>(e.signature)); |
| 220 | env->Deallocate(reinterpret_cast<unsigned char*>(e.generic_signature)); |
| 221 | } |
| 222 | return err; |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 223 | } |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 224 | *out_entry_count_ptr = variables.size(); |
| 225 | memcpy(*out_table_ptr, variables.data(), table_size); |
| 226 | return OK; |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 227 | }; |
| 228 | |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 229 | auto visitor = [&](const art::DexFile::LocalInfo& entry) { |
| 230 | if (err != OK) { |
| 231 | return; |
| 232 | } |
| 233 | JvmtiUniquePtr<char[]> name_str = CopyString(env, entry.name_, &err); |
| 234 | if (err != OK) { |
| 235 | return; |
| 236 | } |
| 237 | JvmtiUniquePtr<char[]> sig_str = CopyString(env, entry.descriptor_, &err); |
| 238 | if (err != OK) { |
| 239 | return; |
| 240 | } |
| 241 | JvmtiUniquePtr<char[]> generic_sig_str = CopyString(env, entry.signature_, &err); |
| 242 | if (err != OK) { |
| 243 | return; |
| 244 | } |
| 245 | variables.push_back({ |
| 246 | .start_location = static_cast<jlocation>(entry.start_address_), |
| 247 | .length = static_cast<jint>(entry.end_address_ - entry.start_address_), |
| 248 | .name = name_str.release(), |
| 249 | .signature = sig_str.release(), |
| 250 | .generic_signature = generic_sig_str.release(), |
| 251 | .slot = entry.reg_, |
| 252 | }); |
| 253 | }; |
| 254 | |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 255 | if (!accessor.DecodeDebugLocalInfo(art_method->IsStatic(), |
| 256 | art_method->GetDexMethodIndex(), |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 257 | visitor)) { |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 258 | // Something went wrong with decoding the debug information. It might as well not be there. |
| 259 | return ERR(ABSENT_INFORMATION); |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 260 | } |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 261 | return release(entry_count_ptr, table_ptr); |
Alex Light | ce68cc6 | 2017-07-26 10:30:38 -0700 | [diff] [blame] | 262 | } |
| 263 | |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 264 | jvmtiError MethodUtil::GetMaxLocals(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 265 | jmethodID method, |
| 266 | jint* max_ptr) { |
| 267 | if (method == nullptr) { |
| 268 | return ERR(INVALID_METHODID); |
| 269 | } |
| 270 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 271 | |
| 272 | if (art_method->IsNative()) { |
| 273 | return ERR(NATIVE_METHOD); |
| 274 | } |
| 275 | |
| 276 | if (max_ptr == nullptr) { |
| 277 | return ERR(NULL_POINTER); |
| 278 | } |
| 279 | |
| 280 | art::ScopedObjectAccess soa(art::Thread::Current()); |
| 281 | if (art_method->IsProxyMethod() || art_method->IsAbstract()) { |
| 282 | // This isn't specified as an error case, so return 0. |
| 283 | *max_ptr = 0; |
| 284 | return ERR(NONE); |
| 285 | } |
| 286 | |
| 287 | DCHECK_NE(art_method->GetCodeItemOffset(), 0u); |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 288 | *max_ptr = art_method->DexInstructionData().RegistersSize(); |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 289 | |
| 290 | return ERR(NONE); |
| 291 | } |
| 292 | |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 293 | jvmtiError MethodUtil::GetMethodName(jvmtiEnv* env, |
| 294 | jmethodID method, |
| 295 | char** name_ptr, |
| 296 | char** signature_ptr, |
| 297 | char** generic_ptr) { |
| 298 | art::ScopedObjectAccess soa(art::Thread::Current()); |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 299 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 300 | art_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize); |
| 301 | |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 302 | JvmtiUniquePtr<char[]> name_copy; |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 303 | if (name_ptr != nullptr) { |
| 304 | const char* method_name = art_method->GetName(); |
| 305 | if (method_name == nullptr) { |
| 306 | method_name = "<error>"; |
| 307 | } |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 308 | jvmtiError ret; |
| 309 | name_copy = CopyString(env, method_name, &ret); |
| 310 | if (name_copy == nullptr) { |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 311 | return ret; |
| 312 | } |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 313 | *name_ptr = name_copy.get(); |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 316 | JvmtiUniquePtr<char[]> signature_copy; |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 317 | if (signature_ptr != nullptr) { |
| 318 | const art::Signature sig = art_method->GetSignature(); |
| 319 | std::string str = sig.ToString(); |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 320 | jvmtiError ret; |
| 321 | signature_copy = CopyString(env, str.c_str(), &ret); |
| 322 | if (signature_copy == nullptr) { |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 323 | return ret; |
| 324 | } |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 325 | *signature_ptr = signature_copy.get(); |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 326 | } |
| 327 | |
Andreas Gampe | 862bdd8 | 2016-11-18 13:31:13 -0800 | [diff] [blame] | 328 | if (generic_ptr != nullptr) { |
| 329 | *generic_ptr = nullptr; |
Andreas Gampe | 27dfa05 | 2017-02-16 15:04:36 -0800 | [diff] [blame] | 330 | if (!art_method->GetDeclaringClass()->IsProxyClass()) { |
Vladimir Marko | acb906d | 2018-05-30 10:23:49 +0100 | [diff] [blame] | 331 | art::ObjPtr<art::mirror::ObjectArray<art::mirror::String>> str_array = |
Andreas Gampe | 27dfa05 | 2017-02-16 15:04:36 -0800 | [diff] [blame] | 332 | art::annotations::GetSignatureAnnotationForMethod(art_method); |
| 333 | if (str_array != nullptr) { |
| 334 | std::ostringstream oss; |
| 335 | for (int32_t i = 0; i != str_array->GetLength(); ++i) { |
| 336 | oss << str_array->Get(i)->ToModifiedUtf8(); |
| 337 | } |
| 338 | std::string output_string = oss.str(); |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 339 | jvmtiError ret; |
| 340 | JvmtiUniquePtr<char[]> generic_copy = CopyString(env, output_string.c_str(), &ret); |
| 341 | if (generic_copy == nullptr) { |
Andreas Gampe | 27dfa05 | 2017-02-16 15:04:36 -0800 | [diff] [blame] | 342 | return ret; |
| 343 | } |
Andreas Gampe | 5471141 | 2017-02-21 12:41:43 -0800 | [diff] [blame] | 344 | *generic_ptr = generic_copy.release(); |
Andreas Gampe | 27dfa05 | 2017-02-16 15:04:36 -0800 | [diff] [blame] | 345 | } else if (soa.Self()->IsExceptionPending()) { |
| 346 | // TODO: Should we report an error here? |
| 347 | soa.Self()->ClearException(); |
| 348 | } |
| 349 | } |
Andreas Gampe | 862bdd8 | 2016-11-18 13:31:13 -0800 | [diff] [blame] | 350 | } |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 351 | |
| 352 | // Everything is fine, release the buffers. |
| 353 | name_copy.release(); |
| 354 | signature_copy.release(); |
| 355 | |
| 356 | return ERR(NONE); |
| 357 | } |
| 358 | |
Andreas Gampe | 368a208 | 2016-10-28 17:33:13 -0700 | [diff] [blame] | 359 | jvmtiError MethodUtil::GetMethodDeclaringClass(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 360 | jmethodID method, |
| 361 | jclass* declaring_class_ptr) { |
| 362 | if (declaring_class_ptr == nullptr) { |
| 363 | return ERR(NULL_POINTER); |
| 364 | } |
| 365 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 366 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
Andreas Gampe | 368a208 | 2016-10-28 17:33:13 -0700 | [diff] [blame] | 367 | // Note: No GetInterfaceMethodIfProxy, we want to actual class. |
| 368 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 369 | art::ScopedObjectAccess soa(art::Thread::Current()); |
Vladimir Marko | d93e374 | 2018-07-18 10:58:13 +0100 | [diff] [blame] | 370 | art::ObjPtr<art::mirror::Class> klass = art_method->GetDeclaringClass(); |
Andreas Gampe | 368a208 | 2016-10-28 17:33:13 -0700 | [diff] [blame] | 371 | *declaring_class_ptr = soa.AddLocalReference<jclass>(klass); |
| 372 | |
| 373 | return ERR(NONE); |
| 374 | } |
| 375 | |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 376 | jvmtiError MethodUtil::GetMethodLocation(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 377 | jmethodID method, |
| 378 | jlocation* start_location_ptr, |
| 379 | jlocation* end_location_ptr) { |
| 380 | if (method == nullptr) { |
| 381 | return ERR(INVALID_METHODID); |
| 382 | } |
| 383 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 384 | |
| 385 | if (art_method->IsNative()) { |
| 386 | return ERR(NATIVE_METHOD); |
| 387 | } |
| 388 | |
| 389 | if (start_location_ptr == nullptr || end_location_ptr == nullptr) { |
| 390 | return ERR(NULL_POINTER); |
| 391 | } |
| 392 | |
| 393 | art::ScopedObjectAccess soa(art::Thread::Current()); |
| 394 | if (art_method->IsProxyMethod() || art_method->IsAbstract()) { |
Andreas Gampe | e1f79b6 | 2017-04-12 21:11:28 -0700 | [diff] [blame] | 395 | // This isn't specified as an error case, so return -1/-1 as the RI does. |
| 396 | *start_location_ptr = -1; |
| 397 | *end_location_ptr = -1; |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 398 | return ERR(NONE); |
| 399 | } |
| 400 | |
| 401 | DCHECK_NE(art_method->GetCodeItemOffset(), 0u); |
| 402 | *start_location_ptr = 0; |
Mathieu Chartier | 808c7a5 | 2017-12-15 11:19:33 -0800 | [diff] [blame] | 403 | *end_location_ptr = art_method->DexInstructions().InsnsSizeInCodeUnits() - 1; |
Andreas Gampe | f71832e | 2017-01-09 11:38:04 -0800 | [diff] [blame] | 404 | |
| 405 | return ERR(NONE); |
| 406 | } |
| 407 | |
Andreas Gampe | 36bcd4f | 2016-10-28 18:07:18 -0700 | [diff] [blame] | 408 | jvmtiError MethodUtil::GetMethodModifiers(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 409 | jmethodID method, |
| 410 | jint* modifiers_ptr) { |
| 411 | if (modifiers_ptr == nullptr) { |
| 412 | return ERR(NULL_POINTER); |
| 413 | } |
| 414 | |
Andreas Gampe | 13b2784 | 2016-11-07 16:48:23 -0800 | [diff] [blame] | 415 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
Andreas Gampe | 36bcd4f | 2016-10-28 18:07:18 -0700 | [diff] [blame] | 416 | uint32_t modifiers = art_method->GetAccessFlags(); |
| 417 | |
| 418 | // Note: Keep this code in sync with Executable.fixMethodFlags. |
| 419 | if ((modifiers & art::kAccAbstract) != 0) { |
| 420 | modifiers &= ~art::kAccNative; |
| 421 | } |
| 422 | modifiers &= ~art::kAccSynchronized; |
| 423 | if ((modifiers & art::kAccDeclaredSynchronized) != 0) { |
| 424 | modifiers |= art::kAccSynchronized; |
| 425 | } |
| 426 | modifiers &= art::kAccJavaFlagsMask; |
| 427 | |
| 428 | *modifiers_ptr = modifiers; |
| 429 | return ERR(NONE); |
| 430 | } |
| 431 | |
Andreas Gampe | da3e561 | 2016-12-13 19:00:53 -0800 | [diff] [blame] | 432 | jvmtiError MethodUtil::GetLineNumberTable(jvmtiEnv* env, |
| 433 | jmethodID method, |
| 434 | jint* entry_count_ptr, |
| 435 | jvmtiLineNumberEntry** table_ptr) { |
| 436 | if (method == nullptr) { |
| 437 | return ERR(NULL_POINTER); |
| 438 | } |
| 439 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 440 | DCHECK(!art_method->IsRuntimeMethod()); |
| 441 | |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 442 | art::CodeItemDebugInfoAccessor accessor; |
Andreas Gampe | da3e561 | 2016-12-13 19:00:53 -0800 | [diff] [blame] | 443 | const art::DexFile* dex_file; |
| 444 | { |
| 445 | art::ScopedObjectAccess soa(art::Thread::Current()); |
| 446 | |
| 447 | if (art_method->IsProxyMethod()) { |
| 448 | return ERR(ABSENT_INFORMATION); |
| 449 | } |
| 450 | if (art_method->IsNative()) { |
| 451 | return ERR(NATIVE_METHOD); |
| 452 | } |
| 453 | if (entry_count_ptr == nullptr || table_ptr == nullptr) { |
| 454 | return ERR(NULL_POINTER); |
| 455 | } |
| 456 | |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 457 | accessor = art::CodeItemDebugInfoAccessor(art_method->DexInstructionDebugInfo()); |
Andreas Gampe | da3e561 | 2016-12-13 19:00:53 -0800 | [diff] [blame] | 458 | dex_file = art_method->GetDexFile(); |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 459 | DCHECK(accessor.HasCodeItem()) << art_method->PrettyMethod() << " " << dex_file->GetLocation(); |
Andreas Gampe | da3e561 | 2016-12-13 19:00:53 -0800 | [diff] [blame] | 460 | } |
| 461 | |
Mathieu Chartier | 3e2e123 | 2018-09-11 12:35:30 -0700 | [diff] [blame] | 462 | std::vector<jvmtiLineNumberEntry> context; |
| 463 | bool success = accessor.DecodeDebugPositionInfo([&](const art::DexFile::PositionInfo& entry) { |
| 464 | context.push_back({static_cast<jlocation>(entry.address_), static_cast<jint>(entry.line_)}); |
| 465 | return false; |
| 466 | }); |
Andreas Gampe | da3e561 | 2016-12-13 19:00:53 -0800 | [diff] [blame] | 467 | if (!success) { |
| 468 | return ERR(ABSENT_INFORMATION); |
| 469 | } |
| 470 | |
| 471 | unsigned char* data; |
| 472 | jlong mem_size = context.size() * sizeof(jvmtiLineNumberEntry); |
| 473 | jvmtiError alloc_error = env->Allocate(mem_size, &data); |
| 474 | if (alloc_error != ERR(NONE)) { |
| 475 | return alloc_error; |
| 476 | } |
| 477 | *table_ptr = reinterpret_cast<jvmtiLineNumberEntry*>(data); |
| 478 | memcpy(*table_ptr, context.data(), mem_size); |
| 479 | *entry_count_ptr = static_cast<jint>(context.size()); |
| 480 | |
| 481 | return ERR(NONE); |
| 482 | } |
| 483 | |
Andreas Gampe | fdeef52 | 2017-01-09 14:40:25 -0800 | [diff] [blame] | 484 | template <typename T> |
| 485 | static jvmtiError IsMethodT(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 486 | jmethodID method, |
| 487 | T test, |
| 488 | jboolean* is_t_ptr) { |
| 489 | if (method == nullptr) { |
| 490 | return ERR(INVALID_METHODID); |
| 491 | } |
| 492 | if (is_t_ptr == nullptr) { |
| 493 | return ERR(NULL_POINTER); |
| 494 | } |
| 495 | |
| 496 | art::ArtMethod* art_method = art::jni::DecodeArtMethod(method); |
| 497 | *is_t_ptr = test(art_method) ? JNI_TRUE : JNI_FALSE; |
| 498 | |
| 499 | return ERR(NONE); |
| 500 | } |
| 501 | |
| 502 | jvmtiError MethodUtil::IsMethodNative(jvmtiEnv* env, jmethodID m, jboolean* is_native_ptr) { |
| 503 | auto test = [](art::ArtMethod* method) { |
| 504 | return method->IsNative(); |
| 505 | }; |
| 506 | return IsMethodT(env, m, test, is_native_ptr); |
| 507 | } |
| 508 | |
| 509 | jvmtiError MethodUtil::IsMethodObsolete(jvmtiEnv* env, jmethodID m, jboolean* is_obsolete_ptr) { |
| 510 | auto test = [](art::ArtMethod* method) { |
| 511 | return method->IsObsolete(); |
| 512 | }; |
| 513 | return IsMethodT(env, m, test, is_obsolete_ptr); |
| 514 | } |
| 515 | |
| 516 | jvmtiError MethodUtil::IsMethodSynthetic(jvmtiEnv* env, jmethodID m, jboolean* is_synthetic_ptr) { |
| 517 | auto test = [](art::ArtMethod* method) { |
| 518 | return method->IsSynthetic(); |
| 519 | }; |
| 520 | return IsMethodT(env, m, test, is_synthetic_ptr); |
| 521 | } |
| 522 | |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 523 | class CommonLocalVariableClosure : public art::Closure { |
| 524 | public: |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 525 | CommonLocalVariableClosure(jint depth, jint slot) |
| 526 | : result_(ERR(INTERNAL)), depth_(depth), slot_(slot) {} |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 527 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 528 | void Run(art::Thread* self) override REQUIRES(art::Locks::mutator_lock_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 529 | art::Locks::mutator_lock_->AssertSharedHeld(art::Thread::Current()); |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 530 | art::ScopedAssertNoThreadSuspension sants("CommonLocalVariableClosure::Run"); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 531 | std::unique_ptr<art::Context> context(art::Context::Create()); |
| 532 | FindFrameAtDepthVisitor visitor(self, context.get(), depth_); |
| 533 | visitor.WalkStack(); |
| 534 | if (!visitor.FoundFrame()) { |
| 535 | // Must have been a bad depth. |
| 536 | result_ = ERR(NO_MORE_FRAMES); |
| 537 | return; |
| 538 | } |
| 539 | art::ArtMethod* method = visitor.GetMethod(); |
Alex Light | 3dea212 | 2017-10-11 15:56:48 +0000 | [diff] [blame] | 540 | // Native and 'art' proxy methods don't have registers. |
| 541 | if (method->IsNative() || method->IsProxyMethod()) { |
| 542 | // TODO It might be useful to fake up support for get at least on proxy frames. |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 543 | result_ = ERR(OPAQUE_FRAME); |
| 544 | return; |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 545 | } else if (method->DexInstructionData().RegistersSize() <= slot_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 546 | result_ = ERR(INVALID_SLOT); |
| 547 | return; |
| 548 | } |
Alex Light | 0a5ec3d | 2017-07-25 16:50:26 -0700 | [diff] [blame] | 549 | bool needs_instrument = !visitor.IsShadowFrame(); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 550 | uint32_t pc = visitor.GetDexPc(/*abort_on_failure*/ false); |
Andreas Gampe | e2abbc6 | 2017-09-15 11:59:26 -0700 | [diff] [blame] | 551 | if (pc == art::dex::kDexNoIndex) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 552 | // Cannot figure out current PC. |
| 553 | result_ = ERR(OPAQUE_FRAME); |
| 554 | return; |
| 555 | } |
| 556 | std::string descriptor; |
| 557 | art::Primitive::Type slot_type = art::Primitive::kPrimVoid; |
| 558 | jvmtiError err = GetSlotType(method, pc, &descriptor, &slot_type); |
| 559 | if (err != OK) { |
| 560 | result_ = err; |
| 561 | return; |
| 562 | } |
| 563 | |
| 564 | err = GetTypeError(method, slot_type, descriptor); |
| 565 | if (err != OK) { |
| 566 | result_ = err; |
| 567 | return; |
| 568 | } |
| 569 | result_ = Execute(method, visitor); |
Alex Light | 0a5ec3d | 2017-07-25 16:50:26 -0700 | [diff] [blame] | 570 | if (needs_instrument) { |
| 571 | art::Runtime::Current()->GetInstrumentation()->InstrumentThreadStack(self); |
| 572 | } |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 575 | virtual jvmtiError GetResult() { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 576 | return result_; |
| 577 | } |
| 578 | |
| 579 | protected: |
| 580 | virtual jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor) |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 581 | REQUIRES_SHARED(art::Locks::mutator_lock_) = 0; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 582 | virtual jvmtiError GetTypeError(art::ArtMethod* method, |
| 583 | art::Primitive::Type type, |
| 584 | const std::string& descriptor) |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 585 | REQUIRES_SHARED(art::Locks::mutator_lock_) = 0; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 586 | |
| 587 | jvmtiError GetSlotType(art::ArtMethod* method, |
| 588 | uint32_t dex_pc, |
| 589 | /*out*/std::string* descriptor, |
| 590 | /*out*/art::Primitive::Type* type) |
| 591 | REQUIRES(art::Locks::mutator_lock_) { |
| 592 | const art::DexFile* dex_file = method->GetDexFile(); |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 593 | if (dex_file == nullptr) { |
| 594 | return ERR(OPAQUE_FRAME); |
| 595 | } |
David Sehr | 0225f8e | 2018-01-31 08:52:24 +0000 | [diff] [blame] | 596 | art::CodeItemDebugInfoAccessor accessor(method->DexInstructionDebugInfo()); |
Mathieu Chartier | 31f4c9f | 2017-12-08 15:46:11 -0800 | [diff] [blame] | 597 | if (!accessor.HasCodeItem()) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 598 | return ERR(OPAQUE_FRAME); |
| 599 | } |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 600 | bool found = false; |
| 601 | *type = art::Primitive::kPrimVoid; |
| 602 | descriptor->clear(); |
| 603 | auto visitor = [&](const art::DexFile::LocalInfo& entry) { |
| 604 | if (!found && |
| 605 | entry.start_address_ <= dex_pc && |
| 606 | entry.end_address_ > dex_pc && |
| 607 | entry.reg_ == slot_) { |
| 608 | found = true; |
| 609 | *type = art::Primitive::GetType(entry.descriptor_[0]); |
| 610 | *descriptor = entry.descriptor_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 611 | } |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 612 | }; |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 613 | if (!accessor.DecodeDebugLocalInfo(method->IsStatic(), method->GetDexMethodIndex(), visitor) || |
| 614 | !found) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 615 | // Something went wrong with decoding the debug information. It might as well not be there. |
| 616 | return ERR(INVALID_SLOT); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 617 | } |
Mathieu Chartier | e5afbf3 | 2018-09-12 17:51:54 -0700 | [diff] [blame^] | 618 | return OK; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | jvmtiError result_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 622 | jint depth_; |
| 623 | jint slot_; |
| 624 | }; |
| 625 | |
| 626 | class GetLocalVariableClosure : public CommonLocalVariableClosure { |
| 627 | public: |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 628 | GetLocalVariableClosure(jint depth, |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 629 | jint slot, |
| 630 | art::Primitive::Type type, |
| 631 | jvalue* val) |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 632 | : CommonLocalVariableClosure(depth, slot), |
| 633 | type_(type), |
| 634 | val_(val), |
| 635 | obj_val_(nullptr) {} |
| 636 | |
Andreas Gampe | fa6a1b0 | 2018-09-07 08:11:55 -0700 | [diff] [blame] | 637 | jvmtiError GetResult() override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 638 | if (result_ == OK && type_ == art::Primitive::kPrimNot) { |
| 639 | val_->l = obj_val_.IsNull() |
| 640 | ? nullptr |
| 641 | : art::Thread::Current()->GetJniEnv()->AddLocalReference<jobject>(obj_val_.Read()); |
| 642 | } |
| 643 | return CommonLocalVariableClosure::GetResult(); |
| 644 | } |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 645 | |
| 646 | protected: |
| 647 | jvmtiError GetTypeError(art::ArtMethod* method ATTRIBUTE_UNUSED, |
| 648 | art::Primitive::Type slot_type, |
| 649 | const std::string& descriptor ATTRIBUTE_UNUSED) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 650 | override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 651 | switch (slot_type) { |
| 652 | case art::Primitive::kPrimByte: |
| 653 | case art::Primitive::kPrimChar: |
| 654 | case art::Primitive::kPrimInt: |
| 655 | case art::Primitive::kPrimShort: |
| 656 | case art::Primitive::kPrimBoolean: |
| 657 | return type_ == art::Primitive::kPrimInt ? OK : ERR(TYPE_MISMATCH); |
| 658 | case art::Primitive::kPrimLong: |
| 659 | case art::Primitive::kPrimFloat: |
| 660 | case art::Primitive::kPrimDouble: |
| 661 | case art::Primitive::kPrimNot: |
| 662 | return type_ == slot_type ? OK : ERR(TYPE_MISMATCH); |
| 663 | case art::Primitive::kPrimVoid: |
| 664 | LOG(FATAL) << "Unexpected primitive type " << slot_type; |
| 665 | UNREACHABLE(); |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 670 | override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 671 | switch (type_) { |
| 672 | case art::Primitive::kPrimNot: { |
| 673 | uint32_t ptr_val; |
| 674 | if (!visitor.GetVReg(method, |
| 675 | static_cast<uint16_t>(slot_), |
| 676 | art::kReferenceVReg, |
| 677 | &ptr_val)) { |
| 678 | return ERR(OPAQUE_FRAME); |
| 679 | } |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 680 | obj_val_ = art::GcRoot<art::mirror::Object>( |
| 681 | reinterpret_cast<art::mirror::Object*>(ptr_val)); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 682 | break; |
| 683 | } |
| 684 | case art::Primitive::kPrimInt: |
| 685 | case art::Primitive::kPrimFloat: { |
| 686 | if (!visitor.GetVReg(method, |
| 687 | static_cast<uint16_t>(slot_), |
| 688 | type_ == art::Primitive::kPrimFloat ? art::kFloatVReg : art::kIntVReg, |
| 689 | reinterpret_cast<uint32_t*>(&val_->i))) { |
| 690 | return ERR(OPAQUE_FRAME); |
| 691 | } |
| 692 | break; |
| 693 | } |
| 694 | case art::Primitive::kPrimDouble: |
| 695 | case art::Primitive::kPrimLong: { |
| 696 | auto lo_type = type_ == art::Primitive::kPrimLong ? art::kLongLoVReg : art::kDoubleLoVReg; |
| 697 | auto high_type = type_ == art::Primitive::kPrimLong ? art::kLongHiVReg : art::kDoubleHiVReg; |
| 698 | if (!visitor.GetVRegPair(method, |
| 699 | static_cast<uint16_t>(slot_), |
| 700 | lo_type, |
| 701 | high_type, |
| 702 | reinterpret_cast<uint64_t*>(&val_->j))) { |
| 703 | return ERR(OPAQUE_FRAME); |
| 704 | } |
| 705 | break; |
| 706 | } |
| 707 | default: { |
| 708 | LOG(FATAL) << "unexpected register type " << type_; |
| 709 | UNREACHABLE(); |
| 710 | } |
| 711 | } |
| 712 | return OK; |
| 713 | } |
| 714 | |
| 715 | private: |
| 716 | art::Primitive::Type type_; |
| 717 | jvalue* val_; |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 718 | art::GcRoot<art::mirror::Object> obj_val_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 719 | }; |
| 720 | |
| 721 | jvmtiError MethodUtil::GetLocalVariableGeneric(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 722 | jthread thread, |
| 723 | jint depth, |
| 724 | jint slot, |
| 725 | art::Primitive::Type type, |
| 726 | jvalue* val) { |
| 727 | if (depth < 0) { |
| 728 | return ERR(ILLEGAL_ARGUMENT); |
| 729 | } |
| 730 | art::Thread* self = art::Thread::Current(); |
| 731 | art::ScopedObjectAccess soa(self); |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 732 | art::Locks::thread_list_lock_->ExclusiveLock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 733 | art::Thread* target = nullptr; |
| 734 | jvmtiError err = ERR(INTERNAL); |
| 735 | if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) { |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 736 | art::Locks::thread_list_lock_->ExclusiveUnlock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 737 | return err; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 738 | } |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 739 | art::ScopedAssertNoThreadSuspension sants("Performing GetLocalVariable"); |
| 740 | GetLocalVariableClosure c(depth, slot, type, val); |
| 741 | // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution. We |
| 742 | // need to avoid suspending as we wait for the checkpoint to occur since we are (potentially) |
| 743 | // transfering a GcRoot across threads. |
| 744 | if (!target->RequestSynchronousCheckpoint(&c, art::ThreadState::kRunnable)) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 745 | return ERR(THREAD_NOT_ALIVE); |
| 746 | } else { |
| 747 | return c.GetResult(); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | class SetLocalVariableClosure : public CommonLocalVariableClosure { |
| 752 | public: |
| 753 | SetLocalVariableClosure(art::Thread* caller, |
| 754 | jint depth, |
| 755 | jint slot, |
| 756 | art::Primitive::Type type, |
| 757 | jvalue val) |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 758 | : CommonLocalVariableClosure(depth, slot), caller_(caller), type_(type), val_(val) {} |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 759 | |
| 760 | protected: |
| 761 | jvmtiError GetTypeError(art::ArtMethod* method, |
| 762 | art::Primitive::Type slot_type, |
| 763 | const std::string& descriptor) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 764 | override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 765 | switch (slot_type) { |
| 766 | case art::Primitive::kPrimNot: { |
| 767 | if (type_ != art::Primitive::kPrimNot) { |
| 768 | return ERR(TYPE_MISMATCH); |
| 769 | } else if (val_.l == nullptr) { |
| 770 | return OK; |
| 771 | } else { |
| 772 | art::ClassLinker* cl = art::Runtime::Current()->GetClassLinker(); |
| 773 | art::ObjPtr<art::mirror::Class> set_class = |
| 774 | caller_->DecodeJObject(val_.l)->GetClass(); |
| 775 | art::ObjPtr<art::mirror::ClassLoader> loader = |
| 776 | method->GetDeclaringClass()->GetClassLoader(); |
| 777 | art::ObjPtr<art::mirror::Class> slot_class = |
| 778 | cl->LookupClass(caller_, descriptor.c_str(), loader); |
| 779 | DCHECK(!slot_class.IsNull()); |
| 780 | return slot_class->IsAssignableFrom(set_class) ? OK : ERR(TYPE_MISMATCH); |
| 781 | } |
| 782 | } |
| 783 | case art::Primitive::kPrimByte: |
| 784 | case art::Primitive::kPrimChar: |
| 785 | case art::Primitive::kPrimInt: |
| 786 | case art::Primitive::kPrimShort: |
| 787 | case art::Primitive::kPrimBoolean: |
| 788 | return type_ == art::Primitive::kPrimInt ? OK : ERR(TYPE_MISMATCH); |
| 789 | case art::Primitive::kPrimLong: |
| 790 | case art::Primitive::kPrimFloat: |
| 791 | case art::Primitive::kPrimDouble: |
| 792 | return type_ == slot_type ? OK : ERR(TYPE_MISMATCH); |
| 793 | case art::Primitive::kPrimVoid: |
| 794 | LOG(FATAL) << "Unexpected primitive type " << slot_type; |
| 795 | UNREACHABLE(); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor) |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 800 | override REQUIRES_SHARED(art::Locks::mutator_lock_) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 801 | switch (type_) { |
| 802 | case art::Primitive::kPrimNot: { |
| 803 | uint32_t ptr_val; |
| 804 | art::ObjPtr<art::mirror::Object> obj(caller_->DecodeJObject(val_.l)); |
| 805 | ptr_val = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(obj.Ptr())); |
| 806 | if (!visitor.SetVReg(method, |
| 807 | static_cast<uint16_t>(slot_), |
| 808 | ptr_val, |
| 809 | art::kReferenceVReg)) { |
| 810 | return ERR(OPAQUE_FRAME); |
| 811 | } |
| 812 | break; |
| 813 | } |
| 814 | case art::Primitive::kPrimInt: |
| 815 | case art::Primitive::kPrimFloat: { |
| 816 | if (!visitor.SetVReg(method, |
| 817 | static_cast<uint16_t>(slot_), |
| 818 | static_cast<uint32_t>(val_.i), |
| 819 | type_ == art::Primitive::kPrimFloat ? art::kFloatVReg |
| 820 | : art::kIntVReg)) { |
| 821 | return ERR(OPAQUE_FRAME); |
| 822 | } |
| 823 | break; |
| 824 | } |
| 825 | case art::Primitive::kPrimDouble: |
| 826 | case art::Primitive::kPrimLong: { |
| 827 | auto lo_type = type_ == art::Primitive::kPrimLong ? art::kLongLoVReg : art::kDoubleLoVReg; |
| 828 | auto high_type = type_ == art::Primitive::kPrimLong ? art::kLongHiVReg : art::kDoubleHiVReg; |
| 829 | if (!visitor.SetVRegPair(method, |
| 830 | static_cast<uint16_t>(slot_), |
| 831 | static_cast<uint64_t>(val_.j), |
| 832 | lo_type, |
| 833 | high_type)) { |
| 834 | return ERR(OPAQUE_FRAME); |
| 835 | } |
| 836 | break; |
| 837 | } |
| 838 | default: { |
| 839 | LOG(FATAL) << "unexpected register type " << type_; |
| 840 | UNREACHABLE(); |
| 841 | } |
| 842 | } |
| 843 | return OK; |
| 844 | } |
| 845 | |
| 846 | private: |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 847 | art::Thread* caller_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 848 | art::Primitive::Type type_; |
| 849 | jvalue val_; |
| 850 | }; |
| 851 | |
| 852 | jvmtiError MethodUtil::SetLocalVariableGeneric(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 853 | jthread thread, |
| 854 | jint depth, |
| 855 | jint slot, |
| 856 | art::Primitive::Type type, |
| 857 | jvalue val) { |
| 858 | if (depth < 0) { |
| 859 | return ERR(ILLEGAL_ARGUMENT); |
| 860 | } |
Alex Light | f285863 | 2018-04-02 11:28:50 -0700 | [diff] [blame] | 861 | // Make sure that we know not to do any OSR anymore. |
| 862 | // TODO We should really keep track of this at the Frame granularity. |
| 863 | DeoptManager::Get()->SetLocalsUpdated(); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 864 | art::Thread* self = art::Thread::Current(); |
| 865 | art::ScopedObjectAccess soa(self); |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 866 | art::Locks::thread_list_lock_->ExclusiveLock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 867 | art::Thread* target = nullptr; |
| 868 | jvmtiError err = ERR(INTERNAL); |
| 869 | if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) { |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 870 | art::Locks::thread_list_lock_->ExclusiveUnlock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 871 | return err; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 872 | } |
| 873 | SetLocalVariableClosure c(self, depth, slot, type, val); |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 874 | // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution. |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 875 | if (!target->RequestSynchronousCheckpoint(&c)) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 876 | return ERR(THREAD_NOT_ALIVE); |
| 877 | } else { |
| 878 | return c.GetResult(); |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | class GetLocalInstanceClosure : public art::Closure { |
| 883 | public: |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 884 | explicit GetLocalInstanceClosure(jint depth) |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 885 | : result_(ERR(INTERNAL)), |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 886 | depth_(depth), |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 887 | val_(nullptr) {} |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 888 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 889 | void Run(art::Thread* self) override REQUIRES(art::Locks::mutator_lock_) { |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 890 | art::ScopedAssertNoThreadSuspension sants("GetLocalInstanceClosure::Run"); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 891 | art::Locks::mutator_lock_->AssertSharedHeld(art::Thread::Current()); |
| 892 | std::unique_ptr<art::Context> context(art::Context::Create()); |
| 893 | FindFrameAtDepthVisitor visitor(self, context.get(), depth_); |
| 894 | visitor.WalkStack(); |
| 895 | if (!visitor.FoundFrame()) { |
| 896 | // Must have been a bad depth. |
| 897 | result_ = ERR(NO_MORE_FRAMES); |
| 898 | return; |
| 899 | } |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 900 | result_ = OK; |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 901 | val_ = art::GcRoot<art::mirror::Object>(visitor.GetThisObject()); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 902 | } |
| 903 | |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 904 | jvmtiError GetResult(jobject* data_out) REQUIRES_SHARED(art::Locks::mutator_lock_) { |
| 905 | if (result_ == OK) { |
| 906 | *data_out = val_.IsNull() |
| 907 | ? nullptr |
| 908 | : art::Thread::Current()->GetJniEnv()->AddLocalReference<jobject>(val_.Read()); |
| 909 | } |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 910 | return result_; |
| 911 | } |
| 912 | |
| 913 | private: |
| 914 | jvmtiError result_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 915 | jint depth_; |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 916 | art::GcRoot<art::mirror::Object> val_; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 917 | }; |
| 918 | |
| 919 | jvmtiError MethodUtil::GetLocalInstance(jvmtiEnv* env ATTRIBUTE_UNUSED, |
| 920 | jthread thread, |
| 921 | jint depth, |
| 922 | jobject* data) { |
| 923 | if (depth < 0) { |
| 924 | return ERR(ILLEGAL_ARGUMENT); |
| 925 | } |
| 926 | art::Thread* self = art::Thread::Current(); |
| 927 | art::ScopedObjectAccess soa(self); |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 928 | art::Locks::thread_list_lock_->ExclusiveLock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 929 | art::Thread* target = nullptr; |
| 930 | jvmtiError err = ERR(INTERNAL); |
| 931 | if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) { |
Alex Light | b1e31a8 | 2017-10-04 16:57:36 -0700 | [diff] [blame] | 932 | art::Locks::thread_list_lock_->ExclusiveUnlock(self); |
Alex Light | 7ddc23d | 2017-09-22 15:33:41 -0700 | [diff] [blame] | 933 | return err; |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 934 | } |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 935 | art::ScopedAssertNoThreadSuspension sants("Performing GetLocalInstance"); |
| 936 | GetLocalInstanceClosure c(depth); |
| 937 | // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution. We |
| 938 | // need to avoid suspending as we wait for the checkpoint to occur since we are (potentially) |
| 939 | // transfering a GcRoot across threads. |
| 940 | if (!target->RequestSynchronousCheckpoint(&c, art::ThreadState::kRunnable)) { |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 941 | return ERR(THREAD_NOT_ALIVE); |
| 942 | } else { |
Alex Light | 318afe6 | 2018-03-22 16:50:10 -0700 | [diff] [blame] | 943 | return c.GetResult(data); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 944 | } |
| 945 | } |
| 946 | |
| 947 | #define FOR_JVMTI_JVALUE_TYPES(fn) \ |
| 948 | fn(jint, art::Primitive::kPrimInt, i) \ |
| 949 | fn(jlong, art::Primitive::kPrimLong, j) \ |
| 950 | fn(jfloat, art::Primitive::kPrimFloat, f) \ |
| 951 | fn(jdouble, art::Primitive::kPrimDouble, d) \ |
| 952 | fn(jobject, art::Primitive::kPrimNot, l) |
| 953 | |
| 954 | namespace impl { |
| 955 | |
| 956 | template<typename T> void WriteJvalue(T, jvalue*); |
| 957 | template<typename T> void ReadJvalue(jvalue, T*); |
| 958 | template<typename T> art::Primitive::Type GetJNIType(); |
| 959 | |
| 960 | #define JNI_TYPE_CHAR(type, prim, id) \ |
| 961 | template<> art::Primitive::Type GetJNIType<type>() { \ |
| 962 | return prim; \ |
| 963 | } |
| 964 | |
| 965 | FOR_JVMTI_JVALUE_TYPES(JNI_TYPE_CHAR); |
| 966 | |
| 967 | #undef JNI_TYPE_CHAR |
| 968 | |
Andreas Gampe | 49fc60e | 2017-08-24 13:19:59 -0700 | [diff] [blame] | 969 | #define RW_JVALUE(srctype, prim, id) \ |
| 970 | template<> void ReadJvalue<srctype>(jvalue in, std::add_pointer<srctype>::type out) { \ |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 971 | *out = in.id; \ |
| 972 | } \ |
Andreas Gampe | 49fc60e | 2017-08-24 13:19:59 -0700 | [diff] [blame] | 973 | template<> void WriteJvalue<srctype>(srctype in, jvalue* out) { \ |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 974 | out->id = in; \ |
| 975 | } |
| 976 | |
| 977 | FOR_JVMTI_JVALUE_TYPES(RW_JVALUE); |
| 978 | |
| 979 | #undef RW_JVALUE |
| 980 | |
| 981 | } // namespace impl |
| 982 | |
| 983 | template<typename T> |
| 984 | jvmtiError MethodUtil::SetLocalVariable(jvmtiEnv* env, |
| 985 | jthread thread, |
| 986 | jint depth, |
| 987 | jint slot, |
| 988 | T data) { |
| 989 | jvalue v = {.j = 0}; |
| 990 | art::Primitive::Type type = impl::GetJNIType<T>(); |
| 991 | impl::WriteJvalue(data, &v); |
| 992 | return SetLocalVariableGeneric(env, thread, depth, slot, type, v); |
| 993 | } |
| 994 | |
| 995 | template<typename T> |
| 996 | jvmtiError MethodUtil::GetLocalVariable(jvmtiEnv* env, |
| 997 | jthread thread, |
| 998 | jint depth, |
| 999 | jint slot, |
| 1000 | T* data) { |
| 1001 | if (data == nullptr) { |
| 1002 | return ERR(NULL_POINTER); |
| 1003 | } |
| 1004 | jvalue v = {.j = 0}; |
| 1005 | art::Primitive::Type type = impl::GetJNIType<T>(); |
| 1006 | jvmtiError err = GetLocalVariableGeneric(env, thread, depth, slot, type, &v); |
| 1007 | if (err != OK) { |
| 1008 | return err; |
| 1009 | } else { |
| 1010 | impl::ReadJvalue(v, data); |
| 1011 | return OK; |
| 1012 | } |
| 1013 | } |
| 1014 | |
Andreas Gampe | 49fc60e | 2017-08-24 13:19:59 -0700 | [diff] [blame] | 1015 | #define GET_SET_LV(srctype, prim, id) \ |
| 1016 | template jvmtiError MethodUtil::GetLocalVariable<srctype>(jvmtiEnv*, \ |
| 1017 | jthread, \ |
| 1018 | jint, \ |
| 1019 | jint, \ |
| 1020 | std::add_pointer<srctype>::type); \ |
| 1021 | template jvmtiError MethodUtil::SetLocalVariable<srctype>(jvmtiEnv*, \ |
| 1022 | jthread, \ |
| 1023 | jint, \ |
| 1024 | jint, \ |
| 1025 | srctype); |
Alex Light | bebd7bd | 2017-07-25 14:05:52 -0700 | [diff] [blame] | 1026 | |
| 1027 | FOR_JVMTI_JVALUE_TYPES(GET_SET_LV); |
| 1028 | |
| 1029 | #undef GET_SET_LV |
| 1030 | |
| 1031 | #undef FOR_JVMTI_JVALUE_TYPES |
| 1032 | |
Andreas Gampe | 3c252f0 | 2016-10-27 18:25:17 -0700 | [diff] [blame] | 1033 | } // namespace openjdkjvmti |