diff --git a/src/config.rs b/src/config.rs index 709516eb..de742d28 100644 --- a/src/config.rs +++ b/src/config.rs @@ -160,12 +160,16 @@ impl Config { .help("PID of a running python program to spy on") .takes_value(true); - #[cfg(feature = "unwind")] - let native = Arg::new("native") + let mut native = Arg::new("native") .short('n') .long("native") .help("Collect stack traces from native extensions written in Cython, C or C++"); + // Only show `--native` on platforms where it's supported + if !cfg!(feature = "unwind") { + native = native.hide(true); + } + #[cfg(not(target_os="freebsd"))] let nonblocking = Arg::new("nonblocking") .long("nonblocking") @@ -327,12 +331,8 @@ impl Config { .help("Shell type"), ); - // add native unwinding if appropriate - #[cfg(feature = "unwind")] let record = record.arg(native.clone()); - #[cfg(feature = "unwind")] let top = top.arg(native.clone()); - #[cfg(feature = "unwind")] let dump = dump.arg(native.clone()); // Nonblocking isn't an option for freebsd, remove @@ -361,6 +361,14 @@ impl Config { let (subcommand, matches) = matches.subcommand().unwrap(); + // Check if `--native` was used on an unsupported platform + if !cfg!(feature = "unwind") && matches.contains_id("native") { + eprintln!( + "Collecting stack traces from native extensions (`--native`) is not supported on your platform." + ); + std::process::exit(1); + } + match subcommand { "record" => { config.sampling_rate = matches.value_of_t("rate")?;