diff --git a/src/main.rs b/src/main.rs index ad3702ba..f8be6928 100644 --- a/src/main.rs +++ b/src/main.rs @@ -102,6 +102,10 @@ struct Opts { #[structopt(long)] force_backtrace: bool, + /// Configure the number of lines to print before a backtrace gets cut off + #[structopt(long)] + max_backtrace_len: Option, + /// Arguments passed after the ELF file path are discarded #[structopt(name = "REST")] _rest: Vec, @@ -145,6 +149,10 @@ fn notmain() -> anyhow::Result { } let force_backtrace = opts.force_backtrace; + let max_backtrace_len = match opts.max_backtrace_len { + Some(len) => len, + None => DEFAULT_MAX_BACKTRACE_LEN, + }; let elf_path = opts.elf.as_deref().unwrap(); let chip = opts.chip.as_deref().unwrap(); let bytes = fs::read(elf_path)?; @@ -561,7 +569,7 @@ fn notmain() -> anyhow::Result { ¤t_dir, // TODO any other cases in which we should force a backtrace? force_backtrace || canary_touched, - DEFAULT_MAX_BACKTRACE_LEN, + max_backtrace_len, )?; core.reset_and_halt(TIMEOUT)?; @@ -855,8 +863,8 @@ fn construct_backtrace( } if frame_index >= max_backtrace_len { - // TODO add hint here on how to extend the length - log::warn!("Maximum backtrace length of {:?} reached; cutting off the rest", + log::warn!("Maximum backtrace length of {:?} reached; cutting off the rest + note: re-run with `--max-backtrace-len=` to extend this limit", max_backtrace_len); return Ok(top_exception); }