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

Debugging Rust with CodeLLDB opens WSL terminal instead of VS Code debug console #867

Open
bigyihsuan opened this issue Feb 24, 2023 · 6 comments
Labels
platform:windows The issue is specific to Windows. See https://github.com/vadimcn/vscode-lldb/wiki/Windows

Comments

@bigyihsuan
Copy link

OS: Windows 11 Home 22H2 22621.1265
VSCode version: 1.75.1
CodeLLDB version: 1.8.1
Compiler: rustc 1.67.1

I'm trying to debug my Rust project with CodeLLDB and I want it to open the debugger in the built-in VS Code debug console. Instead, it opens a new WSL instance and tries to run the following in WSL:

$ c:\Users\bigyi\.vscode\extensions\vadimcn.vscode-lldb-1.8.1\adapter\codelldb.exe terminal-agent --connect=61793 
c:Usersbigyi.vscodeextensionsvadimcn.vscode-lldb-1.8.1adaptercodelldb.exe: command not found

My launch.json config is as follows:

{
    "type": "lldb",
    "request": "launch",
    "name": "Debug Rust",
    "program": "${workspaceFolder}/target/debug/esoteric_reaction.exe",
    "args": [
        "-f",
        "sample/hello-world.er"
    ],
}

Is there a way to get it to open the debug console?

