Continue execution after breakpoint in Swift closure?

Hello,

I've encountered a scenario where Xcode breakpoints are not behaving as expected. I want to:

1) Create a shared breakpoint in a Swift closure
2) Print out a value using LLDB
3) Automatically continue execution after hitting the breakpoint

What I observe is that Xcode not only ignores the "Automatically continue execution" setting in the breakpoint, it actually overwrites the file on disk to remove this option.

I have put together a very simple example app demonstrating this issue: https://github.com/tspike/xcode-breakpoint-issue

Is this a bug?

Thanks,
Tres
AFAICT this is working on my machine. Here’s what I did:
  1. Starting with Xcode 11.5 on macOS 10.15.5…

  2. I downloaded your project.

  3. I ran it in the iOS 13.5 simulator.

  4. It printed [6, 7, 8].

  5. I broke into the debugger and did the following:

.

Code Block
(lldb) br list
Current breakpoints:
1: file = '…/AppDelegate.swift', line = 18, exact_match = 0, locations = 2, resolved = 2, hit count = 4
1.1: where = BreakpointIssue`BreakpointIssue.AppDelegate.application(…) -> Swift.Bool + 64 at AppDelegate.swift:18:24, address = 0x000000010447f510, resolved, hit count = 1
1.2: where = BreakpointIssue`closure #1 (Swift.Int) -> Swift.Int in BreakpointIssue.AppDelegate.application(…) -> Swift.Bool + 39 at AppDelegate.swift:18:41, address = 0x000000010447f6e7, resolved, hit count = 3


The hit count reveals that it actually hit, and then auto continued past, the breakpoint four times, once outside of the map call and three times inside the closure passed to map.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Thanks for the reply Quinn. Frustrating! I'm running all the same versions and do not observe the same behavior. Here's a video showing the issue: https://github.com/tspike/xcode-breakpoint-issue/blob/master/breakpointissue.mov?raw=true

What could the difference be? 🤔

-- Tres

iOS @ WalmartLabs

I am seeing issues and am able to reproduce the exact issue described if I make a few tweaks.

On first running the project and going to do a git diff, I can see the "continueAfterRunningActions" option change to "No". In addition to this, I see that the action on the breakpoint has been removed (po $0).

If I recreate the action that was removed, I am now able to see the behavior that Tres initially pointed out.

From a quick test, this appears to be an issue with single line closures. If I move the closure to be multi-line and just add a breakpoint inside the closure, I can create a breakpoint with a po $0 action that continues after running actions.

e.g.

Code Block
let plusFive = [1,2,3].map {
$0 + 5
}



Jordan
iOS @ WalmartLabs

What could the difference be?

I’m at a loss. I see that you and Jordan are working for the same organisation. Perhaps there’s something specific to your environment that’s triggering this. Can you set up a fresh machine to test this on?

I usually do this sort of testing in a VM, so I can restore it to a fresh snapshot between tests.

And, just to put my money where my mouth is, I re-ran your test on a VM here in my office (Xcode 11.4 on macOS 10.15.4, I guess I need to update :-) and I still don’t see the problem [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"

[1] In the process I learnt that the simulator requires at least 4 GiB of physical memory. Who knew!?
Continue execution after breakpoint in Swift closure?
 
 
Q