Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Commit

Permalink
make DEFAULT_MAX_BACKTRACE_LEN configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Lotte Steenbrink committed Mar 31, 2021
1 parent 9751707 commit c7710b6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,

/// Arguments passed after the ELF file path are discarded
#[structopt(name = "REST")]
_rest: Vec<String>,
Expand Down Expand Up @@ -145,6 +149,10 @@ fn notmain() -> anyhow::Result<i32> {
}

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)?;
Expand Down Expand Up @@ -561,7 +569,7 @@ fn notmain() -> anyhow::Result<i32> {
&current_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)?;
Expand Down Expand Up @@ -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=<your maximum>` to extend this limit",
max_backtrace_len);
return Ok(top_exception);
}
Expand Down

0 comments on commit c7710b6

Please # to comment.