1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use std::error::Error;
use std::fmt;
#[cfg(feature = "jitdump")]
mod jitdump;
#[cfg(feature = "jitdump")]
pub use crate::jitdump::JitDumpAgent;
#[cfg(not(feature = "jitdump"))]
pub type JitDumpAgent = NullProfilerAgent;
#[derive(Debug, Clone, Copy)]
pub enum ProfilingStrategy {
NullProfiler,
JitDumpProfiler,
}
pub trait ProfilingAgent {
fn module_load(
&mut self,
module_name: &str,
addr: *const u8,
len: usize,
dbg_image: Option<&[u8]>,
) -> ();
}
#[derive(Debug, Default, Clone, Copy)]
pub struct NullProfilerAgent {}
#[derive(Debug)]
struct NullProfilerAgentError;
impl fmt::Display for NullProfilerAgentError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "A profiler agent is not supported by this build")
}
}
impl Error for NullProfilerAgentError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
None
}
}
impl ProfilingAgent for NullProfilerAgent {
fn module_load(
&mut self,
_module_name: &str,
_addr: *const u8,
_len: usize,
_dbg_image: Option<&[u8]>,
) -> () {
}
}