use std::ffi::OsString;
use std::path::PathBuf;
use std::time::Duration;
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
pub struct CoreClrProfileProps {
pub enabled: bool,
pub gc_markers: bool,
pub gc_suspensions: bool,
pub gc_detailed_allocs: bool,
pub event_stacks: bool,
}
impl CoreClrProfileProps {
pub fn any_enabled(&self) -> bool {
self.enabled
|| self.gc_markers
|| self.gc_suspensions
|| self.gc_detailed_allocs
|| self.event_stacks
}
}
#[derive(Debug, Clone)]
pub struct RecordingProps {
pub output_file: PathBuf,
pub time_limit: Option<Duration>,
pub interval: Duration,
#[allow(dead_code)]
pub vm_hack: bool,
#[allow(dead_code)]
pub gfx: bool,
#[allow(dead_code)]
pub browsers: bool,
#[allow(dead_code)]
pub keep_etl: bool,
}
#[derive(Debug, Clone)]
pub enum RecordingMode {
All,
Pid(u32),
Launch(ProcessLaunchProps),
}
impl RecordingMode {
#[allow(dead_code)]
pub fn is_attach_mode(&self) -> bool {
match self {
RecordingMode::All => true,
RecordingMode::Pid(_) => true,
RecordingMode::Launch(_) => false,
}
}
}
#[derive(Debug, Clone)]
pub struct ProfileCreationProps {
pub profile_name: Option<String>,
pub fallback_profile_name: String,
#[allow(dead_code)]
pub main_thread_only: bool,
pub reuse_threads: bool,
pub fold_recursive_prefix: bool,
pub unlink_aux_files: bool,
pub create_per_cpu_threads: bool,
pub arg_count_to_include_in_process_name: usize,
#[allow(dead_code)]
pub override_arch: Option<String>,
pub unstable_presymbolicate: bool,
#[allow(dead_code)]
pub coreclr: CoreClrProfileProps,
#[allow(dead_code)]
pub unknown_event_markers: bool,
#[allow(dead_code)]
pub time_range: Option<(std::time::Duration, std::time::Duration)>,
#[allow(dead_code)]
pub should_emit_jit_markers: bool,
#[allow(dead_code)]
pub should_emit_cswitch_markers: bool,
}
impl ProfileCreationProps {
pub fn profile_name(&self) -> &str {
self.profile_name
.as_deref()
.unwrap_or(&self.fallback_profile_name)
}
}
#[derive(Debug, Clone)]
pub struct ProcessLaunchProps {
pub env_vars: Vec<(OsString, OsString)>,
pub command_name: OsString,
pub args: Vec<OsString>,
pub iteration_count: u32,
}