00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _JAVASOFT_JVMPI_H_
00012 #define _JAVASOFT_JVMPI_H_
00013
00014 #include "jni.h"
00015
00016 #define JVMPI_VERSION_1 ((jint)0x10000001)
00017
00018
00019
00020
00021
00022 struct _jobjectID;
00023 typedef struct _jobjectID * jobjectID;
00024
00025
00026 struct _JVMPI_RawMonitor;
00027 typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;
00028
00029
00030 typedef struct {
00031 jint lineno;
00032 jmethodID method_id;
00033 } JVMPI_CallFrame;
00034
00035
00036 typedef struct {
00037 JNIEnv *env_id;
00038 jint num_frames;
00039 JVMPI_CallFrame *frames;
00040 } JVMPI_CallTrace;
00041
00042
00043 typedef struct {
00044 char *method_name;
00045 char *method_signature;
00046 jint start_lineno;
00047 jint end_lineno;
00048 jmethodID method_id;
00049 } JVMPI_Method;
00050
00051
00052 typedef struct {
00053 char *field_name;
00054 char *field_signature;
00055 } JVMPI_Field;
00056
00057
00058 typedef struct {
00059 jint offset;
00060 jint lineno;
00061 } JVMPI_Lineno;
00062
00063
00064 typedef struct {
00065 jint event_type;
00066 JNIEnv *env_id;
00067
00068 union {
00069 struct {
00070 char *class_name;
00071 char *source_name;
00072 jint num_interfaces;
00073 jint num_methods;
00074 JVMPI_Method *methods;
00075 jint num_static_fields;
00076 JVMPI_Field *statics;
00077 jint num_instance_fields;
00078 JVMPI_Field *instances;
00079 jobjectID class_id;
00080 } class_load;
00081
00082 struct {
00083 jobjectID class_id;
00084 } class_unload;
00085
00086 struct {
00087 unsigned char *class_data;
00088 jint class_data_len;
00089 unsigned char *new_class_data;
00090 jint new_class_data_len;
00091 void * (*malloc_f)(unsigned int);
00092 } class_load_hook;
00093
00094 struct {
00095 jint arena_id;
00096 jobjectID class_id;
00097 jint is_array;
00098 jint size;
00099 jobjectID obj_id;
00100 } obj_alloc;
00101
00102 struct {
00103 jobjectID obj_id;
00104 } obj_free;
00105
00106 struct {
00107 jint arena_id;
00108 jobjectID obj_id;
00109 jint new_arena_id;
00110 jobjectID new_obj_id;
00111 } obj_move;
00112
00113 struct {
00114 jint arena_id;
00115 char *arena_name;
00116 } new_arena;
00117
00118 struct {
00119 jint arena_id;
00120 } delete_arena;
00121
00122 struct {
00123 char *thread_name;
00124 char *group_name;
00125 char *parent_name;
00126 jobjectID thread_id;
00127 JNIEnv *thread_env_id;
00128 } thread_start;
00129
00130 struct {
00131 int dump_level;
00132 char *begin;
00133
00134
00135 char *end;
00136 jint num_traces;
00137
00138 JVMPI_CallTrace *traces;
00139
00140 } heap_dump;
00141
00142 struct {
00143 jobjectID obj_id;
00144 jobject ref_id;
00145 } jni_globalref_alloc;
00146
00147 struct {
00148 jobject ref_id;
00149 } jni_globalref_free;
00150
00151 struct {
00152 jmethodID method_id;
00153 } method;
00154
00155 struct {
00156 jmethodID method_id;
00157 jobjectID obj_id;
00158 } method_entry2;
00159
00160 struct {
00161 jmethodID method_id;
00162 void *code_addr;
00163 jint code_size;
00164 jint lineno_table_size;
00165 JVMPI_Lineno *lineno_table;
00166 } compiled_method_load;
00167
00168 struct {
00169 jmethodID method_id;
00170 } compiled_method_unload;
00171
00172 struct {
00173 jmethodID method_id;
00174 jint offset;
00175 union {
00176 struct {
00177 jboolean is_true;
00178 } if_info;
00179 struct {
00180 jint key;
00181 jint low;
00182 jint hi;
00183 } tableswitch_info;
00184 struct {
00185 jint chosen_pair_index;
00186
00187
00188
00189 jint pairs_total;
00190 } lookupswitch_info;
00191 } u;
00192 } instruction;
00193
00194 struct {
00195 char *begin;
00196
00197 char *end;
00198 jint num_traces;
00199 JVMPI_CallTrace *traces;
00200 jint *threads_status;
00201 } monitor_dump;
00202
00203 struct {
00204 char *name;
00205 JVMPI_RawMonitor id;
00206 } raw_monitor;
00207
00208 struct {
00209 jobjectID object;
00210 } monitor;
00211
00212 struct {
00213 jobjectID object;
00214 jlong timeout;
00215 } monitor_wait;
00216
00217 struct {
00218 jlong used_objects;
00219 jlong used_object_space;
00220 jlong total_object_space;
00221 } gc_info;
00222
00223 struct {
00224 jint data_len;
00225 char *data;
00226 } object_dump;
00227 } u;
00228 } JVMPI_Event;
00229
00230
00231 typedef struct {
00232 jint version;
00233
00234
00235
00239 void (*NotifyEvent)(JVMPI_Event *event);
00240
00241
00242
00252 jint (*EnableEvent)(jint event_type, void *arg);
00253 jint (*DisableEvent)(jint event_type, void *arg);
00254 jint (*RequestEvent)(jint event_type, void *arg);
00255
00263 void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth);
00264
00268 void (*ProfilerExit)(jint);
00269
00273 JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name);
00274 void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id);
00275 void (*RawMonitorExit)(JVMPI_RawMonitor lock_id);
00276 void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms);
00277 void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id);
00278 void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id);
00279
00285 jlong (*GetCurrentThreadCpuTime)(void);
00286
00287 void (*SuspendThread)(JNIEnv *env);
00288 void (*ResumeThread)(JNIEnv *env);
00289 jint (*GetThreadStatus)(JNIEnv *env);
00290 jboolean (*ThreadHasRun)(JNIEnv *env);
00291
00292
00293
00294 jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *));
00295
00296
00297
00298 void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr);
00299 void * (*GetThreadLocalStorage)(JNIEnv *env_id);
00300
00301
00302 void (*DisableGC)(void);
00303 void (*EnableGC)(void);
00304 void (*RunGC)(void);
00305
00306 jobjectID (*GetThreadObject)(JNIEnv *env);
00307 jobjectID (*GetMethodClass)(jmethodID mid);
00308 } JVMPI_Interface;
00309
00310
00311 typedef struct {
00312 jint heap_dump_level;
00313 } JVMPI_HeapDumpArg;
00314
00315
00316
00317
00318
00319
00320
00321 #define JVMPI_EVENT_METHOD_ENTRY ((jint)1)
00322 #define JVMPI_EVENT_METHOD_ENTRY2 ((jint)2)
00323 #define JVMPI_EVENT_METHOD_EXIT ((jint)3)
00324
00325 #define JVMPI_EVENT_OBJECT_ALLOC ((jint)4)
00326 #define JVMPI_EVENT_OBJECT_FREE ((jint)5)
00327 #define JVMPI_EVENT_OBJECT_MOVE ((jint)6)
00328
00329 #define JVMPI_EVENT_COMPILED_METHOD_LOAD ((jint)7)
00330 #define JVMPI_EVENT_COMPILED_METHOD_UNLOAD ((jint)8)
00331
00332 #define JVMPI_EVENT_INSTRUCTION_START ((jint)9)
00333
00334 #define JVMPI_EVENT_THREAD_START ((jint)33)
00335 #define JVMPI_EVENT_THREAD_END ((jint)34)
00336
00337 #define JVMPI_EVENT_CLASS_LOAD_HOOK ((jint)35)
00338
00339 #define JVMPI_EVENT_HEAP_DUMP ((jint)37)
00340 #define JVMPI_EVENT_JNI_GLOBALREF_ALLOC ((jint)38)
00341 #define JVMPI_EVENT_JNI_GLOBALREF_FREE ((jint)39)
00342 #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_ALLOC ((jint)40)
00343 #define JVMPI_EVENT_JNI_WEAK_GLOBALREF_FREE ((jint)41)
00344 #define JVMPI_EVENT_CLASS_LOAD ((jint)42)
00345 #define JVMPI_EVENT_CLASS_UNLOAD ((jint)43)
00346 #define JVMPI_EVENT_DATA_DUMP_REQUEST ((jint)44)
00347 #define JVMPI_EVENT_DATA_RESET_REQUEST ((jint)45)
00348
00349 #define JVMPI_EVENT_JVM_INIT_DONE ((jint)46)
00350 #define JVMPI_EVENT_JVM_SHUT_DOWN ((jint)47)
00351
00352 #define JVMPI_EVENT_ARENA_NEW ((jint)48)
00353 #define JVMPI_EVENT_ARENA_DELETE ((jint)49)
00354
00355 #define JVMPI_EVENT_OBJECT_DUMP ((jint)50)
00356
00357 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTER ((jint)51)
00358 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_ENTERED ((jint)52)
00359 #define JVMPI_EVENT_RAW_MONITOR_CONTENDED_EXIT ((jint)53)
00360 #define JVMPI_EVENT_MONITOR_CONTENDED_ENTER ((jint)54)
00361 #define JVMPI_EVENT_MONITOR_CONTENDED_ENTERED ((jint)55)
00362 #define JVMPI_EVENT_MONITOR_CONTENDED_EXIT ((jint)56)
00363 #define JVMPI_EVENT_MONITOR_WAIT ((jint)57)
00364 #define JVMPI_EVENT_MONITOR_WAITED ((jint)58)
00365 #define JVMPI_EVENT_MONITOR_DUMP ((jint)59)
00366
00367 #define JVMPI_EVENT_GC_START ((jint)60)
00368 #define JVMPI_EVENT_GC_FINISH ((jint)61)
00369
00370 #define JVMPI_MAX_EVENT_TYPE_VAL ((jint)61)
00371
00372
00373 #define JVMPI_EVENT_LOAD_COMPILED_METHOD ((jint)7)
00374 #define JVMPI_EVENT_UNLOAD_COMPILED_METHOD ((jint)8)
00375 #define JVMPI_EVENT_NEW_ARENA ((jint)48)
00376 #define JVMPI_EVENT_DELETE_ARENA ((jint)49)
00377 #define JVMPI_EVENT_DUMP_DATA_REQUEST ((jint)44)
00378 #define JVMPI_EVENT_RESET_DATA_REQUEST ((jint)45)
00379 #define JVMPI_EVENT_OBJ_ALLOC ((jint)4)
00380 #define JVMPI_EVENT_OBJ_FREE ((jint)5)
00381 #define JVMPI_EVENT_OBJ_MOVE ((jint)6)
00382
00383 #define JVMPI_REQUESTED_EVENT ((jint)0x10000000)
00384
00385
00386
00387
00388
00389
00390
00391 #define JVMPI_SUCCESS ((jint)0)
00392 #define JVMPI_NOT_AVAILABLE ((jint)1)
00393 #define JVMPI_FAIL ((jint)-1)
00394
00395
00396
00397
00398 enum {
00399 JVMPI_THREAD_RUNNABLE = 1,
00400 JVMPI_THREAD_MONITOR_WAIT,
00401 JVMPI_THREAD_CONDVAR_WAIT
00402 };
00403
00404 #define JVMPI_THREAD_SUSPENDED 0x8000
00405 #define JVMPI_THREAD_INTERRUPTED 0x4000
00406
00407
00408
00409
00410 #define JVMPI_MINIMUM_PRIORITY 1
00411 #define JVMPI_MAXIMUM_PRIORITY 10
00412 #define JVMPI_NORMAL_PRIORITY 5
00413
00414
00415
00416
00417 #define JVMPI_NORMAL_OBJECT ((jint)0)
00418 #define JVMPI_CLASS ((jint)2)
00419 #define JVMPI_BOOLEAN ((jint)4)
00420 #define JVMPI_CHAR ((jint)5)
00421 #define JVMPI_FLOAT ((jint)6)
00422 #define JVMPI_DOUBLE ((jint)7)
00423 #define JVMPI_BYTE ((jint)8)
00424 #define JVMPI_SHORT ((jint)9)
00425 #define JVMPI_INT ((jint)10)
00426 #define JVMPI_LONG ((jint)11)
00427
00428
00429
00430
00431
00432 #define JVMPI_MONITOR_JAVA 0x01
00433 #define JVMPI_MONITOR_RAW 0x02
00434
00435
00436
00437
00438 #define JVMPI_GC_ROOT_UNKNOWN 0xff
00439 #define JVMPI_GC_ROOT_JNI_GLOBAL 0x01
00440 #define JVMPI_GC_ROOT_JNI_LOCAL 0x02
00441 #define JVMPI_GC_ROOT_JAVA_FRAME 0x03
00442 #define JVMPI_GC_ROOT_NATIVE_STACK 0x04
00443 #define JVMPI_GC_ROOT_STICKY_CLASS 0x05
00444 #define JVMPI_GC_ROOT_THREAD_BLOCK 0x06
00445 #define JVMPI_GC_ROOT_MONITOR_USED 0x07
00446 #define JVMPI_GC_ROOT_THREAD_OBJ 0x08
00447
00448 #define JVMPI_GC_CLASS_DUMP 0x20
00449 #define JVMPI_GC_INSTANCE_DUMP 0x21
00450 #define JVMPI_GC_OBJ_ARRAY_DUMP 0x22
00451 #define JVMPI_GC_PRIM_ARRAY_DUMP 0x23
00452
00453
00454
00455
00456 #define JVMPI_DUMP_LEVEL_0 ((jint)0)
00457 #define JVMPI_DUMP_LEVEL_1 ((jint)1)
00458 #define JVMPI_DUMP_LEVEL_2 ((jint)2)
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
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 #endif