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

Introduce VSCode rust debug type. #5369

Closed
wants to merge 5 commits into from
Closed

Introduce VSCode rust debug type. #5369

wants to merge 5 commits into from

Conversation

vsrs
Copy link
Contributor

@vsrs vsrs commented Jul 14, 2020

This PR adds a VSCode-native debug engine integration for rust code.

Well, it's not a real rust debug engine, and internally reuses lldb or ms cpptools as before. But in VSCode UI it looks like a special rust debugger :)

Important note: The PR requires at least 1.46 VSCode engine, so maybe we shouldn't merge it until July VSCode release (1.48 https://github.com/microsoft/vscode/milestone/124).
On the other hand, it might be a good idea to test the code on the nightly version.

Introduced features:
Now it is possible to use special "rust" debugger in the launch.json:

{
    "configurations": [
        {
            // uses cargo to build the executable
            "type": "rust",
            "request": "launch",
            "name": "Main binary (cargo)",
            "cargo": {
                "command": "run",
            }
        },
        {
            // generated from a runnable
            "type": "rust",
            "request": "launch",
            "name": "run bin2",
            "cargo": {
                "command": "run",
                "args": [
                    "--package",
                    "multiple_binaries",
                    "--bin",
                    "bin2",
                    "--all-features"
                ]
            },
            "args": [],
            "cwd": "${workspaceRoot}"
        },
	{
             // does not use cargo
            "type": "rust",
            "request": "launch",
            "name": "Main binary",
            "program": "${workspaceRoot}/target/debug/bin1"
        }
    ]
}

You can use launch.json snippets for rust:
Snippets

Or generate configuration directly from VSCode Select and start debugging peeker (it looks for runnables in the current file).
generate_cfg

Of course, you don't have to create debug configurations and can just use this peeker to start debugging without bothering with launch.json.

P.S. I did not delete existing "rust-analyser.debug" and "rust-analyzer.newDebugConfig" commands but I think that in long term we should remove at least the latter. The former might still be useful for keybindings.

@kjeremy
Copy link
Contributor

kjeremy commented Jul 14, 2020

or ms cpptools as before

Does that mean it work with windows out of the box?

@vsrs
Copy link
Contributor Author

vsrs commented Jul 14, 2020

Not quite. You have to install vscode-cpptools or CodeLLDB. The first works better for windows to my mind.

If none are installed you will get the error message:
no_dbg_engine

It's the same behavior that we have for Debug lens.

@matklad
Copy link
Member

matklad commented Jul 15, 2020

@vsrs heads up, we are moving the typescript code from this repo to rust-lang/vscode-rust#812

@vsrs
Copy link
Contributor Author

vsrs commented Jul 15, 2020

Oh, I missed it and I didn't notice. I'l open then another PR in the new repo after the move completes.

@vsrs vsrs closed this Jul 15, 2020
@vsrs vsrs deleted the dcp branch October 18, 2021 14:02
@vsrs vsrs restored the dcp branch October 18, 2021 14:02
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

Successfully merging this pull request may close these issues.

3 participants