Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-gdb - easy way to run rust-scripts with gdb #54

Closed
gwpl opened this issue May 16, 2022 · 7 comments
Closed

rust-gdb - easy way to run rust-scripts with gdb #54

gwpl opened this issue May 16, 2022 · 7 comments

Comments

@gwpl
Copy link

gwpl commented May 16, 2022

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 ?

@0x003e
Copy link

0x003e commented Jun 7, 2022

 rust-gdb $(rust-script --debug -o  ./my_rust_script.rs --version 2>&1  | rg -w '.+Running `(.+) --version`' -r '$1')

@gwpl
Copy link
Author

gwpl commented Jan 13, 2023

I guess this covers most of my question!
Thank you!
If someone see more work to be done , please reopen issue.

@gwpl gwpl closed this as completed Jan 13, 2023
@joseluis
Copy link
Contributor

joseluis commented Aug 2, 2023

This no longer seems to work (BTW old -o argument is now -c). The compiled binary path doesn't seem to be shown anymore.

@fornwall
Copy link
Owner

fornwall commented Aug 3, 2023

@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.

@joseluis
Copy link
Contributor

joseluis commented Aug 3, 2023

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

fornwall added a commit that referenced this issue Aug 4, 2023
This can be used to run e.g. rust-gdb (#54) or hyperfine. Examples:
fornwall added a commit that referenced this issue Aug 4, 2023
This can be used to run e.g. rust-gdb (#54) or hyperfine. Examples:
fornwall added a commit that referenced this issue Aug 4, 2023
This can be used to run e.g. rust-gdb (#54) or hyperfine. Examples:
fornwall added a commit that referenced this issue Aug 4, 2023
This can be used to run e.g. rust-gdb (#54) or hyperfine. Examples:
fornwall added a commit that referenced this issue Aug 4, 2023
This can be used to run e.g. rust-gdb (#54) or hyperfine. Examples:
@fornwall
Copy link
Owner

fornwall commented Aug 4, 2023

@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?

@joseluis
Copy link
Contributor

joseluis commented Aug 5, 2023

Works wonderfully! thank you @fornwall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants