Can't set Breakpoint within an os_activity_initiate block

I'm just starting out trying to use os_activity and have hit an annoyance. Attempting to add a breakpoint to any line of code with os_activity_initiate block does not work as expected. Instead it seems to break after the call to os_activity_initiate.


E.g Consider this:

- (IBAction)doActivity:(id)sender
{
    os_activity_initiate("Test Activity", OS_ACTIVITY_FLAG_DEFAULT, ^{
        NSLog(@"Doing activity");
        NSBeep(); // <<-- Try to add a preakpoint here
        NSLog(@"Finished activity");
    });
}


Try to put a breakpoint at the NSBeep() line. By the time it fires, both NSLog calls will have already been done.

Only solution I can find is to wrap all such code inside os_activity_initiate blocks into a local block (or other function) but that's no fun.


BTW - Xcode 9.2 Debug configuration and macOS 10.13.2

Accepted Reply

Thanks for that. Reading that bug report it seems like the underlying problem here is that

os_activity_initiate
is a macro, and there’s an issue mixing macros, blocks and the debugger. Alas, there’s no simple workaround. In your shoes I’d move the contents of the block to a separate method or function, and then set my breakpoint there.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

This sounds worthy of a bug report against the debugger; there should be nothing fundamental stopping you from setting a breakpoint in that block.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Already done - 36176497

Thanks for that. Reading that bug report it seems like the underlying problem here is that

os_activity_initiate
is a macro, and there’s an issue mixing macros, blocks and the debugger. Alas, there’s no simple workaround. In your shoes I’d move the contents of the block to a separate method or function, and then set my breakpoint there.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I feared as much, especially having seen what os_activity_initiate preprocesses too. Pretty scary stuff.😁