Xcode Debugger and lldb Fail to display Foundation Types

When stopped at a breakpoint in Xcode variables of (many, most) Types from Foundation don't display correctly in the Variables pane. I can po or Print Description of and the value's description appears in the debugger console but the variables don't display their description in the Variables pane.

I've looked at these Types: Calendar, CharacterSet, Date, DateComponents, Data, IndexPath, Notification and TimeZone. Only Data works as expected. It displays its size in the variables pane. The others are all blank. If the type is an optional then it always displays as nil, even when it isn't nil.

Also, there seems to be a lifespan issue where objects get deinited and then po fails with this:

(lldb) po notification
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=EXC_I386_GPFLT).
The process has been returned to the state before expression evaluation.

I can only guess at the cause of this error message but it seems to happen if you set a breakpoint on the last brace of a method. I've also seen po print out a different object than the one intended. This might also be caused by an object being deinited and then another one replace it. iVars never show this error, only local variables. Presumably the lifespan of an iVar isn't affected when a function comes to the last line. At any rate, one would expect a better error message than this if lifespan is the problem.

Anyway, I didn't find any bugs related to this on this forum. Is this a well known bug? A lot of other types do display correctly in the variables pane but it seems that Foundation types do not.

1 Like

lldb also fails to print these types using frame v and print, although it succeeds with po.

I've filed https://bugs.swift.org/browse/SR-12444

1 Like