blob: 16efc2e358fbd4e6a782424ff0c022405b423224 [file] [log] [blame]
Andreas Gampe3c252f02016-10-27 18:25:17 -07001/* 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
Alex Lighte2ddce32019-05-22 17:08:35 +000034#include <initializer_list>
Andreas Gampe49fc60e2017-08-24 13:19:59 -070035#include <type_traits>
Alex Lighte2ddce32019-05-22 17:08:35 +000036#include <variant>
Andreas Gampe49fc60e2017-08-24 13:19:59 -070037
Alex Lighte2ddce32019-05-22 17:08:35 +000038#include "android-base/macros.h"
Andreas Gampee5d23982019-01-08 10:34:26 -080039#include "arch/context.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070040#include "art_jvmti.h"
41#include "art_method-inl.h"
42#include "base/enums.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000043#include "base/globals.h"
44#include "base/macros.h"
Alex Lightbebd7bd2017-07-25 14:05:52 -070045#include "base/mutex-inl.h"
Alex Lighta4cdd362019-04-18 09:17:10 -070046#include "deopt_manager.h"
David Sehr9e734c72018-01-04 17:56:19 -080047#include "dex/code_item_accessors-inl.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000048#include "dex/code_item_accessors.h"
David Sehr9e734c72018-01-04 17:56:19 -080049#include "dex/dex_file_annotations.h"
50#include "dex/dex_file_types.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000051#include "dex/dex_instruction.h"
52#include "dex/dex_instruction_iterator.h"
David Sehr8c0961f2018-01-23 16:11:38 -080053#include "dex/modifiers.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000054#include "dex/primitive.h"
Alex Lightd78ddec2017-04-18 15:20:38 -070055#include "events-inl.h"
Alex Light318afe62018-03-22 16:50:10 -070056#include "gc_root-inl.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000057#include "handle.h"
Alex Light0a5ec3d2017-07-25 16:50:26 -070058#include "jit/jit.h"
Vladimir Markoa3ad0cd2018-05-04 10:06:38 +010059#include "jni/jni_internal.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000060#include "jvmti.h"
Alex Lightbebd7bd2017-07-25 14:05:52 -070061#include "mirror/class-inl.h"
62#include "mirror/class_loader.h"
63#include "mirror/object-inl.h"
Andreas Gampe27dfa052017-02-16 15:04:36 -080064#include "mirror/object_array-inl.h"
Andreas Gampe373a9b52017-10-18 09:01:57 -070065#include "nativehelper/scoped_local_ref.h"
Nicolas Geoffray58cc1cb2017-11-20 13:27:29 +000066#include "oat_file.h"
Alex Lighta4cdd362019-04-18 09:17:10 -070067#include "obj_ptr.h"
Alex Lightb096c912019-09-25 13:33:06 -070068#include "runtime.h"
Alex Lightd78ddec2017-04-18 15:20:38 -070069#include "runtime_callbacks.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070070#include "scoped_thread_state_change-inl.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000071#include "scoped_thread_state_change.h"
Alex Lightbebd7bd2017-07-25 14:05:52 -070072#include "stack.h"
Andreas Gampeb486a982017-06-01 13:45:54 -070073#include "thread-current-inl.h"
Alex Lighta4cdd362019-04-18 09:17:10 -070074#include "thread.h"
Alex Lightd78ddec2017-04-18 15:20:38 -070075#include "thread_list.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000076#include "ti_logging.h"
Alex Lighte814f9d2017-07-31 16:14:39 -070077#include "ti_stack.h"
Alex Lightbebd7bd2017-07-25 14:05:52 -070078#include "ti_thread.h"
Alex Light0af8cde2017-04-20 13:35:05 -070079#include "ti_phase.h"
Alex Lighte2ddce32019-05-22 17:08:35 +000080#include "verifier/register_line-inl.h"
81#include "verifier/reg_type-inl.h"
82#include "verifier/method_verifier-inl.h"
Andreas Gampe3c252f02016-10-27 18:25:17 -070083
84namespace openjdkjvmti {
85
Alex Lightd78ddec2017-04-18 15:20:38 -070086struct TiMethodCallback : public art::MethodCallback {
87 void RegisterNativeMethod(art::ArtMethod* method,
88 const void* cur_method,
89 /*out*/void** new_method)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +010090 override REQUIRES_SHARED(art::Locks::mutator_lock_) {
Alex Lightd78ddec2017-04-18 15:20:38 -070091 if (event_handler->IsEventEnabledAnywhere(ArtJvmtiEvent::kNativeMethodBind)) {
92 art::Thread* thread = art::Thread::Current();
Alex Light0af8cde2017-04-20 13:35:05 -070093 art::JNIEnvExt* jnienv = thread->GetJniEnv();
Alex Lightd78ddec2017-04-18 15:20:38 -070094 ScopedLocalRef<jthread> thread_jni(
Alex Light0af8cde2017-04-20 13:35:05 -070095 jnienv, PhaseUtil::IsLivePhase() ? jnienv->AddLocalReference<jthread>(thread->GetPeer())
96 : nullptr);
Alex Light79d6c802019-06-27 15:50:11 +000097 jmethodID method_id = art::jni::EncodeArtMethod(method);
Alex Lightd78ddec2017-04-18 15:20:38 -070098 art::ScopedThreadSuspension sts(thread, art::ThreadState::kNative);
99 event_handler->DispatchEvent<ArtJvmtiEvent::kNativeMethodBind>(
100 thread,
Alex Light0af8cde2017-04-20 13:35:05 -0700101 static_cast<JNIEnv*>(jnienv),
Alex Lightd78ddec2017-04-18 15:20:38 -0700102 thread_jni.get(),
Alex Light79d6c802019-06-27 15:50:11 +0000103 method_id,
Alex Lightd78ddec2017-04-18 15:20:38 -0700104 const_cast<void*>(cur_method),
105 new_method);
106 }
107 }
108
109 EventHandler* event_handler = nullptr;
110};
111
112TiMethodCallback gMethodCallback;
113
114void MethodUtil::Register(EventHandler* handler) {
115 gMethodCallback.event_handler = handler;
116 art::ScopedThreadStateChange stsc(art::Thread::Current(),
117 art::ThreadState::kWaitingForDebuggerToAttach);
118 art::ScopedSuspendAll ssa("Add method callback");
Alex Light21611932017-09-26 13:07:39 -0700119 art::RuntimeCallbacks* callbacks = art::Runtime::Current()->GetRuntimeCallbacks();
120 callbacks->AddMethodCallback(&gMethodCallback);
Alex Lightd78ddec2017-04-18 15:20:38 -0700121}
122
123void MethodUtil::Unregister() {
124 art::ScopedThreadStateChange stsc(art::Thread::Current(),
125 art::ThreadState::kWaitingForDebuggerToAttach);
126 art::ScopedSuspendAll ssa("Remove method callback");
Alex Light21611932017-09-26 13:07:39 -0700127 art::RuntimeCallbacks* callbacks = art::Runtime::Current()->GetRuntimeCallbacks();
128 callbacks->RemoveMethodCallback(&gMethodCallback);
Alex Lightd78ddec2017-04-18 15:20:38 -0700129}
130
Alex Light4c174282017-07-05 10:18:18 -0700131jvmtiError MethodUtil::GetBytecodes(jvmtiEnv* env,
132 jmethodID method,
133 jint* size_ptr,
134 unsigned char** bytecode_ptr) {
135 if (method == nullptr) {
136 return ERR(INVALID_METHODID);
137 }
138 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
139
140 if (art_method->IsNative()) {
141 return ERR(NATIVE_METHOD);
142 }
143
144 if (size_ptr == nullptr || bytecode_ptr == nullptr) {
145 return ERR(NULL_POINTER);
146 }
147
148 art::ScopedObjectAccess soa(art::Thread::Current());
David Sehr0225f8e2018-01-31 08:52:24 +0000149 art::CodeItemInstructionAccessor accessor(art_method->DexInstructions());
Mathieu Chartier808c7a52017-12-15 11:19:33 -0800150 if (!accessor.HasCodeItem()) {
Alex Light4c174282017-07-05 10:18:18 -0700151 *size_ptr = 0;
152 *bytecode_ptr = nullptr;
153 return OK;
154 }
155 // 2 bytes per instruction for dex code.
Mathieu Chartier808c7a52017-12-15 11:19:33 -0800156 *size_ptr = accessor.InsnsSizeInCodeUnits() * 2;
Alex Light4c174282017-07-05 10:18:18 -0700157 jvmtiError err = env->Allocate(*size_ptr, bytecode_ptr);
158 if (err != OK) {
159 return err;
160 }
Mathieu Chartier808c7a52017-12-15 11:19:33 -0800161 memcpy(*bytecode_ptr, accessor.Insns(), *size_ptr);
Alex Light4c174282017-07-05 10:18:18 -0700162 return OK;
163}
164
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000165jvmtiError MethodUtil::GetArgumentsSize([[maybe_unused]] jvmtiEnv* env,
Andreas Gampef71832e2017-01-09 11:38:04 -0800166 jmethodID method,
167 jint* size_ptr) {
168 if (method == nullptr) {
169 return ERR(INVALID_METHODID);
170 }
171 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
172
173 if (art_method->IsNative()) {
174 return ERR(NATIVE_METHOD);
175 }
176
177 if (size_ptr == nullptr) {
178 return ERR(NULL_POINTER);
179 }
180
181 art::ScopedObjectAccess soa(art::Thread::Current());
182 if (art_method->IsProxyMethod() || art_method->IsAbstract()) {
Andreas Gampee1f79b62017-04-12 21:11:28 -0700183 // Use the shorty.
184 art::ArtMethod* base_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize);
185 size_t arg_count = art::ArtMethod::NumArgRegisters(base_method->GetShorty());
186 if (!base_method->IsStatic()) {
187 arg_count++;
188 }
189 *size_ptr = static_cast<jint>(arg_count);
Andreas Gampef71832e2017-01-09 11:38:04 -0800190 return ERR(NONE);
191 }
192
Nicolas Geoffray47171752020-08-31 15:03:20 +0100193 DCHECK(art_method->HasCodeItem());
194 DCHECK_NE(art_method->GetCodeItem(), nullptr);
David Sehr0225f8e2018-01-31 08:52:24 +0000195 *size_ptr = art_method->DexInstructionData().InsSize();
Andreas Gampef71832e2017-01-09 11:38:04 -0800196
197 return ERR(NONE);
198}
199
Alex Lightce68cc62017-07-26 10:30:38 -0700200jvmtiError MethodUtil::GetLocalVariableTable(jvmtiEnv* env,
201 jmethodID method,
202 jint* entry_count_ptr,
203 jvmtiLocalVariableEntry** table_ptr) {
204 if (method == nullptr) {
205 return ERR(INVALID_METHODID);
206 }
207 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
208
209 if (art_method->IsNative()) {
210 return ERR(NATIVE_METHOD);
211 }
212
213 if (entry_count_ptr == nullptr || table_ptr == nullptr) {
214 return ERR(NULL_POINTER);
215 }
216
217 art::ScopedObjectAccess soa(art::Thread::Current());
Mathieu Chartier31f4c9f2017-12-08 15:46:11 -0800218
219 const art::DexFile* const dex_file = art_method->GetDexFile();
220 if (dex_file == nullptr) {
221 return ERR(ABSENT_INFORMATION);
222 }
223
224 // TODO HasCodeItem == false means that the method is abstract (or native, but we check that
Alex Lightce68cc62017-07-26 10:30:38 -0700225 // earlier). We should check what is returned by the RI in this situation since it's not clear
226 // what the appropriate return value is from the spec.
David Sehr0225f8e2018-01-31 08:52:24 +0000227 art::CodeItemDebugInfoAccessor accessor(art_method->DexInstructionDebugInfo());
Mathieu Chartier31f4c9f2017-12-08 15:46:11 -0800228 if (!accessor.HasCodeItem()) {
Alex Lightce68cc62017-07-26 10:30:38 -0700229 return ERR(ABSENT_INFORMATION);
230 }
231
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700232 std::vector<jvmtiLocalVariableEntry> variables;
233 jvmtiError err = OK;
Alex Lightce68cc62017-07-26 10:30:38 -0700234
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700235 auto release = [&](jint* out_entry_count_ptr, jvmtiLocalVariableEntry** out_table_ptr) {
236 jlong table_size = sizeof(jvmtiLocalVariableEntry) * variables.size();
237 if (err != OK ||
238 (err = env->Allocate(table_size,
239 reinterpret_cast<unsigned char**>(out_table_ptr))) != OK) {
240 for (jvmtiLocalVariableEntry& e : variables) {
241 env->Deallocate(reinterpret_cast<unsigned char*>(e.name));
242 env->Deallocate(reinterpret_cast<unsigned char*>(e.signature));
243 env->Deallocate(reinterpret_cast<unsigned char*>(e.generic_signature));
244 }
245 return err;
Alex Lightce68cc62017-07-26 10:30:38 -0700246 }
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700247 *out_entry_count_ptr = variables.size();
248 memcpy(*out_table_ptr, variables.data(), table_size);
249 return OK;
Alex Lightce68cc62017-07-26 10:30:38 -0700250 };
251
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700252 auto visitor = [&](const art::DexFile::LocalInfo& entry) {
253 if (err != OK) {
254 return;
255 }
256 JvmtiUniquePtr<char[]> name_str = CopyString(env, entry.name_, &err);
257 if (err != OK) {
258 return;
259 }
260 JvmtiUniquePtr<char[]> sig_str = CopyString(env, entry.descriptor_, &err);
261 if (err != OK) {
262 return;
263 }
264 JvmtiUniquePtr<char[]> generic_sig_str = CopyString(env, entry.signature_, &err);
265 if (err != OK) {
266 return;
267 }
268 variables.push_back({
269 .start_location = static_cast<jlocation>(entry.start_address_),
270 .length = static_cast<jint>(entry.end_address_ - entry.start_address_),
271 .name = name_str.release(),
272 .signature = sig_str.release(),
273 .generic_signature = generic_sig_str.release(),
274 .slot = entry.reg_,
275 });
276 };
277
Mathieu Chartier808c7a52017-12-15 11:19:33 -0800278 if (!accessor.DecodeDebugLocalInfo(art_method->IsStatic(),
279 art_method->GetDexMethodIndex(),
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700280 visitor)) {
Alex Lightce68cc62017-07-26 10:30:38 -0700281 // Something went wrong with decoding the debug information. It might as well not be there.
282 return ERR(ABSENT_INFORMATION);
Alex Lightce68cc62017-07-26 10:30:38 -0700283 }
Mathieu Chartiere5afbf32018-09-12 17:51:54 -0700284 return release(entry_count_ptr, table_ptr);
Alex Lightce68cc62017-07-26 10:30:38 -0700285}
286
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000287jvmtiError MethodUtil::GetMaxLocals([[maybe_unused]] jvmtiEnv* env,
Andreas Gampef71832e2017-01-09 11:38:04 -0800288 jmethodID method,
289 jint* max_ptr) {
290 if (method == nullptr) {
291 return ERR(INVALID_METHODID);
292 }
293 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
294
295 if (art_method->IsNative()) {
296 return ERR(NATIVE_METHOD);
297 }
298
299 if (max_ptr == nullptr) {
300 return ERR(NULL_POINTER);
301 }
302
303 art::ScopedObjectAccess soa(art::Thread::Current());
304 if (art_method->IsProxyMethod() || art_method->IsAbstract()) {
305 // This isn't specified as an error case, so return 0.
306 *max_ptr = 0;
307 return ERR(NONE);
308 }
309
Nicolas Geoffray47171752020-08-31 15:03:20 +0100310 DCHECK(art_method->HasCodeItem());
311 DCHECK_NE(art_method->GetCodeItem(), nullptr);
David Sehr0225f8e2018-01-31 08:52:24 +0000312 *max_ptr = art_method->DexInstructionData().RegistersSize();
Andreas Gampef71832e2017-01-09 11:38:04 -0800313
314 return ERR(NONE);
315}
316
Andreas Gampe3c252f02016-10-27 18:25:17 -0700317jvmtiError MethodUtil::GetMethodName(jvmtiEnv* env,
318 jmethodID method,
319 char** name_ptr,
320 char** signature_ptr,
321 char** generic_ptr) {
322 art::ScopedObjectAccess soa(art::Thread::Current());
Andreas Gampe13b27842016-11-07 16:48:23 -0800323 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
Andreas Gampe3c252f02016-10-27 18:25:17 -0700324 art_method = art_method->GetInterfaceMethodIfProxy(art::kRuntimePointerSize);
325
Andreas Gampe54711412017-02-21 12:41:43 -0800326 JvmtiUniquePtr<char[]> name_copy;
Andreas Gampe3c252f02016-10-27 18:25:17 -0700327 if (name_ptr != nullptr) {
328 const char* method_name = art_method->GetName();
329 if (method_name == nullptr) {
330 method_name = "<error>";
331 }
Andreas Gampe54711412017-02-21 12:41:43 -0800332 jvmtiError ret;
333 name_copy = CopyString(env, method_name, &ret);
334 if (name_copy == nullptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700335 return ret;
336 }
Andreas Gampe54711412017-02-21 12:41:43 -0800337 *name_ptr = name_copy.get();
Andreas Gampe3c252f02016-10-27 18:25:17 -0700338 }
339
Andreas Gampe54711412017-02-21 12:41:43 -0800340 JvmtiUniquePtr<char[]> signature_copy;
Andreas Gampe3c252f02016-10-27 18:25:17 -0700341 if (signature_ptr != nullptr) {
342 const art::Signature sig = art_method->GetSignature();
343 std::string str = sig.ToString();
Andreas Gampe54711412017-02-21 12:41:43 -0800344 jvmtiError ret;
345 signature_copy = CopyString(env, str.c_str(), &ret);
346 if (signature_copy == nullptr) {
Andreas Gampe3c252f02016-10-27 18:25:17 -0700347 return ret;
348 }
Andreas Gampe54711412017-02-21 12:41:43 -0800349 *signature_ptr = signature_copy.get();
Andreas Gampe3c252f02016-10-27 18:25:17 -0700350 }
351
Andreas Gampe862bdd82016-11-18 13:31:13 -0800352 if (generic_ptr != nullptr) {
353 *generic_ptr = nullptr;
Andreas Gampe27dfa052017-02-16 15:04:36 -0800354 if (!art_method->GetDeclaringClass()->IsProxyClass()) {
Vladimir Markoacb906d2018-05-30 10:23:49 +0100355 art::ObjPtr<art::mirror::ObjectArray<art::mirror::String>> str_array =
Andreas Gampe27dfa052017-02-16 15:04:36 -0800356 art::annotations::GetSignatureAnnotationForMethod(art_method);
357 if (str_array != nullptr) {
358 std::ostringstream oss;
Alex Lighta9bbc082019-11-14 14:51:41 -0800359 for (auto str : str_array->Iterate()) {
360 oss << str->ToModifiedUtf8();
Andreas Gampe27dfa052017-02-16 15:04:36 -0800361 }
362 std::string output_string = oss.str();
Andreas Gampe54711412017-02-21 12:41:43 -0800363 jvmtiError ret;
364 JvmtiUniquePtr<char[]> generic_copy = CopyString(env, output_string.c_str(), &ret);
365 if (generic_copy == nullptr) {
Andreas Gampe27dfa052017-02-16 15:04:36 -0800366 return ret;
367 }
Andreas Gampe54711412017-02-21 12:41:43 -0800368 *generic_ptr = generic_copy.release();
Andreas Gampe27dfa052017-02-16 15:04:36 -0800369 } else if (soa.Self()->IsExceptionPending()) {
370 // TODO: Should we report an error here?
371 soa.Self()->ClearException();
372 }
373 }
Andreas Gampe862bdd82016-11-18 13:31:13 -0800374 }
Andreas Gampe3c252f02016-10-27 18:25:17 -0700375
376 // Everything is fine, release the buffers.
377 name_copy.release();
378 signature_copy.release();
379
380 return ERR(NONE);
381}
382
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000383jvmtiError MethodUtil::GetMethodDeclaringClass([[maybe_unused]] jvmtiEnv* env,
Andreas Gampe368a2082016-10-28 17:33:13 -0700384 jmethodID method,
385 jclass* declaring_class_ptr) {
386 if (declaring_class_ptr == nullptr) {
387 return ERR(NULL_POINTER);
388 }
389
Andreas Gampe13b27842016-11-07 16:48:23 -0800390 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
Andreas Gampe368a2082016-10-28 17:33:13 -0700391 // Note: No GetInterfaceMethodIfProxy, we want to actual class.
392
Andreas Gampe13b27842016-11-07 16:48:23 -0800393 art::ScopedObjectAccess soa(art::Thread::Current());
Vladimir Markod93e3742018-07-18 10:58:13 +0100394 art::ObjPtr<art::mirror::Class> klass = art_method->GetDeclaringClass();
Andreas Gampe368a2082016-10-28 17:33:13 -0700395 *declaring_class_ptr = soa.AddLocalReference<jclass>(klass);
396
397 return ERR(NONE);
398}
399
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000400jvmtiError MethodUtil::GetMethodLocation([[maybe_unused]] jvmtiEnv* env,
Andreas Gampef71832e2017-01-09 11:38:04 -0800401 jmethodID method,
402 jlocation* start_location_ptr,
403 jlocation* end_location_ptr) {
404 if (method == nullptr) {
405 return ERR(INVALID_METHODID);
406 }
407 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
408
409 if (art_method->IsNative()) {
410 return ERR(NATIVE_METHOD);
411 }
412
413 if (start_location_ptr == nullptr || end_location_ptr == nullptr) {
414 return ERR(NULL_POINTER);
415 }
416
417 art::ScopedObjectAccess soa(art::Thread::Current());
418 if (art_method->IsProxyMethod() || art_method->IsAbstract()) {
Andreas Gampee1f79b62017-04-12 21:11:28 -0700419 // This isn't specified as an error case, so return -1/-1 as the RI does.
420 *start_location_ptr = -1;
421 *end_location_ptr = -1;
Andreas Gampef71832e2017-01-09 11:38:04 -0800422 return ERR(NONE);
423 }
424
Nicolas Geoffray47171752020-08-31 15:03:20 +0100425 DCHECK(art_method->HasCodeItem());
426 DCHECK_NE(art_method->GetCodeItem(), nullptr);
Andreas Gampef71832e2017-01-09 11:38:04 -0800427 *start_location_ptr = 0;
Mathieu Chartier808c7a52017-12-15 11:19:33 -0800428 *end_location_ptr = art_method->DexInstructions().InsnsSizeInCodeUnits() - 1;
Andreas Gampef71832e2017-01-09 11:38:04 -0800429
430 return ERR(NONE);
431}
432
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000433jvmtiError MethodUtil::GetMethodModifiers([[maybe_unused]] jvmtiEnv* env,
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700434 jmethodID method,
435 jint* modifiers_ptr) {
436 if (modifiers_ptr == nullptr) {
437 return ERR(NULL_POINTER);
438 }
439
Andreas Gampe13b27842016-11-07 16:48:23 -0800440 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
Andreas Gampe36bcd4f2016-10-28 18:07:18 -0700441 uint32_t modifiers = art_method->GetAccessFlags();
442
443 // Note: Keep this code in sync with Executable.fixMethodFlags.
444 if ((modifiers & art::kAccAbstract) != 0) {
445 modifiers &= ~art::kAccNative;
446 }
447 modifiers &= ~art::kAccSynchronized;
448 if ((modifiers & art::kAccDeclaredSynchronized) != 0) {
449 modifiers |= art::kAccSynchronized;
450 }
451 modifiers &= art::kAccJavaFlagsMask;
452
453 *modifiers_ptr = modifiers;
454 return ERR(NONE);
455}
456
Andreas Gampeda3e5612016-12-13 19:00:53 -0800457jvmtiError MethodUtil::GetLineNumberTable(jvmtiEnv* env,
458 jmethodID method,
459 jint* entry_count_ptr,
460 jvmtiLineNumberEntry** table_ptr) {
461 if (method == nullptr) {
462 return ERR(NULL_POINTER);
463 }
464 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
465 DCHECK(!art_method->IsRuntimeMethod());
466
Mathieu Chartier31f4c9f2017-12-08 15:46:11 -0800467 art::CodeItemDebugInfoAccessor accessor;
Andreas Gampeda3e5612016-12-13 19:00:53 -0800468 const art::DexFile* dex_file;
469 {
470 art::ScopedObjectAccess soa(art::Thread::Current());
471
472 if (art_method->IsProxyMethod()) {
473 return ERR(ABSENT_INFORMATION);
474 }
475 if (art_method->IsNative()) {
476 return ERR(NATIVE_METHOD);
477 }
478 if (entry_count_ptr == nullptr || table_ptr == nullptr) {
479 return ERR(NULL_POINTER);
480 }
481
David Sehr0225f8e2018-01-31 08:52:24 +0000482 accessor = art::CodeItemDebugInfoAccessor(art_method->DexInstructionDebugInfo());
Andreas Gampeda3e5612016-12-13 19:00:53 -0800483 dex_file = art_method->GetDexFile();
Mathieu Chartier31f4c9f2017-12-08 15:46:11 -0800484 DCHECK(accessor.HasCodeItem()) << art_method->PrettyMethod() << " " << dex_file->GetLocation();
Andreas Gampeda3e5612016-12-13 19:00:53 -0800485 }
486
Mathieu Chartier3e2e1232018-09-11 12:35:30 -0700487 std::vector<jvmtiLineNumberEntry> context;
488 bool success = accessor.DecodeDebugPositionInfo([&](const art::DexFile::PositionInfo& entry) {
489 context.push_back({static_cast<jlocation>(entry.address_), static_cast<jint>(entry.line_)});
490 return false;
491 });
Andreas Gampeda3e5612016-12-13 19:00:53 -0800492 if (!success) {
493 return ERR(ABSENT_INFORMATION);
494 }
495
496 unsigned char* data;
497 jlong mem_size = context.size() * sizeof(jvmtiLineNumberEntry);
498 jvmtiError alloc_error = env->Allocate(mem_size, &data);
499 if (alloc_error != ERR(NONE)) {
500 return alloc_error;
501 }
502 *table_ptr = reinterpret_cast<jvmtiLineNumberEntry*>(data);
503 memcpy(*table_ptr, context.data(), mem_size);
504 *entry_count_ptr = static_cast<jint>(context.size());
505
506 return ERR(NONE);
507}
508
Andreas Gampefdeef522017-01-09 14:40:25 -0800509template <typename T>
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000510static jvmtiError IsMethodT([[maybe_unused]] jvmtiEnv* env,
Andreas Gampefdeef522017-01-09 14:40:25 -0800511 jmethodID method,
512 T test,
513 jboolean* is_t_ptr) {
514 if (method == nullptr) {
515 return ERR(INVALID_METHODID);
516 }
517 if (is_t_ptr == nullptr) {
518 return ERR(NULL_POINTER);
519 }
520
521 art::ArtMethod* art_method = art::jni::DecodeArtMethod(method);
522 *is_t_ptr = test(art_method) ? JNI_TRUE : JNI_FALSE;
523
524 return ERR(NONE);
525}
526
527jvmtiError MethodUtil::IsMethodNative(jvmtiEnv* env, jmethodID m, jboolean* is_native_ptr) {
528 auto test = [](art::ArtMethod* method) {
529 return method->IsNative();
530 };
531 return IsMethodT(env, m, test, is_native_ptr);
532}
533
534jvmtiError MethodUtil::IsMethodObsolete(jvmtiEnv* env, jmethodID m, jboolean* is_obsolete_ptr) {
535 auto test = [](art::ArtMethod* method) {
536 return method->IsObsolete();
537 };
538 return IsMethodT(env, m, test, is_obsolete_ptr);
539}
540
541jvmtiError MethodUtil::IsMethodSynthetic(jvmtiEnv* env, jmethodID m, jboolean* is_synthetic_ptr) {
542 auto test = [](art::ArtMethod* method) {
543 return method->IsSynthetic();
544 };
545 return IsMethodT(env, m, test, is_synthetic_ptr);
546}
547
Alex Lightbebd7bd2017-07-25 14:05:52 -0700548class CommonLocalVariableClosure : public art::Closure {
549 public:
Alex Lighte2ddce32019-05-22 17:08:35 +0000550 // The verifier isn't always able to be as specific as the local-variable-table. We can only get
551 // 32-bit, 64-bit or reference.
552 enum class VerifierPrimitiveType {
553 k32BitValue, // float, int, short, char, boolean, byte
554 k64BitValue, // double, long
555 kReferenceValue, // Object
556 kZeroValue, // null or zero constant. Might be either k32BitValue or kReferenceValue
557 };
Alex Lightbebd7bd2017-07-25 14:05:52 -0700558
Alex Lighte2ddce32019-05-22 17:08:35 +0000559 using SlotType = std::variant<art::Primitive::Type, VerifierPrimitiveType>;
560
561 CommonLocalVariableClosure(jvmtiEnv* jvmti, jint depth, jint slot)
562 : jvmti_(jvmti), result_(ERR(INTERNAL)), depth_(depth), slot_(slot) {}
563
564 void Run(art::Thread* self) override REQUIRES_SHARED(art::Locks::mutator_lock_) {
Alex Lightbebd7bd2017-07-25 14:05:52 -0700565 art::Locks::mutator_lock_->AssertSharedHeld(art::Thread::Current());
Alex Lighta4cdd362019-04-18 09:17:10 -0700566 bool needs_instrument;
567 {
568 art::ScopedAssertNoThreadSuspension sants("CommonLocalVariableClosure::Run");
569 std::unique_ptr<art::Context> context(art::Context::Create());
570 FindFrameAtDepthVisitor visitor(self, context.get(), depth_);
571 visitor.WalkStack();
572 if (!visitor.FoundFrame()) {
573 // Must have been a bad depth.
574 result_ = ERR(NO_MORE_FRAMES);
575 return;
576 }
577 art::ArtMethod* method = visitor.GetMethod();
578 // Native and 'art' proxy methods don't have registers.
579 if (method->IsNative() || method->IsProxyMethod()) {
580 // TODO It might be useful to fake up support for get at least on proxy frames.
581 result_ = ERR(OPAQUE_FRAME);
582 return;
Alex Light6045bc22019-05-22 08:33:30 -0700583 } else if (slot_ >= method->DexInstructionData().RegistersSize() || slot_ < 0) {
Alex Lighta4cdd362019-04-18 09:17:10 -0700584 result_ = ERR(INVALID_SLOT);
585 return;
586 }
587 needs_instrument = !visitor.IsShadowFrame();
588 uint32_t pc = visitor.GetDexPc(/*abort_on_failure=*/false);
589 if (pc == art::dex::kDexNoIndex) {
590 // Cannot figure out current PC.
591 result_ = ERR(OPAQUE_FRAME);
592 return;
593 }
594 std::string descriptor;
Alex Lighte2ddce32019-05-22 17:08:35 +0000595 SlotType slot_type{ art::Primitive::kPrimVoid };
Alex Lighta4cdd362019-04-18 09:17:10 -0700596 jvmtiError err = GetSlotType(method, pc, &descriptor, &slot_type);
597 if (err != OK) {
598 result_ = err;
599 return;
600 }
Alex Lightbebd7bd2017-07-25 14:05:52 -0700601
Alex Lighta4cdd362019-04-18 09:17:10 -0700602 err = GetTypeError(method, slot_type, descriptor);
603 if (err != OK) {
604 result_ = err;
605 return;
606 }
607 result_ = Execute(method, visitor);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700608 }
Alex Light0a5ec3d2017-07-25 16:50:26 -0700609 if (needs_instrument) {
Alex Lighta4cdd362019-04-18 09:17:10 -0700610 DeoptManager::Get()->DeoptimizeThread(self);
Alex Light0a5ec3d2017-07-25 16:50:26 -0700611 }
Alex Lightbebd7bd2017-07-25 14:05:52 -0700612 }
613
Alex Light318afe62018-03-22 16:50:10 -0700614 virtual jvmtiError GetResult() {
Alex Lightbebd7bd2017-07-25 14:05:52 -0700615 return result_;
616 }
617
618 protected:
619 virtual jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor)
Alex Light318afe62018-03-22 16:50:10 -0700620 REQUIRES_SHARED(art::Locks::mutator_lock_) = 0;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700621 virtual jvmtiError GetTypeError(art::ArtMethod* method,
Alex Lighte2ddce32019-05-22 17:08:35 +0000622 SlotType type,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700623 const std::string& descriptor)
Alex Light318afe62018-03-22 16:50:10 -0700624 REQUIRES_SHARED(art::Locks::mutator_lock_) = 0;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700625
626 jvmtiError GetSlotType(art::ArtMethod* method,
627 uint32_t dex_pc,
628 /*out*/std::string* descriptor,
Alex Lighte2ddce32019-05-22 17:08:35 +0000629 /*out*/SlotType* type)
630 REQUIRES_SHARED(art::Locks::mutator_lock_);
631
632 jvmtiError InferSlotTypeFromVerifier(art::ArtMethod* method,
633 uint32_t dex_pc,
634 /*out*/ std::string* descriptor,
635 /*out*/ SlotType* type)
636 REQUIRES_SHARED(art::Locks::mutator_lock_) {
Nicolas Geoffraya6400982023-06-14 10:25:46 +0100637 art::StackHandleScope<2> hs(art::Thread::Current());
638 art::Handle<art::mirror::DexCache> dex_cache(hs.NewHandle(method->GetDexCache()));
639 art::Handle<art::mirror::ClassLoader> class_loader(hs.NewHandle(method->GetClassLoader()));
Alex Lighte2ddce32019-05-22 17:08:35 +0000640 std::unique_ptr<art::verifier::MethodVerifier> verifier(
641 art::verifier::MethodVerifier::CalculateVerificationInfo(
Nicolas Geoffray2cb25272021-07-15 14:24:29 +0100642 art::Thread::Current(),
Alex Lighte2ddce32019-05-22 17:08:35 +0000643 method,
Nicolas Geoffraya6400982023-06-14 10:25:46 +0100644 dex_cache,
645 class_loader,
Nicolas Geoffray2cb25272021-07-15 14:24:29 +0100646 dex_pc));
Alex Lighte2ddce32019-05-22 17:08:35 +0000647 if (verifier == nullptr) {
648 JVMTI_LOG(WARNING, jvmti_) << "Unable to extract verification information from "
649 << method->PrettyMethod() << " due to hard verification failures! "
650 << "How did this method even get loaded!";
651 return ERR(INTERNAL);
652 }
653 art::verifier::RegisterLine* line = verifier->GetRegLine(dex_pc);
654 if (line == nullptr) {
655 JVMTI_LOG(WARNING, jvmti_) << "Unable to determine register line at dex-pc " << dex_pc
656 << " for method " << method->PrettyMethod();
Mathieu Chartier31f4c9f2017-12-08 15:46:11 -0800657 return ERR(OPAQUE_FRAME);
658 }
Alex Lighte2ddce32019-05-22 17:08:35 +0000659 const art::verifier::RegType& rt = line->GetRegisterType(verifier.get(), slot_);
660 if (rt.IsUndefined()) {
661 return ERR(INVALID_SLOT);
662 } else if (rt.IsNonZeroReferenceTypes() || rt.IsNull()) {
663 *descriptor = (rt.HasClass() ? rt.GetDescriptor() : "Ljava/lang/Object;");
664 *type = VerifierPrimitiveType::kReferenceValue;
665 return OK;
666 } else if (rt.IsZero()) {
667 *descriptor = "I";
668 *type = VerifierPrimitiveType::kZeroValue;
669 return OK;
670 } else if (rt.IsCategory1Types()) {
671 *descriptor = "I";
672 *type = VerifierPrimitiveType::k32BitValue;
673 return OK;
674 } else if (rt.IsCategory2Types() && rt.IsLowHalf()) {
675 *descriptor = "J";
676 *type = VerifierPrimitiveType::k64BitValue;
677 return OK;
678 } else {
679 // The slot doesn't have a type. Must not be valid here.
David Srbecky99cbfb52019-05-22 11:39:45 +0000680 return ERR(INVALID_SLOT);
Alex Lighte48fd0b2019-05-20 10:04:44 -0700681 }
682 }
683
Alex Lighte2ddce32019-05-22 17:08:35 +0000684 constexpr VerifierPrimitiveType SquashType(SlotType t) {
685 if (std::holds_alternative<art::Primitive::Type>(t)) {
686 switch (std::get<art::Primitive::Type>(t)) {
687 // 32-bit primitives
688 case art::Primitive::kPrimByte:
689 case art::Primitive::kPrimChar:
690 case art::Primitive::kPrimInt:
691 case art::Primitive::kPrimShort:
692 case art::Primitive::kPrimBoolean:
693 case art::Primitive::kPrimFloat:
694 return VerifierPrimitiveType::k32BitValue;
695 // 64-bit primitives
696 case art::Primitive::kPrimLong:
697 case art::Primitive::kPrimDouble:
698 return VerifierPrimitiveType::k64BitValue;
699 case art::Primitive::kPrimNot:
700 return VerifierPrimitiveType::kReferenceValue;
701 case art::Primitive::kPrimVoid:
702 LOG(FATAL) << "Got kPrimVoid";
703 UNREACHABLE();
704 }
705 } else {
706 return std::get<VerifierPrimitiveType>(t);
707 }
708 }
709
710 jvmtiEnv* jvmti_;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700711 jvmtiError result_;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700712 jint depth_;
713 jint slot_;
Alex Lighte2ddce32019-05-22 17:08:35 +0000714
715 private:
716 DISALLOW_COPY_AND_ASSIGN(CommonLocalVariableClosure);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700717};
718
Alex Lighte2ddce32019-05-22 17:08:35 +0000719std::ostream& operator<<(std::ostream& os,
720 CommonLocalVariableClosure::VerifierPrimitiveType state) {
721 switch (state) {
722 case CommonLocalVariableClosure::VerifierPrimitiveType::k32BitValue:
723 return os << "32BitValue";
724 case CommonLocalVariableClosure::VerifierPrimitiveType::k64BitValue:
725 return os << "64BitValue";
726 case CommonLocalVariableClosure::VerifierPrimitiveType::kReferenceValue:
727 return os << "ReferenceValue";
728 case CommonLocalVariableClosure::VerifierPrimitiveType::kZeroValue:
729 return os << "ZeroValue";
730 }
731}
732
733std::ostream& operator<<(std::ostream& os, CommonLocalVariableClosure::SlotType state) {
734 if (std::holds_alternative<art::Primitive::Type>(state)) {
735 return os << "Primitive::Type[" << std::get<art::Primitive::Type>(state) << "]";
736 } else {
737 return os << "VerifierPrimitiveType["
738 << std::get<CommonLocalVariableClosure::VerifierPrimitiveType>(state) << "]";
739 }
740}
741
742jvmtiError CommonLocalVariableClosure::GetSlotType(art::ArtMethod* method,
743 uint32_t dex_pc,
744 /*out*/ std::string* descriptor,
745 /*out*/ SlotType* type) {
746 const art::DexFile* dex_file = method->GetDexFile();
747 if (dex_file == nullptr) {
748 return ERR(OPAQUE_FRAME);
749 }
750 art::CodeItemDebugInfoAccessor accessor(method->DexInstructionDebugInfo());
751 if (!accessor.HasCodeItem()) {
752 return ERR(OPAQUE_FRAME);
753 }
754 bool found = false;
755 *type = art::Primitive::kPrimVoid;
756 descriptor->clear();
757 auto visitor = [&](const art::DexFile::LocalInfo& entry) {
758 if (!found && entry.start_address_ <= dex_pc && entry.end_address_ > dex_pc &&
759 entry.reg_ == slot_) {
760 found = true;
761 *type = art::Primitive::GetType(entry.descriptor_[0]);
762 *descriptor = entry.descriptor_;
763 }
764 };
765 if (!accessor.DecodeDebugLocalInfo(method->IsStatic(), method->GetDexMethodIndex(), visitor) ||
766 !found) {
767 // Something went wrong with decoding the debug information. It might as well not be there.
768 // Try to find the type with the verifier.
769 // TODO This is very slow.
770 return InferSlotTypeFromVerifier(method, dex_pc, descriptor, type);
771 } else if (art::kIsDebugBuild) {
772 std::string type_unused;
773 SlotType verifier_type{ art::Primitive::kPrimVoid };
774 DCHECK_EQ(InferSlotTypeFromVerifier(method, dex_pc, &type_unused, &verifier_type), OK)
775 << method->PrettyMethod() << " failed to verify!";
776 if (*type == SlotType{ art::Primitive::kPrimNot }) {
777 // We cannot distinguish between a constant 0 and a null reference so we return that it is a
778 // 32bit value (Due to the way references are read by the interpreter this is safe even if
779 // it's modified, the value will remain null). This is not ideal since it prevents modifying
780 // locals in some circumstances but generally is not a big deal (since one can just modify it
781 // later once it's been determined to be a reference by a later instruction).
782 DCHECK(verifier_type == SlotType { VerifierPrimitiveType::kZeroValue } ||
783 verifier_type == SlotType { VerifierPrimitiveType::kReferenceValue })
784 << "Verifier disagrees on type of slot! debug: " << *type
785 << " verifier: " << verifier_type;
786 } else if (verifier_type == SlotType { VerifierPrimitiveType::kZeroValue }) {
787 DCHECK(VerifierPrimitiveType::k32BitValue == SquashType(*type) ||
788 VerifierPrimitiveType::kReferenceValue == SquashType(*type))
789 << "Verifier disagrees on type of slot! debug: " << *type
790 << " verifier: " << verifier_type;
791 } else {
792 DCHECK_EQ(SquashType(verifier_type), SquashType(*type))
793 << "Verifier disagrees on type of slot! debug: " << *type
794 << " verifier: " << verifier_type;
795 }
796 }
797 return OK;
798}
799
Alex Lightbebd7bd2017-07-25 14:05:52 -0700800class GetLocalVariableClosure : public CommonLocalVariableClosure {
801 public:
Alex Lighte2ddce32019-05-22 17:08:35 +0000802 GetLocalVariableClosure(jvmtiEnv* jvmti,
803 jint depth,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700804 jint slot,
805 art::Primitive::Type type,
806 jvalue* val)
Alex Lighte2ddce32019-05-22 17:08:35 +0000807 : CommonLocalVariableClosure(jvmti, depth, slot),
Alex Light318afe62018-03-22 16:50:10 -0700808 type_(type),
809 val_(val),
810 obj_val_(nullptr) {}
811
Andreas Gampefa6a1b02018-09-07 08:11:55 -0700812 jvmtiError GetResult() override REQUIRES_SHARED(art::Locks::mutator_lock_) {
Alex Light318afe62018-03-22 16:50:10 -0700813 if (result_ == OK && type_ == art::Primitive::kPrimNot) {
Alex Lighta4cdd362019-04-18 09:17:10 -0700814 if (obj_val_ == nullptr) {
815 val_->l = nullptr;
816 } else {
817 art::JNIEnvExt* jni = art::Thread::Current()->GetJniEnv();
818 val_->l = static_cast<JNIEnv*>(jni)->NewLocalRef(obj_val_);
819 jni->DeleteGlobalRef(obj_val_);
820 obj_val_ = nullptr;
821 }
Alex Light318afe62018-03-22 16:50:10 -0700822 }
823 return CommonLocalVariableClosure::GetResult();
824 }
Alex Lightbebd7bd2017-07-25 14:05:52 -0700825
826 protected:
Alex Lighte2ddce32019-05-22 17:08:35 +0000827 jvmtiError
828 GetTypeError(art::ArtMethod* method, SlotType slot_type, const std::string& descriptor) override
829 REQUIRES_SHARED(art::Locks::mutator_lock_) {
830 jvmtiError res = GetTypeErrorInner(method, slot_type, descriptor);
831 if (res == ERR(TYPE_MISMATCH)) {
832 JVMTI_LOG(INFO, jvmti_) << "Unable to Get local variable in slot " << slot_ << ". Expected"
833 << " slot to be of type compatible with " << SlotType { type_ }
834 << " but slot is " << slot_type;
835 } else if (res != OK) {
836 JVMTI_LOG(INFO, jvmti_) << "Unable to get local variable in slot " << slot_ << ".";
837 }
838 return res;
839 }
840
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000841 jvmtiError GetTypeErrorInner([[maybe_unused]] art::ArtMethod* method,
Alex Lighte2ddce32019-05-22 17:08:35 +0000842 SlotType slot_type,
Stefano Cianciulli78f3c722023-05-16 10:32:54 +0000843 [[maybe_unused]] const std::string& descriptor)
Alex Lighte2ddce32019-05-22 17:08:35 +0000844 REQUIRES_SHARED(art::Locks::mutator_lock_) {
845 switch (type_) {
David Srbecky99cbfb52019-05-22 11:39:45 +0000846 case art::Primitive::kPrimFloat:
Alex Lighte2ddce32019-05-22 17:08:35 +0000847 case art::Primitive::kPrimInt: {
848 if (std::holds_alternative<VerifierPrimitiveType>(slot_type)) {
849 return (slot_type == SlotType { VerifierPrimitiveType::k32BitValue } ||
850 slot_type == SlotType { VerifierPrimitiveType::kZeroValue })
851 ? OK
852 : ERR(TYPE_MISMATCH);
853 } else if (type_ == art::Primitive::kPrimFloat ||
854 slot_type == SlotType { art::Primitive::kPrimFloat }) {
855 // Check that we are actually a float.
856 return (SlotType { type_ } == slot_type) ? OK : ERR(TYPE_MISMATCH);
857 } else {
858 // Some smaller int type.
859 return SquashType(slot_type) == SquashType(SlotType { type_ }) ? OK : ERR(TYPE_MISMATCH);
860 }
861 }
862 case art::Primitive::kPrimLong:
863 case art::Primitive::kPrimDouble: {
864 // todo
865 if (std::holds_alternative<VerifierPrimitiveType>(slot_type)) {
866 return (slot_type == SlotType { VerifierPrimitiveType::k64BitValue })
867 ? OK
868 : ERR(TYPE_MISMATCH);
869 } else {
870 return slot_type == SlotType { type_ } ? OK : ERR(TYPE_MISMATCH);
871 }
872 }
David Srbecky99cbfb52019-05-22 11:39:45 +0000873 case art::Primitive::kPrimNot:
Alex Lighte2ddce32019-05-22 17:08:35 +0000874 return (SquashType(slot_type) == VerifierPrimitiveType::kReferenceValue ||
875 SquashType(slot_type) == VerifierPrimitiveType::kZeroValue)
876 ? OK
877 : ERR(TYPE_MISMATCH);
878 case art::Primitive::kPrimShort:
879 case art::Primitive::kPrimChar:
880 case art::Primitive::kPrimByte:
881 case art::Primitive::kPrimBoolean:
Alex Lightbebd7bd2017-07-25 14:05:52 -0700882 case art::Primitive::kPrimVoid:
883 LOG(FATAL) << "Unexpected primitive type " << slot_type;
884 UNREACHABLE();
885 }
886 }
887
888 jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +0100889 override REQUIRES_SHARED(art::Locks::mutator_lock_) {
Alex Lightbebd7bd2017-07-25 14:05:52 -0700890 switch (type_) {
891 case art::Primitive::kPrimNot: {
892 uint32_t ptr_val;
893 if (!visitor.GetVReg(method,
894 static_cast<uint16_t>(slot_),
895 art::kReferenceVReg,
896 &ptr_val)) {
897 return ERR(OPAQUE_FRAME);
898 }
Alex Lighta4cdd362019-04-18 09:17:10 -0700899 art::ObjPtr<art::mirror::Object> obj(reinterpret_cast<art::mirror::Object*>(ptr_val));
Alex Lightb096c912019-09-25 13:33:06 -0700900 obj_val_ = art::Runtime::Current()->GetJavaVM()->AddGlobalRef(art::Thread::Current(), obj);
Alex Lightbebd7bd2017-07-25 14:05:52 -0700901 break;
902 }
903 case art::Primitive::kPrimInt:
904 case art::Primitive::kPrimFloat: {
905 if (!visitor.GetVReg(method,
906 static_cast<uint16_t>(slot_),
907 type_ == art::Primitive::kPrimFloat ? art::kFloatVReg : art::kIntVReg,
908 reinterpret_cast<uint32_t*>(&val_->i))) {
909 return ERR(OPAQUE_FRAME);
910 }
911 break;
912 }
913 case art::Primitive::kPrimDouble:
914 case art::Primitive::kPrimLong: {
915 auto lo_type = type_ == art::Primitive::kPrimLong ? art::kLongLoVReg : art::kDoubleLoVReg;
916 auto high_type = type_ == art::Primitive::kPrimLong ? art::kLongHiVReg : art::kDoubleHiVReg;
917 if (!visitor.GetVRegPair(method,
918 static_cast<uint16_t>(slot_),
919 lo_type,
920 high_type,
921 reinterpret_cast<uint64_t*>(&val_->j))) {
922 return ERR(OPAQUE_FRAME);
923 }
924 break;
925 }
926 default: {
927 LOG(FATAL) << "unexpected register type " << type_;
928 UNREACHABLE();
929 }
930 }
931 return OK;
932 }
933
934 private:
935 art::Primitive::Type type_;
936 jvalue* val_;
Alex Lighta4cdd362019-04-18 09:17:10 -0700937 // A global reference to the return value. We use the global reference to safely transfer the
938 // value between threads.
939 jobject obj_val_;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700940};
941
Alex Lighte2ddce32019-05-22 17:08:35 +0000942jvmtiError MethodUtil::GetLocalVariableGeneric(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700943 jthread thread,
944 jint depth,
945 jint slot,
946 art::Primitive::Type type,
947 jvalue* val) {
948 if (depth < 0) {
949 return ERR(ILLEGAL_ARGUMENT);
950 }
951 art::Thread* self = art::Thread::Current();
952 art::ScopedObjectAccess soa(self);
Alex Lightb1e31a82017-10-04 16:57:36 -0700953 art::Locks::thread_list_lock_->ExclusiveLock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -0700954 art::Thread* target = nullptr;
955 jvmtiError err = ERR(INTERNAL);
956 if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) {
Alex Lightb1e31a82017-10-04 16:57:36 -0700957 art::Locks::thread_list_lock_->ExclusiveUnlock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -0700958 return err;
Alex Lightbebd7bd2017-07-25 14:05:52 -0700959 }
Alex Lighte2ddce32019-05-22 17:08:35 +0000960 GetLocalVariableClosure c(env, depth, slot, type, val);
Alex Lighta4cdd362019-04-18 09:17:10 -0700961 // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution.
962 if (!target->RequestSynchronousCheckpoint(&c)) {
Alex Lightbebd7bd2017-07-25 14:05:52 -0700963 return ERR(THREAD_NOT_ALIVE);
964 } else {
965 return c.GetResult();
966 }
967}
968
969class SetLocalVariableClosure : public CommonLocalVariableClosure {
970 public:
Alex Lighte2ddce32019-05-22 17:08:35 +0000971 SetLocalVariableClosure(jvmtiEnv* jvmti,
972 art::Thread* caller,
Alex Lightbebd7bd2017-07-25 14:05:52 -0700973 jint depth,
974 jint slot,
975 art::Primitive::Type type,
976 jvalue val)
Alex Lighte2ddce32019-05-22 17:08:35 +0000977 : CommonLocalVariableClosure(jvmti, depth, slot), caller_(caller), type_(type), val_(val) {}
Alex Lightbebd7bd2017-07-25 14:05:52 -0700978
979 protected:
Alex Lighte2ddce32019-05-22 17:08:35 +0000980 jvmtiError
981 GetTypeError(art::ArtMethod* method, SlotType slot_type, const std::string& descriptor) override
982 REQUIRES_SHARED(art::Locks::mutator_lock_) {
983 jvmtiError res = GetTypeErrorInner(method, slot_type, descriptor);
984 if (res != OK) {
985 if (res == ERR(TYPE_MISMATCH)) {
986 std::ostringstream desc_exp;
987 std::ostringstream desc_set;
988 if (type_ == art::Primitive::kPrimNot) {
989 desc_exp << " (type: " << descriptor << ")";
990 art::ObjPtr<art::mirror::Object> new_val(art::Thread::Current()->DecodeJObject(val_.l));
991 desc_set << " (type: "
992 << (new_val.IsNull() ? "NULL" : new_val->GetClass()->PrettyDescriptor()) << ")";
993 }
994 JVMTI_LOG(INFO, jvmti_) << "Unable to Set local variable in slot " << slot_ << ". Expected"
995 << " slot to be of type compatible with " << SlotType{ type_ }
996 << desc_set.str() << " but slot is " << slot_type << desc_exp.str();
997 } else {
998 JVMTI_LOG(INFO, jvmti_) << "Unable to set local variable in slot " << slot_ << ". "
999 << err_.str();
1000 }
1001 }
1002 return res;
1003 }
1004
1005 jvmtiError
1006 GetTypeErrorInner(art::ArtMethod* method, SlotType slot_type, const std::string& descriptor)
1007 REQUIRES_SHARED(art::Locks::mutator_lock_) {
1008 switch (SquashType(SlotType{ type_ })) {
1009 case VerifierPrimitiveType::k32BitValue: {
1010 if (slot_type == SlotType{ VerifierPrimitiveType::kZeroValue }) {
1011 if (val_.i == 0) {
1012 return OK;
1013 } else {
1014 err_ << "Cannot determine if slot " << slot_ << " is a null reference or 32bit "
1015 << "constant. Cannot allow writing to slot.";
1016 return ERR(INTERNAL);
1017 }
1018 } else if (SquashType(slot_type) != VerifierPrimitiveType::k32BitValue) {
1019 return ERR(TYPE_MISMATCH);
1020 } else if (slot_type == SlotType { VerifierPrimitiveType::k32BitValue } ||
1021 slot_type == SlotType { type_ }) {
1022 return OK;
1023 } else if (type_ == art::Primitive::kPrimFloat ||
1024 slot_type == SlotType { art::Primitive::kPrimFloat }) {
1025 // we should have hit the get == type_ above
1026 return ERR(TYPE_MISMATCH);
1027 } else {
1028 // Some smaller type then int.
1029 return OK;
1030 }
1031 }
1032 case VerifierPrimitiveType::k64BitValue: {
1033 if (slot_type == SlotType { VerifierPrimitiveType::k64BitValue } ||
1034 slot_type == SlotType { type_ }) {
1035 return OK;
1036 } else {
1037 return ERR(TYPE_MISMATCH);
1038 }
1039 }
1040 case VerifierPrimitiveType::kReferenceValue: {
1041 if (SquashType(slot_type) != VerifierPrimitiveType::kReferenceValue &&
1042 SquashType(slot_type) != VerifierPrimitiveType::kZeroValue) {
Alex Lightbebd7bd2017-07-25 14:05:52 -07001043 return ERR(TYPE_MISMATCH);
1044 } else if (val_.l == nullptr) {
1045 return OK;
Alex Lighte2ddce32019-05-22 17:08:35 +00001046 } else if (slot_type == SlotType { VerifierPrimitiveType::kZeroValue }) {
1047 err_ << "Cannot determine if slot " << slot_ << " is a null "
1048 << "reference or 32bit constant. Cannot allow writing to slot.";
1049 return ERR(INTERNAL);
Alex Lightbebd7bd2017-07-25 14:05:52 -07001050 } else {
1051 art::ClassLinker* cl = art::Runtime::Current()->GetClassLinker();
Alex Lighte2ddce32019-05-22 17:08:35 +00001052 art::ObjPtr<art::mirror::Class> set_class = caller_->DecodeJObject(val_.l)->GetClass();
Alex Lightbebd7bd2017-07-25 14:05:52 -07001053 art::ObjPtr<art::mirror::ClassLoader> loader =
1054 method->GetDeclaringClass()->GetClassLoader();
1055 art::ObjPtr<art::mirror::Class> slot_class =
1056 cl->LookupClass(caller_, descriptor.c_str(), loader);
Alex Lighte2ddce32019-05-22 17:08:35 +00001057 DCHECK(!slot_class.IsNull()) << descriptor << " slot: " << slot_type;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001058 return slot_class->IsAssignableFrom(set_class) ? OK : ERR(TYPE_MISMATCH);
1059 }
1060 }
Alex Lighte2ddce32019-05-22 17:08:35 +00001061 case VerifierPrimitiveType::kZeroValue: {
1062 LOG(FATAL) << "Illegal result from SquashType of art::Primitive::Type " << type_;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001063 UNREACHABLE();
Alex Lighte2ddce32019-05-22 17:08:35 +00001064 }
Alex Lightbebd7bd2017-07-25 14:05:52 -07001065 }
1066 }
1067
1068 jvmtiError Execute(art::ArtMethod* method, art::StackVisitor& visitor)
Roland Levillainbbc6e7e2018-08-24 16:58:47 +01001069 override REQUIRES_SHARED(art::Locks::mutator_lock_) {
Alex Lightbebd7bd2017-07-25 14:05:52 -07001070 switch (type_) {
1071 case art::Primitive::kPrimNot: {
Vladimir Marko439d1262019-04-12 14:45:07 +01001072 if (!visitor.SetVRegReference(method,
1073 static_cast<uint16_t>(slot_),
1074 caller_->DecodeJObject(val_.l))) {
Alex Lightbebd7bd2017-07-25 14:05:52 -07001075 return ERR(OPAQUE_FRAME);
1076 }
1077 break;
1078 }
1079 case art::Primitive::kPrimInt:
1080 case art::Primitive::kPrimFloat: {
1081 if (!visitor.SetVReg(method,
1082 static_cast<uint16_t>(slot_),
1083 static_cast<uint32_t>(val_.i),
1084 type_ == art::Primitive::kPrimFloat ? art::kFloatVReg
1085 : art::kIntVReg)) {
1086 return ERR(OPAQUE_FRAME);
1087 }
1088 break;
1089 }
1090 case art::Primitive::kPrimDouble:
1091 case art::Primitive::kPrimLong: {
1092 auto lo_type = type_ == art::Primitive::kPrimLong ? art::kLongLoVReg : art::kDoubleLoVReg;
1093 auto high_type = type_ == art::Primitive::kPrimLong ? art::kLongHiVReg : art::kDoubleHiVReg;
1094 if (!visitor.SetVRegPair(method,
1095 static_cast<uint16_t>(slot_),
1096 static_cast<uint64_t>(val_.j),
1097 lo_type,
1098 high_type)) {
1099 return ERR(OPAQUE_FRAME);
1100 }
1101 break;
1102 }
1103 default: {
1104 LOG(FATAL) << "unexpected register type " << type_;
1105 UNREACHABLE();
1106 }
1107 }
1108 return OK;
1109 }
1110
1111 private:
Alex Light318afe62018-03-22 16:50:10 -07001112 art::Thread* caller_;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001113 art::Primitive::Type type_;
1114 jvalue val_;
Alex Lighte2ddce32019-05-22 17:08:35 +00001115 std::ostringstream err_;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001116};
1117
Alex Lighte2ddce32019-05-22 17:08:35 +00001118jvmtiError MethodUtil::SetLocalVariableGeneric(jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -07001119 jthread thread,
1120 jint depth,
1121 jint slot,
1122 art::Primitive::Type type,
1123 jvalue val) {
1124 if (depth < 0) {
1125 return ERR(ILLEGAL_ARGUMENT);
1126 }
Alex Lightf2858632018-04-02 11:28:50 -07001127 // Make sure that we know not to do any OSR anymore.
1128 // TODO We should really keep track of this at the Frame granularity.
1129 DeoptManager::Get()->SetLocalsUpdated();
Alex Lightbebd7bd2017-07-25 14:05:52 -07001130 art::Thread* self = art::Thread::Current();
1131 art::ScopedObjectAccess soa(self);
Alex Lightb1e31a82017-10-04 16:57:36 -07001132 art::Locks::thread_list_lock_->ExclusiveLock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -07001133 art::Thread* target = nullptr;
1134 jvmtiError err = ERR(INTERNAL);
1135 if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) {
Alex Lightb1e31a82017-10-04 16:57:36 -07001136 art::Locks::thread_list_lock_->ExclusiveUnlock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -07001137 return err;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001138 }
Alex Lighte2ddce32019-05-22 17:08:35 +00001139 SetLocalVariableClosure c(env, self, depth, slot, type, val);
Alex Lightb1e31a82017-10-04 16:57:36 -07001140 // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution.
Alex Light318afe62018-03-22 16:50:10 -07001141 if (!target->RequestSynchronousCheckpoint(&c)) {
Alex Lightbebd7bd2017-07-25 14:05:52 -07001142 return ERR(THREAD_NOT_ALIVE);
1143 } else {
1144 return c.GetResult();
1145 }
1146}
1147
1148class GetLocalInstanceClosure : public art::Closure {
1149 public:
Alex Light318afe62018-03-22 16:50:10 -07001150 explicit GetLocalInstanceClosure(jint depth)
Alex Lightbebd7bd2017-07-25 14:05:52 -07001151 : result_(ERR(INTERNAL)),
Alex Lightbebd7bd2017-07-25 14:05:52 -07001152 depth_(depth),
Alex Light318afe62018-03-22 16:50:10 -07001153 val_(nullptr) {}
Alex Lightbebd7bd2017-07-25 14:05:52 -07001154
Roland Levillainbbc6e7e2018-08-24 16:58:47 +01001155 void Run(art::Thread* self) override REQUIRES(art::Locks::mutator_lock_) {
Alex Light318afe62018-03-22 16:50:10 -07001156 art::ScopedAssertNoThreadSuspension sants("GetLocalInstanceClosure::Run");
Alex Lightbebd7bd2017-07-25 14:05:52 -07001157 art::Locks::mutator_lock_->AssertSharedHeld(art::Thread::Current());
1158 std::unique_ptr<art::Context> context(art::Context::Create());
1159 FindFrameAtDepthVisitor visitor(self, context.get(), depth_);
1160 visitor.WalkStack();
1161 if (!visitor.FoundFrame()) {
1162 // Must have been a bad depth.
1163 result_ = ERR(NO_MORE_FRAMES);
1164 return;
1165 }
Alex Lightbebd7bd2017-07-25 14:05:52 -07001166 result_ = OK;
Alex Light318afe62018-03-22 16:50:10 -07001167 val_ = art::GcRoot<art::mirror::Object>(visitor.GetThisObject());
Alex Lightbebd7bd2017-07-25 14:05:52 -07001168 }
1169
Alex Light318afe62018-03-22 16:50:10 -07001170 jvmtiError GetResult(jobject* data_out) REQUIRES_SHARED(art::Locks::mutator_lock_) {
1171 if (result_ == OK) {
1172 *data_out = val_.IsNull()
1173 ? nullptr
1174 : art::Thread::Current()->GetJniEnv()->AddLocalReference<jobject>(val_.Read());
1175 }
Alex Lightbebd7bd2017-07-25 14:05:52 -07001176 return result_;
1177 }
1178
1179 private:
1180 jvmtiError result_;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001181 jint depth_;
Alex Light318afe62018-03-22 16:50:10 -07001182 art::GcRoot<art::mirror::Object> val_;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001183};
1184
Stefano Cianciulli78f3c722023-05-16 10:32:54 +00001185jvmtiError MethodUtil::GetLocalInstance([[maybe_unused]] jvmtiEnv* env,
Alex Lightbebd7bd2017-07-25 14:05:52 -07001186 jthread thread,
1187 jint depth,
1188 jobject* data) {
1189 if (depth < 0) {
1190 return ERR(ILLEGAL_ARGUMENT);
1191 }
1192 art::Thread* self = art::Thread::Current();
1193 art::ScopedObjectAccess soa(self);
Alex Lightb1e31a82017-10-04 16:57:36 -07001194 art::Locks::thread_list_lock_->ExclusiveLock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -07001195 art::Thread* target = nullptr;
1196 jvmtiError err = ERR(INTERNAL);
1197 if (!ThreadUtil::GetAliveNativeThread(thread, soa, &target, &err)) {
Alex Lightb1e31a82017-10-04 16:57:36 -07001198 art::Locks::thread_list_lock_->ExclusiveUnlock(self);
Alex Light7ddc23d2017-09-22 15:33:41 -07001199 return err;
Alex Lightbebd7bd2017-07-25 14:05:52 -07001200 }
Alex Light318afe62018-03-22 16:50:10 -07001201 art::ScopedAssertNoThreadSuspension sants("Performing GetLocalInstance");
1202 GetLocalInstanceClosure c(depth);
1203 // RequestSynchronousCheckpoint releases the thread_list_lock_ as a part of its execution. We
1204 // need to avoid suspending as we wait for the checkpoint to occur since we are (potentially)
1205 // transfering a GcRoot across threads.
1206 if (!target->RequestSynchronousCheckpoint(&c, art::ThreadState::kRunnable)) {
Alex Lightbebd7bd2017-07-25 14:05:52 -07001207 return ERR(THREAD_NOT_ALIVE);
1208 } else {
Alex Light318afe62018-03-22 16:50:10 -07001209 return c.GetResult(data);
Alex Lightbebd7bd2017-07-25 14:05:52 -07001210 }
1211}
1212
1213#define FOR_JVMTI_JVALUE_TYPES(fn) \
1214 fn(jint, art::Primitive::kPrimInt, i) \
1215 fn(jlong, art::Primitive::kPrimLong, j) \
1216 fn(jfloat, art::Primitive::kPrimFloat, f) \
1217 fn(jdouble, art::Primitive::kPrimDouble, d) \
1218 fn(jobject, art::Primitive::kPrimNot, l)
1219
1220namespace impl {
1221
1222template<typename T> void WriteJvalue(T, jvalue*);
1223template<typename T> void ReadJvalue(jvalue, T*);
1224template<typename T> art::Primitive::Type GetJNIType();
1225
1226#define JNI_TYPE_CHAR(type, prim, id) \
1227template<> art::Primitive::Type GetJNIType<type>() { \
1228 return prim; \
1229}
1230
1231FOR_JVMTI_JVALUE_TYPES(JNI_TYPE_CHAR);
1232
1233#undef JNI_TYPE_CHAR
1234
Andreas Gampe49fc60e2017-08-24 13:19:59 -07001235#define RW_JVALUE(srctype, prim, id) \
1236 template<> void ReadJvalue<srctype>(jvalue in, std::add_pointer<srctype>::type out) { \
Alex Lightbebd7bd2017-07-25 14:05:52 -07001237 *out = in.id; \
1238 } \
Andreas Gampe49fc60e2017-08-24 13:19:59 -07001239 template<> void WriteJvalue<srctype>(srctype in, jvalue* out) { \
Alex Lightbebd7bd2017-07-25 14:05:52 -07001240 out->id = in; \
1241 }
1242
1243FOR_JVMTI_JVALUE_TYPES(RW_JVALUE);
1244
1245#undef RW_JVALUE
1246
1247} // namespace impl
1248
1249template<typename T>
1250jvmtiError MethodUtil::SetLocalVariable(jvmtiEnv* env,
1251 jthread thread,
1252 jint depth,
1253 jint slot,
1254 T data) {
1255 jvalue v = {.j = 0};
1256 art::Primitive::Type type = impl::GetJNIType<T>();
1257 impl::WriteJvalue(data, &v);
1258 return SetLocalVariableGeneric(env, thread, depth, slot, type, v);
1259}
1260
1261template<typename T>
1262jvmtiError MethodUtil::GetLocalVariable(jvmtiEnv* env,
1263 jthread thread,
1264 jint depth,
1265 jint slot,
1266 T* data) {
1267 if (data == nullptr) {
1268 return ERR(NULL_POINTER);
1269 }
1270 jvalue v = {.j = 0};
1271 art::Primitive::Type type = impl::GetJNIType<T>();
1272 jvmtiError err = GetLocalVariableGeneric(env, thread, depth, slot, type, &v);
1273 if (err != OK) {
1274 return err;
1275 } else {
1276 impl::ReadJvalue(v, data);
1277 return OK;
1278 }
1279}
1280
Andreas Gampe49fc60e2017-08-24 13:19:59 -07001281#define GET_SET_LV(srctype, prim, id) \
1282 template jvmtiError MethodUtil::GetLocalVariable<srctype>(jvmtiEnv*, \
1283 jthread, \
1284 jint, \
1285 jint, \
1286 std::add_pointer<srctype>::type); \
1287 template jvmtiError MethodUtil::SetLocalVariable<srctype>(jvmtiEnv*, \
1288 jthread, \
1289 jint, \
1290 jint, \
1291 srctype);
Alex Lightbebd7bd2017-07-25 14:05:52 -07001292
1293FOR_JVMTI_JVALUE_TYPES(GET_SET_LV);
1294
1295#undef GET_SET_LV
1296
1297#undef FOR_JVMTI_JVALUE_TYPES
1298
Andreas Gampe3c252f02016-10-27 18:25:17 -07001299} // namespace openjdkjvmti