xref: /aosp_15_r20/art/openjdkjvmti/ti_method.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /* Copyright (C) 2016 The Android Open Source Project
2*795d594fSAndroid Build Coastguard Worker  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * This file implements interfaces from the file jvmti.h. This implementation
5*795d594fSAndroid Build Coastguard Worker  * is licensed under the same terms as the file jvmti.h.  The
6*795d594fSAndroid Build Coastguard Worker  * copyright and license information for the file jvmti.h follows.
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
9*795d594fSAndroid Build Coastguard Worker  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
10*795d594fSAndroid Build Coastguard Worker  *
11*795d594fSAndroid Build Coastguard Worker  * This code is free software; you can redistribute it and/or modify it
12*795d594fSAndroid Build Coastguard Worker  * under the terms of the GNU General Public License version 2 only, as
13*795d594fSAndroid Build Coastguard Worker  * published by the Free Software Foundation.  Oracle designates this
14*795d594fSAndroid Build Coastguard Worker  * particular file as subject to the "Classpath" exception as provided
15*795d594fSAndroid Build Coastguard Worker  * by Oracle in the LICENSE file that accompanied this code.
16*795d594fSAndroid Build Coastguard Worker  *
17*795d594fSAndroid Build Coastguard Worker  * This code is distributed in the hope that it will be useful, but WITHOUT
18*795d594fSAndroid Build Coastguard Worker  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19*795d594fSAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20*795d594fSAndroid Build Coastguard Worker  * version 2 for more details (a copy is included in the LICENSE file that
21*795d594fSAndroid Build Coastguard Worker  * accompanied this code).
22*795d594fSAndroid Build Coastguard Worker  *
23*795d594fSAndroid Build Coastguard Worker  * You should have received a copy of the GNU General Public License version
24*795d594fSAndroid Build Coastguard Worker  * 2 along with this work; if not, write to the Free Software Foundation,
25*795d594fSAndroid Build Coastguard Worker  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
26*795d594fSAndroid Build Coastguard Worker  *
27*795d594fSAndroid Build Coastguard Worker  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28*795d594fSAndroid Build Coastguard Worker  * or visit www.oracle.com if you need additional information or have any
29*795d594fSAndroid Build Coastguard Worker  * questions.
30*795d594fSAndroid Build Coastguard Worker  */
31*795d594fSAndroid Build Coastguard Worker 
32*795d594fSAndroid Build Coastguard Worker #ifndef ART_OPENJDKJVMTI_TI_METHOD_H_
33*795d594fSAndroid Build Coastguard Worker #define ART_OPENJDKJVMTI_TI_METHOD_H_
34*795d594fSAndroid Build Coastguard Worker 
35*795d594fSAndroid Build Coastguard Worker #include "dex/primitive.h"
36*795d594fSAndroid Build Coastguard Worker #include "jni.h"
37*795d594fSAndroid Build Coastguard Worker #include "jvmti.h"
38*795d594fSAndroid Build Coastguard Worker 
39*795d594fSAndroid Build Coastguard Worker namespace openjdkjvmti {
40*795d594fSAndroid Build Coastguard Worker 
41*795d594fSAndroid Build Coastguard Worker class EventHandler;
42*795d594fSAndroid Build Coastguard Worker 
43*795d594fSAndroid Build Coastguard Worker class MethodUtil {
44*795d594fSAndroid Build Coastguard Worker  public:
45*795d594fSAndroid Build Coastguard Worker   static void Register(EventHandler* event_handler);
46*795d594fSAndroid Build Coastguard Worker   static void Unregister();
47*795d594fSAndroid Build Coastguard Worker 
48*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetBytecodes(jvmtiEnv* env,
49*795d594fSAndroid Build Coastguard Worker                                  jmethodID method,
50*795d594fSAndroid Build Coastguard Worker                                  jint* count_ptr,
51*795d594fSAndroid Build Coastguard Worker                                  unsigned char** bytecodes);
52*795d594fSAndroid Build Coastguard Worker 
53*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetArgumentsSize(jvmtiEnv* env, jmethodID method, jint* size_ptr);
54*795d594fSAndroid Build Coastguard Worker 
55*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetMaxLocals(jvmtiEnv* env, jmethodID method, jint* max_ptr);
56*795d594fSAndroid Build Coastguard Worker 
57*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetMethodName(jvmtiEnv* env,
58*795d594fSAndroid Build Coastguard Worker                                   jmethodID method,
59*795d594fSAndroid Build Coastguard Worker                                   char** name_ptr,
60*795d594fSAndroid Build Coastguard Worker                                   char** signature_ptr,
61*795d594fSAndroid Build Coastguard Worker                                   char** generic_ptr);
62*795d594fSAndroid Build Coastguard Worker 
63*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetMethodDeclaringClass(jvmtiEnv* env,
64*795d594fSAndroid Build Coastguard Worker                                             jmethodID method,
65*795d594fSAndroid Build Coastguard Worker                                             jclass* declaring_class_ptr);
66*795d594fSAndroid Build Coastguard Worker 
67*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetMethodLocation(jvmtiEnv* env,
68*795d594fSAndroid Build Coastguard Worker                                       jmethodID method,
69*795d594fSAndroid Build Coastguard Worker                                       jlocation* start_location_ptr,
70*795d594fSAndroid Build Coastguard Worker                                       jlocation* end_location_ptr);
71*795d594fSAndroid Build Coastguard Worker 
72*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetMethodModifiers(jvmtiEnv* env,
73*795d594fSAndroid Build Coastguard Worker                                        jmethodID method,
74*795d594fSAndroid Build Coastguard Worker                                        jint* modifiers_ptr);
75*795d594fSAndroid Build Coastguard Worker 
76*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetLineNumberTable(jvmtiEnv* env,
77*795d594fSAndroid Build Coastguard Worker                                        jmethodID method,
78*795d594fSAndroid Build Coastguard Worker                                        jint* entry_count_ptr,
79*795d594fSAndroid Build Coastguard Worker                                        jvmtiLineNumberEntry** table_ptr);
80*795d594fSAndroid Build Coastguard Worker 
81*795d594fSAndroid Build Coastguard Worker   static jvmtiError IsMethodNative(jvmtiEnv* env, jmethodID method, jboolean* is_native_ptr);
82*795d594fSAndroid Build Coastguard Worker   static jvmtiError IsMethodObsolete(jvmtiEnv* env, jmethodID method, jboolean* is_obsolete_ptr);
83*795d594fSAndroid Build Coastguard Worker   static jvmtiError IsMethodSynthetic(jvmtiEnv* env, jmethodID method, jboolean* is_synthetic_ptr);
84*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetLocalVariableTable(jvmtiEnv* env,
85*795d594fSAndroid Build Coastguard Worker                                           jmethodID method,
86*795d594fSAndroid Build Coastguard Worker                                           jint* entry_count_ptr,
87*795d594fSAndroid Build Coastguard Worker                                           jvmtiLocalVariableEntry** table_ptr);
88*795d594fSAndroid Build Coastguard Worker 
89*795d594fSAndroid Build Coastguard Worker   template<typename T>
90*795d594fSAndroid Build Coastguard Worker   static jvmtiError SetLocalVariable(jvmtiEnv* env, jthread thread, jint depth, jint slot, T data);
91*795d594fSAndroid Build Coastguard Worker 
92*795d594fSAndroid Build Coastguard Worker   template<typename T>
93*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetLocalVariable(jvmtiEnv* env, jthread thread, jint depth, jint slot, T* data);
94*795d594fSAndroid Build Coastguard Worker 
95*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetLocalInstance(jvmtiEnv* env, jthread thread, jint depth, jobject* data);
96*795d594fSAndroid Build Coastguard Worker 
97*795d594fSAndroid Build Coastguard Worker  private:
98*795d594fSAndroid Build Coastguard Worker   static jvmtiError SetLocalVariableGeneric(jvmtiEnv* env,
99*795d594fSAndroid Build Coastguard Worker                                             jthread thread,
100*795d594fSAndroid Build Coastguard Worker                                             jint depth,
101*795d594fSAndroid Build Coastguard Worker                                             jint slot,
102*795d594fSAndroid Build Coastguard Worker                                             art::Primitive::Type type,
103*795d594fSAndroid Build Coastguard Worker                                             jvalue value);
104*795d594fSAndroid Build Coastguard Worker   static jvmtiError GetLocalVariableGeneric(jvmtiEnv* env,
105*795d594fSAndroid Build Coastguard Worker                                             jthread thread,
106*795d594fSAndroid Build Coastguard Worker                                             jint depth,
107*795d594fSAndroid Build Coastguard Worker                                             jint slot,
108*795d594fSAndroid Build Coastguard Worker                                             art::Primitive::Type type,
109*795d594fSAndroid Build Coastguard Worker                                             jvalue* value);
110*795d594fSAndroid Build Coastguard Worker };
111*795d594fSAndroid Build Coastguard Worker 
112*795d594fSAndroid Build Coastguard Worker }  // namespace openjdkjvmti
113*795d594fSAndroid Build Coastguard Worker 
114*795d594fSAndroid Build Coastguard Worker #endif  // ART_OPENJDKJVMTI_TI_METHOD_H_
115