iphone - 为什么在使用 lldb 调试时有时 'self' 不可用?

标签 iphone ios objective-c llvm lldb

很多时候(不是每次都这样)当我尝试在 lldb 上打印对象时出现以下错误。是否有一些构建/调试配置需要更改,或者这是 lldb 中的错误?

(lldb) po userLevel
error: warning: Stopped in an Objective-C method, but 'self' isn't available; pretending we are in a generic context
error: use of undeclared identifier 'userLevel'
error: 1 errors parsing expression

我使用 llvm 构建并且不去除调试符号。

编辑:这是回溯:

(lldb) bt
* thread #1: tid = 0x1c03, 0x001169c5 FanCake-Beta`-[KWUserLevelController addPoints:](, _cmd=0x0029187b, points=15) + 179 at KWUserLevelController.m:53, stop reason = step over
    frame #0: 0x001169c5 FanCake-Beta`-[KWUserLevelController addPoints:](, _cmd=0x0029187b, points=15) + 179 at KWUserLevelController.m:53
    frame #1: 0x00112172 FanCake-Beta`-[KWEventRealTimeControllergameEngine:hostedGame:didSucceedIn:withScore:](self=0x0b9d7740, _cmd=0x0027a2a7, engine=0x1be5af40, game=0x1be5a850, completionTime=3.59473554800206, score=0) + 421 at KWEventRealTimeController.m:647
    frame #2: 0x0007189a FanCake-Beta`__35-[KMCatchEmGameEngine animateStep6]_block_invoke197(, finished='\x01') + 257 at KMCatchEmGameEngine.m:214
    frame #3: 0x01990df6 UIKit`-[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 223
    frame #4: 0x01983d66 UIKit`-[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 237
    frame #5: 0x01983f04 UIKit`-[UIViewAnimationState animationDidStop:finished:] + 68
    frame #6: 0x017587d8 QuartzCore`CA::Layer::run_animation_callbacks(void*) + 284
    frame #7: 0x03634014 libdispatch.dylib`_dispatch_client_callout + 14
    frame #8: 0x036247d5 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 296
    frame #9: 0x04737af5 CoreFoundation`__CFRunLoopRun + 1925
    frame #10: 0x04736f44 CoreFoundation`CFRunLoopRunSpecific + 276
    frame #11: 0x04736e1b CoreFoundation`CFRunLoopRunInMode + 123
    frame #12: 0x040367e3 GraphicsServices`GSEventRunModal + 88
    frame #13: 0x04036668 GraphicsServices`GSEventRun + 104
    frame #14: 0x01945ffc UIKit`UIApplicationMain + 1211
    frame #15: 0x000039a8 FanCake-Beta`main(argc=1, argv=0xbffff354) + 94 at main.m:13
    frame #16: 0x00002dc5 FanCake-Beta`start + 53

编辑 2:当我尝试打印本地变量时同样如此

(lldb) po currentUser
error: variable not available

如果我在代码中放置一些 NSLog() ,就会打印出正确的值。但不是使用 po 命令。

最佳答案

当我打开编译器优化时,我通常会遇到这个错误。编译器将生成不一定遵循您的代码逻辑流程的代码。

在导航器中转到您的项目 -> 目标 -> build设置 -> 搜索优化级别 -> 展开优化级别 -> 选择调试行 -> 在项目和目标的两列中更改为无。

希望这对您有所帮助。

关于iphone - 为什么在使用 lldb 调试时有时 'self' 不可用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15265949/

相关文章:

iphone - subview 打开时禁用父 View

iphone - 为什么我的核心动画转换总是返回到它的开始状态?

iphone - 子项目的 Xcode 环境变量

iphone - 如何在 iPhone 中的 map View 中心添加注释?

ios - 在 Swift 中更改导航栏中的字体

objective-c - 获取日期与 [NSDate date] 相差几个小时

c# - 检查通知权限是否被授予(Xamarin,iOS)

ios - 自动滚动到 ScrollView 中的 subview

objective-c - Yahoo OAuth 与 Mac 应用程序的 gtm-oauth

c - 如何使用 Objective-C 对象的二维 C 数组?