Author Topic: Should I be able to debug Swift apps on Mac?  (Read 2153 times)

macjohnmcc

  • Community Member
  • Posts: 59
  • Hero Points: 1
Should I be able to debug Swift apps on Mac?
« on: October 23, 2015, 05:38:42 pm »
When I try to debug my app (Swift with a little bit of C) I get an error.
Error starting debugger: GDB returned an error opening the executable

"/Users/john/dev/projects/AppName/build/Debug/AppName.app: No such file or directory."

The app is in that folder with that name.

I would assume if this is meant to work it would also use LLDB instead of GDB but figured I should ask. If it's not meant to work I would prefer that the debug option was disabled in the menu.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2815
  • Hero Points: 426
Re: Should I be able to debug Swift apps on Mac?
« Reply #1 on: October 23, 2015, 09:52:36 pm »
I am not sure how you set up your project, but the debugger needs to be pointed at the executable, not the application package.  Try using "/Users/john/dev/projects/AppName/build/Debug/AppName.app/Contents/MacOS/AppName"

We do not yet have support for LLDB, but that is planned for a future release.

macjohnmcc

  • Community Member
  • Posts: 59
  • Hero Points: 1
Re: Should I be able to debug Swift apps on Mac?
« Reply #2 on: October 23, 2015, 09:54:51 pm »
Other than opening the xcodeproject I have done nothing more. I assumed that selecting the project type would come with some logic to figure out the rest as it does in Xcode and AppCode.

I'll check out the settings.

How far in the future for LLDB? Next major version or an update to 2015?

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2815
  • Hero Points: 426
Re: Should I be able to debug Swift apps on Mac?
« Reply #3 on: October 23, 2015, 10:01:11 pm »
Would you be able to share your Xcode project with us, I might be able to tweak things to feed the correct executable to GDB.  You could also use Debug > Attach Debug > Debug Other Executable... and point it to the executable.

macjohnmcc

  • Community Member
  • Posts: 59
  • Hero Points: 1
Re: Should I be able to debug Swift apps on Mac?
« Reply #4 on: October 23, 2015, 10:34:46 pm »
I tried the debug other executable option and get this result:

Error stepping: GDB could not step application

"Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x7be0"

I did get a warning about required elevated privileges when I first tried debugging so I'm not sure that it's related to that.

I also tried it no breakpoint set. Once it was running I selected a breakpoint and got the program to that point (from what I can tell) and I can step through the lines of the code fine but not able to see the values of any variables. I suspect that won't be available soon.

In any event when it does finally fully support LLDB and Swift I think it will be a top contender for developing Swift apps due to editor functionality and the debugger.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2815
  • Hero Points: 426
Re: Should I be able to debug Swift apps on Mac?
« Reply #5 on: October 24, 2015, 01:13:47 am »
I was able to step through a simple Swift project and set and hit breakpoints with GDB, those thing worked pretty well.  It could evaluate simple (integer) local variables.  Globals and function names were pretty badly mangled, it looks like GDB has no clue about Swift name mangling at this early stage, maybe a future release of GDB will.  Swift string variables are opaque, so you couldn't really see their contents, though you could drill down far enough to see their length.

LLDB integration will be a huge improvement for MacOS, but it is no trivial undertaking so for the time being, it still falls under the "future, hopefully next, release" status.

macjohnmcc

  • Community Member
  • Posts: 59
  • Hero Points: 1
Re: Should I be able to debug Swift apps on Mac?
« Reply #6 on: October 24, 2015, 02:33:30 am »
Maybe it's time to document how GDB integration is done then maybe someone can do the same for LLDB as a third party/community.