-
Notifications
You must be signed in to change notification settings - Fork 4
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
Question: Remote debugging of swift code with LLDB? #4
Comments
(Sorry for the long delay on replying to this.) Correct, at the moment remote debugging isn't supported by the adapter, but it could be, like you suspected. By "server-side applications" here, we only meant "those being built and debugged on the Mac" for the time being. I haven't specifically started work on this, only really because nobody had really asked until now. I don't think it would be too much work. Icarus's debug adapter essentially sits on top of LLDB.framework, which does most of the heavy lifting with attaching to and driving the debuggee. I believe LLDB.framework exposes LLDB's remote debugging functionality, as well, so it would presumably be a matter of exposing that upwards to Swift and adding support to the adapter (and lots of testing, I suppose. 😄) I'm happy to take a look into this soon. We've been busy with the current Nova development milestone but I could use a break on something else. |
Hi Logan. No worries - thanks for the reply. Since Xcode doesn't support this (remote / source code debugging a server side swift app in a local docker container (or other VM?), or remote debugging a server side swift app on a remote server), the only choice now is VS Code which is not a nice native app like Nova :) One can use something like BBedit to edit files and then terminal logged into the container to launch builds but debugging source code debugging in an app/IDE. As for interest: I asked a question about how to do this on one of the iOS Slack instances I'm on and got a couple of folks saying they didn't know if Nova could do this but would be very interested in finding out if it did. So there are at least a few people who'd appreciate it :) Some things I ran into thinking about this:
That's good to hear that the plumbing might be in lldbLib and that we maybe don't have to write the socket communication stuff entirely from scratch. I'm dealing with some health challenges and so am only intermittently available for the next couple of months, but I'd be willing to test dev versions of this and give feedback if that would be helpful. I also might be able to contribute more once I'm done with treatment. |
Good news: After spending a day or two messing around, I think I've managed to get an initial implementation of remote debugging working. I've placed it on a separate branch for the time being: https://github.com/panicinc/icarus/tree/remote-debugging. The debug adapter has been modified to support LLDB's remote debugging features, and there's a new task template for Nova named "LLDB Remote Debug" which wires into this. It's the same adapter, just with different configuration options for remote debugging. There's configuration options for how to connect and how paths map between the local and remote file systems (for proper breakpoint and stack frame translation in Nova). At the moment, this is only working for remote Linux systems, as I've hard-coded the LLDB platform driver name ( The remote system needs to be running For Docker containers, that port needs to be exposed as well as a few other options so that LLDB can connect and remotely drive properly. Here's a copy of the Docker Compose file I'm using for testing this: services:
lldb-server:
image: swift
entrypoint: /bin/bash
command: "-c 'lldb-server p --server --listen *:8000 --min-gdbserver-port 31200 --max-gdbserver-port 31300'"
stdin_open: true
tty: true
ports:
- 8000:8000
- 31200-31300:31200-31300
working_dir: /app
volumes:
- ./:/app
cap_add:
- SYS_PTRACE
security_opt:
- seccomp=unconfined I'll keep working on this as I can figure things out, but this is really promising. It required far less work than I'd imagined, as most of it was just figuring out the exact APIs and steps with LLDB that need to be wrapped and used in the adapter. |
Super Cool! Great News! I'm really looking forward to trying this out. Thanks so much for taking a look at it. I think a lot of folks will be excited about this. |
Related: Great that this pitch got approved. Will hopefully make the build-on-macOS_and_run-and-debug-on-Linux(etc) easier in the future. https://forums.swift.org/t/pitch-cross-compilation-destination-bundles/61777 |
Indeed! I was happy to see that work start. |
Finally getting to this (sorry for the delay) but I'm getting a build error on this 13" M1 MBP (arm64):
Dumped symbols for LLDB framework and I'm not seeing Since I didn't see anyone calling |
Build steps in the readme don't seem quite right so I made a patch for what seems right #7. (edited: removed comments about issues getting it to run). Ok. So I got this branch build, loaded into Nova and activated as an extension. Do I need to add a specific Run action to the "LLDB Remote Debug" Task? For the "LLDB Remote Debug" Task I added a Build script step like this: where "swift-dev" is the name in the docker-compose.yml file so I could reference it easily:
That compose file is otherwise identical to what you posted above. Perhaps I don't have the LLDB Remote Debug Task setup properly. Here's what I have: |
Happy to spend more time exercising this but I think I need a hint on how to get the debugger working (local/remote Path Mappings entry(ies) needed? Something else?). |
I swear this is still on my mind, sorry for the delays again. Panic was just at PAX West in Seattle at the start of September and most of my time for engineering work has been taken up by other things. I'm hoping to look into this more in the coming days, if not today! |
:) No problem! I saw you scrambling to complete your cool cosplay costume via Mastodon, so I knew you had important stuff you were dealing with :). That was one heck of a costume - super impressive. Thank you. Let me know if there's anything I can do to help with testing or whatever. I feel like it might work better than I was able to get it to work if I understood what settings to put into the LLDB Remote Debug configuration window better. |
I'm not seeing support for remote debugging with LLDB (use case 1: from Nova on my Mac to a Docker container on the same Mac running Linux and bound to a folder on the Mac that has the source code so Nova can edit it but it can be built and run inside the docker container).
Looking inside Icarus UI and source I don't see any specific support for remote debugging with LLDB but the Readme file says:
and the "server-side applications" part made me think it might.
I was able to use a generic task (not the LLDB) task and get Nova editing and able to invoke a remote build and run command via Run Script Tasks like
docker exec -i -w /app {ContainerID} swift build
anddocker exec -i -w /app {ContainerID} swift run
but that doesn't give you debugging inside Nova via LLDB.I started looking at what it would take to add support for this to Icarus and I'd have a lot to learn before I could do it. I'm working though that as time permits, but it seemed worth asking if:
TIA
The text was updated successfully, but these errors were encountered: