error: Couldn't materialize struct: Couldn'

2020-02-24 17:17发布

问题:

For debugging on iOS simulator, I used to be able to read out $eax register and get the error message. However, I don't know if it's the new XCode version 4.6 and iOS 6.1, I can't do that any more.

(lldb) po $eax
error: Couldn't materialize struct: Couldn't read eax (materialize)
Errored out in Execute, couldn't PrepareToExecuteJITExpression

What now? Also eax is not in the real device, what do I do?

回答1:

According to this LLDB guide, you can use:

register read

To examine the general purpose registers of the current thread



回答2:

While trojanfoe gave a great answer, something that might help others too is that if you're attempting to print $eax as a result of an exception that is not displaying a message, be sure you're in the objc_exception_throw frame in the Debug Navigator (+6) when printing it out. Otherwise you'll get the "couldn't materialize" error above.



回答3:

Make sure your current build scheme is on debug mode, because otherwise the compiled app will be optimised by stripping out additional information for debugging.

If you are setting your own build schemes, go to Build Settings -> Code Generation -> Optimization Level, set the value to 'None [-O0]'.