-
Notifications
You must be signed in to change notification settings - Fork 31
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
Windows Debug hello World -> Unable to launch Rust Project from selection #149
Comments
The timing is funny, PR #148 was just merged, which probably takes care of your problem. Note that you will probably face further problems on Windows, since the gdb-rust tool is just a shim in the Rust "windows-gnu" targets writing an error message (see this ticket ). In the debug config you have to specify the absolute path to your gdb directly instead. And you have to add a few lines to your "gdbinit" ( or ".gdbinit") file, which you also have to configure as an absolute path. Here is the needed content of the "gdbinit" file:
The rust install directory is usually under your user's home, so something like this: I hope this helps. |
Note: As a workaround you can right now specify the absolute path to the executable to be debugged in the debug configuration. This way you don't have to wait for PR #148 to land in a Corrosion release. |
Snapshots were already built including patches from @Boereck (thanks to him by the way!). |
@Boereck Once you are convinced this issue is fixed, we can decide to trigger a release ASAP. I think this issue is critical enough to be worth it. |
I will test the snapshot build later today to be sure the fix is working not only in my dev environment and give feedback. |
The debug action now does ..nothing. |
I found two more issues (one of which I introduced myself) which I addressed in #152, but the missing gdb-rust still prevents right-click "Debug As > Rust Project" from working on Windows. But creating a debug configuration should be a smoother experience on Windows. |
I've tested the current snapshot and the program path issue seems to be resolved. I didn't observe path related errors on Windows and Linux. However, the gdb issue is still there. I have been thinking about this issue a bit more. It is unfortunate that rust does not ship a working version of the gdb-rust tool. So what are the options we have to make the "Debug As" functionality work on Windows? I think what we could do is taking the GDB configuration from the C++ preferences by default on Windows. This makes the "Debug As" functionality work as long as the preferences are configured correctly. Maybe we can add some explanation for Windows users to configure GDB in the preferences in the README.md file. Regarding the pretty printers: I consider all this a workaround until gdb-rust is available. But since the issue is open since 2015 and there is no update for over one year, I think it is safe to assume we will live with the current situation for some time to come. As soon as a rust stable version ships with gdb-rust, the workarounds should be removed. |
@Boereck the very best thing would be obviously to get it fixed upstream. It seems like the first thing would be to just try the suggested change against latest versions on Windows. It could be a bug in another component that's fixed now. Do you think you'd be able to try this? |
@mickaelistria I had a look and realized gdb-rust is actually a bash script. I guess this makes it even more difficult to ship it with the Windows version. I always assumed it was a Rust program. The logic however is extremely simple. I think it would be feasible to re-implement the tiny logic in Java. So far I haven't had problems with GDB (8.1.0) installed via scoop on a recent Windows 10 using the pretty printing scripts. You are right, we should investigate if there are plans to fix this issue in the Rust project (the preferable outcome). I don't have the resources though to test several GDB distributions on several Windows versions. |
Or in powershell upstream? |
I've tried to create a powershell script with the same logic (see below), but it seems MinGW has a bug when passing the # Exit if anything fails
$ErrorActionPreference = "Stop"
# Find out where the pretty printer Python module is
$RUSTC_SYSROOT = rustc --print=sysroot
$GDB_PYTHON_MODULE_DIRECTORY = "$RUSTC_SYSROOT\lib\rustlib\etc" #-replace '\\','/'
if ($LASTEXITCODE -ne 0) {
throw "rustc exited with $LASTEXITCODE"
}
# Run GDB with the additional arguments that load the pretty printers
# Set the environment variable `RUST_GDB` to overwrite the call to a
# different/specific command (defaults to `gdb`).
if (Test-Path env:RUST_GDB) {
$RUST_GDB = $env:RUST_GDB
} else {
$RUST_GDB = "gdb"
}
$PYTHONPATH="$env:PYTHONPATH;$GDB_PYTHON_MODULE_DIRECTORY"
& "$RUST_GDB" --directory="$GDB_PYTHON_MODULE_DIRECTORY" -iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" $args EDIT: Script did contain command used for debugging |
After updating Corrosion today it looks different: .cargo\rust-gdb.exe just prints at command line: @Boereck: so the issue is that rust-gdb for windows is a .sh script and we need an real executable shipped with rust by rustup? Anyway: I will try the workarounds with .gdbinit and MinGW GDB 8.2 (from MSYS2)... |
If rust-gdb ships a working .sh script for windows, then we don't really need an executable, we just need the RustDebugTabGroup/RustDebugDelegate to replace the debug command that will be used by invocation of the script. |
@anb0s This behavior is expected right now, since we haven't fixed the second part of the problem. You can still create a run config, directly referencing the GDB on your system and add the lines I stated above to your gdbinit file. Let me give a bit of background: Rust on Linux comes with the shell script rust-gdb this script does start gdb with some parameters that make gdb load the rust pretty printer scripts. On windows we have two problems:
@mickaelistria I've tried to run a poweshell script using the Java ProcessBuilder (not sure if this is used under the hood) and it does not work directly. You have to call powershell with the script as the parameter. Traditional batch scripts (bat/cmd files) seem to work however. |
So... the MinGW GCC version 8.2 provided via MSYS2 does not have the bug the MinGW 8.1 I installed via scoop. So we have a path forward. We can either
|
@Boereck Good news! Thanks a lot for facing all those challenges! I suggest that we first try to put the script in Rust and see how likely it is to happen. If it can be merged upstream then good, we don't have anything to change in Corrosion, and we've made Rust better by the way. |
@mickaelistria Yep, I think you are right. I proposed Windows version scripts on the issue and requested a re-evaluation on hanging GDB on Windows. I didn't have any of these problems so far. But I only tested on my machine which is only one version of Windows and only one Intel processor (not tested on AMD processors and other processor generations). Let's see what the Rust folks will say. By the way: I tried running the batch version of the script from Java and there you just have to specify the script file name (e.g. |
I've tried the workarounds with no luck. MinGW GDB is usable from cmd and MSYS2 shell:
I've adapted .gdbinit like described above, but have no idea if it used at all, because of version error... |
See #138: GDB 8.2 is may be the problem here? |
OK, now it works with MinGW GDB 8.2 if i create other debug config like described in #138 under "C/C++ Application" and full path to executable with .gdbinit for rust pretty printers --> it stops at breakpoint and shows the Variables :) So there is something different in debug config under "Rust" for launching gdb with working dir or exe path... |
That's the same workaround I found, except for the pretty printing (which I haven't got to look at yet). |
Besides: rust-lang/rust#54615 |
@anb0s This is strange! The Rust debug configuration actually uses the CDT mechanisms under the hood to start gdb. This message should only be shown if GDB was not found or GDB printed a very unusual version string. I will try to contribute a change that logs the exact error message, so you can provide more detailed information. |
This ticket and #138 should be merged, I think... |
@Boereck Yes it's strange. I've just tried it again and shows now the error log:
No idea why Python shows problem during launch of the GDB executable... The same gdb.exe is working with "C/C++ Application" debug config! |
@anb0s Thanks for the quick feedback! This is at least an error we can try to track down. The error is coming from the stderr of GDB and Python is used by GDB for the pretty printers. Still strange, but at least a lead. |
Thanks for the feedback. Feel free to open new tickets for remaing or new glitches |
I installed rust, eclipse, created a new cargo project and tried to launch it.
Eclipse opened the settings panel complaining: "install missing rls component in rustup"
I installed
rustup component add rls-preview rust-analysis rust-src
and the message was gone. It would have been nice to get a better help than "install missing rls component in rustup"Running the application worked fine now, but debugging gave me:
I should mention, that I'm a rust newcomer without hardly any C/C++ background, but I suppose this actually should run "out of the box"?
The text was updated successfully, but these errors were encountered: