Swift LLDB Message "<Unable to determine byte size.>"
Asked Answered
O

5

16

I'm having a pretty annoying problem in the Swift debugger when I'm trying to print out the description of an object. When trying to print and object, either using the po command or fr v command, I get messages like

error: <EXPR>:1:1: error: use of unresolved identifier 'self' self ^

or

self = <Unable to determine byte size.>

What's going on here? Are there reasons why the debugger isn't able to read something like self?

Outface answered 3/8, 2015 at 19:43 Comment(2)
I'm having this problem as well. Not just for self but for many variables in frame. I've set SWIFT_OPTIMIZATION_LEVEL and GCC_OPTIMIZATION_LEVEL to None, as other's have advised, but this has had no effect.Maramarabel
Yeah, I've been having this issue with more than just self. The full printout of fr v will often include the details of other in-memory variables and have no issue printing those. I suspect that there is some kind of object type that the debugger is unable to analyze that is a member of all the different objects I'm unable to print, but I don't know what properties that kind of problematic object type would have that would cause this.Outface
G
3
<Unable to determine byte size>

is the (admittedly somewhat cryptic) error message that LLDB will print out when it does not understand the type of something.

Let me elaborate a little bit more. When you type an expression, or do a frame variable, the debugger has to evaluate whatever code you provided, or lookup the variable(s) you asked for.

In order to present the results of that to you, it also has to understand the type of things. For instance, an Int is a thing that has a numeric value whose size matches the pointer size on your machine, ... (well, to be 100% precise, an Int is a thing that has a member that has a numeric value..., but LLDB abstracts that away from you). A String is a thing that has some text (again, it's a little trickier, but LLDB abstracts that). One of the things the debugger likes to know is the "byte size" of a type, as in how many bytes in memory does an object of this type occupy?

Sometimes, the debugger can't understand the types that are being talked about. When that happens, obviously, one of the things that can't be determined is the byte size. Hence, the message.

If you run into situations where the debugger can't infer types in your apps, please file bugs http://bugreport.apple.com

Geochemistry answered 4/8, 2015 at 17:57 Comment(1)
What kind of information would be helpful in a bug report about this? As far as I can tell, this issue arises whenever the object I'm trying to inspect has a reference to a particular class in my project. I can't really share the class itself (it's for work, confidential), but what kind of information would be helpful to pass along?Outface
M
1

In my case, after much research and testing, I've found that the 3rd party add-ons "Crashlytics" and "TwitterKit" (installed via cocoapods in my case) were causing this issue for me. After removing those libraries and doing a clean then build, I was able to use LLDB correctly again.

See https://mcmap.net/q/645731/-lldb-throwing-auto-import-error-in-swift-xcode-project

Maramarabel answered 26/8, 2015 at 1:29 Comment(0)
S
1

As Scott D mentioned, this can be something with Fabric. If you are using Fabric, especially with TwitterKit go to TwitterKit framework and edit TwitterKit.h manually. Replacing

#import <TwitterCore/TwitterCore.h>

with

@import TwitterCore;

makes debugger usable again. Sidenote: Fabric and Crahlytics pods are updated and don't break debugger anymore.

EDIT: Twitter pods from fabric also were updated and starting version 1.12.0 they don't break the debugger. Yay!

Stinkweed answered 30/9, 2015 at 15:47 Comment(0)
X
1

I have intermittent problems with this. Clean the build folder and rebuild resolves it. (Product -> Clean build folder)

Xenophobia answered 9/1, 2022 at 22:58 Comment(0)
S
0

If the value you're trying to print out is an optional, try using the nil-coalescing operator (??) to make it non-optional.

Sabinasabine answered 28/1, 2023 at 17:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.