swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
761 stars 55 forks source link

Forward LLDB debugger logs to an output pane #1104

Open tristanlabelle opened 2 months ago

tristanlabelle commented 2 months ago

Is your feature request related to a problem? Please describe. The LLDB debugger is very unreliable/crashy (at least on Windows). In order to help with investigations, it would be useful to capture logs from LLDB.

Describe the solution you'd like If LLDB offers any sort of logging mechanism, the DAP server should send it back to the client and the VS Code Swift extension should manage an output pane that displays it. The enablement and verbosity of it could be controlled by a setting if it is a concern.

Bonus points if we can have a pane that shows what lldb command-line commands are executed for IDE operations as a learning tool :)

Describe alternatives you've considered Currently we can only debug the debugger. Or would there be a way to ask the DAP to save a log to a file?

Additional context It seems like the VSCode API has limited ability to customize how the debug adapter is launched and stdout is already used for the DAP communication. I can think of two possible implementations:

  1. Create a named pipe and pass it as a command line argument to the DAP for it to configure LLDB to send logs there.
  2. Use custom DAP notifications to send LLDB logs.

(this is all assuming LLDB has some logging mechanism)

plemarquand commented 2 months ago

@tristanlabelle There is an LLDB entry in dropdown on the Output panel today, but in order to see verbose output there you'll need to set the "lldb.verboseLogging" VS Code setting to true. This will show all the logs written by CodeLLDB. Is this enough for your usecase?

tristanlabelle commented 2 months ago

I saw that one and suspected it was for CodeLLDB. I'm interested in the Swift-LLDB adapter since that is compatible with newer toolchains on Windows.

plemarquand commented 2 months ago

Ah, understood, definitely worthwhile to add this!