emacs-lsp / dap-mode

Emacs :heart: Debug Adapter Protocol
https://emacs-lsp.github.io/dap-mode
GNU General Public License v3.0
1.3k stars 183 forks source link

Rust debugger doesn't print array elements in local variables #744

Open gnuemacscoin opened 1 year ago

gnuemacscoin commented 1 year ago

Invoking the debugger via code lens results in expanded slices showing only data_ptr and length fields, and expanding data_ptr shows only the element at index 0. I found the following vscode configuration elsewhere:

    {
        "name": "(gdb) Launch",
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceFolder}/bin/main",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "/usr/bin/gdb",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ]
    }

then tried to adapt it to dap-mode :

(setf lsp-rust-analyzer-debug-lens-extra-dap-args
      '(:MIMode "gdb" :miDebuggerPath "rust-gdb" :stopAtEntry t :externalConsole :json-false :setupCommands
                [#s(hash-table size 12 data
                               ("description" "Enable pretty-printing for gdb" "text" "-enable-pretty-printing" "ignoreFailures" t))]))

and it fixed my problem. Due to the immense usefulnes of locals, I believe this deserves at least a mention in the docs, if not an outright change of defaults.

yyoncho commented 1 year ago

Sounds good. Willing to prove a PR?

yyoncho commented 1 year ago

You may put it here: https://github.com/emacs-lsp/lsp-mode/blob/master/docs/manual-language-docs/lsp-rust-analyzer.md?plain=1#L1