< prev index next >

src/jdk.jdwp.agent/share/native/libjdwp/util.h

Print this page

 66     struct RefNode *next;       /* next RefNode* in bucket chain */
 67     jint         count;         /* count of references */
 68     unsigned     strongCount;   /* count of strong reference */
 69 } RefNode;
 70 
 71 /* Value of a NULL ID */
 72 #define NULL_OBJECT_ID  ((jlong)0)
 73 
 74 /*
 75  * Globals used throughout the back end
 76  */
 77 
 78 typedef jint FrameNumber;
 79 
 80 typedef struct {
 81     jvmtiEnv *jvmti;
 82     JavaVM   *jvm;
 83     volatile jboolean vmDead; /* Once VM is dead it stays that way - don't put in init */
 84     jboolean assertOn;
 85     jboolean assertFatal;




 86     jboolean doerrorexit;
 87     jboolean modifiedUtf8;
 88     jboolean quiet;
 89 
 90     /* Debug flags (bit mask) */
 91     int      debugflags;
 92 
 93     /* Possible debug flags */
 94     #define USE_ITERATE_THROUGH_HEAP 0X001
 95 
 96     char * options;
 97 
 98     jclass              classClass;
 99     jclass              threadClass;
100     jclass              threadGroupClass;
101     jclass              classLoaderClass;
102     jclass              stringClass;
103     jclass              systemClass;
104     jmethodID           threadConstructor;
105     jmethodID           threadSetDaemon;
106     jmethodID           threadResume;
107     jmethodID           systemGetProperty;
108     jmethodID           setProperty;
109     jthreadGroup        systemThreadGroup;

110     jobject             agent_properties;
111 
112     jint                cachedJvmtiVersion;
113     jvmtiCapabilities   cachedJvmtiCapabilities;
114     jboolean            haveCachedJvmtiCapabilities;
115     jvmtiEventCallbacks callbacks;
116 
117     /* Various property values we should grab on initialization */
118     char* property_java_version;          /* UTF8 java.version */
119     char* property_java_vm_name;          /* UTF8 java.vm.name */
120     char* property_java_vm_info;          /* UTF8 java.vm.info */
121     char* property_java_class_path;       /* UTF8 java.class.path */
122     char* property_sun_boot_library_path; /* UTF8 sun.boot.library.path */
123     char* property_path_separator;        /* UTF8 path.separator */
124     char* property_user_dir;              /* UTF8 user.dir */
125 
126     unsigned log_flags;
127 
128     /* Common References static data */
129     jrawMonitorID refLock;

153         EI_SINGLE_STEP          =  1,
154         EI_BREAKPOINT           =  2,
155         EI_FRAME_POP            =  3,
156         EI_EXCEPTION            =  4,
157         EI_THREAD_START         =  5,
158         EI_THREAD_END           =  6,
159         EI_CLASS_PREPARE        =  7,
160         EI_GC_FINISH            =  8,
161         EI_CLASS_LOAD           =  9,
162         EI_FIELD_ACCESS         = 10,
163         EI_FIELD_MODIFICATION   = 11,
164         EI_EXCEPTION_CATCH      = 12,
165         EI_METHOD_ENTRY         = 13,
166         EI_METHOD_EXIT          = 14,
167         EI_MONITOR_CONTENDED_ENTER = 15,
168         EI_MONITOR_CONTENDED_ENTERED = 16,
169         EI_MONITOR_WAIT         = 17,
170         EI_MONITOR_WAITED       = 18,
171         EI_VM_INIT              = 19,
172         EI_VM_DEATH             = 20,
173         EI_max                  = 20



174 } EventIndex;
175 
176 /* Agent errors that might be in a jvmtiError for JDWP or internal.
177  *    (Done this way so that compiler allows it's use as a jvmtiError)
178  */
179 #define _AGENT_ERROR(x)                 ((jvmtiError)(JVMTI_ERROR_MAX+64+x))
180 #define AGENT_ERROR_INTERNAL                    _AGENT_ERROR(1)
181 #define AGENT_ERROR_VM_DEAD                     _AGENT_ERROR(2)
182 #define AGENT_ERROR_NO_JNI_ENV                  _AGENT_ERROR(3)
183 #define AGENT_ERROR_JNI_EXCEPTION               _AGENT_ERROR(4)
184 #define AGENT_ERROR_JVMTI_INTERNAL              _AGENT_ERROR(5)
185 #define AGENT_ERROR_JDWP_INTERNAL               _AGENT_ERROR(6)
186 #define AGENT_ERROR_NOT_CURRENT_FRAME           _AGENT_ERROR(7)
187 #define AGENT_ERROR_OUT_OF_MEMORY               _AGENT_ERROR(8)
188 #define AGENT_ERROR_INVALID_TAG                 _AGENT_ERROR(9)
189 #define AGENT_ERROR_ALREADY_INVOKING            _AGENT_ERROR(10)
190 #define AGENT_ERROR_INVALID_INDEX               _AGENT_ERROR(11)
191 #define AGENT_ERROR_INVALID_LENGTH              _AGENT_ERROR(12)
192 #define AGENT_ERROR_INVALID_STRING              _AGENT_ERROR(13)
193 #define AGENT_ERROR_INVALID_CLASS_LOADER        _AGENT_ERROR(14)
194 #define AGENT_ERROR_INVALID_ARRAY               _AGENT_ERROR(15)
195 #define AGENT_ERROR_TRANSPORT_LOAD              _AGENT_ERROR(16)
196 #define AGENT_ERROR_TRANSPORT_INIT              _AGENT_ERROR(17)
197 #define AGENT_ERROR_NATIVE_METHOD               _AGENT_ERROR(18)
198 #define AGENT_ERROR_INVALID_COUNT               _AGENT_ERROR(19)
199 #define AGENT_ERROR_INVALID_FRAMEID             _AGENT_ERROR(20)
200 #define AGENT_ERROR_NULL_POINTER                _AGENT_ERROR(21)
201 #define AGENT_ERROR_ILLEGAL_ARGUMENT            _AGENT_ERROR(22)
202 #define AGENT_ERROR_INVALID_THREAD              _AGENT_ERROR(23)
203 #define AGENT_ERROR_INVALID_EVENT_TYPE          _AGENT_ERROR(24)
204 #define AGENT_ERROR_INVALID_OBJECT              _AGENT_ERROR(25)
205 #define AGENT_ERROR_NO_MORE_FRAMES              _AGENT_ERROR(26)
206 #define AGENT_ERROR_INVALID_MODULE              _AGENT_ERROR(27)
207 
208 /* Combined event information */
209 
210 typedef struct {
211 
212     EventIndex  ei;
213     jthread     thread;

214     jclass      clazz;
215     jmethodID   method;
216     jlocation   location;
217     jobject     object; /* possibly an exception or user object */
218 
219     union {
220 
221         /* ei = EI_FIELD_ACCESS */
222         struct {
223             jclass      field_clazz;
224             jfieldID    field;
225         } field_access;
226 
227         /* ei = EI_FIELD_MODIFICATION */
228         struct {
229             jclass      field_clazz;
230             jfieldID    field;
231             char        signature_type;
232             jvalue      new_value;
233         } field_modification;

310 void sharedGetFieldValues(struct PacketInputStream *in,
311                           struct PacketOutputStream *out,
312                           jboolean isStatic);
313 jboolean sharedInvoke(struct PacketInputStream *in,
314                       struct PacketOutputStream *out);
315 
316 jvmtiError fieldSignature(jclass, jfieldID, char **, char **, char **);
317 jvmtiError fieldModifiers(jclass, jfieldID, jint *);
318 jvmtiError methodSignature(jmethodID, char **, char **, char **);
319 jvmtiError methodReturnType(jmethodID, char *);
320 jvmtiError methodModifiers(jmethodID, jint *);
321 jvmtiError methodClass(jmethodID, jclass *);
322 jvmtiError methodLocation(jmethodID, jlocation*, jlocation*);
323 jvmtiError classLoader(jclass, jobject *);
324 
325 /*
326  * Thin wrappers on top of JNI
327  */
328 JNIEnv *getEnv(void);
329 jboolean isClass(jobject object);

330 jboolean isThread(jobject object);
331 jboolean isThreadGroup(jobject object);
332 jboolean isString(jobject object);
333 jboolean isClassLoader(jobject object);
334 jboolean isArray(jobject object);
335 
336 /*
337  * Thin wrappers on top of JVMTI
338  */
339 jvmtiError jvmtiGetCapabilities(jvmtiCapabilities *caps);
340 jint jvmtiMajorVersion(void);
341 jint jvmtiMinorVersion(void);
342 jint jvmtiMicroVersion(void);
343 jvmtiError getSourceDebugExtension(jclass clazz, char **extensionPtr);
344 
345 jrawMonitorID debugMonitorCreate(char *name);
346 void debugMonitorEnter(jrawMonitorID theLock);
347 void debugMonitorExit(jrawMonitorID theLock);
348 void debugMonitorWait(jrawMonitorID theLock);
349 void debugMonitorTimedWait(jrawMonitorID theLock, jlong millis);

 66     struct RefNode *next;       /* next RefNode* in bucket chain */
 67     jint         count;         /* count of references */
 68     unsigned     strongCount;   /* count of strong reference */
 69 } RefNode;
 70 
 71 /* Value of a NULL ID */
 72 #define NULL_OBJECT_ID  ((jlong)0)
 73 
 74 /*
 75  * Globals used throughout the back end
 76  */
 77 
 78 typedef jint FrameNumber;
 79 
 80 typedef struct {
 81     jvmtiEnv *jvmti;
 82     JavaVM   *jvm;
 83     volatile jboolean vmDead; /* Once VM is dead it stays that way - don't put in init */
 84     jboolean assertOn;
 85     jboolean assertFatal;
 86     jboolean vthreadsSupported; /* If true, debugging support for vthreads is enabled.*/
 87     jboolean enumerateVThreads; /* If true, JDWP APIs returns vthreads in thread lists. */
 88     jboolean notifyVThreads;    /* If true, all vthread START and DEATH events are sent, subject to filtering. */
 89     jboolean trackAllVThreads;  /* If true, track all vthreads. Otherwise just track ones we need to track. */
 90     jboolean doerrorexit;
 91     jboolean modifiedUtf8;
 92     jboolean quiet;
 93 
 94     /* Debug flags (bit mask) */
 95     int      debugflags;
 96 
 97     /* Possible debug flags */
 98     #define USE_ITERATE_THROUGH_HEAP 0X001
 99 
100     char * options;
101 
102     jclass              classClass;
103     jclass              threadClass;
104     jclass              threadGroupClass;
105     jclass              classLoaderClass;
106     jclass              stringClass;
107     jclass              systemClass;
108     jmethodID           threadConstructor;
109     jmethodID           threadSetDaemon;
110     jmethodID           threadResume;
111     jmethodID           systemGetProperty;
112     jmethodID           setProperty;
113     jthreadGroup        systemThreadGroup;
114     jthreadGroup        vthreadThreadGroup;
115     jobject             agent_properties;
116 
117     jint                cachedJvmtiVersion;
118     jvmtiCapabilities   cachedJvmtiCapabilities;
119     jboolean            haveCachedJvmtiCapabilities;
120     jvmtiEventCallbacks callbacks;
121 
122     /* Various property values we should grab on initialization */
123     char* property_java_version;          /* UTF8 java.version */
124     char* property_java_vm_name;          /* UTF8 java.vm.name */
125     char* property_java_vm_info;          /* UTF8 java.vm.info */
126     char* property_java_class_path;       /* UTF8 java.class.path */
127     char* property_sun_boot_library_path; /* UTF8 sun.boot.library.path */
128     char* property_path_separator;        /* UTF8 path.separator */
129     char* property_user_dir;              /* UTF8 user.dir */
130 
131     unsigned log_flags;
132 
133     /* Common References static data */
134     jrawMonitorID refLock;

158         EI_SINGLE_STEP          =  1,
159         EI_BREAKPOINT           =  2,
160         EI_FRAME_POP            =  3,
161         EI_EXCEPTION            =  4,
162         EI_THREAD_START         =  5,
163         EI_THREAD_END           =  6,
164         EI_CLASS_PREPARE        =  7,
165         EI_GC_FINISH            =  8,
166         EI_CLASS_LOAD           =  9,
167         EI_FIELD_ACCESS         = 10,
168         EI_FIELD_MODIFICATION   = 11,
169         EI_EXCEPTION_CATCH      = 12,
170         EI_METHOD_ENTRY         = 13,
171         EI_METHOD_EXIT          = 14,
172         EI_MONITOR_CONTENDED_ENTER = 15,
173         EI_MONITOR_CONTENDED_ENTERED = 16,
174         EI_MONITOR_WAIT         = 17,
175         EI_MONITOR_WAITED       = 18,
176         EI_VM_INIT              = 19,
177         EI_VM_DEATH             = 20,
178         EI_VIRTUAL_THREAD_START = 21,
179         EI_VIRTUAL_THREAD_END   = 22,
180 
181         EI_max                  = 22
182 } EventIndex;
183 
184 /* Agent errors that might be in a jvmtiError for JDWP or internal.
185  *    (Done this way so that compiler allows it's use as a jvmtiError)
186  */
187 #define _AGENT_ERROR(x)                 ((jvmtiError)(JVMTI_ERROR_MAX+64+x))
188 #define AGENT_ERROR_INTERNAL                    _AGENT_ERROR(1)
189 #define AGENT_ERROR_VM_DEAD                     _AGENT_ERROR(2)
190 #define AGENT_ERROR_NO_JNI_ENV                  _AGENT_ERROR(3)
191 #define AGENT_ERROR_JNI_EXCEPTION               _AGENT_ERROR(4)
192 #define AGENT_ERROR_JVMTI_INTERNAL              _AGENT_ERROR(5)
193 #define AGENT_ERROR_JDWP_INTERNAL               _AGENT_ERROR(6)
194 #define AGENT_ERROR_NOT_CURRENT_FRAME           _AGENT_ERROR(7)
195 #define AGENT_ERROR_OUT_OF_MEMORY               _AGENT_ERROR(8)
196 #define AGENT_ERROR_INVALID_TAG                 _AGENT_ERROR(9)
197 #define AGENT_ERROR_ALREADY_INVOKING            _AGENT_ERROR(10)
198 #define AGENT_ERROR_INVALID_INDEX               _AGENT_ERROR(11)
199 #define AGENT_ERROR_INVALID_LENGTH              _AGENT_ERROR(12)
200 #define AGENT_ERROR_INVALID_STRING              _AGENT_ERROR(13)
201 #define AGENT_ERROR_INVALID_CLASS_LOADER        _AGENT_ERROR(14)
202 #define AGENT_ERROR_INVALID_ARRAY               _AGENT_ERROR(15)
203 #define AGENT_ERROR_TRANSPORT_LOAD              _AGENT_ERROR(16)
204 #define AGENT_ERROR_TRANSPORT_INIT              _AGENT_ERROR(17)
205 #define AGENT_ERROR_NATIVE_METHOD               _AGENT_ERROR(18)
206 #define AGENT_ERROR_INVALID_COUNT               _AGENT_ERROR(19)
207 #define AGENT_ERROR_INVALID_FRAMEID             _AGENT_ERROR(20)
208 #define AGENT_ERROR_NULL_POINTER                _AGENT_ERROR(21)
209 #define AGENT_ERROR_ILLEGAL_ARGUMENT            _AGENT_ERROR(22)
210 #define AGENT_ERROR_INVALID_THREAD              _AGENT_ERROR(23)
211 #define AGENT_ERROR_INVALID_EVENT_TYPE          _AGENT_ERROR(24)
212 #define AGENT_ERROR_INVALID_OBJECT              _AGENT_ERROR(25)
213 #define AGENT_ERROR_NO_MORE_FRAMES              _AGENT_ERROR(26)
214 #define AGENT_ERROR_INVALID_MODULE              _AGENT_ERROR(27)
215 
216 /* Combined event information */
217 
218 typedef struct {
219 
220     EventIndex  ei;
221     jthread     thread;
222     jboolean    is_vthread;
223     jclass      clazz;
224     jmethodID   method;
225     jlocation   location;
226     jobject     object; /* possibly an exception or user object */
227 
228     union {
229 
230         /* ei = EI_FIELD_ACCESS */
231         struct {
232             jclass      field_clazz;
233             jfieldID    field;
234         } field_access;
235 
236         /* ei = EI_FIELD_MODIFICATION */
237         struct {
238             jclass      field_clazz;
239             jfieldID    field;
240             char        signature_type;
241             jvalue      new_value;
242         } field_modification;

319 void sharedGetFieldValues(struct PacketInputStream *in,
320                           struct PacketOutputStream *out,
321                           jboolean isStatic);
322 jboolean sharedInvoke(struct PacketInputStream *in,
323                       struct PacketOutputStream *out);
324 
325 jvmtiError fieldSignature(jclass, jfieldID, char **, char **, char **);
326 jvmtiError fieldModifiers(jclass, jfieldID, jint *);
327 jvmtiError methodSignature(jmethodID, char **, char **, char **);
328 jvmtiError methodReturnType(jmethodID, char *);
329 jvmtiError methodModifiers(jmethodID, jint *);
330 jvmtiError methodClass(jmethodID, jclass *);
331 jvmtiError methodLocation(jmethodID, jlocation*, jlocation*);
332 jvmtiError classLoader(jclass, jobject *);
333 
334 /*
335  * Thin wrappers on top of JNI
336  */
337 JNIEnv *getEnv(void);
338 jboolean isClass(jobject object);
339 jboolean isVThread(jobject object);
340 jboolean isThread(jobject object);
341 jboolean isThreadGroup(jobject object);
342 jboolean isString(jobject object);
343 jboolean isClassLoader(jobject object);
344 jboolean isArray(jobject object);
345 
346 /*
347  * Thin wrappers on top of JVMTI
348  */
349 jvmtiError jvmtiGetCapabilities(jvmtiCapabilities *caps);
350 jint jvmtiMajorVersion(void);
351 jint jvmtiMinorVersion(void);
352 jint jvmtiMicroVersion(void);
353 jvmtiError getSourceDebugExtension(jclass clazz, char **extensionPtr);
354 
355 jrawMonitorID debugMonitorCreate(char *name);
356 void debugMonitorEnter(jrawMonitorID theLock);
357 void debugMonitorExit(jrawMonitorID theLock);
358 void debugMonitorWait(jrawMonitorID theLock);
359 void debugMonitorTimedWait(jrawMonitorID theLock, jlong millis);
< prev index next >