Verbose log
Initial debug configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Debug Rust',
  program: '${workspaceFolder}/target/debug/esoteric_reaction.exe',
  args: [ '-f', 'sample/hello-world.er' ],
  __configurationTarget: 6
}
Resolved debug configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Debug Rust',
  program: '${workspaceFolder}/target/debug/esoteric_reaction.exe',
  args: [ '-f', 'sample/hello-world.er' ],
  __configurationTarget: 6,
  relativePathBase: 'd:\\Programming\\GithubRepos\\EsotericReaction',
  _adapterSettings: {
    displayFormat: 'auto',
    showDisassembly: 'auto',
    dereferencePointers: true,
    suppressMissingSourceFiles: true,
    evaluationTimeout: 5,
    consoleMode: 'commands',
    sourceLanguages: null,
    terminalPromptClear: null,
    evaluateForHovers: true,
    commandCompletions: true,
    reproducer: false
  }
}
liblldb: c:\Users\bigyi\.vscode\extensions\vadimcn.vscode-lldb-1.8.1\lldb\bin\liblldb.dll
environment: {}
params: { evaluateForHovers: true, commandCompletions: true }
[2023-02-24T15:16:44.675Z DEBUG codelldb] New debug session
[2023-02-24T15:16:44.786Z DEBUG codelldb::dap_codec] --> {"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"lldb","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en","supportsProgressReporting":true,"supportsInvalidatedEvent":true,"supportsMemoryReferences":true,"supportsArgsCanBeInterpretedByShell":true,"supportsMemoryEvent":true},"type":"request","seq":1}
[2023-02-24T15:16:44.786Z DEBUG codelldb::dap_codec] <-- {"seq":1,"type":"response","request_seq":1,"success":true,"command":"initialize","body":{"exceptionBreakpointFilters":[{"default":true,"filter":"cpp_throw","label":"C++: on throw"},{"default":false,"filter":"cpp_catch","label":"C++: on catch"}],"supportTerminateDebuggee":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsLogPoints":true,"supportsReadMemoryRequest":true,"supportsRestartFrame":true,"supportsSetVariable":true,"supportsWriteMemoryRequest":true}}
[2023-02-24T15:16:44.788Z DEBUG codelldb::dap_codec] --> {"command":"launch","arguments":{"type":"lldb","request":"launch","name":"Debug Rust","program":"D:\\Programming\\GithubRepos\\EsotericReaction/target/debug/esoteric_reaction.exe","args":["-f","sample/hello-world.er"],"__configurationTarget":6,"relativePathBase":"d:\\Programming\\GithubRepos\\EsotericReaction","_adapterSettings":{"displayFormat":"auto","showDisassembly":"auto","dereferencePointers":true,"suppressMissingSourceFiles":true,"evaluationTimeout":5,"consoleMode":"commands","sourceLanguages":null,"terminalPromptClear":null,"evaluateForHovers":true,"commandCompletions":true,"reproducer":false},"__sessionId":"beac51a5-93d9-4ce8-a20a-8e271675e55e"},"type":"request","seq":2}
[2023-02-24T15:16:44.789Z DEBUG codelldb::dap_codec] <-- {"seq":2,"type":"event","event":"output","body":{"output":"Console is in 'commands' mode, prefix expressions with '?'.\n"}}
INFO(Python) 10:16:44 formatters: Initializing
INFO(Python) 10:16:44 formatters.rust: Initializing
[2023-02-24T15:16:44.858Z DEBUG codelldb::dap_codec] <-- {"seq":3,"type":"event","event":"initialized"}
[2023-02-24T15:16:44.858Z DEBUG codelldb::debug_session] Debug event: 00000194D93BDD90 Event: broadcaster = 00000194D9764CB0 (lldb.target), type = 0x00000002 (modules-loaded), data = {esoteric_reaction.exe}
[2023-02-24T15:16:44.858Z DEBUG codelldb::dap_codec] <-- {"seq":4,"type":"event","event":"module","body":{"module":{"addressRange":"FFFFFFFFFFFFFFFF","id":"FFFFFFFFFFFFFFFF","name":"esoteric_reaction.exe","path":"D:\\Programming\\GithubRepos\\EsotericReaction\\target\\debug\\esoteric_reaction.exe","symbolFilePath":"D:\\Programming\\GithubRepos\\EsotericReaction\\target\\debug\\esoteric_reaction.exe","symbolStatus":"Symbols loaded."},"reason":"new"}}
[2023-02-24T15:16:44.858Z DEBUG codelldb::dap_codec] <-- {"seq":5,"type":"request","command":"runInTerminal","arguments":{"args":["c:\\Users\\bigyi\\.vscode\\extensions\\vadimcn.vscode-lldb-1.8.1\\adapter\\codelldb.exe","terminal-agent","--connect=61751"],"cwd":"","kind":"integrated","title":"Debug Rust"}}
[2023-02-24T15:16:44.861Z DEBUG codelldb::dap_codec] --> {"command":"setBreakpoints","arguments":{"source":{"name":"lex.rs","path":"d:\\Programming\\GithubRepos\\EsotericReaction\\src\\lex.rs"},"lines":[164],"breakpoints":[{"line":164}],"sourceModified":false},"type":"request","seq":3}
[2023-02-24T15:16:44.861Z DEBUG codelldb::dap_codec] --> {"command":"setFunctionBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":4}
[2023-02-24T15:16:44.861Z DEBUG codelldb::dap_codec] --> {"command":"setDataBreakpoints","arguments":{"breakpoints":[]},"type":"request","seq":5}
[2023-02-24T15:16:44.861Z DEBUG codelldb::dap_codec] --> {"command":"setExceptionBreakpoints","arguments":{"filters":["cpp_throw"]},"type":"request","seq":6}
[2023-02-24T15:16:44.882Z DEBUG codelldb::debug_session] Debug event: 00000194D87DF610 Event: broadcaster = 00000194D9764CB0 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {bkpt: 1 type: breakpoint added}
[2023-02-24T15:16:44.882Z DEBUG codelldb::dap_codec] <-- {"seq":6,"type":"response","request_seq":3,"success":true,"command":"setBreakpoints","body":{"breakpoints":[{"id":1,"line":164,"message":"Resolved locations: 0","verified":true}]}}
[2023-02-24T15:16:44.882Z DEBUG codelldb::dap_codec] <-- {"seq":7,"type":"response","request_seq":4,"success":true,"command":"setFunctionBreakpoints","body":{"breakpoints":[]}}
[2023-02-24T15:16:44.882Z DEBUG codelldb::dap_codec] <-- {"seq":8,"type":"response","request_seq":5,"success":true,"command":"setDataBreakpoints","body":{"breakpoints":[]}}
[2023-02-24T15:16:44.882Z DEBUG codelldb::dap_codec] <-- {"seq":9,"type":"response","request_seq":6,"success":true,"command":"setExceptionBreakpoints"}
[2023-02-24T15:16:44.882Z DEBUG codelldb::debug_session] Debug event: 00000194D87DFAD0 Event: broadcaster = 00000194D9764CB0 (lldb.target), type = 0x00000001 (breakpoint-changed), data = {bkpt: 2 type: breakpoint added}
[2023-02-24T15:16:44.923Z DEBUG codelldb::dap_codec] --> {"command":"configurationDone","type":"request","seq":7}
[2023-02-24T15:16:44.923Z DEBUG codelldb::dap_codec] <-- {"seq":10,"type":"response","request_seq":7,"success":true,"command":"configurationDone"}
[2023-02-24T15:16:44.934Z DEBUG codelldb::dap_codec] --> {"command":"threads","type":"request","seq":8}
[2023-02-24T15:16:44.934Z DEBUG codelldb::dap_codec] <-- {"seq":11,"type":"response","request_seq":8,"success":true,"command":"threads","body":{"threads":[]}}
[2023-02-24T15:16:45.961Z DEBUG codelldb::dap_codec] --> {"type":"response","seq":9,"command":"runInTerminal","request_seq":5,"success":true,"body":{"shellProcessId":17896}}
@vadimcn
Copy link
Owner

vadimcn commented Feb 25, 2023

What is your shell for the integrated terminal? Try setting it to cmd if it isn't already.

@bigyihsuan
Copy link
Author

bigyihsuan commented Feb 27, 2023

What is your shell for the integrated terminal? Try setting it to cmd if it isn't already.

Where is the setting for this?

EDIT: I set it to Powershell (F1 > Terminal: Select Default Profile) and VS Code still opens WSL.

@vadimcn
Copy link
Owner

vadimcn commented Feb 28, 2023

Where is the setting for this?

terminal.integrated.defaultProfile.windows, but note that it says that terminal.integrated.shell.windows overrides it.

This problem is more about VSCode than it is about CodeLLDB, as the latter just requests that a command is executed in a terminal, the rest is done by VSCode, using its defaults, etc.

@bigyihsuan
Copy link
Author

bigyihsuan commented Feb 28, 2023

terminal.integrated.defaultProfile.windows, but note that it says that terminal.integrated.shell.windows overrides it.

That fixed it. Now the problem is that the window doesn't follow code execution, like how the Golang extension follows execution.

EDIT: running it with

{
    "type": "lldb",
    "request": "launch",
    "name": "Debug Rust",
    "cargo": {
        "args": [
            "run",
            "--"
        ]
    },
    "args": [...],
}

has it working now.

@vadimcn
Copy link
Owner

vadimcn commented Feb 28, 2023

cargo run just runs your target without debugging. The point of "cargo": {} feature is to have Cargo build the target and report the location of the built executable, which CodeLLDB can subsequently launch.

@vadimcn
Copy link
Owner

vadimcn commented Mar 10, 2023

Not sure what's up with your vscode configuration, but it should not be using WSL shell to launch commands requested by the debug adapter. The WSL shell obviously does not expect backslashes at a path separator, which causes the error you see.

@vadimcn vadimcn added the platform:windows The issue is specific to Windows. See https://github.com/vadimcn/vscode-lldb/wiki/Windows label Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:windows The issue is specific to Windows. See https://github.com/vadimcn/vscode-lldb/wiki/Windows
Projects
None yet
Development

No branches or pull requests

2 participants