home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 39 / IOPROG_39.ISO / SOFT / sdkjava40.exe / data1.cab / fg_Include / Include / jevmon.idl < prev    next >
Encoding:
Text File  |  2000-05-04  |  45.5 KB  |  1,210 lines

  1. /*++
  2.  
  3. Copyright (c) 1997-1998  Microsoft Corporation, All Rights Reserved
  4.  
  5. Module Name:
  6.  
  7.     jevmon.idl
  8.  
  9. Abstract:
  10.  
  11.     Defines the Java VM event monitor interface.
  12.  
  13. --*/
  14.  
  15.  
  16. cpp_quote("//+-------------------------------------------------------------------------")
  17. cpp_quote("//")
  18. cpp_quote("//  Microsoft Virtual Machine for Java(TM) Event Monitor Interfaces")
  19. cpp_quote("//  Copyright (C) Microsoft Corporation, 1997-1998.")
  20. cpp_quote("//")
  21. cpp_quote("//--------------------------------------------------------------------------")
  22. cpp_quote("")
  23. cpp_quote("//")
  24. cpp_quote("// Declarations for the Java VM event monitor interface.")
  25. cpp_quote("//")
  26. cpp_quote("")
  27. cpp_quote("#ifndef __JEVMON_H__")
  28. cpp_quote("#define __JEVMON_H__")
  29. cpp_quote("")
  30.  
  31.  
  32. #ifndef DO_NO_IMPORTS
  33. import "oleidl.idl";
  34. #endif
  35.  
  36.  
  37. //
  38. // Event monitor registration:
  39. //
  40. //      HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM\Monitors\<monitor key name>
  41. //          default value REG_SZ    = "<event monitor description>"
  42. //          CLSID REG_SZ            = "{<event monitor CLSID>}"
  43. //
  44. // E.g.,
  45. //
  46. //      HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM\Monitors\FleaMonitor
  47. //          default value REG_SZ    = "Flea Software's Java Event Monitor version 2.1"
  48. //          CLSID REG_SZ            = "{57339315-CE82-11d0-A329-00C04FB68D0E}"
  49.  
  50. // A unique handle from the Java VM to an event monitor
  51. typedef DWORD UniqueID;
  52.  
  53. // A ThreadID uniquely identifies a thread.
  54. typedef UniqueID ThreadID;
  55.  
  56. // A StackID uniquely identifies a stack frame.
  57. typedef UniqueID StackID;
  58.  
  59. // An ObjectID uniquely identifies an object.
  60. typedef UniqueID ObjectID;
  61.  
  62. // An ObjectHandleID uniquely identifies a handle to an object.
  63. typedef UniqueID ObjectHandleID;
  64.  
  65. // A MethodID uniquely identifies a method.
  66. typedef UniqueID MethodID;
  67.  
  68. // A FieldID uniquely identifies a field.
  69. typedef UniqueID FieldID;
  70.  
  71. // A ClassID uniquely identifies a class.
  72. typedef UniqueID ClassID;
  73.  
  74. typedef enum jvm_id_type
  75. {
  76.     JVM_ID_FIRST,
  77.  
  78.     JVM_ID_THREAD,
  79.  
  80.     JVM_ID_STACK,
  81.  
  82.     JVM_ID_OBJECT,
  83.  
  84.     JVM_ID_OBJECT_HANDLE,
  85.  
  86.     JVM_ID_METHOD,
  87.  
  88.     JVM_ID_FIELD,
  89.  
  90.     JVM_ID_CLASS,
  91.  
  92.     JVM_ID_LAST,
  93. }
  94. JVM_ID_TYPE;
  95.  
  96. // Source code line number information is expressed as an array of SourceLineInfos.
  97. typedef struct tagSourceLineInfo
  98. {
  99.     DWORD code_offset;
  100.     DWORD line_number;
  101. }
  102. SourceLineInfo;
  103.  
  104. // Interpreted methods are compoosed of BYTE_CODEs.
  105. typedef unsigned char BYTE_CODE;
  106.  
  107. // The following environment variables and associated registry settings control
  108. // the Java VM's execution state:
  109. //
  110. //      MSJAVA_ENABLE_MONITORS      event monitors      default off
  111. //          "EnableEventMonitors" REG_DWORD under "HKEY_CURRENT_USER\Software\Microsoft\Java VM"
  112. //
  113. //      MSJAVA_ENABLE_DEBUGGING     debugger            default off
  114. //          "HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM\Debug", or
  115. //          "HKEY_LOCAL_MACHINE\Software\Microsoft\Java VM\ActiveXDebug" key
  116. //
  117. //      MSJAVA_ENABLE_JIT           JIT compiler        default on
  118. //          "EnableJIT" REG_DWORD under "HKEY_CURRENT_USER\Software\Microsoft\Java VM"
  119. //
  120. //      MSJAVA_ENABLE_FI            fast interpreter    default on
  121. //          "EnableFI" REG_DWORD under "HKEY_CURRENT_USER\Software\Microsoft\Java VM"
  122. //
  123. // Set a variable to a non-0 value to enable it, 0 to disable it, or leave it unset
  124. // to accept the default setting.  Any environment variable setting overrides the
  125. // associated registry setting.
  126.  
  127. // Java VM state flags.
  128. typedef enum java_state_flags
  129. {
  130.     // Interpreter loop enabled.
  131.  
  132.     JVM_STATE_INTERPRETER_ENABLED       = 0x0001,
  133.  
  134.     // Fast interpreter loop enabled.
  135.  
  136.     JVM_STATE_FAST_INTERPRETER_ENABLED  = 0x0002,
  137.  
  138.     // JIT compiler enabled.
  139.  
  140.     JVM_STATE_JIT_COMPILER_ENABLED      = 0x0004,
  141.  
  142.     // Debugging enabled.
  143.  
  144.     JVM_STATE_DEBUGGER_ENABLED          = 0x0008,
  145.  
  146.     // flag combinations
  147.  
  148.     ALL_JVM_FLAGS                       = (JVM_STATE_INTERPRETER_ENABLED |
  149.                                            JVM_STATE_FAST_INTERPRETER_ENABLED |
  150.                                            JVM_STATE_JIT_COMPILER_ENABLED |
  151.                                            JVM_STATE_DEBUGGER_ENABLED)
  152. }
  153. JAVA_STATE_FLAGS;
  154.  
  155. // Event monitors can request notification of these event categories.
  156. typedef enum java_event_category
  157. {
  158.     JVM_MONITOR_NONE                    = 0x00000000,
  159.  
  160.     JVM_MONITOR_CLASS_LOADS             = 0x00000001,
  161.  
  162.     JVM_MONITOR_METHOD_CALLS            = 0x00000002,
  163.  
  164.     JVM_MONITOR_JIT_COMPILATION         = 0x00000004,
  165.  
  166.     JVM_MONITOR_BYTE_CODE_EXECUTION     = 0x00000008,
  167.  
  168.     JVM_MONITOR_SOURCE_LINE_EXECUTION   = 0x00000010,
  169.  
  170.     JVM_MONITOR_EXCEPTIONS              = 0x00000020,
  171.  
  172.     JVM_MONITOR_MONITOR_OPERATIONS      = 0x00000040,
  173.  
  174.     JVM_MONITOR_GARBAGE_COLLECTIONS     = 0x00000080,
  175.  
  176.     JVM_MONITOR_THREADS                 = 0x00000100,
  177.  
  178.     JVM_MONITOR_SAMPLING                = 0x00000200,
  179.  
  180.     JVM_MONITOR_EXCEPTION_UNWIND        = 0x00000400,
  181.  
  182.     JVM_MONITOR_SPECIFIC_METHOD_CALLS   = 0x00000800,
  183.  
  184.     ALL_JVM_MONITOR_EVENTS              = (JVM_MONITOR_NONE |
  185.                                            JVM_MONITOR_CLASS_LOADS |
  186.                                            JVM_MONITOR_METHOD_CALLS |
  187.                                            JVM_MONITOR_JIT_COMPILATION |
  188.                                            JVM_MONITOR_BYTE_CODE_EXECUTION |
  189.                                            JVM_MONITOR_SOURCE_LINE_EXECUTION |
  190.                                            JVM_MONITOR_EXCEPTIONS |
  191.                                            JVM_MONITOR_MONITOR_OPERATIONS |
  192.                                            JVM_MONITOR_GARBAGE_COLLECTIONS |
  193.                                            JVM_MONITOR_THREADS |
  194.                                            JVM_MONITOR_SAMPLING |
  195.                                            JVM_MONITOR_EXCEPTION_UNWIND |
  196.                                            JVM_MONITOR_SPECIFIC_METHOD_CALLS)
  197. }
  198. JAVA_EVENT_CATEGORY;
  199.  
  200. // Options that may be modified during initialization of the monitor.  The VM
  201. // uses these settings to optimize event monitoring overhead.
  202. typedef enum java_monitor_init_options
  203. {
  204.     // The monitor will preserve floating point state during MethodEntry and
  205.     // MethodExit[2] callbacks.
  206.     JVM_INIT_OPT_FP_SAFE_METHOD_CALLS           = 0x00000001,
  207.  
  208.     // The monitor will not enable garbage collection during MethodEntry and
  209.     // MethodExit[2] callbacks.
  210.     JVM_INIT_OPT_GC_SAFE_METHOD_CALLS           = 0x00000002,
  211.  
  212.     // The monitor will not call GetMethodExitReturnValue.
  213.     JVM_INIT_OPT_RETURN_VALUE_NOT_NEEDED        = 0x00000004,
  214.  
  215.     // The monitor will not toggle method call events after initialization.
  216.     JVM_INIT_OPT_WONT_TOGGLE_METHOD_CALL_EVENTS = 0x00000008,
  217.  
  218.     ALL_JVM_INIT_OPTIONS                = (JVM_INIT_OPT_FP_SAFE_METHOD_CALLS |
  219.                                            JVM_INIT_OPT_GC_SAFE_METHOD_CALLS |
  220.                                            JVM_INIT_OPT_RETURN_VALUE_NOT_NEEDED |
  221.                                            JVM_INIT_OPT_WONT_TOGGLE_METHOD_CALL_EVENTS),
  222. }
  223. JAVA_MONITOR_INIT_OPTIONS;
  224.  
  225. // Method execution models.
  226. typedef enum java_execution_model
  227. {
  228.     // sentinel
  229.  
  230.     JVM_EXECUTION_FIRST             = -2,
  231.  
  232.     JVM_EXECUTION_INVALID,
  233.  
  234.     JVM_EXECUTION_JIT_COMPILED,
  235.  
  236.     JVM_EXECUTION_NATIVE,
  237.  
  238.     JVM_EXECUTION_INTERPRETED,
  239.  
  240.     JVM_EXECUTION_FAST_INTERPRETED,
  241.  
  242.     JVM_EXECUTION_COM,
  243.  
  244.     // sentinel
  245.  
  246.     JVM_EXECUTION_LAST
  247. }
  248. JAVA_EXECUTION_MODEL;
  249.  
  250. // Field flags.
  251. typedef enum java_field_flags
  252. {
  253.     JVM_FIELD_STATIC                = 0x00000001,
  254.  
  255.     JVM_FIELD_OBJECTREF             = 0x00000002,
  256.  
  257.     ALL_JVM_FIELD_FLAGS             = (JVM_FIELD_STATIC|JVM_FIELD_OBJECTREF),
  258. }
  259. JVM_FIELD_FLAGS;
  260.  
  261. // Object flags.
  262. typedef enum java_object_flags
  263. {
  264.     JVM_OBJ_ALREADY_REPORTED        = 0x00000001,   // Object has already been reported as a reference.
  265.  
  266.     JVM_OBJ_ALREADY_VISITED         = 0x00000002,   // Object has already been visited and will not be traversed.
  267.  
  268.     JVM_OBJ_MORE_REFERENCES         = 0x00010000,   // Additional references from the same object will be reported in subsequent calls.
  269.  
  270.     ALL_JVM_OBJECT_FLAGS            = (JVM_OBJ_ALREADY_REPORTED|JVM_OBJ_ALREADY_VISITED|JVM_OBJ_MORE_REFERENCES),
  271. }
  272. JVM_OBJECT_FLAGS;
  273.  
  274. // Special class properties.
  275. typedef enum java_class_properties
  276. {
  277.     JVM_CLS_VARIABLE_SIZE           = 0x00000001,   // Fields may not be present in all instances of the class.
  278.  
  279.     JVM_CLS_HAS_DESCRIPTION         = 0x00000002,   // The object may proxy to or contain internal VM data structures.
  280.                                                     // 'DescribeObject' may be used to describe the contents of instances.
  281.  
  282.     ALL_JVM_CLS_PROPERTIES          = (JVM_CLS_VARIABLE_SIZE|JVM_CLS_HAS_DESCRIPTION),
  283. }
  284. JVM_CLASS_PROPERTIES;
  285.  
  286.  
  287. typedef enum java_method_sample_accuracy
  288. {
  289.     JVM_SAMPLE_NONE          = 0,           // A sample could not be obtained.
  290.  
  291.     JVM_SAMPLE_POOR          = 1,           // The sample is not very accurate.
  292.  
  293.     JVM_SAMPLE_EXACT         = 100,         // The sample is 100% accurate.
  294. }
  295. JVM_METHOD_SAMPLE_ACCURACY;
  296.  
  297. typedef enum java_method_sample_location_type
  298. {
  299.     JVM_LOCATION_UNKNOWN,                   // The sampled location could not be identified.
  300.     JVM_LOCATION_JIT,                       //   is in JIT-compiled code.
  301.     JVM_LOCATION_NATIVE,                    //   is in misc. native code (VM, DLL, OS, etc.).
  302.     JVM_LOCATION_GC,                        //   is performing a garbage-collection-related task.
  303.     JVM_LOCATION_COMPILER,                  //   is compiling a method or performing on-first-call tasks for a method.
  304.     JVM_LOCATION_LOADER,                    //   is performing a VM loader-related task.
  305.     JVM_LOCATION_DEBUGGER,                  //   is performing a VM debugger-related task.
  306.     JVM_LOCATION_SECURITY,                  //   is performing a VM security-related task.
  307.     JVM_LOCATION_PROFILER,                  //   is performing a VM profiling-related task.
  308.     JVM_LOCATION_BLOCKING,                  //   is in a wait state.
  309.  
  310.     JVM_LOCATION_LAST,
  311. }
  312. JVM_METHOD_SAMPLE_LOCATION_TYPE;
  313.  
  314. typedef enum java_method_sample_flags
  315. {
  316.     JVM_SAMPLE_STACK_ID         = 0x00000001,  // stack_id is valid
  317.     JVM_SAMPLE_METHOD_ID        = 0x00000002,  // method_id is valid
  318.     JVM_SAMPLE_LOCATION         = 0x00000004,  // location_type is valid
  319.  
  320.     JVM_SAMPLE_GENERATED_CODE   = 0x00000008,  // the sampled ip was in VM-generated code.  if possible,
  321.                                                //  ip has been filled in with the caller of the generated
  322.                                                //  code, which may also be generated code.
  323.  
  324.     JVM_SAMPLE_PC               = 0x00000010,  // pc_offset is valid
  325.  
  326.     ALL_JVM_SAMPLE_FIELDS   = JVM_SAMPLE_STACK_ID | JVM_SAMPLE_METHOD_ID | JVM_SAMPLE_LOCATION | JVM_SAMPLE_PC,
  327.  
  328.     ALL_JVM_SAMPLE_FLAGS    = ALL_JVM_SAMPLE_FIELDS | JVM_SAMPLE_GENERATED_CODE,
  329. }
  330. JVM_METHOD_SAMPLE_FLAGS;
  331.  
  332. typedef struct java_method_sample
  333. {
  334.     DWORD                               flags;          // bit mask of flags from JVM_METHOD_SAMPLE_FLAGS,
  335.     JVM_METHOD_SAMPLE_ACCURACY          accuracy;       // estimate of the relative accuracy of the information in this struct
  336.     StackID                             stack_id;       // stack frame for the current location
  337.     MethodID                            method_id;      // method for which the code is executing
  338.     JVM_METHOD_SAMPLE_LOCATION_TYPE     location_type;  // type/activity of code at the location, if known
  339.     DWORD                               ip;             // instruction pointer at the time of the sample
  340.     DWORD                               sp;             // stack pointer at the time of the sample
  341.     DWORD                               pc_offset;      // bytecode offset, if the method is currently interpreted
  342. }
  343. JVM_METHOD_SAMPLE;
  344.  
  345. typedef enum java_calling_convention
  346. {
  347.     JVM_CALL_FIRST,
  348.  
  349.     JVM_CALL_PASCAL,
  350.  
  351.     JVM_CALL_CDECL,
  352.  
  353.     JVM_CALL_LAST,
  354. }
  355. JVM_CALLING_CONVENTION;
  356.  
  357. typedef enum java_call_flags
  358. {
  359.     JVM_CALL_THIS       = 0x00000001,
  360.  
  361.     ALL_JVM_CALL_FLAGS  = JVM_CALL_THIS,
  362. }
  363. JVM_CALL_FLAGS;
  364.  
  365.  
  366. // Java VM events
  367.  
  368. // These events are passed to IJavaEventMonitor::NotifyEvent().  Notification of
  369. // other events occurs through other methods on IJavaEventMonitor or
  370. // IJavaEventMonitor2.  Each event has an additional information ID associated
  371. // with it.
  372. //
  373. // Certain events may require special synchronization with use of apis that
  374. // operate on the event's parameters.  For example, a THREAD_DESTROYED event
  375. // may be sent before another thread gets to use ThreadInformation.  The VM
  376. // does not check that the id has been destroyed.  Profilers should take care
  377. // to synchronize the destruction events with their uses by ensuring that
  378. // the last use of the id occurs before returning from handling the destruction
  379. // event.  Events/ids that need to be synchronized:
  380. // THREAD_DESTROYED: ThreadID
  381. // CLASS_UNLOADED: ClassID, MethodIDs for members of the unloaded ClassID
  382.  
  383. typedef enum tagJVM_EVENT_TYPE
  384. {
  385.   // sentinel
  386.  
  387.   JVM_EVENT_TYPE_FIRST = -1,
  388.  
  389.   // execution
  390.  
  391.   JVM_EVENT_TYPE_EXCEPTION_OCCURRED = 0,    // An exception occurred.  The exception handler will be executed in StackID's stack frame.
  392.  
  393.   // object monitors
  394.  
  395.   JVM_EVENT_TYPE_MONITOR_BLOCKED = 1,       // NOT IMPLEMENTED: The current thread blocked while trying to acquire object ObjectID's monitor.
  396.  
  397.   JVM_EVENT_TYPE_MONITOR_ACQUIRING = 2,     // The current thread is about to try to acquire object ObjectID's monitor.
  398.  
  399.   JVM_EVENT_TYPE_MONITOR_ACQUIRED = 16,     // The current thread acquired object ObjectID's monitor.
  400.  
  401.   JVM_EVENT_TYPE_MONITOR_RELEASED = 3,      // The current thread released object ObjectID's monitor.
  402.  
  403.   // threads
  404.  
  405.   JVM_EVENT_TYPE_THREAD_CREATE = 4,         // Java thread ThreadID is being created.
  406.  
  407.   JVM_EVENT_TYPE_THREAD_DESTROY = 5,        // Java thread ThreadID is being destroyed.
  408.  
  409.   // classes
  410.  
  411.   JVM_EVENT_TYPE_CLASS_LOAD_STARTED = 6,    // A class is starting to be loaded.  ID is pointer to UTF8 string name of class.
  412.  
  413.   JVM_EVENT_TYPE_CLASS_LOAD_FINISHED = 7,   // Class ClassID is finished being loaded.
  414.  
  415.   JVM_EVENT_TYPE_CLASS_LOAD_FAILED = 17,    // A class load failed.  ID is pointer to UTF8 string name of class.
  416.  
  417.   JVM_EVENT_TYPE_CLASS_UNLOAD = 8,          // Class ClassID is being unloaded.
  418.  
  419.   // JIT compiler
  420.  
  421.   JVM_EVENT_TYPE_JIT_COMPILE_STARTED = 9,   // The JIT compiler is starting to compile method MethodID.
  422.  
  423.   JVM_EVENT_TYPE_JIT_COMPILE_FINISHED = 10, // The JIT compiler is finished compiling method MethodID.
  424.  
  425.   JVM_EVENT_TYPE_JIT_COMPILE_FAILED = 18,   // The JIT compiler failed to compile method MethodID.
  426.  
  427.   // garbage collection
  428.  
  429.   JVM_EVENT_TYPE_GC_STARTED = 11,           // Garbage collection is starting (ID undefined).
  430.  
  431.   JVM_EVENT_TYPE_GC_FINISHED = 12,          // Garbage collection is finished (ID undefined).
  432.  
  433.   // shutdown
  434.  
  435.   JVM_EVENT_TYPE_SHUTDOWN = 13,             // The program is exiting (ID undefined).
  436.  
  437.   // reserved
  438.  
  439.   JVM_EVENT_TYPE_RESERVED_14 = 14,          // Deprecated.  Formerly JVM_EVENT_TYPE_SHUTDOWN_ERROR.  No longer dispatched.
  440.  
  441.   JVM_EVENT_TYPE_RESERVED_15 = 15,          // Deprecated.  Formerly JVM_EVENT_TYPE_SHUTDOWN_INTERRUPTED.  No longer dispatched.
  442.  
  443.   JVM_EVENT_TYPE_RESERVED_16 = 16,          // Used as JVM_EVENT_TYPE_MONITOR_ACQUIRED above.
  444.  
  445.   JVM_EVENT_TYPE_RESERVED_17 = 17,          // Used as JVM_EVENT_TYPE_CLASS_LOAD_FAILED above.
  446.  
  447.   JVM_EVENT_TYPE_RESERVED_18 = 18,          // Used as JVM_EVENT_TYPE_JIT_COMPILE_FAILED above.
  448.  
  449.   // sentinel
  450.  
  451.   JVM_EVENT_TYPE_LAST
  452. }
  453. JVM_EVENT_TYPE;
  454.  
  455. // These events are passed to IJavaEventMonitor2::NotifyEvent2().  Notification
  456. // of other events occurs through other methods on IJavaEventMonitor or
  457. // IJavaEventMonitor2.  Each event has two additional information IDs
  458. // associated with it.
  459.  
  460. typedef enum tagJVM_EVENT_TYPE2
  461. {
  462.   // sentinel
  463.  
  464.   JVM_EVENT_TYPE2_FIRST = 1024,
  465.  
  466.   // threads
  467.  
  468.   JVM_EVENT_TYPE2_THREAD_SET_NAME,          // A thread's name has been set.  ID1 is ThreadID.  ID2 is pointer to Unicode string thread name.
  469.  
  470.   // execution
  471.  
  472.   JVM_EVENT_TYPE2_EXCEPTION_OCCURRED,       // An exception occurred.  ID1 is MethodID, ID2 is StackID.  The exception handler will be executed in MethodID/StackID's stack frame.
  473.  
  474.   JVM_EVENT_TYPE2_EXCEPTION_THROWN,         // An exception is about to be thrown.  ID1 is the ClassID of the exception, ID2 is the ObjectID of the exception.
  475.  
  476.   JVM_EVENT_TYPE2_EXCEPTION_UNWIND,         // An exception is being thrown past this frame.  ID1 is MethodID, ID2 is StackID.
  477.  
  478.   // stack trace
  479.  
  480.   JVM_EVENT_TYPE2_STACK_TRACE,              // Callback from GetStackTrace.  ID1 is MethodID, ID2 is StackID.
  481.  
  482.   // initialization
  483.  
  484.   JVM_EVENT_TYPE2_INITIALIZED,              // The vm has fully initialized.
  485.  
  486.   JVM_EVENT_TYPE2_MONITORS_INITIALIZED,     // All event monitors have initialized.  Returning a failed
  487.                                             // HRESULT from NotifyEvent2 will detach the monitor from the VM, and
  488.                                             // no more events will be sent to the monitor.  ID1 is the number of
  489.                                             // event monitors attached to the VM. ID2 is a bitmask of
  490.                                             // JAVA_EVENT_CATEGORY, indicating the maximum possible set of events
  491.                                             // that may be enabled by all attached profilers.
  492.  
  493.   // sentinel
  494.  
  495.   JVM_EVENT_TYPE2_LAST
  496. }
  497. JVM_EVENT_TYPE2;
  498.  
  499. // The Java VM implements IEventMonitorInfo.  The Java VM passes an IEventMonitorInfo
  500. // to each event monitor during initialization.  The event monitor should AddRef()
  501. // the IJavaEventMonitorInfo interface.  Given an ID, an event monitor can call
  502. // back on IEventMonitorInfo to get information about the method, thread, object,
  503. // class, etc., associated with the ID.  The IEventMonitorInfo methods must be
  504. // called on the same thread that the ID was supplied on.
  505. //
  506. // Return S_OK on success, or E_FAIL on failure.
  507. //
  508. // If non-NULL, the [out] buffer parameters are filled with pointers to buffers
  509. // created with CoTaskMemAlloc().  The callee must free them via CoTaskMemFree().
  510.  
  511. // IJavaEventMonitorIDInfo interface
  512. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitorIDInfo, 0xa57d3f40, 0x8b8a, 0x11d0, 0x93, 0x81, 0x0, 0xa0, 0xc9, 0xa, 0x8f, 0xbe);")
  513. [
  514.     object,
  515.     uuid(A57D3F40-8B8A-11d0-9381-00A0C90A8FBE),
  516.     helpstring("IJavaEventMonitorIDInfo interface"),
  517.     pointer_default(unique)
  518. ]
  519. interface IJavaEventMonitorIDInfo : IUnknown
  520. {
  521.     // Set the event notifications requested.
  522.  
  523.     HRESULT SetEventMask(
  524.         [in] DWORD events);     // bit mask of flags from JAVA_EVENT_CATEGORY
  525.  
  526.     // Get the event notifications requested.
  527.  
  528.     HRESULT GetEventMask(
  529.         [in] DWORD *pevents);   // bit mask of flags from JAVA_EVENT_CATEGORY
  530.  
  531.     // Describe a method.
  532.  
  533.     HRESULT MethodInformation(
  534.         [in] MethodID method_id,
  535.         [out] LPSTR *ppmethod_name,
  536.         [out] ClassID *pclass_id,
  537.         [out] JAVA_EXECUTION_MODEL *pexec,
  538.         [out] int *psource_line_info_length,
  539.         [out] SourceLineInfo **ppsource_line_info);
  540.  
  541.     // Describe an interpreted method.
  542.  
  543.     HRESULT InterpretedMethodInformation(
  544.         [in] MethodID method_id,
  545.         [out] unsigned int *pbyte_code_length,
  546.         [out] BYTE_CODE **ppbyte_codes);
  547.  
  548.     // Describe a JIT-compiled method.
  549.  
  550.     HRESULT JITCompiledMethodInformation(
  551.         [in] MethodID method_id,
  552.         [out] unsigned int *pjit_code_length,
  553.         [out] unsigned char **ppjit_code);
  554.  
  555.     // Describe a class.
  556.  
  557.     HRESULT ClassInformation(
  558.         [in] ClassID class_id,
  559.         [out] LPSTR *ppclass_name,
  560.         [out] LPSTR *ppsource_file_name,
  561.         [out] int *pmethods,
  562.         [out] MethodID **ppmethod_ids,
  563.         [out] __int64 *pobjects_created);
  564.  
  565.     // Describe an object.
  566.  
  567.     HRESULT ObjectInformation(
  568.         [in] ObjectID objectID,
  569.         [out] ClassID *pclass_id);
  570.  
  571.     // Get the number of object monitors that have been used.
  572.  
  573.     HRESULT GetMonitorUsage(
  574.         [out] __int64 *pmonitors_used);
  575. }
  576.  
  577. // IJavaEventMonitorIDInfo2 interface
  578. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitorIDInfo2, 0x25ef5e75, 0x5b53, 0x11d1, 0xa3, 0x89, 0x0, 0xc0, 0x4f, 0xb6, 0x8d, 0xe);")
  579. [
  580.     object,
  581.     uuid(25EF5E75-5B53-11d1-A389-00C04FB68D0E),
  582.     helpstring("IJavaEventMonitorIDInfo2 interface"),
  583.     pointer_default(unique)
  584. ]
  585. interface IJavaEventMonitorIDInfo2 : IJavaEventMonitorIDInfo
  586. {
  587.     // Describe a thread.
  588.  
  589.     HRESULT ThreadInformation(
  590.         [in] ThreadID threadID,
  591.         [out] DWORD *pWin32ThreadID);
  592.  
  593.     // Static class information.
  594.  
  595.     HRESULT StaticClassInformation(
  596.         [in] ClassID class_id,
  597.         [out] DWORD *pStaticDataSize,
  598.         [out] DWORD *pInstanceSize);
  599.  
  600.     // Obtains class path.
  601.  
  602.     HRESULT GetClassPath(
  603.         [out] LPSTR *ppszClassPath);
  604.  
  605.     // Get object size.
  606.  
  607.     HRESULT GetObjectSize(
  608.         [in] ObjectID objectID,
  609.         [out] DWORD *pSize);
  610.  
  611.     // Profiling capabilities.
  612.  
  613.     HRESULT GetProfilingCapabilities(
  614.         [out] DWORD *pStates,               // bit mask of flags from JAVA_STATE_FLAGS
  615.         [out] DWORD *pCategories,           // bit mask of flags from JAVA_EVENT_CATEGORY
  616.         [out] JAVA_EXECUTION_MODEL *pLastModel,
  617.         [out] JVM_EVENT_TYPE *pLastType,
  618.         [out] JVM_EVENT_TYPE2 *pLastType2);
  619.  
  620.     // Describes fields of a class.  The fields are ordered in memory
  621.     // layout - not necessarily the order they are declared.
  622.  
  623.     HRESULT GetClassFields(
  624.         [in] ClassID class_id,
  625.         [out] unsigned *pnfields,
  626.         [out] FieldID **pfield_ids);
  627.  
  628.     HRESULT FieldInformation(
  629.         [in] FieldID id,
  630.         [out] LPSTR *pname,
  631.         [out] DWORD *pflags);               // bit mask of flags from JVM_FIELD_FLAGS
  632.  
  633.     // Obatins the current thread.
  634.  
  635.     HRESULT GetCurrentThread(
  636.         [out] ThreadID *pcurrent_thread_id);
  637.  
  638.     // Obtains a stack trace for the specified thread.  Frames are enumerated
  639.     // from lowest to highest through NotifyEvent2 with JVM_EVENT_TYPE2_STACK_TRACE.
  640.     // The thread will be temporarily suspended - no other events will be sent
  641.     // for this thread for the duration of this method.
  642.     // The NotifyEvent2 callback should return S_OK to continue enumerating stack frames.
  643.     //
  644.     // thread_id may be NULL to indicate the current thread.
  645.     //
  646.     // Returns E_FAIL if the thread is not in a state in which a stack trace can be obtained.
  647.     // Otherwise, returns the result of the last NotifyEvent2 callback, or S_OK if
  648.     // the stack was empty or all callbacks return S_OK.
  649.  
  650.     HRESULT GetStackTrace(
  651.         [in] ThreadID thread_id);
  652.  
  653.     // Samples the current method for the given thread.  If the method is not
  654.     // known, a "guess" (a recent caller, nearest native caller, etc.) may be
  655.     // returned, along with an estimate of the accuracy.  A precise sample may
  656.     // always be obtained using GetStackTrace; however, it is slower and may
  657.     // require code to be executed before reporting stack frames.
  658.     // JVM_MONITOR_SAMPLING is not required, but will improve the ability to
  659.     // provide accurate samples at the expense of some overhead on non-jit
  660.     // method calls.
  661.  
  662.     HRESULT SampleThreadLocation(
  663.         [in] ThreadID thread_id,
  664.         [in,out] JVM_METHOD_SAMPLE *psample);
  665.  
  666.     // Obtains a list of classes that have special properties.
  667.  
  668.     HRESULT GetSpecialClassProperties(
  669.         [out] unsigned *pnspecial_classes,
  670.         [out] ClassID **ppclass_ids,
  671.         [out] DWORD **ppclass_flags);  // mask of JVM_CLASS_PROPERTIES for each class
  672.  
  673.     // Obtains a description of a special object that contains vm-dependent
  674.     // fields.  A list of objects supported by this function may be obtained
  675.     // through GetSpecialClassProperties - this function works on any class
  676.     // with JVM_CLS_HAS_DESCRIPTION. ex. for a java/lang/Class instance, this
  677.     // returns the class's name.
  678.  
  679.     HRESULT DescribeObject(
  680.         [in] ObjectID object_id,
  681.         [out] LPWSTR *pdescr);
  682.  
  683.     // Obtains the value of a field from an object.
  684.     // For references fields, *pvalue will be an ObjectID.  Otherwise, *pvalue
  685.     // is the value of the field.
  686.  
  687.     HRESULT GetObjectField(
  688.         [in] ObjectID object_id,
  689.         [in] FieldID field_id,
  690.         [out] __int64 *pvalue);
  691.  
  692.     // Obtains the value of an array element.  index is 0-based.
  693.     // For arrays of objects, *pvalue will be an ObjectID.  Otherwise, *pvalue
  694.     // is the value of the element.
  695.  
  696.     HRESULT GetArrayElement(
  697.         [in] ObjectID object_id,
  698.         [in] unsigned index,
  699.         [out] __int64 *pvalue);
  700.  
  701.     // Obtains persistent handles to objects.  The handles are valid across
  702.     // garbage collections and may be converted to their current ObjectIDs
  703.     // to allow tracking of specific objects.  Owning a handle to an object
  704.     // will not prevent the object from being garbage collected.
  705.  
  706.     HRESULT GetHandlesToObjects(
  707.         [in] unsigned nobjects,
  708.         [in] ObjectID *pobject_ids,
  709.         [in,out] ObjectHandleID *pobject_handles);
  710.  
  711.     HRESULT FreeHandlesToObjects(
  712.         [in] unsigned nhandles,
  713.         [in] ObjectHandleID *pobject_handles);
  714.  
  715.     // Obtains the current ObjectIDs for a list of ObjectHandleIDs.  Objects
  716.     // that have been collected will have a NULL ObjectID, the handle will be
  717.     // automatically freed, and the handle be set to NULL.
  718.  
  719.     HRESULT GetObjectsFromHandles(
  720.         [in] unsigned nhandles,
  721.         [in,out] ObjectHandleID *pobject_handles,
  722.         [in,out] ObjectID *pobject_ids);
  723. }
  724.  
  725.  
  726. typedef enum method_call_events_disposition
  727. {
  728.     JVM_PROHIBIT_METHOD_CALL_EVENTS = 1,
  729.  
  730.     JVM_PERMIT_METHOD_CALL_EVENTS   = 2,
  731.  
  732.     JVM_QUERY_DISPOSITION           = 3,
  733. }
  734. JVM_METHOD_CALL_EVENTS_DISPOSITION;
  735.  
  736. // IJavaEventMonitorIDInfo3 interface
  737. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitorIDInfo3, 0x5be7cd50, 0xe3eb, 0x11d1, 0xb0, 0x42, 0x0, 0x60, 0x8, 0x3, 0x9b, 0xf0);")
  738. [
  739.     object,
  740.     uuid(5BE7CD50-E3EB-11d1-B042-006008039BF0),
  741.     helpstring("IJavaEventMonitorIDInfo3 interface"),
  742.     pointer_default(unique)
  743. ]
  744. interface IJavaEventMonitorIDInfo3 : IJavaEventMonitorIDInfo2
  745. {
  746.     // Turns method call events (MethodEnter/MethodExit/MethodExit2 calls) on
  747.     // or off for a specific method.  The final determination to hook a method
  748.     // is as follows:
  749.     //
  750.     // - if any profiler has requested that a specific method *not* be hooked
  751.     // by specifying JVM_PROHIBIT_METHOD_CALL_EVENTS, no profilers will
  752.     // receive callbacks for the method.  The decision by a profiler to not
  753.     // hook a method is irreversible.  This is intended for use by a profiler
  754.     // to disable hooking of methods that are required to execute unobstructed
  755.     // for the proper functioning of the profiler (ex. a profiler that has
  756.     // Java-implemented methods that are invoked in response to a method call
  757.     // event).
  758.     //
  759.     // - if any profiler may possibly enable JVM_MONITOR_METHOD_CALLS, then all
  760.     // methods (except those specifically forbidden above) will be hooked.
  761.     // Any profiler that has requested JVM_MONITOR_METHOD_CALLS or
  762.     // JVM_MONITOR_SPECIFIC_METHOD_CALLS will receive method call events for
  763.     // the method.
  764.     //
  765.     // - if any profiler turns on method call events for a specific set of
  766.     // methods by specifying JVM_PERMIT_METHOD_CALL_EVENTS, all profilers that
  767.     // have requested JVM_MONITOR_SPECIFIC_METHOD_CALLS will receive the events
  768.     // for the methods.  This means that if one profiler requests events for a
  769.     // specific method, all profilers will receive the events.
  770.     //
  771.     // A profiler should *not* use JVM_PROHIBIT_METHOD_CALL_EVENTS to
  772.     // selectively disable method call events for a method.  Instead, request
  773.     // that no methods be hooked and then enable hooking for those that are
  774.     // interesting, i.e. implement IJavaEventMonitorIDInfo2, do not return
  775.     // JVM_MONITOR_METHOD_CALLS from GetPossibleEventCategories, enable
  776.     // JVM_MONITOR_CLASS_LOADS, and at each JVM_EVENT_TYPE_CLASS_LOAD_FINISHED
  777.     // event, use JVM_PERMIT_METHOD_CALL_EVENTS to enable hooking for the
  778.     // methods that are interesting.
  779.     //
  780.     // Currently, this function will fail if the method has already been
  781.     // executed; it should be called during the class load event for the
  782.     // method's class.
  783.     //
  784.     // If 'idtype' is JVM_ID_METHOD, 'id' should be a MethodID.  Returns S_OK
  785.     // if the method will be hooked, S_FALSE if not, or E_FAIL if the method is
  786.     // already running, hooking does not apply to the method, or hooking cannot
  787.     // be disabled for the method.
  788.     //
  789.     // If 'idtype' is JVM_ID_CLASS, 'id' should be a ClassID - this is the
  790.     // same as enumerating all of the MethodIDs of a class and invoking this
  791.     // function on each.  In this case, the function returns S_OK if all of
  792.     // the methods will be hooked, S_FALSE if any of them will not or cannot
  793.     // be hooked, or E_FAIL if none of them can be hooked.
  794.     //
  795.     // JVM_QUERY_DISPOSITION may be specified to determine the hook status of
  796.     // a method.
  797.  
  798.     HRESULT EnableMethodCallEvents(
  799.         [in] UniqueID id,
  800.         [in] JVM_ID_TYPE idtype,
  801.         [in] JVM_METHOD_CALL_EVENTS_DISPOSITION Disposition);
  802.  
  803.     // Obtains a pointer to the base of the parameters passed to the current
  804.     // method.  This function should only be called during a MethodEntry
  805.     // callback.
  806.  
  807.     HRESULT GetMethodEntryParameters(
  808.         [out] DWORD **pslots,
  809.         [out] DWORD **preserved,
  810.         [out] JVM_CALLING_CONVENTION *pcalling_convention,
  811.         [out] DWORD *pflags);           // bitmask of JVM_CALL_FLAGS
  812.  
  813.     // Obtains a pointer to the method return value for the method that just
  814.     // returned.  This function should only be called during a
  815.     // MethodExit/MethodExit2 callback.
  816.  
  817.     HRESULT GetMethodExitReturnValue(
  818.         [out] MethodID *preturning_method_id,
  819.         [out] __int64 **pret_value);
  820.  
  821.     // Obtains more information about a class: the superclass, interfaces, and
  822.     // all methods implemented by the class, including those inherited from
  823.     // superclasses but not those overridden in superclasses.
  824.     //
  825.     // An interface may appear in the returned interface list more than once.
  826.     // Base interfaces of explicitly implemented interfaces will be in the
  827.     // list, i.e. it is not necessary to call ClassInformation2 again for each
  828.     // listed interface.
  829.     //
  830.     // The list of methods includes the contents of the vtable plus all static
  831.     // and non-virtual methods.  The list of methods will include any private
  832.     // methods of superclasses or other methods that may not be accessible
  833.     // through the given class.  Methods may be in the list more than once, and
  834.     // if the class is abstract, abstract methods may also be listed.
  835.  
  836.     HRESULT ClassInformation2(
  837.         [in] ClassID class_id,
  838.         [out] ClassID *psuperclass,                     // ClassID of superclass, or NULL for java/lang/Object
  839.         [out] ClassID **pinterfaces,                    // ClassIDs of implemented interfaces
  840.         [out] unsigned *pinterfaces_length,
  841.         [out] MethodID **pimplemented_methods,          // MethodIDs of all implemented methods, including those inherited
  842.         [out] unsigned *pimplemented_methods_length);
  843. }
  844.  
  845.  
  846. // IJavaEventMonitorIDInfo4 interface
  847. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitorIDInfo4, 0x5a183bd0, 0x4f46, 0x11d2, 0xb0, 0x64, 0x0, 0x60, 0x8, 0x3, 0x9b, 0xf0);")
  848. [
  849.     object,
  850.     uuid(5A183BD0-4F46-11d2-B064-006008039BF0),
  851.     helpstring("IJavaEventMonitorIDInfo4 interface"),
  852.     pointer_default(unique)
  853. ]
  854. interface IJavaEventMonitorIDInfo4 : IJavaEventMonitorIDInfo3
  855. {
  856.     // Retrieves the per-monitor initialization options that were set through
  857.     // SetMonitorInitializationOptions.  After all monitors have been
  858.     // initialized, GetFinalInitializationOptions may be used to retrieve the
  859.     // options that were actually used to initialize profiling support.
  860.     HRESULT GetMonitorInitializationOptions (
  861.         [out] DWORD *pflags);                           // bitmask of JAVA_MONITOR_INIT_OPTIONS
  862.  
  863.     // Sets the initialization options requested by this monitor.  This method
  864.     // will fail after all monitors have been initialized, which is indicated
  865.     // by receipt of JVM_EVENT_TYPE2_MONITORS_INITIALIZED.  Event monitors may
  866.     // call GetFinalInitializationOptions when
  867.     // JVM_EVENT_TYPE2_MONITORS_INITIALIZED is received to check which options
  868.     // were enabled.
  869.     HRESULT SetMonitorInitializationOptions (
  870.         [in] DWORD flags);                              // bitmask of JAVA_MONITOR_INIT_OPTIONS
  871.  
  872.     // Retrives the final options used to initialize profiling support.  This
  873.     // method will fail before all monitors have been initialized, which is
  874.     // indicated by receipt of JVM_EVENT_TYPE2_MONITORS_INITIALIZED.
  875.     HRESULT GetFinalInitializationOptions (
  876.         [out] DWORD *pflags);                           // bitmask of JAVA_MONITOR_INIT_OPTIONS
  877. }
  878.  
  879.  
  880. // Each event monitor implements IJavaEventMonitor.  The Java VM calls methods
  881. // on IJavaEventMonitor to notify the event monitor of events that occur during
  882. // Java VM execution.
  883. //
  884. // Return S_OK on success, or E_FAIL on failure.
  885.  
  886. // IJavaEventMonitor interface
  887. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitor, 0xa57d3f41, 0x8b8a, 0x11d0, 0x93, 0x81, 0x0, 0xa0, 0xc9, 0xa, 0x8f, 0xbe);")
  888. [
  889.     object,
  890.     uuid(A57D3F41-8B8A-11d0-9381-00A0C90A8FBE),
  891.     helpstring("IJavaEventMonitor interface"),
  892.     pointer_default(unique)
  893. ]
  894. interface IJavaEventMonitor : IUnknown
  895. {
  896.     // Initialize an event monitor.
  897.     HRESULT Initialize(
  898.         [in] LPCSTR pclass_file_name,
  899.         [in] IJavaEventMonitorIDInfo *pmonitor_info,
  900.         [in] DWORD java_flags,                          // bit mask of flags from JAVA_STATE_FLAGS
  901.         [out] DWORD *prequested_events);                // bit mask of events from JAVA_EVENT_CATEGORY
  902.  
  903.     // An event from JVM_EVENT_TYPE is about to occur.
  904.     HRESULT NotifyEvent(
  905.         [in] JVM_EVENT_TYPE event,
  906.         [in] UniqueID event_id);
  907.  
  908.     // A method is about to be entered.
  909.     HRESULT MethodEntry(
  910.         [in] MethodID method_id,
  911.         [in] StackID stack_id);
  912.  
  913.     // A method is about to be exited.
  914.     HRESULT MethodExit(
  915.         [in] StackID stack_id);
  916.  
  917.     // The execution of a bytecode instruction is about to occur.
  918.     HRESULT ExecuteByteCode(
  919.         [in] MethodID method_id,
  920.         [in] BYTE_CODE *pbyte_code,
  921.         [in] DWORD byte_code_offset);
  922.  
  923.     // The execution of a source line is about to occur.
  924.     HRESULT ExecuteSourceLine(
  925.         [in] MethodID method_id,
  926.         [in] DWORD line_number);
  927. }
  928.  
  929. // Each event monitor may implement IJavaEventMonitor2.  The Java VM calls
  930. // methods on IJavaEventMonitor2 to notify the event monitor of events that
  931. // occur during Java VM execution.
  932. //
  933. // Return S_OK on success, or E_FAIL on failure.
  934.  
  935. // IJavaEventMonitor2 interface
  936. cpp_quote("DEFINE_GUID(IID_IJavaEventMonitor2, 0x20f66f6f, 0x5b32, 0x11d1, 0xa3, 0x89, 0x0, 0xc0, 0x4f, 0xb6, 0x8d, 0xe);")
  937. [
  938.     object,
  939.     uuid(20F66F6F-5B32-11d1-A389-00C04FB68D0E),
  940.     helpstring("IJavaEventMonitor2 interface"),
  941.     pointer_default(unique)
  942. ]
  943. interface IJavaEventMonitor2 : IJavaEventMonitor
  944. {
  945.     // An event from JVM_EVENT_TYPE2 is about to occur.
  946.     HRESULT NotifyEvent2(
  947.         [in] JVM_EVENT_TYPE2 event2,
  948.         [in] UniqueID first_event_id,
  949.         [in] UniqueID second_event_id);
  950.  
  951.     // A method is about to be exited.
  952.     HRESULT MethodExit2(
  953.         [in] MethodID method_id,
  954.         [in] StackID stack_id);
  955.  
  956.     // Obtains the maximal set of event categories that will ever be enabled.
  957.     // This information is used to eliminate profiling overhead for callbacks
  958.     // that will never be requested.
  959.     HRESULT GetPossibleEventCategories(
  960.         [out] DWORD *ppossible_events);                 // bit mask of events from JAVA_EVENT_CATEGORY
  961. }
  962.  
  963.  
  964. // G C  H E A P    M O N I T O R   I N T E R F A C E S
  965. //
  966. // The heap monitoring API's allow one to get the following:
  967. // - notification on each object allocation
  968. // - heap dump (right after a GC)
  969. //
  970. // The Heap Dump will first dump all roots.  The roots are
  971. // labeled with C_RT_XXXXXX.   After all roots are dumped,
  972. // any remaining heap contents are dumped as C_HEAP.
  973.  
  974.  
  975.  
  976.  
  977.  
  978. // C O N T A I N E R S
  979. //
  980. // The notion of a container is used when passing heap information
  981. // to the monitor.   This way the monitor can completely rebuild
  982. // all containment hierarchy within the roots.
  983. //
  984. // Stack frame types are always subcontainers of a THREAD container, and are
  985. // reported bottom-up.  Other types are top-level containers.
  986. //
  987. // THREAD containers may be reported multiple times.  The same frames
  988. // may not be reported both times, but equal ids in both reports can
  989. // be assumed to be the same frames, and frames may be ordered by
  990. // their id values.
  991.  
  992. typedef enum container_type
  993. {
  994.     C_FIRST,
  995.     C_BEGIN,                        // Dummy container noting the start of heap enumeration.
  996.     C_RT_THREAD,                    // Roots for thread                 // id1=ThreadID
  997.     C_RT_JIT,                       // Live Pointers in JIT'd methods   // id1=StackID, id2=MethodID
  998.     C_RT_NATIVE,                    // Native Frame                     // id1=StackID, id2=MethodID
  999.     C_RT_NATIVEGC,                  // Native GC Frame                  // id1=StackID
  1000.     C_RT_COM,                       // COM Frame                        // id1=StackID, id2=MethodID
  1001.     C_RT_INTERPRETED,               // Interpreted Method Frame         // id1=StackID, id2=MethodID
  1002.     C_RT_FASTINTERPRETED,           // Fast Interpreted Method Frame    // id1=StackID, id2=MethodID
  1003.     C_RT_INTERNALFRAME,             // Internal VM Frame                // id1=StackID
  1004.     C_RT_INTERNALVM,                // Internal VM Object
  1005.     C_RT_CLASS,                     // Static class references          // id1=ClassID
  1006.     C_RT_ROOTTABLE,                 // Misc. roots
  1007.     C_RT_STRONGPTR,                 // Strong ptr
  1008.     C_FINALIZED,                    // Objects awaiting finalization
  1009.     C_HEAP,                         // Remaining portions of the heap not reported in the above
  1010.     C_END,                          // Dummy container noting the end of heap enumeration.
  1011.     C_LAST,
  1012. }
  1013. CONTAINER_TYPE;
  1014.  
  1015.  
  1016. //
  1017. // I H e a p I n f o C a l l b a c k
  1018. //
  1019. // Callback interface implemented by tool for heap dumping.
  1020.  
  1021. cpp_quote("DEFINE_GUID(IID_IHeapInfoCallback, 0x81a26182, 0x439f, 0x11d1, 0xb1, 0x4a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);")
  1022. [
  1023.     object,
  1024.     uuid(81A26182-439F-11d1-B14A-000000000000),
  1025.     helpstring("IHeapInfo Interface"),
  1026.     pointer_default(unique)
  1027. ]
  1028. interface IHeapInfoCallback : IUnknown
  1029. {
  1030.     HRESULT BeginContainer(
  1031.         [in] CONTAINER_TYPE type,
  1032.         [in] UniqueID id1,
  1033.         [in] UniqueID id2);
  1034.  
  1035.     //
  1036.     // RootReferences: reports references from the current container.
  1037.     // ObjectReferences: reports an object and the object's references.
  1038.     //
  1039.     // Each reference will be traversed in a depth-first fashion.  A parallel
  1040.     // array indicates objects that have been seen before that will not be
  1041.     // traversed.  This identifies recursive structures and objects with
  1042.     // multiple references.  If an object has a reference to itself, the
  1043.     // reference will be reported as visited.
  1044.     //
  1045.     // All references in an object will be reported before descending.  If
  1046.     // all references cannot be reported in a single call,
  1047.     // JVM_OBJ_MORE_REFERENCES will be set for the object.
  1048.     //
  1049.     // References not reported during root traversal are reported later
  1050.     // within the C_HEAP container.
  1051.     //
  1052.     // Each reference corresponds to a field, in the same order obtained
  1053.     // from GetClassFields, so 'null' references are reported.  Note that
  1054.     // only fields with JVM_FIELD_OBJECTREF and without JVM_FIELD_STATIC
  1055.     // are relevant.  Note that for some objects (ex. java/lang/String),
  1056.     // the number of references reported may not match the number of fields.
  1057.     //
  1058.     // Clients can obtain a flat list of objects by always returning
  1059.     // S_POSTPONE_REFERENCES.
  1060.     //
  1061.     // Result codes:
  1062.     // FAILED(): stop heap enumeration completely
  1063.     // S_POSTPONE_REFERENCES && !(flags & JVM_OBJ_MORE_REFERENCES):
  1064.     //      do not descend references - report them independently in C_HEAP.
  1065.     //      Only respected on the final reference dump for an object, e.g.
  1066.     //      JVM_OBJ_MORE_REFERENCES is not set in 'flags'.
  1067.     // else SUCCEEDED(): continue/descend all references from this object
  1068.     //
  1069.  
  1070.     HRESULT RootReferences(
  1071.         [in] const ObjectID *prefs,         // references within this root
  1072.         [in] unsigned nrefs,                // number of references being reported
  1073.         [in] const DWORD *pflags);          // JVM_OBJECT_FLAGS for each reference
  1074.  
  1075.     HRESULT ObjectReferences(
  1076.         [in] ObjectID id,                   // object being reported
  1077.         [in] DWORD flags,                   // JVM_OBJECT_FLAGS for the object
  1078.         [in] const ObjectID *prefs,         // references within this object
  1079.         [in] unsigned nrefs,                // number of references being reported
  1080.         [in] const DWORD *pflags);          // JVM_OBJECT_FLAGS for each reference
  1081. };
  1082.  
  1083.  
  1084. // Postpone reporting references to C_HEAP.
  1085. cpp_quote("static const int S_POSTPONE_REFERENCES   = MAKE_HRESULT(0, FACILITY_ITF, 0x01);")
  1086.  
  1087.  
  1088. //
  1089. // I O b j e c t A l l o c a t i o n C a l l b a c k
  1090. //
  1091. // Callback interface implemented by tool for notification on object allocation.
  1092.  
  1093. cpp_quote("DEFINE_GUID(IID_IObjectAllocationCallback, 0x76514ea2, 0x33f4, 0x11d1, 0xa4, 0xa3, 0x0, 0xa0, 0xc9, 0xa, 0xeb, 0x5d);")
  1094. [
  1095.     object,
  1096.     uuid(76514EA2-33F4-11d1-A4A3-00A0C90AEB5D),
  1097.     helpstring("IObjectAllocationCallback Interface"),
  1098.     pointer_default(unique)
  1099. ]
  1100. interface IObjectAllocationCallback : IUnknown
  1101. {
  1102.     // Return S_OK.
  1103.     HRESULT OnObjectAllocated(
  1104.         [in] ObjectID oid,
  1105.         [in] ClassID type);
  1106. };
  1107.  
  1108.  
  1109. typedef enum tagJVM_HEAPMON_CAPABILITIES
  1110. {
  1111.     // Requests that the vm track the age of each object where possible.
  1112.     // Must be enabled/disabled during the event monitor's Initialize.
  1113.     JVM_HEAPMON_OBJECT_AGE          = 0x00000001,
  1114.  
  1115.     ALL_JVM_HEAPMON_CAPABILITIES    = JVM_HEAPMON_OBJECT_AGE,
  1116. }
  1117. JVM_HEAPMON_CAPABILITIES;
  1118.  
  1119.  
  1120. //
  1121. // I J a v a H e a p M o n i t o r
  1122. //
  1123. // Heap Monitor interface implemented by Java VM
  1124. //
  1125. cpp_quote("DEFINE_GUID(IID_IJavaHeapMonitor, 0x81a26183, 0x439f, 0x11d1, 0xb1, 0x4a, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0);")
  1126. [
  1127.     object,
  1128.     uuid(81A26183-439F-11d1-B14A-000000000000),
  1129.     helpstring("IJavaHeapMonitor Interface"),
  1130.     pointer_default(unique)
  1131. ]
  1132. interface IJavaHeapMonitor : IUnknown
  1133. {
  1134.     // Registers a heap callback.  The heap is dumped at the end of each gc.
  1135.     // A monitor may only have one callback installed at a time.  If
  1136.     // pihicb == NULL, the callback is revoked.
  1137.  
  1138.     HRESULT GetHeapInfo(
  1139.         [in] IHeapInfoCallback *pihicb);
  1140.  
  1141.     // Registers an object allocation callback.
  1142.     // A monitor may only have one callback installed at a time.  If
  1143.     // pioacb == NULL, the callback is revoked.
  1144.  
  1145.     HRESULT NotifyOnObjectAllocations(
  1146.         [in] IObjectAllocationCallback *pioacb);
  1147.  
  1148.     // Obtains descriptions of the given container type.
  1149.  
  1150.     HRESULT GetContainerDescription(
  1151.         [in] CONTAINER_TYPE type,
  1152.         [out] LPWSTR *pshort,
  1153.         [out] LPWSTR *plong);
  1154.  
  1155.     // Requests that specific heap monitor functionality be enabled or
  1156.     // disabled.  Certain capabilities may have specific times during
  1157.     // which they may be enabled or disabled.
  1158.  
  1159.     HRESULT ModifyHeapMonitorCapabilities(
  1160.         [in] DWORD capabilities,                // mask of JVM_HEAPMON_CAPABILITIES
  1161.         [in] BOOL fenable,                      // TRUE to enable capabilities, FALSE to disable
  1162.         [out] DWORD *penabled_capabilities);    // mask of JVM_HEAPMON_CAPABILITIES
  1163.  
  1164.     // Obtains the number of collections an object has survived.
  1165.  
  1166.     HRESULT GetObjectAge(
  1167.         [in] ObjectID object_id,
  1168.         [out] DWORD *pncollections_survived);
  1169. };
  1170.  
  1171.  
  1172. typedef enum tagJVM_WALKHEAP_FLAGS
  1173. {
  1174.     // Do not enumerate through roots.  No BeginContainer or RootReferences
  1175.     // calls will be received.
  1176.     JVM_WALKHEAP_NO_ROOTS       = 0x00000001,
  1177. }
  1178. JVM_WALKHEAP_FLAGS;
  1179.  
  1180.  
  1181. cpp_quote("DEFINE_GUID(IID_IJavaHeapMonitor2, 0x86e81530, 0x5dd8, 0x11d2, 0xb0, 0x67, 0x0, 0x60, 0x8, 0x3, 0x9b, 0xf0);")
  1182. [
  1183.     object,
  1184.     uuid(86E81530-5DD8-11d2-B067-006008039BF0),
  1185.     helpstring("IJavaHeapMonitor2 Interface"),
  1186.     pointer_default(unique)
  1187. ]
  1188. interface IJavaHeapMonitor2 : IJavaHeapMonitor
  1189. {
  1190.     // Initiates a heap dump.  This method may only be called from the
  1191.     // profiler's BeginContainer callback when C_END is received.  This method
  1192.     // will return E_FAIL if called from a different thread or at any other
  1193.     // time.  ObjectIDs from the previous heap dump will remain valid across
  1194.     // the new heap dump.
  1195.     //
  1196.     // Unlike passive heap callbacks, C_BEGIN and C_END notifications will not
  1197.     // be received.  (They convey no useful information, since the caller is
  1198.     // initiating the dump.)
  1199.     
  1200.     HRESULT WalkHeap(
  1201.         [in] IHeapInfoCallback *pihicb,
  1202.         [in] DWORD flags);                      // mask of JVM_WALKHEAP_FLAGS
  1203. };
  1204.  
  1205.  
  1206. cpp_quote("")
  1207. cpp_quote("#endif   // __JEVMON_H__")
  1208. cpp_quote("")
  1209.  
  1210.