From b1fa235f630a134585aa99a63a6b4f955dcd4f5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Mon, 10 Jun 2024 22:00:24 +0300 Subject: [PATCH] feat: support finding binary with `which` --- Cargo.lock | 31 +++++++++++++++++++++++++------ Cargo.toml | 3 ++- src/ui/supervisor.rs | 7 +++++++ 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f03706e..1fa063d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -191,7 +191,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "which", + "which 4.3.0", ] [[package]] @@ -268,6 +268,7 @@ dependencies = [ "unwind", "uuid", "walkdir", + "which 6.0.1", ] [[package]] @@ -634,9 +635,9 @@ dependencies = [ [[package]] name = "either" -version = "1.8.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "endian-type" @@ -736,7 +737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947" dependencies = [ "cfg-if", - "rustix 0.38.28", + "rustix 0.38.34", "windows-sys 0.52.0", ] @@ -1744,9 +1745,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.4.0", "errno 0.3.8", @@ -2488,6 +2489,18 @@ dependencies = [ "once_cell", ] +[[package]] +name = "which" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +dependencies = [ + "either", + "home", + "rustix 0.38.34", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -2736,6 +2749,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "yaml-rust" version = "0.4.5" diff --git a/Cargo.toml b/Cargo.toml index de9f40d..56f1bd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,7 @@ bit_field = "0.10.1" serde = { version = "1.0.164", features = ["derive"] } toml = "0.8.13" home = "0.5.9" +which = "6.0.1" [dev-dependencies] serial_test = "3.0.0" @@ -78,4 +79,4 @@ serial_test = "3.0.0" [features] default = ["libunwind"] libunwind = ["unwind"] -int_test = [] \ No newline at end of file +int_test = [] diff --git a/src/ui/supervisor.rs b/src/ui/supervisor.rs index 88f8190..4247ffe 100644 --- a/src/ui/supervisor.rs +++ b/src/ui/supervisor.rs @@ -1,3 +1,5 @@ +use std::path::Path; + use crate::debugger::process::Child; use crate::debugger::DebuggerBuilder; use crate::oracle::builtin; @@ -62,6 +64,11 @@ impl Supervisor { let process = match src { DebugeeSource::File { path, args } => { + let path = if !Path::new(path).exists() { + which::which(path)?.to_string_lossy().to_string() + } else { + path.to_string() + }; let proc_tpl = Child::new(path, args, stdout_writer, stderr_writer); proc_tpl .install()