Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef _JAVASOFT_JVMPI_H_
00009 #define _JAVASOFT_JVMPI_H_
00010
00011 #include "jni.h"
00012
00013 #define JVMPI_VERSION_1 ((jint)0x10000001)
00014 #define JVMPI_VERSION_1_1 ((jint)0x10000002)
00015 #define JVMPI_VERSION_1_2 ((jint)0x10000003)
00016
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 typedef void (*jvmpi_void_function_of_void)(void *);
00021 #ifdef __cplusplus
00022 }
00023 #endif
00024
00025
00026
00027
00028
00029 struct _jobjectID;
00030 typedef struct _jobjectID * jobjectID;
00031
00032
00033 struct _JVMPI_RawMonitor;
00034 typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;
00035
00036
00037 typedef struct {
00038 jint lineno;
00039 jmethodID method_id;
00040 } JVMPI_CallFrame;
00041
00042
00043 typedef struct {
00044 JNIEnv *env_id;
00045 jint num_frames;
00046 JVMPI_CallFrame *frames;
00047 } JVMPI_CallTrace;
00048
00049
00050 typedef struct {
00051 char *method_name;
00052 char *method_signature;
00053 jint start_lineno;
00054 jint end_lineno;
00055 jmethodID method_id;
00056 } JVMPI_Method;
00057
00058
00059 typedef struct {
00060 char *field_name;
00061 char *field_signature;
00062 } JVMPI_Field;
00063
00064
00065 typedef struct {
00066 jint offset;
00067 jint lineno;
00068 } JVMPI_Lineno;
00069
00070
00071 typedef struct {
00072 jint event_type;
00073 JNIEnv *env_id;
00074
00075 union {
00076 struct {
00077 const char *class_name;
00078 char *source_name;
00079 jint num_interfaces;
00080 jint num_methods;
00081 JVMPI_Method *methods;
00082 jint num_static_fields;
00083 JVMPI_Field *statics;
00084 jint num_instance_fields;
00085 JVMPI_Field *instances;
00086 jobjectID class_id;
00087 } class_load;
00088
00089 struct {
00090 jobjectID class_id;
00091 } class_unload;
00092
00093 struct {
00094 unsigned char *class_data;
00095 jint class_data_len;
00096 unsigned char *new_class_data;
00097 jint new_class_data_len;
00098 void * (*malloc_f)(unsigned int);
00099 } class_load_hook;
00100
00101 struct {
00102 jint arena_id;
00103 jobjectID class_id;
00104 jint is_array;
00105 jint size;
00106 jobjectID obj_id;
00107 } obj_alloc;
00108
00109 struct {
00110 jobjectID obj_id;
00111 } obj_free;
00112
00113 struct {
00114 jint arena_id;
00115 jobjectID obj_id;
00116 jint new_arena_id;
00117 jobjectID new_obj_id;
00118 } obj_move;
00119
00120 struct {
00121 jint arena_id;
00122 const char *arena_name;
00123 } new_arena;
00124
00125 struct {
00126 jint arena_id;
00127 } delete_arena;
00128
00129 struct {
00130 char *thread_name;
00131 char *group_name;
00132 char *parent_name;
00133 jobjectID thread_id;
00134 JNIEnv *thread_env_id;
00135 } thread_start;
00136
00137 struct {
00138 int dump_level;
00139 char *begin;
00140
00141
00142 char *end;
00143 jint num_traces;
00144
00145 JVMPI_CallTrace *traces;
00146
00147 } heap_dump;
00148
00149 struct {
00150 jobjectID obj_id;
00151 jobject ref_id;
00152 } jni_globalref_alloc;
00153
00154 struct {
00155 jobject ref_id;
00156 } jni_globalref_free;
00157
00158 struct {
00159 jmethodID method_id;
00160 } method;
00161
00162 struct {
00163 jmethodID method_id;
00164 jobjectID obj_id;
00165 } method_entry2;
00166
00167 struct {
00168 jmethodID method_id;
00169 void *code_addr;
00170 jint code_size;
00171 jint lineno_table_size;
00172 JVMPI_Lineno *lineno_table;
00173 } compiled_method_load;
00174
00175 struct {
00176 jmethodID method_id;
00177 } compiled_method_unload;
00178
00179 struct {
00180 jmethodID method_id;
00181 jint offset;
00182 union {
00183 struct {
00184 jboolean is_true;
00185 } if_info;
00186 struct {
00187 jint key;
00188 jint low;
00189 jint hi;
00190 } tableswitch_info;
00191 struct {
00192 jint chosen_pair_index;
00193
00194
00195
00196 jint pairs_total;
00197 } lookupswitch_info;
00198 } u;
00199 } instruction;
00200
00201 struct {
00202 char *begin;
00203
00204 char *end;
00205 jint num_traces;
00206 JVMPI_CallTrace *traces;
00207 jint *threads_status;
00208 } monitor_dump;
00209
00210 struct {
00211 const char *name;
00212 JVMPI_RawMonitor id;
00213 } raw_monitor;
00214
00215 struct {
00216 jobjectID object;
00217 } monitor;
00218
00219 struct {
00220 jobjectID object;
00221 jlong timeout;
00222 } monitor_wait;
00223
00224 struct {
00225 jlong used_objects;
00226 jlong used_object_space;
00227 jlong total_object_space;
00228 } gc_info;
00229
00230 struct {
00231 jint data_len;
00232 char *data;
00233 } object_dump;
00234 } u;
00235 } JVMPI_Event;
00236
00237
00238 typedef struct {
00239 jint version;
00240
00241
00242
00246 void (*NotifyEvent)(JVMPI_Event *event);
00247
00248
00249
00259 jint (*EnableEvent)(jint event_type, void *arg);
00260 jint (*DisableEvent)(jint event_type, void *arg);
00261 jint (*RequestEvent)(jint event_type, void *arg);
00262
00270 void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
00271
00275 void (*ProfilerExit)(jint);
00276
00280 JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
00281 void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
00282 void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
00283 void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
00284 void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
00285 void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
00286
00292 jlong (*GetCurrentThreadCpuTime)(void);
00293
00294 void (*SuspendThread)(JNIEnv *env);
00295 void (*ResumeThread)(JNIEnv *env);
00296 jint (*GetThreadStatus)(JNIEnv *env);
00297 jboolean (*ThreadHasRun)(JNIEnv *env);
00298
00299
00300
00301 jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
00302
00303
00304
00305 void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
00306 void * (*GetThreadLocalStorage)(JNIEnv *env_id);
00307
00308
00309 void (*DisableGC)(void);
00310 void (*EnableGC)(void);
00311 void (*RunGC)(void);
00312
00313 jobjectID (*GetThreadObject)(JNIEnv *env);
00314 jobjectID (*GetMethodClass)(jmethodID mid);
00315
00316
00317 jobject (*jobjectID2jobject)(jobjectID jid);
00318 jobjectID (*jobject2jobjectID)(jobject jobj);
00319
00320 void (*SuspendThreadList)
00321 (jint reqCount, JNIEnv **reqList, jint *results);
00322 void (*ResumeThreadList)
00323 (jint reqCount, JNIEnv **reqList, jint *results);
00324 } JVMPI_Interface;
00325
00326
00327 typedef struct {
00328 jint heap_dump_level;
00329 } JVMPI_HeapDumpArg;
00330
00331
00332
00333
00334
00335
00336
00337 #define JVMPI_EVENT_METHOD_ENTRY ((jint)1)
00338 #define JVMPI_EVENT_METHOD_ENTRY2 ((jint)2)
00339 #define JVMPI_EVENT_METHOD_EXIT ((jint)3)
00340
00341 #define JVMPI_EVENT_OBJECT_ALLOC ((jint)4)
00342 #define JVMPI_EVENT_OBJECT_FREE ((jint)5)
00343 #define JVMPI_EVENT_OBJECT_MOVE ((jint)6)
00344
00345 #define JVMPI_EVENT_COMPILED_METHOD_LOAD ((jint)7)
00346 #define JVMPI_EVENT_COMPILED_METHOD_UNLOAD ((jint)8)
00347
00348 #define JVMPI_EVENT_INSTRUCTION_START ((jint)9)
00349
00350 #define JVMPI_EVENT_THREAD_START ((jint)33)
00351 #define JVMPI_EVENT_THREAD_END ((jint)34)
00352
00353 #define JVMPI_EVENT_CLASS_LOAD_HOOK ((jint)35)
00354
00355 #define JVMPI_EVENT_HEAP_DUMP ((jint)37)
00356 #define JVMPI_EVENT_JNI_GLOBALREF_ALLOC ((jint)38)
00357 #define JVMPI_EVENT_JNI_GLOBALREF_FREE ((jint)39)
00358 #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC ((jint)40)
00359 #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE ((jint)41)
00360 #define JVMPI_EVENT_CLASS_LOAD ((jint)42)
00361 #define JVMPI_EVENT_CLASS_UNLOAD ((jint)43)
00362 #define JVMPI_EVENT_DATA_DUMP_REQUEST ((jint)44)
00363 #define JVMPI_EVENT_DATA_RESET_REQUEST ((jint)45)
00364
00365 #define JVMPI_EVENT_JVM_INIT_DONE ((jint)46)
00366 #define JVMPI_EVENT_JVM_SHUT_DOWN ((jint)47)
00367
00368 #define JVMPI_EVENT_ARENA_NEW ((jint)48)
00369 #define JVMPI_EVENT_ARENA_DELETE ((jint)49)
00370
00371 #define JVMPI_EVENT_OBJECT_DUMP ((jint)50)
00372
00373 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER ((jint)51)
00374 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED ((jint)52)
00375 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT ((jint)53)
00376 #define JVMPI_EVENT_MONITOR_CONTENDED_ENTER ((jint)54)
00377 #define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED ((jint)55)
00378 #define JVMPI_EVENT_MONITOR_CONTENDED_EXIT ((jint)56)
00379 #define JVMPI_EVENT_MONITOR_WAIT ((jint)57)
00380 #define JVMPI_EVENT_MONITOR_WAITED ((jint)58)
00381 #define JVMPI_EVENT_MONITOR_DUMP ((jint)59)
00382
00383 #define JVMPI_EVENT_GC_START ((jint)60)
00384 #define JVMPI_EVENT_GC_FINISH ((jint)61)
00385
00386 #define JVMPI_MAX_EVENT_TYPE_VAL ((jint)61)
00387
00388
00389 #define JVMPI_EVENT_LOAD_COMPILED_METHOD ((jint)7)
00390 #define JVMPI_EVENT_UNLOAD_COMPILED_METHOD ((jint)8)
00391 #define JVMPI_EVENT_NEW_ARENA ((jint)48)
00392 #define JVMPI_EVENT_DELETE_ARENA ((jint)49)
00393 #define JVMPI_EVENT_DUMP_DATA_REQUEST ((jint)44)
00394 #define JVMPI_EVENT_RESET_DATA_REQUEST ((jint)45)
00395 #define JVMPI_EVENT_OBJ_ALLOC ((jint)4)
00396 #define JVMPI_EVENT_OBJ_FREE ((jint)5)
00397 #define JVMPI_EVENT_OBJ_MOVE ((jint)6)
00398
00399 #define JVMPI_REQUESTED_EVENT ((jint)0x10000000)
00400
00401
00402
00403
00404
00405
00406
00407 #define JVMPI_SUCCESS ((jint)0)
00408 #define JVMPI_NOT_AVAILABLE ((jint)1)
00409 #define JVMPI_FAIL ((jint)-1)
00410
00411
00412
00413
00414 enum {
00415 JVMPI_THREAD_RUNNABLE = 1,
00416 JVMPI_THREAD_MONITOR_WAIT,
00417 JVMPI_THREAD_CONDVAR_WAIT
00418 };
00419
00420 #define JVMPI_THREAD_SUSPENDED 0x8000
00421 #define JVMPI_THREAD_INTERRUPTED 0x4000
00422
00423
00424
00425
00426 #define JVMPI_MINIMUM_PRIORITY 1
00427 #define JVMPI_MAXIMUM_PRIORITY 10
00428 #define JVMPI_NORMAL_PRIORITY 5
00429
00430
00431
00432
00433 #define JVMPI_NORMAL_OBJECT ((jint)0)
00434 #define JVMPI_CLASS ((jint)2)
00435 #define JVMPI_BOOLEAN ((jint)4)
00436 #define JVMPI_CHAR ((jint)5)
00437 #define JVMPI_FLOAT ((jint)6)
00438 #define JVMPI_DOUBLE ((jint)7)
00439 #define JVMPI_BYTE ((jint)8)
00440 #define JVMPI_SHORT ((jint)9)
00441 #define JVMPI_INT ((jint)10)
00442 #define JVMPI_LONG ((jint)11)
00443
00444
00445
00446
00447
00448 #define JVMPI_MONITOR_JAVA 0x01
00449 #define JVMPI_MONITOR_RAW 0x02
00450
00451
00452
00453
00454 #define JVMPI_GC_ROOT_UNKNOWN 0xff
00455 #define JVMPI_GC_ROOT_JNI_GLOBAL 0x01
00456 #define JVMPI_GC_ROOT_JNI_LOCAL 0x02
00457 #define JVMPI_GC_ROOT_JAVA_FRAME 0x03
00458 #define JVMPI_GC_ROOT_NATIVE_STACK 0x04
00459 #define JVMPI_GC_ROOT_STICKY_CLASS 0x05
00460 #define JVMPI_GC_ROOT_THREAD_BLOCK 0x06
00461 #define JVMPI_GC_ROOT_MONITOR_USED 0x07
00462 #define JVMPI_GC_ROOT_THREAD_OBJ 0x08
00463
00464 #define JVMPI_GC_CLASS_DUMP 0x20
00465 #define JVMPI_GC_INSTANCE_DUMP 0x21
00466 #define JVMPI_GC_OBJ_ARRAY_DUMP 0x22
00467 #define JVMPI_GC_PRIM_ARRAY_DUMP 0x23
00468
00469
00470
00471
00472 #define JVMPI_DUMP_LEVEL_0 ((jint)0)
00473 #define JVMPI_DUMP_LEVEL_1 ((jint)1)
00474 #define JVMPI_DUMP_LEVEL_2 ((jint)2)
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 #endif