📄 jvmpi.h
字号:
/* * @(#)jvmpi.h 1.28 03/12/19 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */#ifndef _JAVASOFT_JVMPI_H_#define _JAVASOFT_JVMPI_H_#include "jni.h"#define JVMPI_VERSION_1 ((jint)0x10000001) /* implied 0 for minor version */#define JVMPI_VERSION_1_1 ((jint)0x10000002)#define JVMPI_VERSION_1_2 ((jint)0x10000003)#ifdef __cplusplusextern "C" {#endif typedef void (*jvmpi_void_function_of_void)(void *);#ifdef __cplusplus}#endif/**************************************************************** * Profiler interface data structures. ****************************************************************//* identifier types. */struct _jobjectID;typedef struct _jobjectID * jobjectID; /* type of object ids */ /* raw monitors */struct _JVMPI_RawMonitor;typedef struct _JVMPI_RawMonitor * JVMPI_RawMonitor;/* call frame */typedef struct { jint lineno; /* line number in the source file */ jmethodID method_id; /* method executed in this frame */} JVMPI_CallFrame;/* call trace */typedef struct { JNIEnv *env_id; /* Env where trace was recorded */ jint num_frames; /* number of frames in this trace */ JVMPI_CallFrame *frames; /* frames */} JVMPI_CallTrace;/* method */typedef struct { char *method_name; /* name of method */ char *method_signature; /* signature of method */ jint start_lineno; /* -1 if native, abstract .. */ jint end_lineno; /* -1 if native, abstract .. */ jmethodID method_id; /* id assigned to this method */} JVMPI_Method;/* Field */typedef struct { char *field_name; /* name of field */ char *field_signature; /* signature of field */} JVMPI_Field;/* line number info for a compiled method */typedef struct { jint offset; /* offset from beginning of method */ jint lineno; /* lineno from beginning of src file */} JVMPI_Lineno;/* event */typedef struct { jint event_type; /* event_type */ JNIEnv *env_id; /* env where this event occured */ union { struct { const char *class_name; /* class name */ char *source_name; /* name of source file */ jint num_interfaces; /* number of interfaces implemented */ jint num_methods; /* number of methods in the class */ JVMPI_Method *methods; /* methods */ jint num_static_fields; /* number of static fields */ JVMPI_Field *statics; /* static fields */ jint num_instance_fields; /* number of instance fields */ JVMPI_Field *instances; /* instance fields */ jobjectID class_id; /* id of the class object */ } class_load; struct { jobjectID class_id; /* id of the class object */ } class_unload; struct { unsigned char *class_data; /* content of class file */ jint class_data_len; /* class file length */ unsigned char *new_class_data; /* instrumented class file */ jint new_class_data_len; /* new class file length */ void * (*malloc_f)(unsigned int); /* memory allocation function */ } class_load_hook; struct { jint arena_id; jobjectID class_id; /* id of object class */ jint is_array; /* JVMPI_NORMAL_OBJECT, ... */ jint size; /* size in number of bytes */ jobjectID obj_id; /* id assigned to this object */ } obj_alloc; struct { jobjectID obj_id; /* id of the object */ } obj_free; struct { jint arena_id; /* cur arena id */ jobjectID obj_id; /* cur object id */ jint new_arena_id; /* new arena id */ jobjectID new_obj_id; /* new object id */ } obj_move; struct { jint arena_id; /* id of arena */ const char *arena_name; /* name of arena */ } new_arena; struct { jint arena_id; /* id of arena */ } delete_arena; struct { char *thread_name; /* name of thread */ char *group_name; /* name of group */ char *parent_name; /* name of parent */ jobjectID thread_id; /* id of the thread object */ JNIEnv *thread_env_id; } thread_start; struct { int dump_level; /* level of the heap dump info */ char *begin; /* where all the root records begin, please see the heap dump buffer format described below */ char *end; /* where the object records end. */ jint num_traces; /* number of thread traces, 0 if dump level = JVMPI_DUMP_LEVEL_0 */ JVMPI_CallTrace *traces; /* thread traces collected during heap dump */ } heap_dump; struct { jobjectID obj_id; /* object id */ jobject ref_id; /* id assigned to the globalref */ } jni_globalref_alloc; struct { jobject ref_id; /* id of the global ref */ } jni_globalref_free; struct { jmethodID method_id; /* method */ } method; struct { jmethodID method_id; /* id of method */ jobjectID obj_id; /* id of target object */ } method_entry2; struct { jmethodID method_id; /* id of compiled method */ void *code_addr; /* code start addr. in memory */ jint code_size; /* code size */ jint lineno_table_size; /* size of lineno table */ JVMPI_Lineno *lineno_table; /* lineno info */ } compiled_method_load; struct { jmethodID method_id; /* id of unloaded compiled method */ } compiled_method_unload; struct { jmethodID method_id; /* id of the method the instruction belongs to */ jint offset; /* instruction offset in the method's bytecode */ union { struct { jboolean is_true; /* whether true or false branch is taken */ } if_info; struct { jint key; /* top stack value used as an index */ jint low; /* min value of the index */ jint hi; /* max value of the index */ } tableswitch_info; struct { jint chosen_pair_index; /* actually chosen pair index (0-based) * if chosen_pair_index == pairs_total then * the 'default' branch is taken */ jint pairs_total; /* total number of lookupswitch pairs */ } lookupswitch_info; } u; } instruction; struct { char *begin; /* beginning of dump buffer, see below for format */ char *end; /* end of dump buffer */ jint num_traces; /* number of traces */ JVMPI_CallTrace *traces; /* traces of all threads */ jint *threads_status; /* status of all threads */ } monitor_dump; struct { const char *name; /* name of raw monitor */ JVMPI_RawMonitor id; /* id */ } raw_monitor; struct { jobjectID object; /* Java object */ } monitor; struct { jobjectID object; /* Java object */ jlong timeout; /* timeout period */ } monitor_wait; struct { jlong used_objects; jlong used_object_space; jlong total_object_space; } gc_info; struct { jint data_len; char *data; } object_dump; } u;} JVMPI_Event;/* interface functions */typedef struct { jint version; /* JVMPI version */ /* ------interface implemented by the profiler------ */ /** * Function called by the JVM to notify an event. */ void (*NotifyEvent)(JVMPI_Event *event); /* ------interface implemented by the JVM------ */ /** * Function called by the profiler to enable/disable/send notification * for a particular event type. * * event_type - event_type * arg - event specific arg * * return JVMPI_NOT_AVAILABLE, JVMPI_SUCCESS or JVMPI_FAIL */ jint (*EnableEvent)(jint event_type, void *arg); jint (*DisableEvent)(jint event_type, void *arg); jint (*RequestEvent)(jint event_type, void *arg); /** * Function called by the profiler to get a stack * trace from the JVM. * * trace - trace data structure to be filled * depth - maximum depth of the trace. */ void (*GetCallTrace)(JVMPI_CallTrace *trace, jint depth); /** * Function called by profiler when it wants to exit/stop. */ void (*ProfilerExit)(jint); /** * Utility functions provided by the JVM. */ JVMPI_RawMonitor (*RawMonitorCreate)(char *lock_name); void (*RawMonitorEnter)(JVMPI_RawMonitor lock_id); void (*RawMonitorExit)(JVMPI_RawMonitor lock_id); void (*RawMonitorWait)(JVMPI_RawMonitor lock_id, jlong ms); void (*RawMonitorNotifyAll)(JVMPI_RawMonitor lock_id); void (*RawMonitorDestroy)(JVMPI_RawMonitor lock_id); /** * Function called by the profiler to get the current thread's CPU time. * * return time in nanoseconds; */ jlong (*GetCurrentThreadCpuTime)(void); void (*SuspendThread)(JNIEnv *env); void (*ResumeThread)(JNIEnv *env); jint (*GetThreadStatus)(JNIEnv *env); jboolean (*ThreadHasRun)(JNIEnv *env); /* This function can be called safely only after JVMPI_EVENT_VM_INIT_DONE notification by the JVM. */ jint (*CreateSystemThread)(char *name, jint priority, void (*f)(void *)); /* thread local storage access functions to avoid locking in time critical functions */ void (*SetThreadLocalStorage)(JNIEnv *env_id, void *ptr); void * (*GetThreadLocalStorage)(JNIEnv *env_id); /* control GC */ void (*DisableGC)(void); void (*EnableGC)(void); void (*RunGC)(void); jobjectID (*GetThreadObject)(JNIEnv *env); jobjectID (*GetMethodClass)(jmethodID mid); /* JNI <-> jobject conversions */ jobject (*jobjectID2jobject)(jobjectID jid); jobjectID (*jobject2jobjectID)(jobject jobj); void (*SuspendThreadList) (jint reqCount, JNIEnv **reqList, jint *results); void (*ResumeThreadList)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -