Vscode + gdb + rust-analyzer = pretty printing?

Hello there,

is there a way to make rust-analyzer (running in vscode) load rust gdb pretty-printing scripts when debugging?

Without rust-analyzer, I would just gdb to point to rust-gdb instead: "miDebuggerPath": "${env:HOME}/.cargo/bin/rust-gdb" in launch.json, but rust-analyzer seems to ignore my gdb-related configuration.

I tried the following in settings.json with no success either:

{
    "rust-analyzer.debug.engine": "ms-vscode.cpptools",
    "rust-analyzer.debug.engineSettings": {
        "cppdbg": {
            "miDebuggerPath": "${env:HOME}/.cargo/bin/rust-gdb"
        }
    }
}

How do I either:

  • Make rust-analyzer to launch rust-gdb instead of just gdb?
  • Pass custom commands (like loading gdb_load_rust_pretty_printers.py) to gdb that rust-analyzer launches?

Thanks!

Seems like I was just one step away from solving the issue: enabling the pretty-printing via "setupCommands" xD

So the final solution is:

{
    "rust-analyzer.debug.engine": "ms-vscode.cpptools",
    "rust-analyzer.debug.engineSettings": {
        "cppdbg": {
            "miDebuggerPath": "${env:HOME}/.cargo/bin/rust-gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": false
                }
            ],
        }
    }
}

Nevertheless, why don't rust-analyzer do it by default? Or why isn't it on the manual page? Or is it and I've just missed that? :slight_smile:

1 Like

Makes sense to enable this by default, feel free to submit a PR. Though, truth to be told, I don't exactly know how our debugging infrastructure works :smiley:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.