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