1extern crate jni;
2extern crate jni_sys;
3#[macro_use]
4extern crate lazy_static;
5
6use std::os::raw::c_char;
7
8use log::{error, info};
9
10pub use wrapper::*;
11
12use crate::{event::JEventManager, runner};
13pub use crate::event::jvmti_event_breakpoint_handler;
14pub use crate::event::jvmti_event_class_file_load_hook_handler;
15pub use crate::event::jvmti_event_class_load_handler;
16pub use crate::event::jvmti_event_class_prepare_handler;
17pub use crate::event::jvmti_event_compiled_method_load_handler;
18pub use crate::event::jvmti_event_compiled_method_unload_handler;
19pub use crate::event::jvmti_event_data_dump_request_handler;
20pub use crate::event::jvmti_event_dynamic_code_generated_handler;
21pub use crate::event::jvmti_event_exception_catch_handler;
22pub use crate::event::jvmti_event_exception_handler;
23pub use crate::event::jvmti_event_field_access_handler;
24pub use crate::event::jvmti_event_field_modification_handler;
25pub use crate::event::jvmti_event_frame_pop_handler;
26pub use crate::event::jvmti_event_garbage_collection_finish_handler;
27pub use crate::event::jvmti_event_garbage_collection_start_handler;
28pub use crate::event::jvmti_event_method_entry_handler;
29pub use crate::event::jvmti_event_method_exit_handler;
30pub use crate::event::jvmti_event_monitor_contended_enter_handler;
31pub use crate::event::jvmti_event_monitor_contended_entered_handler;
32pub use crate::event::jvmti_event_monitor_wait_handler;
33pub use crate::event::jvmti_event_monitor_waited_handler;
34pub use crate::event::jvmti_event_native_method_bind_handler;
35pub use crate::event::jvmti_event_object_free_handler;
36pub use crate::event::jvmti_event_resource_exhausted_handler;
37pub use crate::event::jvmti_event_single_step_handler;
38pub use crate::event::jvmti_event_thread_end_handler;
39pub use crate::event::jvmti_event_thread_start_handler;
40pub use crate::event::jvmti_event_vm_death_handler;
41pub use crate::event::jvmti_event_vm_init_handler;
42pub use crate::event::jvmti_event_vm_object_alloc_handler;
43pub use crate::event::jvmti_event_vm_start_handler;
44
45pub mod sys;
46pub mod perf;
47
48mod wrapper {
49 pub use decoder::*;
50 pub use descriptors::*;
51 pub use enums::*;
52
53 pub use jvmtienv::*;
54
55 pub use metadata::*;
56 pub use transforms::*;
57 pub use utils::*;
58 pub use vm::*;
59
60 #[macro_use]
61 mod macros;
62 mod enums;
63 mod descriptors;
64 mod transforms;
65 mod utils;
66
67 mod decoder;
68 mod metadata;
69 mod jvmtifns;
70 mod jvmtienv;
71 mod vm;
72 mod facade;
73
74 pub mod errors;
75 pub mod objects;
76 pub mod runner;
77 pub mod builder;
78 pub mod event;
79}
80
81pub fn agent_on_load(vm: &JavaVM, options: *const c_char, initialize: fn(*const c_char, &mut JEventManager)) -> i32 {
82 info!("Agent starting...");
83
84 match runner::do_on_load(vm, options, initialize) {
85 Ok(_) => 0,
86 Err(e) => {
87 error!("Failed to load agent: {}", e);
88 return -1;
89 }
90 }
91}
92
93pub fn agent_on_unload(_vm: &JavaVM) {
94 info!("Agent unloaded");
95}