home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Java / Java.zip / jahea131.zip / jvmmi.h < prev    next >
C/C++ Source or Header  |  2003-01-18  |  13KB  |  272 lines

  1. /*
  2.  * @(#)src/contract/jvm/sov/jvmmi.h, core, xs131, 20030107 1.4.2.3
  3.  * ===========================================================================
  4.  * Licensed Materials - Property of IBM
  5.  * "Restricted Materials of IBM"
  6.  *
  7.  * IBM Java(tm)2 SDK, Standard Edition, v 1.3.1
  8.  * (C) Copyright IBM Corp. 1998, 2001. All Rights Reserved
  9.  * US Government Users Restricted Rights - Use, duplication or disclosure
  10.  * restricted by GSA ADP Schedule Contract with IBM Corp.
  11.  * ===========================================================================
  12.  */
  13.  
  14. /*
  15.  *
  16.  * ===========================================================================
  17.  *
  18.  *
  19.  *
  20.  * ===========================================================================
  21.  * Change activity:
  22.  *
  23.  * Reason  Date   Origin  Description
  24.  * ------  ----   ------  ----------------------------------------------------
  25.  * 028883  250401 hdmsa   Creation
  26.  * 033898  050701 hdrjm   Tidy up - add module information
  27.  * 034149  180701 hdseb   Definition of JVMMI_callback structure for use in
  28.  *                        monitor and object enumeration routines
  29.  * 034693  070801 hdbdp   Definition of JVMMI_callback incorrect
  30.  * 041832  120302 jkbar3  JVMMI enhancements (events only)
  31.  * 042159  230302 jkbar3  JVMMI enhancements (event details)
  32.  * 042232  260302 jkbar3  JVMMI enhancements (Thread Creation Requested et al)
  33.  * 042240  260326 jkbar3  JVMMI - Enumerate definitions and events
  34.  * 042321  120202 jkbar3  Monitor enumeration not returning any monitors
  35.  * 051608  110602 jkbar3  corect misleading monitor_info comments
  36.  * 055597  280902 hdcrk   RAS backport from 1.4.0
  37.  *
  38.  * ===========================================================================
  39.  * Module Information:
  40.  *
  41.  * DESCRIPTION: Contains definitions/declarations related to JVMMI. This
  42.  * header is likely to be published if the Monitoring Interface is made public.
  43.  * Additional non-public JVMMI elements are defined in ci_jvmmi.h.
  44.  * ===========================================================================
  45.  */
  46.  
  47. #include <jni.h>
  48.  
  49. #define JVMMI_VERSION_1         ((jint)0x00010011)
  50.  
  51.  
  52. /****************************************************************************/
  53. /* Event types which may be monitored                                       */
  54. /****************************************************************************/
  55.  
  56. /*ibm@41832-start*/
  57. #define JVMMI_EVENT_COUNT                    17 /* Number of events defined */
  58.  
  59. #define JVMMI_EVENT_THREAD_START      0
  60. #define JVMMI_EVENT_THREAD_STOP       1
  61. #define JVMMI_EVENT_CLASS_LOAD        2
  62. #define JVMMI_EVENT_CLASS_UNLOAD      3
  63.  
  64. #define JVMMI_EVENT_THREAD_CREATED            4
  65. #define JVMMI_EVENT_THREAD_CREATION_REQUESTED 5
  66. #define JVMMI_EVENT_JVM_INIT_DONE             6
  67. #define JVMMI_EVENT_JVM_SHUTDOWN              7
  68. #define JVMMI_EVENT_GC_MARK_START             8
  69. #define JVMMI_EVENT_GC_START                  9
  70. #define JVMMI_EVENT_GC_FINISH                10
  71. #define JVMMI_EVENT_HEAP_SIZE                11
  72. #define JVMMI_EVENT_HEAP_FULL                12
  73. #define JVMMI_EVENT_HEAP_LOW                 13
  74. #define JVMMI_EVENT_AREA_ALLOC               14
  75. #define JVMMI_EVENT_OUT_OF_MEMORY            15
  76. #define JVMMI_EVENT_HEAP_DUMP                16
  77. /*ibm@41832-end*/
  78.  
  79. /****************************************************************************/
  80. /* "Items" which may be enumerated over                                     */
  81. /* Any changes here need to be reflected in jvmmi_enumerateDefinitions      */
  82. /****************************************************************************/
  83.  
  84. #define JVMMI_LIST_COUNT        6           /* number of lists defined      */ /*ibm@41832*/
  85.  
  86. #define JVMMI_LIST_DEFINITION   0x10000000  /* what can be enumerated       */ /*ibm@42240*/
  87. #define JVMMI_LIST_EVENT              0x10000001  /* what events can be monitored */
  88. #define JVMMI_LIST_COMPONENT    0x10000002  /* components: st, gc, etc.     */
  89. #define JVMMI_LIST_MONITOR            0x10000003  /* monitors */
  90. #define JVMMI_LIST_OBJECT             0x10000004  /* All objects in heap */
  91. #define JVMMI_LIST_THREAD       0x10000005  /* All threads                  */ /*ibm@42159*/
  92.  
  93.  
  94. /****************************************************************************/
  95. /* Return codes                                                             */
  96. /****************************************************************************/
  97.  
  98. #define JVMMI_OK     JNI_OK
  99. #define JVMMI_ERR    JNI_ERR
  100. #define JVMMI_OTHER  999
  101.  
  102.  
  103. /****************************************************************************/
  104. /* Heap Constants                                                           */
  105. /* The following constants will be used to identify the heap to which a     */
  106. /* heap event (e.g. Heap Low) relates.  If running in non-resettable mode,  */
  107. /* the only value seen will be JVMMI_MAIN_HEAP.                             */
  108. /****************************************************************************/
  109. #define JVMMI_MAIN_HEAP        1   /* The main heap (non-resettable mode)   */
  110. #define JVMMI_MIDDLEWARE_HEAP  1   /* The Middleware Heap (resettable mode) */
  111. #define JVMMI_TRANSIENT_HEAP   2   /* The Transient Heap (resettable mode)  */
  112.  
  113.  
  114. /****************************************************************************/
  115. /* JVMMI_Event                                                              */
  116. /****************************************************************************/
  117.  
  118. typedef struct JVMMI_Event{
  119.  
  120. /****************************************************************************/
  121. /* NOTE: Any change to this structure may need reflecting in the            */
  122. /* jvmmi_enumerateEvents function.                                          */
  123. /****************************************************************************/
  124.  
  125.     int type;                 /* The type of the event */
  126.     JNIEnv *envID;            /* Env where event occured */
  127.  
  128. /*ibm41832-start*/
  129.     union{                           /* The valid element of the union is   */
  130.                                      /* dictated by type                    */
  131.       struct{
  132.           void *id;           /* Unique ID of monitor */
  133.           int tid;                   /* Thread id of current owner          */ /*ibm@51608*/
  134.           int flat_inflated;  /* 0 = flat, 1 = inflated */
  135.           char *name;                /* name of monitor                     */ /*ibm@42321*/
  136.       } monitor_info;
  137.  
  138.       struct{
  139.           void *id;           /* Unique ID of object */
  140.           int size;           /* Size of object */
  141.           char *classname;    /* Name of class this is instance of */
  142.       } object_info;
  143.  
  144.       struct{
  145.           char *name;         /* Class name */
  146.           char *source;       /* Source file name */
  147.           int interfaces;     /* Number of interfaces */
  148.           int methods;        /* Number of methods */
  149.           int fields;         /* Number of fields */
  150.       } class_info;
  151.  
  152.       struct{
  153.           int type;                  /* object Type which can be enumerated */
  154.           char *description;         /* V brief description of enmeration   */ /*ibm@42240*/
  155.       } enumeration_info;
  156.  
  157.       struct{
  158.           char name[3];       /* Name of component */
  159.           void *interface;    /* Pointer to components interface */
  160.       } component_info;
  161.  
  162.       struct{
  163.           int type;           /* Type of event */
  164.           char *detail_name;  /* Name of element in detail union */
  165.           char *elements;     /* List of elements in detail */
  166.           char *description;  /* V brief description of event */
  167.       } event_info;
  168.  
  169.       struct {
  170.           int unused;                /* unused                              */
  171.       } no_additional_info;
  172.  
  173.       struct {
  174.           int  heap_type;            /* which heap was involved?            */
  175.           size_t old_heap_size;      /* how big was this heap before?       */
  176.           size_t new_heap_size;      /* how big is this heap now?           */
  177.           size_t free_heap_size;     /* how much room is left on it?        */
  178.       } heap_info;
  179.  
  180.       struct {
  181.           size_t alloc_bytes;        /* bytes allocated since last alloc    */
  182.                                      /* event                               */
  183.       } alloc_info;
  184.  
  185.       struct {
  186.           void *id;                  /* which thread generated event?       */
  187.           void *parent_id;           /* ID of it's creator                  */
  188.           void *child_id;            /* ID it (just) created or NULL        */
  189.                                      /* if not a thread created event       */
  190.           char *name;                /* name of thread - e.g. "main"        */
  191.       } thread_info;
  192.  
  193.       struct {
  194.           char    *detail_message;   /* detail message                      */
  195.           long     allocated_memory; /* allocated bytes                     */
  196.           int      GC_cycles_done;   /* number of GC cycles performed       */
  197.           size_t   max_heap_size;    /* max size of heap                    */
  198.           size_t   free_list_bytes;  /* bytes on the free list              */
  199.       } memory_exception_info;
  200.  
  201.       struct {
  202.           size_t   free_space;        /* free heap space                    */
  203.           size_t   expected_space;    /* a size_t for expected space        */
  204.           size_t   kickoff_threshold; /* less than this left and we mark    */
  205.       } mark_info;
  206. /*ibm41832-start*/
  207.  
  208.     } detail;
  209. } JVMMI_Event;
  210.  
  211.  
  212.  
  213. /****************************************************************************/
  214. /* JVMMI_Interface                                                          */
  215. /****************************************************************************/
  216.  
  217. typedef int(JNICALL *jvmmi_callback_t)(JNIEnv *env, JVMMI_Event *evt,          /*ibm@42232*/
  218.                                        void *userData, int tid);               /*ibm@42232*/
  219.  
  220. typedef struct JVMMI_Interface{
  221.     /* Enable a callback to "func" on event type "eventId" */
  222.     int (JNICALL *EnableEvent)(JNIEnv *env,
  223.                                jvmmi_callback_t func,                          /*ibm@42232*/
  224.                                void *userData,
  225.                                int eventId);
  226.     /* Disable previously enabled callback to "func" on event type "eventId" */
  227.     int (JNICALL *DisableEvent)(JNIEnv *env,
  228.                                jvmmi_callback_t func,                          /*ibm@42232*/
  229.                                void *userData,
  230.                                int eventId);
  231.     /* Request a callback to "func" for each item of type "itemType", up to a maximum of "limit" items */
  232.     int (JNICALL *EnumerateOver)(JNIEnv *env,
  233.                                int itemType,
  234.                                int limit,
  235.                                jvmmi_callback_t func,                          /*ibm@42232*/
  236.                                void *userData);
  237. } JVMMI_Interface;
  238.  
  239.  
  240. /****************************************************************************/
  241. /* JVMMI_callbackDetail                                                     */
  242. /****************************************************************************/
  243.  
  244. typedef struct JVMMI_callbackDetail{
  245.     jvmmi_callback_t func;                                                     /*ibm@42232*/
  246.     void *userData;
  247.     char enabledEvents[JVMMI_EVENT_COUNT];
  248.     struct JVMMI_callbackDetail *next;
  249. } JVMMI_callbackDetail;
  250.  
  251.  
  252.  
  253. /****************************************************************************/
  254. /* JVMMI_callback                                                           */
  255. /****************************************************************************/
  256.  
  257. typedef struct JVMMI_callback {                                             /*ibm@34149 starts*/
  258.     void *userdata;
  259.     JNIEnv *env;
  260.     int limit;
  261.     int objcount;
  262.     jvmmi_callback_t func;                                                   /*ibm@42232*/
  263. } JVMMI_callback;                                                            /*ibm@34149 ends ibm@34693*/
  264.  
  265.  
  266. /****************************************************************************/
  267. /* Function declarations                                                    */
  268. /****************************************************************************/
  269.  
  270. JVMMI_Interface * jvmmi_GetInterface_1(JavaVM *vm);
  271.  
  272.