From 08bc36a4d07ea26d229e4e3920740f420597f0cf Mon Sep 17 00:00:00 2001 From: Jason Fager Date: Wed, 26 Jul 2017 16:20:21 -0400 Subject: [PATCH] use bindgen --- Cargo.toml | 4 +- build-helper-class.rs | 35 + src/jvmti_sys/mod.rs | 1339 +-------------------------------------- src/jvmti_sys/wrapper.h | 1 + src/lib.rs | 10 +- 5 files changed, 46 insertions(+), 1343 deletions(-) create mode 100644 src/jvmti_sys/wrapper.h diff --git a/Cargo.toml b/Cargo.toml index e596254..120b54e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,4 +17,6 @@ zip = { version = "0.2", default-features = false } [build-dependencies] log = "0.3" -env_logger = "0.3" \ No newline at end of file +env_logger = "0.3" +bindgen = "^0.28.0" + diff --git a/build-helper-class.rs b/build-helper-class.rs index fbfd1ef..541eca5 100644 --- a/build-helper-class.rs +++ b/build-helper-class.rs @@ -1,4 +1,7 @@ +extern crate bindgen; +use std::env; +use std::path::PathBuf; use std::process::Command; fn main() { @@ -20,4 +23,36 @@ fn main() { println!("Gradle stdout: {}", String::from_utf8_lossy(&output.stdout)); println!("Gradle stderr: {}", String::from_utf8_lossy(&output.stderr)); assert!(output.status.success()); + + + let bindings = bindgen::builder() + .header("src/jvmti_sys/wrapper.h") + + // We want jni defs from the jni-sys crate + .raw_line("use jni_sys::*;") + .whitelist_recursively(false) + + .whitelisted_type(".*JVMTI.*") + .whitelisted_type(".*jvmti.*") + .whitelisted_type("^jlocation") + .whitelisted_type("^jthread.*") + .whitelisted_type("^jniNativeInterface$") + + // This is not defined in jni-sys for some reason + .whitelisted_type("^_?jrawMonitorID") + + .whitelisted_var(".*JVMTI.*") + .whitelisted_var(".*jvmti.*") + + .derive_default(true) + + .generate() + .expect("Unable to generate bindings"); + + + // Write the bindings to the $OUT_DIR/bindings.rs file. + let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()); + bindings + .write_to_file(out_path.join("bindings.rs")) + .expect("Couldn't write bindings!"); } diff --git a/src/jvmti_sys/mod.rs b/src/jvmti_sys/mod.rs index cbca2a0..9854339 100644 --- a/src/jvmti_sys/mod.rs +++ b/src/jvmti_sys/mod.rs @@ -1,1338 +1,3 @@ -// Modified from https://github.com/sfackler/rust-jni-sys to clean up naming, use jni-sys, and get rid of libc -#![allow(non_snake_case, non_camel_case_types, dead_code)] +#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, dead_code)] -extern crate jni_sys; - -use std::os::raw::{c_char, c_uchar, c_int, c_uint, c_void}; -use jni_sys::{jobject, jlong, jint, jvalue, jchar, jboolean, jfloat, jdouble, jclass, jmethodID, - jfieldID, JNIEnv, JNINativeInterface_}; -use std::mem; - -pub const JVMTI_VERSION_1: c_uint = 805371904; -pub const JVMTI_VERSION_1_0: c_uint = 805371904; -pub const JVMTI_VERSION_1_1: c_uint = 805372160; -pub const JVMTI_VERSION_1_2: c_uint = 805372416; -pub const JVMTI_VERSION: c_int = 805372417; - -pub type jvmtiEnv = *const jvmtiInterface_1; -pub type jthread = jobject; -pub type jthreadGroup = jobject; -pub type jlocation = jlong; -pub enum _jrawMonitorID { } -pub type jrawMonitorID = *mut _jrawMonitorID; - -pub const JVMTI_THREAD_STATE_ALIVE: c_uint = 1; -pub const JVMTI_THREAD_STATE_TERMINATED: c_uint = 2; -pub const JVMTI_THREAD_STATE_RUNNABLE: c_uint = 4; -pub const JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER: c_uint = 1024; -pub const JVMTI_THREAD_STATE_WAITING: c_uint = 128; -pub const JVMTI_THREAD_STATE_WAITING_INDEFINITELY: c_uint = 16; -pub const JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT: c_uint = 32; -pub const JVMTI_THREAD_STATE_SLEEPING: c_uint = 64; -pub const JVMTI_THREAD_STATE_IN_OBJECT_WAIT: c_uint = 256; -pub const JVMTI_THREAD_STATE_PARKED: c_uint = 512; -pub const JVMTI_THREAD_STATE_SUSPENDED: c_uint = 1048576; -pub const JVMTI_THREAD_STATE_INTERRUPTED: c_uint = 2097152; -pub const JVMTI_THREAD_STATE_IN_NATIVE: c_uint = 4194304; -pub const JVMTI_THREAD_STATE_VENDOR_1: c_uint = 268435456; -pub const JVMTI_THREAD_STATE_VENDOR_2: c_uint = 536870912; -pub const JVMTI_THREAD_STATE_VENDOR_3: c_uint = 1073741824; - -pub const JVMTI_JAVA_LANG_THREAD_STATE_MASK: c_uint = 1207; -pub const JVMTI_JAVA_LANG_THREAD_STATE_NEW: c_uint = 0; -pub const JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED: c_uint = 2; -pub const JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE: c_uint = 5; -pub const JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED: c_uint = 1025; -pub const JVMTI_JAVA_LANG_THREAD_STATE_WAITING: c_uint = 145; -pub const JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING: c_uint = 161; - -pub const JVMTI_THREAD_MIN_PRIORITY: c_uint = 1; -pub const JVMTI_THREAD_NORM_PRIORITY: c_uint = 5; -pub const JVMTI_THREAD_MAX_PRIORITY: c_uint = 10; - -pub const JVMTI_HEAP_FILTER_TAGGED: c_uint = 4; -pub const JVMTI_HEAP_FILTER_UNTAGGED: c_uint = 8; -pub const JVMTI_HEAP_FILTER_CLASS_TAGGED: c_uint = 16; -pub const JVMTI_HEAP_FILTER_CLASS_UNTAGGED: c_uint = 32; - -pub const JVMTI_VISIT_OBJECTS: c_uint = 256; -pub const JVMTI_VISIT_ABORT: c_uint = 32768; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiHeapReferenceKind { - JVMTI_HEAP_REFERENCE_CLASS = 1, - JVMTI_HEAP_REFERENCE_FIELD = 2, - JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_HEAP_REFERENCE_CLASS_LOADER = 4, - JVMTI_HEAP_REFERENCE_SIGNERS = 5, - JVMTI_HEAP_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_HEAP_REFERENCE_INTERFACE = 7, - JVMTI_HEAP_REFERENCE_STATIC_FIELD = 8, - JVMTI_HEAP_REFERENCE_CONSTANT_POOL = 9, - JVMTI_HEAP_REFERENCE_SUPERCLASS = 10, - JVMTI_HEAP_REFERENCE_JNI_GLOBAL = 21, - JVMTI_HEAP_REFERENCE_SYSTEM_CLASS = 22, - JVMTI_HEAP_REFERENCE_MONITOR = 23, - JVMTI_HEAP_REFERENCE_STACK_LOCAL = 24, - JVMTI_HEAP_REFERENCE_JNI_LOCAL = 25, - JVMTI_HEAP_REFERENCE_THREAD = 26, - JVMTI_HEAP_REFERENCE_OTHER = 27, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiPrimitiveType { - JVMTI_PRIMITIVE_TYPE_BOOLEAN = 90, - JVMTI_PRIMITIVE_TYPE_BYTE = 66, - JVMTI_PRIMITIVE_TYPE_CHAR = 67, - JVMTI_PRIMITIVE_TYPE_SHORT = 83, - JVMTI_PRIMITIVE_TYPE_INT = 73, - JVMTI_PRIMITIVE_TYPE_LONG = 74, - JVMTI_PRIMITIVE_TYPE_FLOAT = 70, - JVMTI_PRIMITIVE_TYPE_DOUBLE = 68, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiHeapObjectFilter { - JVMTI_HEAP_OBJECT_TAGGED = 1, - JVMTI_HEAP_OBJECT_UNTAGGED = 2, - JVMTI_HEAP_OBJECT_EITHER = 3, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiHeapRootKind { - JVMTI_HEAP_ROOT_JNI_GLOBAL = 1, - JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2, - JVMTI_HEAP_ROOT_MONITOR = 3, - JVMTI_HEAP_ROOT_STACK_LOCAL = 4, - JVMTI_HEAP_ROOT_JNI_LOCAL = 5, - JVMTI_HEAP_ROOT_THREAD = 6, - JVMTI_HEAP_ROOT_OTHER = 7, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiObjectReferenceKind { - JVMTI_REFERENCE_CLASS = 1, - JVMTI_REFERENCE_FIELD = 2, - JVMTI_REFERENCE_ARRAY_ELEMENT = 3, - JVMTI_REFERENCE_CLASS_LOADER = 4, - JVMTI_REFERENCE_SIGNERS = 5, - JVMTI_REFERENCE_PROTECTION_DOMAIN = 6, - JVMTI_REFERENCE_INTERFACE = 7, - JVMTI_REFERENCE_STATIC_FIELD = 8, - JVMTI_REFERENCE_CONSTANT_POOL = 9, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiIterationControl { - JVMTI_ITERATION_CONTINUE = 1, - JVMTI_ITERATION_IGNORE = 2, - JVMTI_ITERATION_ABORT = 0, -} - -pub const JVMTI_CLASS_STATUS_VERIFIED: c_uint = 1; -pub const JVMTI_CLASS_STATUS_PREPARED: c_uint = 2; -pub const JVMTI_CLASS_STATUS_INITIALIZED: c_uint = 4; -pub const JVMTI_CLASS_STATUS_ERROR: c_uint = 8; -pub const JVMTI_CLASS_STATUS_ARRAY: c_uint = 16; -pub const JVMTI_CLASS_STATUS_PRIMITIVE: c_uint = 32; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiEventMode { - JVMTI_ENABLE = 1, - JVMTI_DISABLE = 0, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiParamTypes { - JVMTI_TYPE_JBYTE = 101, - JVMTI_TYPE_JCHAR = 102, - JVMTI_TYPE_JSHORT = 103, - JVMTI_TYPE_JINT = 104, - JVMTI_TYPE_JLONG = 105, - JVMTI_TYPE_JFLOAT = 106, - JVMTI_TYPE_JDOUBLE = 107, - JVMTI_TYPE_JBOOLEAN = 108, - JVMTI_TYPE_JOBJECT = 109, - JVMTI_TYPE_JTHREAD = 110, - JVMTI_TYPE_JCLASS = 111, - JVMTI_TYPE_JVALUE = 112, - JVMTI_TYPE_JFIELDID = 113, - JVMTI_TYPE_JMETHODID = 114, - JVMTI_TYPE_CCHAR = 115, - JVMTI_TYPE_CVOID = 116, - JVMTI_TYPE_JNIENV = 117, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiParamKind { - JVMTI_KIND_IN = 91, - JVMTI_KIND_IN_PTR = 92, - JVMTI_KIND_IN_BUF = 93, - JVMTI_KIND_ALLOC_BUF = 94, - JVMTI_KIND_ALLOC_ALLOC_BUF = 95, - JVMTI_KIND_OUT = 96, - JVMTI_KIND_OUT_BUF = 97, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiTimerKind { - JVMTI_TIMER_USER_CPU = 30, - JVMTI_TIMER_TOTAL_CPU = 31, - JVMTI_TIMER_ELAPSED = 32, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiPhase { - JVMTI_PHASE_ONLOAD = 1, - JVMTI_PHASE_PRIMORDIAL = 2, - JVMTI_PHASE_START = 6, - JVMTI_PHASE_LIVE = 4, - JVMTI_PHASE_DEAD = 8, -} - -pub const JVMTI_VERSION_INTERFACE_JNI: c_uint = 0; -pub const JVMTI_VERSION_INTERFACE_JVMTI: c_uint = 805306368; - -pub const JVMTI_VERSION_MASK_INTERFACE_TYPE: c_uint = 1879048192; -pub const JVMTI_VERSION_MASK_MAJOR: c_uint = 268369920; -pub const JVMTI_VERSION_MASK_MINOR: c_uint = 65280; -pub const JVMTI_VERSION_MASK_MICRO: c_uint = 255; - -pub const JVMTI_VERSION_SHIFT_MAJOR: c_uint = 16; -pub const JVMTI_VERSION_SHIFT_MINOR: c_uint = 8; -pub const JVMTI_VERSION_SHIFT_MICRO: c_uint = 0; - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiVerboseFlag { - JVMTI_VERBOSE_OTHER = 0, - JVMTI_VERBOSE_GC = 1, - JVMTI_VERBOSE_CLASS = 2, - JVMTI_VERBOSE_JNI = 4, -} - -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiJlocationFormat { - JVMTI_JLOCATION_JVMBCI = 1, - JVMTI_JLOCATION_MACHINEPC = 2, - JVMTI_JLOCATION_OTHER = 0, -} - -pub const JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR: c_uint = 1; -pub const JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP: c_uint = 2; -pub const JVMTI_RESOURCE_EXHAUSTED_THREADS: c_uint = 4; - -#[derive(Clone, Copy, Debug)] -#[repr(C)] -pub enum jvmtiError { - JVMTI_ERROR_NONE = 0, - JVMTI_ERROR_INVALID_THREAD = 10, - JVMTI_ERROR_INVALID_THREAD_GROUP = 11, - JVMTI_ERROR_INVALID_PRIORITY = 12, - JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13, - JVMTI_ERROR_THREAD_SUSPENDED = 14, - JVMTI_ERROR_THREAD_NOT_ALIVE = 15, - JVMTI_ERROR_INVALID_OBJECT = 20, - JVMTI_ERROR_INVALID_CLASS = 21, - JVMTI_ERROR_CLASS_NOT_PREPARED = 22, - JVMTI_ERROR_INVALID_METHODID = 23, - JVMTI_ERROR_INVALID_LOCATION = 24, - JVMTI_ERROR_INVALID_FIELDID = 25, - JVMTI_ERROR_NO_MORE_FRAMES = 31, - JVMTI_ERROR_OPAQUE_FRAME = 32, - JVMTI_ERROR_TYPE_MISMATCH = 34, - JVMTI_ERROR_INVALID_SLOT = 35, - JVMTI_ERROR_DUPLICATE = 40, - JVMTI_ERROR_NOT_FOUND = 41, - JVMTI_ERROR_INVALID_MONITOR = 50, - JVMTI_ERROR_NOT_MONITOR_OWNER = 51, - JVMTI_ERROR_INTERRUPT = 52, - JVMTI_ERROR_INVALID_CLASS_FORMAT = 60, - JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61, - JVMTI_ERROR_FAILS_VERIFICATION = 62, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64, - JVMTI_ERROR_INVALID_TYPESTATE = 65, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67, - JVMTI_ERROR_UNSUPPORTED_VERSION = 68, - JVMTI_ERROR_NAMES_DONT_MATCH = 69, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70, - JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71, - JVMTI_ERROR_UNMODIFIABLE_CLASS = 79, - JVMTI_ERROR_NOT_AVAILABLE = 98, - JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99, - JVMTI_ERROR_NULL_POINTER = 100, - JVMTI_ERROR_ABSENT_INFORMATION = 101, - JVMTI_ERROR_INVALID_EVENT_TYPE = 102, - JVMTI_ERROR_ILLEGAL_ARGUMENT = 103, - JVMTI_ERROR_NATIVE_METHOD = 104, - JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED = 106, - JVMTI_ERROR_OUT_OF_MEMORY = 110, - JVMTI_ERROR_ACCESS_DENIED = 111, - JVMTI_ERROR_WRONG_PHASE = 112, - JVMTI_ERROR_INTERNAL = 113, - JVMTI_ERROR_UNATTACHED_THREAD = 115, - JVMTI_ERROR_INVALID_ENVIRONMENT = 116, -} -pub const JVMTI_ERROR_MAX: c_uint = 116; - -pub const JVMTI_MIN_EVENT_TYPE_VAL: c_uint = 50; -#[derive(Clone, Copy)] -#[repr(C)] -pub enum jvmtiEvent { - JVMTI_EVENT_VM_INIT = 50, - JVMTI_EVENT_VM_DEATH = 51, - JVMTI_EVENT_THREAD_START = 52, - JVMTI_EVENT_THREAD_END = 53, - JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54, - JVMTI_EVENT_CLASS_LOAD = 55, - JVMTI_EVENT_CLASS_PREPARE = 56, - JVMTI_EVENT_VM_START = 57, - JVMTI_EVENT_EXCEPTION = 58, - JVMTI_EVENT_EXCEPTION_CATCH = 59, - JVMTI_EVENT_SINGLE_STEP = 60, - JVMTI_EVENT_FRAME_POP = 61, - JVMTI_EVENT_BREAKPOINT = 62, - JVMTI_EVENT_FIELD_ACCESS = 63, - JVMTI_EVENT_FIELD_MODIFICATION = 64, - JVMTI_EVENT_METHOD_ENTRY = 65, - JVMTI_EVENT_METHOD_EXIT = 66, - JVMTI_EVENT_NATIVE_METHOD_BIND = 67, - JVMTI_EVENT_COMPILED_METHOD_LOAD = 68, - JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69, - JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70, - JVMTI_EVENT_DATA_DUMP_REQUEST = 71, - JVMTI_EVENT_MONITOR_WAIT = 73, - JVMTI_EVENT_MONITOR_WAITED = 74, - JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75, - JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76, - JVMTI_EVENT_RESOURCE_EXHAUSTED = 80, - JVMTI_EVENT_GARBAGE_COLLECTION_START = 81, - JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82, - JVMTI_EVENT_OBJECT_FREE = 83, - JVMTI_EVENT_VM_OBJECT_ALLOC = 84, -} -pub const JVMTI_MAX_EVENT_TYPE_VAL: c_uint = 84; - -//#[allow(non_camel_case_types)] -//pub type jvmtiThreadInfo = Struct__jvmtiThreadInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiMonitorStackDepthInfo = Struct__jvmtiMonitorStackDepthInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiThreadGroupInfo = Struct__jvmtiThreadGroupInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiFrameInfo = Struct__jvmtiFrameInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiStackInfo = Struct__jvmtiStackInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoField = Struct__jvmtiHeapReferenceInfoField; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoArray = Struct__jvmtiHeapReferenceInfoArray; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoConstantPool = Struct__jvmtiHeapReferenceInfoConstantPool; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoStackLocal = Struct__jvmtiHeapReferenceInfoStackLocal; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoJniLocal = Struct__jvmtiHeapReferenceInfoJniLocal; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfoReserved = Struct__jvmtiHeapReferenceInfoReserved; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapReferenceInfo = Union__jvmtiHeapReferenceInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiHeapCallbacks = Struct__jvmtiHeapCallbacks; -//#[allow(non_camel_case_types)] -//pub type jvmtiClassDefinition = Struct__jvmtiClassDefinition; -//#[allow(non_camel_case_types)] -//pub type jvmtiMonitorUsage = Struct__jvmtiMonitorUsage; -//#[allow(non_camel_case_types)] -//pub type jvmtiLineNumberEntry = Struct__jvmtiLineNumberEntry; -//#[allow(non_camel_case_types)] -//pub type jvmtiLocalVariableEntry = Struct__jvmtiLocalVariableEntry; -//#[allow(non_camel_case_types)] -//pub type jvmtiParamInfo = Struct__jvmtiParamInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiExtensionFunctionInfo = Struct__jvmtiExtensionFunctionInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiExtensionEventInfo = Struct__jvmtiExtensionEventInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiTimerInfo = Struct__jvmtiTimerInfo; -//#[allow(non_camel_case_types)] -//pub type jvmtiAddrLocationMap = Struct__jvmtiAddrLocationMap; -//#[allow(non_camel_case_types)] - -pub type jvmtiStartFunction = Option ()>; -pub type jvmtiHeapIterationCallback = Option jint>; -pub type jvmtiHeapReferenceCallback = - Option jint>; -pub type jvmtiPrimitiveFieldCallback = - Option jint>; -pub type jvmtiArrayPrimitiveValueCallback = - Option jint>; -pub type jvmtiStringPrimitiveValueCallback = Option jint>; -pub type jvmtiReservedCallback = Option jint>; -pub type jvmtiHeapObjectCallback = Option jvmtiIterationControl>; -pub type jvmtiHeapRootCallback = Option jvmtiIterationControl>; -pub type jvmtiStackReferenceCallback = Option jvmtiIterationControl>; -pub type jvmtiObjectReferenceCallback = - Option jvmtiIterationControl>; -pub type jvmtiExtensionFunction = Option jvmtiError>; -pub type jvmtiExtensionEvent = Option ()>; - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiThreadInfo { - pub name: *mut c_char, - pub priority: jint, - pub is_daemon: jboolean, - pub thread_group: jthreadGroup, - pub context_class_loader: jobject, -} -impl Clone for jvmtiThreadInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiThreadInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiMonitorStackDepthInfo { - pub monitor: jobject, - pub stack_depth: jint, -} -impl Clone for jvmtiMonitorStackDepthInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiMonitorStackDepthInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiThreadGroupInfo { - pub parent: jthreadGroup, - pub name: *mut c_char, - pub max_priority: jint, - pub is_daemon: jboolean, -} -impl Clone for jvmtiThreadGroupInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiThreadGroupInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiFrameInfo { - pub method: jmethodID, - pub location: jlocation, -} -impl Clone for jvmtiFrameInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiFrameInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiStackInfo { - pub thread: jthread, - pub state: jint, - pub frame_buffer: *mut jvmtiFrameInfo, - pub frame_count: jint, -} -impl Clone for jvmtiStackInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiStackInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoField { - pub index: jint, -} -impl Clone for jvmtiHeapReferenceInfoField { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoField { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoArray { - pub index: jint, -} -impl Clone for jvmtiHeapReferenceInfoArray { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoArray { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoConstantPool { - pub index: jint, -} -impl Clone for jvmtiHeapReferenceInfoConstantPool { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoConstantPool { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoStackLocal { - pub thread_tag: jlong, - pub thread_id: jlong, - pub depth: jint, - pub method: jmethodID, - pub location: jlocation, - pub slot: jint, -} -impl Clone for jvmtiHeapReferenceInfoStackLocal { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoStackLocal { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoJniLocal { - pub thread_tag: jlong, - pub thread_id: jlong, - pub depth: jint, - pub method: jmethodID, -} -impl Clone for jvmtiHeapReferenceInfoJniLocal { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoJniLocal { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfoReserved { - pub reserved1: jlong, - pub reserved2: jlong, - pub reserved3: jlong, - pub reserved4: jlong, - pub reserved5: jlong, - pub reserved6: jlong, - pub reserved7: jlong, - pub reserved8: jlong, -} -impl Clone for jvmtiHeapReferenceInfoReserved { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfoReserved { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapReferenceInfo { - pub _bindgen_data_: [u64; 8usize], -} -impl jvmtiHeapReferenceInfo { - pub unsafe fn field(&mut self) -> *mut jvmtiHeapReferenceInfoField { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } - pub unsafe fn array(&mut self) -> *mut jvmtiHeapReferenceInfoArray { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } - pub unsafe fn constant_pool(&mut self) -> *mut jvmtiHeapReferenceInfoConstantPool { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } - pub unsafe fn stack_local(&mut self) -> *mut jvmtiHeapReferenceInfoStackLocal { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } - pub unsafe fn jni_local(&mut self) -> *mut jvmtiHeapReferenceInfoJniLocal { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } - pub unsafe fn other(&mut self) -> *mut jvmtiHeapReferenceInfoReserved { - let raw: *mut u8 = mem::transmute(&self._bindgen_data_); - mem::transmute(raw.offset(0)) - } -} -impl Clone for jvmtiHeapReferenceInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapReferenceInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiHeapCallbacks { - pub heap_iteration_callback: jvmtiHeapIterationCallback, - pub heap_reference_callback: jvmtiHeapReferenceCallback, - pub primitive_field_callback: jvmtiPrimitiveFieldCallback, - pub array_primitive_value_callback: jvmtiArrayPrimitiveValueCallback, - pub string_primitive_value_callback: jvmtiStringPrimitiveValueCallback, - pub reserved5: jvmtiReservedCallback, - pub reserved6: jvmtiReservedCallback, - pub reserved7: jvmtiReservedCallback, - pub reserved8: jvmtiReservedCallback, - pub reserved9: jvmtiReservedCallback, - pub reserved10: jvmtiReservedCallback, - pub reserved11: jvmtiReservedCallback, - pub reserved12: jvmtiReservedCallback, - pub reserved13: jvmtiReservedCallback, - pub reserved14: jvmtiReservedCallback, - pub reserved15: jvmtiReservedCallback, -} -impl Clone for jvmtiHeapCallbacks { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiHeapCallbacks { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiClassDefinition { - pub klass: jclass, - pub class_byte_count: jint, - pub class_bytes: *const c_uchar, -} -impl Clone for jvmtiClassDefinition { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiClassDefinition { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiMonitorUsage { - pub owner: jthread, - pub entry_count: jint, - pub waiter_count: jint, - pub waiters: *mut jthread, - pub notify_waiter_count: jint, - pub notify_waiters: *mut jthread, -} -impl Clone for jvmtiMonitorUsage { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiMonitorUsage { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiLineNumberEntry { - pub start_location: jlocation, - pub line_number: jint, -} -impl Clone for jvmtiLineNumberEntry { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiLineNumberEntry { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiLocalVariableEntry { - pub start_location: jlocation, - pub length: jint, - pub name: *mut c_char, - pub signature: *mut c_char, - pub generic_signature: *mut c_char, - pub slot: jint, -} -impl Clone for jvmtiLocalVariableEntry { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiLocalVariableEntry { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiParamInfo { - pub name: *mut c_char, - pub kind: jvmtiParamKind, - pub base_type: jvmtiParamTypes, - pub null_ok: jboolean, -} -impl Clone for jvmtiParamInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiParamInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiExtensionFunctionInfo { - pub func: jvmtiExtensionFunction, - pub id: *mut c_char, - pub short_description: *mut c_char, - pub param_count: jint, - pub params: *mut jvmtiParamInfo, - pub error_count: jint, - pub errors: *mut jvmtiError, -} -impl Clone for jvmtiExtensionFunctionInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiExtensionFunctionInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiExtensionEventInfo { - pub extension_event_index: jint, - pub id: *mut c_char, - pub short_description: *mut c_char, - pub param_count: jint, - pub params: *mut jvmtiParamInfo, -} -impl Clone for jvmtiExtensionEventInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiExtensionEventInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiTimerInfo { - pub max_value: jlong, - pub may_skip_forward: jboolean, - pub may_skip_backward: jboolean, - pub kind: jvmtiTimerKind, - pub reserved1: jlong, - pub reserved2: jlong, -} -impl Clone for jvmtiTimerInfo { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiTimerInfo { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiAddrLocationMap { - pub start_address: *const c_void, - pub location: jlocation, -} -impl Clone for jvmtiAddrLocationMap { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiAddrLocationMap { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiCapabilities { - pub _bindgen_bitfield_1_: c_uint, - pub _bindgen_bitfield_2_: c_uint, - pub _bindgen_bitfield_3_: c_uint, - pub _bindgen_bitfield_4_: c_uint, -} -impl Clone for jvmtiCapabilities { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiCapabilities { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -pub type jvmtiEventReserved = Option ()>; -pub type jvmtiEventBreakpoint = Option ()>; -pub type jvmtiEventClassFileLoadHook = - Option ()>; -pub type jvmtiEventClassLoad = Option ()>; -pub type jvmtiEventClassPrepare = Option ()>; -pub type jvmtiEventCompiledMethodLoad = - Option ()>; -pub type jvmtiEventCompiledMethodUnload = Option ()>; -pub type jvmtiEventDataDumpRequest = Option ()>; -pub type jvmtiEventDynamicCodeGenerated = Option ()>; -pub type jvmtiEventException = Option ()>; -pub type jvmtiEventExceptionCatch = Option ()>; -pub type jvmtiEventFieldAccess = Option ()>; -pub type jvmtiEventFieldModification = Option ()>; -pub type jvmtiEventFramePop = Option ()>; -pub type jvmtiEventGarbageCollectionFinish = Option ()>; -pub type jvmtiEventGarbageCollectionStart = Option ()>; -pub type jvmtiEventMethodEntry = Option ()>; -pub type jvmtiEventMethodExit = Option ()>; -pub type jvmtiEventMonitorContendedEnter = Option ()>; -pub type jvmtiEventMonitorContendedEntered = Option ()>; -pub type jvmtiEventMonitorWait = Option ()>; -pub type jvmtiEventMonitorWaited = Option ()>; -pub type jvmtiEventNativeMethodBind = - Option ()>; -pub type jvmtiEventObjectFree = Option ()>; -pub type jvmtiEventResourceExhausted = Option ()>; -pub type jvmtiEventSingleStep = Option ()>; -pub type jvmtiEventThreadEnd = Option ()>; -pub type jvmtiEventThreadStart = Option ()>; -pub type jvmtiEventVMDeath = Option ()>; -pub type jvmtiEventVMInit = Option ()>; -pub type jvmtiEventVMObjectAlloc = Option ()>; -pub type jvmtiEventVMStart = Option ()>; - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiEventCallbacks { - pub VMInit: jvmtiEventVMInit, - pub VMDeath: jvmtiEventVMDeath, - pub ThreadStart: jvmtiEventThreadStart, - pub ThreadEnd: jvmtiEventThreadEnd, - pub ClassFileLoadHook: jvmtiEventClassFileLoadHook, - pub ClassLoad: jvmtiEventClassLoad, - pub ClassPrepare: jvmtiEventClassPrepare, - pub VMStart: jvmtiEventVMStart, - pub Exception: jvmtiEventException, - pub ExceptionCatch: jvmtiEventExceptionCatch, - pub SingleStep: jvmtiEventSingleStep, - pub FramePop: jvmtiEventFramePop, - pub Breakpoint: jvmtiEventBreakpoint, - pub FieldAccess: jvmtiEventFieldAccess, - pub FieldModification: jvmtiEventFieldModification, - pub MethodEntry: jvmtiEventMethodEntry, - pub MethodExit: jvmtiEventMethodExit, - pub NativeMethodBind: jvmtiEventNativeMethodBind, - pub CompiledMethodLoad: jvmtiEventCompiledMethodLoad, - pub CompiledMethodUnload: jvmtiEventCompiledMethodUnload, - pub DynamicCodeGenerated: jvmtiEventDynamicCodeGenerated, - pub DataDumpRequest: jvmtiEventDataDumpRequest, - pub reserved72: jvmtiEventReserved, - pub MonitorWait: jvmtiEventMonitorWait, - pub MonitorWaited: jvmtiEventMonitorWaited, - pub MonitorContendedEnter: jvmtiEventMonitorContendedEnter, - pub MonitorContendedEntered: jvmtiEventMonitorContendedEntered, - pub reserved77: jvmtiEventReserved, - pub reserved78: jvmtiEventReserved, - pub reserved79: jvmtiEventReserved, - pub ResourceExhausted: jvmtiEventResourceExhausted, - pub GarbageCollectionStart: jvmtiEventGarbageCollectionStart, - pub GarbageCollectionFinish: jvmtiEventGarbageCollectionFinish, - pub ObjectFree: jvmtiEventObjectFree, - pub VMObjectAlloc: jvmtiEventVMObjectAlloc, -} -impl Clone for jvmtiEventCallbacks { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiEventCallbacks { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct jvmtiInterface_1 { - pub reserved1: *mut c_void, - pub SetEventNotificationMode: Option jvmtiError>, - pub reserved3: *mut c_void, - pub GetAllThreads: Option jvmtiError>, - pub SuspendThread: Option jvmtiError>, - pub ResumeThread: Option jvmtiError>, - pub StopThread: Option jvmtiError>, - pub InterruptThread: Option jvmtiError>, - pub GetThreadInfo: Option jvmtiError>, - pub GetOwnedMonitorInfo: Option jvmtiError>, - pub GetCurrentContendedMonitor: Option jvmtiError>, - pub RunAgentThread: Option jvmtiError>, - pub GetTopThreadGroups: Option jvmtiError>, - pub GetThreadGroupInfo: Option jvmtiError>, - pub GetThreadGroupChildren: Option jvmtiError>, - pub GetFrameCount: Option jvmtiError>, - pub GetThreadState: Option jvmtiError>, - pub GetCurrentThread: Option jvmtiError>, - pub GetFrameLocation: Option jvmtiError>, - pub NotifyFramePop: Option jvmtiError>, - pub GetLocalObject: Option jvmtiError>, - pub GetLocalInt: Option jvmtiError>, - pub GetLocalLong: Option jvmtiError>, - pub GetLocalFloat: Option jvmtiError>, - pub GetLocalDouble: Option jvmtiError>, - pub SetLocalObject: Option jvmtiError>, - pub SetLocalInt: Option jvmtiError>, - pub SetLocalLong: Option jvmtiError>, - pub SetLocalFloat: Option jvmtiError>, - pub SetLocalDouble: Option jvmtiError>, - pub CreateRawMonitor: Option jvmtiError>, - pub DestroyRawMonitor: Option jvmtiError>, - pub RawMonitorEnter: Option jvmtiError>, - pub RawMonitorExit: Option jvmtiError>, - pub RawMonitorWait: Option jvmtiError>, - pub RawMonitorNotify: Option jvmtiError>, - pub RawMonitorNotifyAll: Option jvmtiError>, - pub SetBreakpoint: Option jvmtiError>, - pub ClearBreakpoint: Option jvmtiError>, - pub reserved40: *mut c_void, - pub SetFieldAccessWatch: Option jvmtiError>, - pub ClearFieldAccessWatch: Option jvmtiError>, - pub SetFieldModificationWatch: Option jvmtiError>, - pub ClearFieldModificationWatch: Option jvmtiError>, - pub IsModifiableClass: Option jvmtiError>, - pub Allocate: Option jvmtiError>, - pub Deallocate: Option jvmtiError>, - pub GetClassSignature: Option jvmtiError>, - pub GetClassStatus: Option jvmtiError>, - pub GetSourceFileName: Option jvmtiError>, - pub GetClassModifiers: Option jvmtiError>, - pub GetClassMethods: Option jvmtiError>, - pub GetClassFields: Option jvmtiError>, - pub GetImplementedInterfaces: Option jvmtiError>, - pub IsInterface: Option jvmtiError>, - pub IsArrayClass: Option jvmtiError>, - pub GetClassLoader: Option jvmtiError>, - pub GetObjectHashCode: Option jvmtiError>, - pub GetObjectMonitorUsage: Option jvmtiError>, - pub GetFieldName: Option jvmtiError>, - pub GetFieldDeclaringClass: Option jvmtiError>, - pub GetFieldModifiers: Option jvmtiError>, - pub IsFieldSynthetic: Option jvmtiError>, - pub GetMethodName: Option jvmtiError>, - pub GetMethodDeclaringClass: Option jvmtiError>, - pub GetMethodModifiers: Option jvmtiError>, - pub reserved67: *mut c_void, - pub GetMaxLocals: Option jvmtiError>, - pub GetArgumentsSize: Option jvmtiError>, - pub GetLineNumberTable: Option jvmtiError>, - pub GetMethodLocation: Option jvmtiError>, - pub GetLocalVariableTable: Option jvmtiError>, - pub SetNativeMethodPrefix: Option jvmtiError>, - pub SetNativeMethodPrefixes: Option jvmtiError>, - pub GetBytecodes: Option jvmtiError>, - pub IsMethodNative: Option jvmtiError>, - pub IsMethodSynthetic: Option jvmtiError>, - pub GetLoadedClasses: Option jvmtiError>, - pub GetClassLoaderClasses: Option jvmtiError>, - pub PopFrame: Option jvmtiError>, - pub ForceEarlyReturnObject: Option jvmtiError>, - pub ForceEarlyReturnInt: Option jvmtiError>, - pub ForceEarlyReturnLong: Option jvmtiError>, - pub ForceEarlyReturnFloat: Option jvmtiError>, - pub ForceEarlyReturnDouble: Option jvmtiError>, - pub ForceEarlyReturnVoid: Option jvmtiError>, - pub RedefineClasses: Option jvmtiError>, - pub GetVersionNumber: Option jvmtiError>, - pub GetCapabilities: Option jvmtiError>, - pub GetSourceDebugExtension: Option jvmtiError>, - pub IsMethodObsolete: Option jvmtiError>, - pub SuspendThreadList: Option jvmtiError>, - pub ResumeThreadList: Option jvmtiError>, - pub reserved94: *mut c_void, - pub reserved95: *mut c_void, - pub reserved96: *mut c_void, - pub reserved97: *mut c_void, - pub reserved98: *mut c_void, - pub reserved99: *mut c_void, - pub GetAllStackTraces: Option jvmtiError>, - pub GetThreadListStackTraces: Option jvmtiError>, - pub GetThreadLocalStorage: Option jvmtiError>, - pub SetThreadLocalStorage: Option jvmtiError>, - pub GetStackTrace: Option jvmtiError>, - pub reserved105: *mut c_void, - pub GetTag: Option jvmtiError>, - pub SetTag: Option jvmtiError>, - pub ForceGarbageCollection: Option jvmtiError>, - pub IterateOverObjectsReachableFromObject: Option jvmtiError>, - pub IterateOverReachableObjects: Option jvmtiError>, - pub IterateOverHeap: Option jvmtiError>, - pub IterateOverInstancesOfClass: Option jvmtiError>, - pub reserved113: *mut c_void, - pub GetObjectsWithTags: Option jvmtiError>, - pub FollowReferences: Option jvmtiError>, - pub IterateThroughHeap: Option jvmtiError>, - pub reserved117: *mut c_void, - pub reserved118: *mut c_void, - pub reserved119: *mut c_void, - pub SetJNIFunctionTable: Option jvmtiError>, - pub GetJNIFunctionTable: Option jvmtiError>, - pub SetEventCallbacks: Option jvmtiError>, - pub GenerateEvents: Option jvmtiError>, - pub GetExtensionFunctions: Option jvmtiError>, - pub GetExtensionEvents: Option jvmtiError>, - pub SetExtensionEventCallback: Option jvmtiError>, - pub DisposeEnvironment: Option jvmtiError>, - pub GetErrorName: Option jvmtiError>, - pub GetJLocationFormat: Option jvmtiError>, - pub GetSystemProperties: Option jvmtiError>, - pub GetSystemProperty: Option jvmtiError>, - pub SetSystemProperty: Option jvmtiError>, - pub GetPhase: Option jvmtiError>, - pub GetCurrentThreadCpuTimerInfo: Option jvmtiError>, - pub GetCurrentThreadCpuTime: Option jvmtiError>, - pub GetThreadCpuTimerInfo: Option jvmtiError>, - pub GetThreadCpuTime: Option jvmtiError>, - pub GetTimerInfo: Option jvmtiError>, - pub GetTime: Option jvmtiError>, - pub GetPotentialCapabilities: Option jvmtiError>, - pub reserved141: *mut c_void, - pub AddCapabilities: Option jvmtiError>, - pub RelinquishCapabilities: Option jvmtiError>, - pub GetAvailableProcessors: Option jvmtiError>, - pub GetClassVersionNumbers: Option jvmtiError>, - pub GetConstantPool: Option jvmtiError>, - pub GetEnvironmentLocalStorage: Option jvmtiError>, - pub SetEnvironmentLocalStorage: Option jvmtiError>, - pub AddToBootstrapClassLoaderSearch: Option jvmtiError>, - pub SetVerboseFlag: Option jvmtiError>, - pub AddToSystemClassLoaderSearch: Option jvmtiError>, - pub RetransformClasses: Option jvmtiError>, - pub GetOwnedMonitorStackDepthInfo: Option jvmtiError>, - pub GetObjectSize: Option jvmtiError>, - pub GetLocalInstance: Option jvmtiError>, -} -impl Clone for jvmtiInterface_1 { - fn clone(&self) -> Self { - *self - } -} -impl Default for jvmtiInterface_1 { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} - -#[repr(C)] -#[derive(Copy)] -pub struct _jvmtiEnv { - pub functions: *const jvmtiInterface_1, -} -impl Clone for _jvmtiEnv { - fn clone(&self) -> Self { - *self - } -} -impl Default for _jvmtiEnv { - fn default() -> Self { - unsafe { mem::zeroed() } - } -} +include!(concat!(env!("OUT_DIR"), "/bindings.rs")); diff --git a/src/jvmti_sys/wrapper.h b/src/jvmti_sys/wrapper.h new file mode 100644 index 0000000..ed49fb3 --- /dev/null +++ b/src/jvmti_sys/wrapper.h @@ -0,0 +1 @@ +#include diff --git a/src/lib.rs b/src/lib.rs index 62b3051..84c65d5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ pub mod bytecode; pub mod native; use jni_sys::{JavaVM, jint, jclass, jobject, JNIEnv, JNI_OK}; -use jvmti_sys::{jvmtiEnv, JVMTI_VERSION, jvmtiEventCallbacks, jvmtiCapabilities, jvmtiEventMode, jvmtiEvent, jthread}; +use jvmti_sys::{jvmtiEnv, JVMTI_VERSION, jvmtiEventCallbacks, jvmtiCapabilities, jvmtiEventMode, jvmtiEvent, jthread, jvmtiEvent_JVMTI_EVENT_VM_INIT}; use std::os::raw::{c_char, c_void, c_uchar}; use std::ffi::CStr; use std::mem::size_of; @@ -59,7 +59,7 @@ fn init(_options: *mut c_char) { unsafe fn get_env(vm: *mut JavaVM) -> Result<*mut jvmtiEnv, String> { let mut ptr: *mut c_void = ptr::null_mut() as *mut c_void; - let env_res = (**vm).GetEnv.unwrap()(vm, &mut ptr, JVMTI_VERSION); + let env_res = (**vm).GetEnv.unwrap()(vm, &mut ptr, JVMTI_VERSION as i32); if env_res != JNI_OK { return Result::Err(format!("No environment, err: {}", env_res)); } @@ -69,7 +69,7 @@ unsafe fn get_env(vm: *mut JavaVM) -> Result<*mut jvmtiEnv, String> { unsafe fn add_capabilities(jvmti_env: *mut jvmtiEnv) -> Result<(), String> { let caps = jvmtiCapabilities { // can_access_local_variables | can_generate_all_class_hook_events - _bindgen_bitfield_1_: 0x00004000 | 0x04000000, + _bitfield_1: std::mem::transmute([0x00004000u64 | 0x04000000u64, 0]), ..Default::default() }; return util::unit_or_jvmti_err((**jvmti_env).AddCapabilities.unwrap()(jvmti_env, &caps)); @@ -89,8 +89,8 @@ unsafe fn set_event_callbacks(jvmti_env: *mut jvmtiEnv) -> Result<(), String> { } unsafe fn enable_notifications(jvmti_env: *mut jvmtiEnv) -> Result<(), String> { - enable_notification(jvmti_env, jvmtiEvent::JVMTI_EVENT_VM_INIT)?; - return enable_notification(jvmti_env, jvmtiEvent::JVMTI_EVENT_CLASS_FILE_LOAD_HOOK); + enable_notification(jvmti_env, jvmtiEvent_JVMTI_EVENT_VM_INIT)?; + enable_notification(jvmti_env, jvmtiEvent::JVMTI_EVENT_CLASS_FILE_LOAD_HOOK) } unsafe fn enable_notification(jvmti_env: *mut jvmtiEnv, event: jvmtiEvent) -> Result<(), String> {