-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Description
So, I've started this discussion a few days ago, but I have looked some more into it after that and I still can't make any sense of it.
The LLDB part seems to be just fine, but it just drops the communication with OpenOCD's GDB server out of nowhere. I've tried changing the request from launch to attach, but then it got even worse, even the LLDB part wouldn't work then.
I'm out of ideas on how to make this work, is it something I'm doing wrong or is it a bug in the DAP implementation? Is there anything else I can try? I'm open to running tests here to help diagnose any possible issues, just tell me what to do 🫡
Discussed in #12317
Originally posted by lucas-yotsui December 22, 2024
Hi, I'm currently working on a project in Zig for embedded devices and I'd like to debug it using Helix's DAP.
I'm currently targetting a STM32F411CC (black pill).
I've already debugged this project extensively using OpenOCD and GDB's CLI and it works fine. To do so, I do the following:
- start OpenOCD in a terminal tab
- run
gdb <EXECUTABLE_DIR>/<EXECUTABLE>.elf -ex "target extended-remote localhost:3333"in a separate tab
This works fine, but running GDB in the terminal is not really my favorite thing in the world, so i'd like to run it in Helix.
To configure my debugger template I've taken the configurations shown in #10236 and modified it in about every possible way, but nothing seems to work.
My latest attempt looks like this:
[[language]]
name = "zig"
[language.debugger]
name = "lldb-dap"
transport = "stdio"
command = "lldb-dap"
[[language.debugger.templates]]
name = "gdbserver (arm-none-eabi)"
request = "launch"
runInTerminal = true
completion = [ { name = "host", default = "localhost:3333" }, { name = "file", completion = "filename" } ]
args = { console = "internalConsole", program = "{1}", MIMode = "gdb", targetArchitecture = "arm", miDebuggerPath = "arm-none-eabi-gdb", miDebuggerServerAddress = "{0}", useExtendedRemote = true, stopAtEntry = true, initCommands = [ "platform select remote-gdb-server", "platform connect connect://{0}", "file {1}" ] }This gave me the best result so far, as it starts GDB and connects it to OpenOCD. However, that's as far as it gets, not running the application properly: it just gives me a Lost debug server connection error as soon as I try to do anything (restart, continue or step).
Here's the log obtained after running helix with helix -v . and trying to use the debugger:
2024-12-22T22:36:13.186 helix_dap::transport [INFO] -> DAP {"type":"request","seq":0,"command":"initialize","arguments":{"adapterID":"lldb-dap","clientID":"hx","clientName":"helix","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsInvalidatedEvent":false,"supportsMemoryReferences":false,"supportsProgressReporting":false,"supportsRunInTerminalRequest":true,"supportsVariablePaging":false,"supportsVariableType":true}}
2024-12-22T22:36:13.231 helix_dap::transport [INFO] <- DAP {"body":{"completionTriggerCharacters":["."," ","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++ Catch"},{"default":false,"filter":"cpp_throw","label":"C++ Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C Throw"},{"default":false,"filter":"swift_catch","label":"Swift Catch"},{"default":false,"filter":"swift_throw","label":"Swift Throw"}],"supportTerminateDebuggee":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDelayedStackTraceLoading":true,"supportsDisassembleRequest":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsGotoTargetsRequest":false,"supportsHitConditionalBreakpoints":true,"supportsLoadedSourcesRequest":false,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsProgressReporting":true,"supportsRestartFrame":false,"supportsRestartRequest":true,"supportsRunInTerminalRequest":true,"supportsSetVariable":true,"supportsStepBack":false,"supportsStepInTargetsRequest":false,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":0,"seq":0,"success":true,"type":"response"}
2024-12-22T22:36:13.231 helix_dap::transport [INFO] <- DAP success in response to 0
2024-12-22T22:36:13.232 helix_dap::transport [INFO] -> DAP {"type":"request","seq":1,"command":"launch","arguments":{"MIMode":"gdb","console":"internalConsole","cwd":"/home/lucas/Projects/Personal/Zig/UniMicroTest","initCommands":["platform select remote-gdb-server","platform connect connect://localhost:3333","file /home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf"],"miDebuggerPath":"arm-none-eabi-gdb","miDebuggerServerAddress":"localhost:3333","program":"/home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf","stopAtEntry":true,"targetArchitecture":"arm","useExtendedRemote":true}}
2024-12-22T22:36:13.240 helix_dap::transport [INFO] <- DAP {"body":{"category":"console","output":"Running initCommands:\n(lldb) platform select remote-gdb-server\n Platform: remote-gdb-server\n Connected: no\n(lldb) platform connect connect://localhost:3333\n Platform: remote-gdb-server\n Hostname: (null)\n Connected: yes\n(lldb) file /home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf\nCurrent executable set to '/home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf' (arm).\n"},"event":"output","seq":0,"type":"event"}
2024-12-22T22:36:13.240 helix_dap::transport [INFO] <- DAP event Output(Output { output: "Running initCommands:\n(lldb) platform select remote-gdb-server\n Platform: remote-gdb-server\n Connected: no\n(lldb) platform connect connect://localhost:3333\n Platform: remote-gdb-server\n Hostname: (null)\n Connected: yes\n(lldb) file /home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf\nCurrent executable set to '/home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf' (arm).\n", category: Some("console"), group: None, line: None, column: None, variables_reference: None, source: None, data: None })
2024-12-22T22:36:13.240 helix_view::handlers::dap [INFO] Running initCommands:
(lldb) platform select remote-gdb-server
Platform: remote-gdb-server
Connected: no
(lldb) platform connect connect://localhost:3333
Platform: remote-gdb-server
Hostname: (null)
Connected: yes
(lldb) file /home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf
Current executable set to '/home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf' (arm).
2024-12-22T22:36:13.252 helix_dap::transport [INFO] <- DAP {"command":"launch","message":"Lost debug server connection","request_seq":1,"seq":0,"success":false,"type":"response"}
2024-12-22T22:36:13.252 helix_dap::transport [ERROR] <- DAP error Some("Lost debug server connection") (None) for command #1 launch
2024-12-22T22:36:13.252 helix_dap::transport [INFO] <- DAP {"event":"initialized","seq":0,"type":"event"}
2024-12-22T22:36:13.252 helix_dap::transport [INFO] <- DAP event Initialized(None)
2024-12-22T22:36:13.252 helix_dap::transport [INFO] -> DAP {"type":"request","seq":2,"command":"setBreakpoints","arguments":{"breakpoints":[{"line":7}],"source":{"path":"/home/lucas/Projects/Personal/Zig/UniMicroTest/src/main.zig"},"sourceModified":false}}
2024-12-22T22:36:13.259 helix_dap::transport [INFO] <- DAP {"body":{"breakpoints":[{"column":16,"id":1,"instructionReference":"0xFFFFFFFFFFFFFFFF","line":7,"source":{"name":"main.zig","path":"/home/lucas/Projects/Personal/Zig/UniMicroTest/src/main.zig"},"verified":false}]},"command":"setBreakpoints","request_seq":2,"seq":0,"success":true,"type":"response"}
2024-12-22T22:36:13.259 helix_dap::transport [INFO] <- DAP success in response to 2
2024-12-22T22:36:13.259 helix_dap::transport [INFO] -> DAP {"type":"request","seq":3,"command":"configurationDone","arguments":null}
2024-12-22T22:36:13.259 helix_dap::transport [INFO] <- DAP {"command":"configurationDone","request_seq":3,"seq":0,"success":true,"type":"response"}
2024-12-22T22:36:13.259 helix_dap::transport [INFO] <- DAP success in response to 3
2024-12-22T22:36:21.824 helix_dap::transport [INFO] -> DAP {"type":"request","seq":4,"command":"restart","arguments":{"MIMode":"gdb","console":"internalConsole","cwd":"/home/lucas/Projects/Personal/Zig/UniMicroTest","initCommands":["platform select remote-gdb-server","platform connect connect://localhost:3333","file /home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf"],"miDebuggerPath":"arm-none-eabi-gdb","miDebuggerServerAddress":"localhost:3333","program":"/home/lucas/Projects/Personal/Zig/UniMicroTest/zig-out/bin/blinky.elf","stopAtEntry":true,"targetArchitecture":"arm","useExtendedRemote":true}}
2024-12-22T22:36:21.825 helix_dap::transport [INFO] <- DAP {"command":"restart","request_seq":4,"seq":0,"success":true,"type":"response"}
2024-12-22T22:36:21.825 helix_dap::transport [INFO] <- DAP success in response to 4
2024-12-22T22:36:28.135 helix_dap::transport [INFO] -> DAP {"type":"request","seq":5,"command":"threads","arguments":null}
2024-12-22T22:36:28.135 helix_dap::transport [INFO] <- DAP {"body":{"threads":[]},"command":"threads","request_seq":5,"seq":0,"success":false,"type":"response"}
2024-12-22T22:36:28.135 helix_dap::transport [ERROR] <- DAP error None (Some(Object {"threads": Array []})) for command #5 threads
The logs seem to show that GDB is started properly, lldb connects to it with the initCommands but it dies as soon as it hits the launch command.
Am I doing something wrong? Is there a way to make this setup work?