rustup
rustup copied to clipboard
rust-gdb not working, fails with `error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain`
Problem No working GDB, cannot debug rust programs.
Fresh install of rust on Windows 10 x64, running rust-gdb.exe
from the command line results in:
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain
Steps
Either a: run rust-gdb.exe
from a command shell.
or b: launch or configure a debug session from Eclipse and observe the error message: Could not determine GDB version using command: rust-gdb --version [cause: error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-gnu' toolchain]
Notes
Though I want to eventually use Eclipse for debugging, Eclipse is nothing to do with the issue (it also happens on a fresh install on a machine with Rust, and no Eclipse), I only mention it so that other users searching for the error messages will land here too. It needs to work on the command line first, then it can be used in Eclipse.
Initially I had only the mscv
toolchain installed and the error message is similar:
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain
However, that makes some sense, as for the msvc
toolchain there is no GDB, one must use WinDBG instead which is what VSCode uses under the hood, but for me that is not a solution as Eclipse uses GDB and is an aside to the non-working rust-gdb
for the gnu
toolchain anyway.
Output of rustup --version
:
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.54.0 (a178d0322 2021-07-26)`
Output of rustup show
:
C:\Users\Hydra>rustup show
Default host: x86_64-pc-windows-msvc
rustup home: F:\Data\.rustup
installed toolchains
--------------------
stable-x86_64-pc-windows-gnu (default)
stable-x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-gnu (default)
rustc 1.54.0 (a178d0322 2021-07-26)
Eclipse 2021-06. Eclipse IDE for C/C++ Developers 4.20.0.20210612-1200 epp.package.cpp Eclipse Packaging Project
Corrosion: Corrosion: Rust edition in Eclipse IDE 1.2.1.202106081156 org.eclipse.corrosion.feature.feature.group Eclipse Corrosion
Other users have had this issue: https://users.rust-lang.org/t/not-able-to-open-rust-gdb-in-windows/50331/3 https://users.rust-lang.org/t/rust-gdb-and-windows/58168
Other related references: https://bugs.eclipse.org/bugs/show_bug.cgi?id=119600 https://www.brycevandyk.com/debug-rust-on-windows-with-visual-studio-code-and-the-msvc-debugger/ https://sourceware.org/gdb/current/onlinedocs/gdb/Rust.html#Rust https://bitshifter.github.io/rr+rust/index.html#1
I think this is a duplicate of #2838.
Also, FWIW, the rust-gdb wrapper mostly just adds some pretty-printers for some common std types. I think you should be able to run gdb
directly.
A workaround is to run the gdb-wrapper directly, such as ~/.rustup/toolchains/nightly-x86_64-pc-windows-gnu/bin/rust-gdb
Hi @ehuss I did a search on the issue tracker for rust-gdb but no other issues showed up, maybe a made a typo when I searched or something daft.
Yes #2838 is the probably the same issue.
With regards to running 'gdb' directly, excuse me for being dumb and/or blind, but exactly which gdb
could I run? I didn't see any mention of installing gdb separately. I'm used to gdb being bundled with the compiler, like it is when you download say, the GNU Arm Tools GCC compiler.
I looked in the Rust Book, but there is no mention of the word debugger:
Conversely, the Embedded rust guide specifically makes a mention of it, here:
https://docs.rust-embedded.org/book/intro/install/windows.html
The only documentation on debugging appears to be on 3rd party sites, e.g.
https://blog.logrocket.com/debugging-rust-apps-with-gdb/ https://bitshifter.github.io/rr+rust/index.html#1
I am aware that the rust-gdb is a script, I tried opening it in a text editor.
https://github.com/rust-lang/rust/blob/master/src/etc/rust-gdb
However, being a script it clearly assumes the host OS has python installed, I do not have a native windows installation of Python, nor do I know which version (2? 3?) of python is required.
Maybe rustup should be mentioning and/or checking python availability, or even downloading and installing a suitable python and gdb distribution?
There seems to be a need to clarify just exactly how you go about installing a debugger, on Windows, OSX and Linux, in the Rust documentation and what any prerequisites are. Is there a specific issue tracker that I should raise an issue in regarding this?
On Windows, if you want to use gdb, you'll need to download and install it yourself. This can usually be done with something like pacman
(usually via something like msys2). Rust doesn't distribute debuggers itself. There are open issues such as https://github.com/rust-lang/rust/issues/34457 or https://github.com/rust-lang/rust/issues/48168 to do that, but it is a non-trivial problem.
As for Python, I think gdb has it built-in (I know lldb does). I don't think that's something you need to worry about.
I can understand it is frustrating not having specific documentation for debugging, but it is just an area of Rust where it hasn't been fleshed out very well. Typically you can use any C or C++ debugger. I know CLion has very good support for debugging Rust. CodeLLDB or the official Windows C/C++ extensions with VSCode is also popular. Or just running gdb or lldb directly should also be fine.
There isn't a specific place to open an issue about this. Unfortunately I don't think there is anyone focusing on debugging right now (though I may be wrong). You can always ask on https://internals.rust-lang.org/, but I think https://internals.rust-lang.org/t/how-to-support-rust-debugging-post-tromey/9207 is the latest status. There are some focused experiments like tokio console for non-conventional debugging.
The Rust Corrosion Eclipse plugin has a section on debugging on windows, here:
https://github.com/eclipse/corrosion/blob/master/documentation/Troubleshooting.md#debugging-on-windows
Their current workaround is to create a rust-gdb.cmd
script, I'm trying this out now along with the MSYS2 gdb
.
I'll look at the links you have provided, many thanks for taking the time to respond, much appreciated.
I think the suggestion I just threw into #2838 might be relevant. We should probably consolidate the two issues.
The Rust Corrosion Eclipse plugin has a section on debugging on windows, here:
https://github.com/eclipse/corrosion/blob/master/documentation/Troubleshooting.md#debugging-on-windows
Their current workaround is to create a
rust-gdb.cmd
script, I'm trying this out now along with the MSYS2gdb
.I'll look at the links you have provided, many thanks for taking the time to respond, much appreciated.
This doen't works on windows 10 for me
For what it's worth, I'm running into this issue as well. I'm having no end of trouble getting gdb to work with Rust. I have a binary that I have cross-compiled for riscv32imac-unknown-xous-elf
, and I'd like to debug that in GDB.
If I run rust-gdb.exe
it tells me that it doesn't work for my target, even if I specify one:
5:19:10 pm] E:/Code/Xous/Core> rust-gdb.exe
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain
[5:21:08 pm] E:/Code/Xous/Core> rust-gdb.exe --target riscv32imac-unknown-xous-elf
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain
[5:21:41 pm] E:/Code/Xous/Core>
I can manually run riscv32imac-unknown-none-gdb
, but then symbol resolution does not work at all:
(gdb) p SYSTEM_SERVICES
'SYSTEM_SERVICES' has unknown type; cast it to its declared type
(gdb) p SYSTEM_SERVICES as xous_kernel::services::SystemServices::
A syntax error in expression, near `as xous_kernel::services::SystemServices::'.
(gdb) p SYSTEM_SERVICES as xous_kernel::services::SystemServices
A syntax error in expression, near `as xous_kernel::services::SystemServices'.
(gdb)
I imagine the gdb wrapper is used to teach gdb how to resolve paths, because currently it doesn't seem to be able to do that properly.
The Rust Corrosion Eclipse plugin has a section on debugging on windows, here: https://github.com/eclipse/corrosion/blob/master/documentation/Troubleshooting.md#debugging-on-windows Their current workaround is to create a
rust-gdb.cmd
script, I'm trying this out now along with the MSYS2gdb
. I'll look at the links you have provided, many thanks for taking the time to respond, much appreciated.This doen't works on windows 10 for me
It dont works because it dont load pretty printers. I'm testing it. Rust team would solve this on windows and provide out of the box tools for rustanceans under windows.
Could not determine GDB version using command: rust-gdb --version error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'stable-x86_64-pc-windows-msvc' toolchain
Windows 10
Has there been any progress on this? I tried it today and got the same issue.
@NossicaSystems Doesn't look like it, similar message from a recent nightly:
error: the 'rust-gdb.exe' binary, normally provided by the 'rustc' component, is not applicable to the 'nightly-2023-06-17-x86_64-pc-windows-gnu' toolchain
Maintainers: How can we get some developer time allocated to this issue so that we have a working GDB for a default install of rust and have the documentation updated accordingly?
Dup of #2838