Skip to content

Commit

Permalink
Don't require gdb script
Browse files Browse the repository at this point in the history
Having the gdb script in the archive reduces reproducibility as it
contains local paths. Having humility run gdb is probably not
scriptly necessary anyway so make a best effort and then spit out
an error.
  • Loading branch information
labbott committed Oct 4, 2024
1 parent 9948f3f commit 0e98940
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions cmd/gdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ struct GdbArgs {
/// specifies the probe serial number to use with OpenOCD
#[clap(long, requires = "run_openocd")]
serial: Option<String>,

/// Path to gdb script to run
gdb_script: Option<String>,
}

fn gdb(context: &mut ExecutionContext) -> Result<()> {
Expand Down Expand Up @@ -75,12 +78,23 @@ fn gdb(context: &mut ExecutionContext) -> Result<()> {
&work_dir.path().join("openocd.gdb"),
)
.context("GDB config missing. Is your Hubris build too old?")?;
hubris
.extract_file_to(
"debug/script.gdb",
&work_dir.path().join("script.gdb"),
)
.context("GDB script missing. Is your Hubris build too old?")?;

let gdb_script_path = work_dir.path().join("script.gdb");
// We moved the gdb file out of the hubris archive because it was
// preventing reproducible builds. An extraction is non fatal
let _ = hubris.extract_file_to("debug/script.gdb", &gdb_script_path);

if let Some(path) = subargs.gdb_script {
// It's possible we overwrite the script in the old archive but
// that seems like behavior someone would want when actively
// passing in a path!
std::fs::copy(path, &gdb_script_path)?;
}

if !gdb_script_path.exists() {
bail!("GDB script missing; recent archives don't include it because humility gdb is deprecated, use xtask gdb");
}

hubris
.extract_file_to("img/final.elf", &work_dir.path().join("final.elf"))?;

Expand Down

0 comments on commit 0e98940

Please sign in to comment.