Closed gwpl closed 1 year ago
rust-gdb $(rust-script --debug -o ./my_rust_script.rs --version 2>&1 | rg -w '.+Running `(.+) --version`' -r '$1')
I guess this covers most of my question! Thank you! If someone see more work to be done , please reopen issue.
This no longer seems to work (BTW old -o
argument is now -c
). The compiled binary path doesn't seem to be shown anymore.
@joseluis Nowadays rust-script runs the executable directly on subsequent runs for speed (to avoid the small overhead of running cargo, instead of the binary directly.
You can run -f
/--force
to force cargo to be used:
rust-gdb $(rust-script --debug -f -c ./my_rust_script.rs --version 2>&1 | rg -w '.+Running `(.+) --version`' -r '$1')
Does that work for you?
Still probably makes sense to make this easier.
The first time the script is run (or after calling rust-script --clear-cache
) there doesn't seem to be anything to grep:
$ rust-script --debug -f -c .my_rust_script.rs --version
Compiling rust-script_b9303157d5d5afccc45846fa v0.1.0 (/home/USER/.cache/rust-script/projects/b9303157d5d5afccc45846fa)
Finished dev [unoptimized + debuginfo] target(s) in 0.32s
afterwards subsequent invocations show even less:
$ rust-script --debug -f -c ./scripts/rust-script.rs --version
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
@joseluis The just released 0.31.0 version now suports a -w
/--wrapper
option, so after updating to that you should be able to use e.g. rust-gdb
as a wrapper by running:
rust-script --debug --wrapper rust-gdb my-script.rs
Does that work as expected for you?
Works wonderfully! thank you @fornwall
rust-gdb -
Could you please add some feature to make it easy to run rust-scripts with
gdb
?I've found flag
--debug
to build in debug mode. However it : 1. also runs script and 2. still I need to sk cache directory looking for path to debug build binary.What about flag (maybe with shorter name)
--build-only-and-return-absolute-path-to-binary
?That way I could run
rust-gdb "$(rust-script --debug --build-only-and-return-absolute-path-to-binary my_script.rs)"
to comfortably run script in debugger ?