在Xcode中,GDB允许您在调试时更改局部变量(请参阅在XCode中调试时如何更改NSString值?).LLDB是否提供类似的功能?如果是这样,我们如何使用它?
好吧,想象一下我的断点objc_exception_throw刚刚触发.我正坐在调试器提示符下,我想获得有关异常对象的更多信息.我在哪里找到它?
是否有一个LLDB命令可以将原始地址转换为可用的Swift类?
例如:
(lldb) po 0x7df67c50 as MKPinAnnotationView
Run Code Online (Sandbox Code Playgroud)
我知道这个地址指向MKPinAnnotationView,但它不在我可以选择的框架中.但是,我想将原始地址转换为MKPinAnnotationView,以便我可以检查其属性.这可能吗?
我想查看指针指向的元素数组.在GDB中,这可以通过使用运算符'@'将指向的内存视为给定长度的人工数组来完成
*pointer @ length
Run Code Online (Sandbox Code Playgroud)
length我想要查看的元素数量在哪里.
上述语法在随Xcode 4.1提供的LLDB中不起作用.
有什么方法可以在LLDB中完成上述工作吗?
我知道我可以print someFloatVariable在设置断点时键入po [self someIvarHoldingAnObject],但是我不能做有用的事情,比如:
[self setAlpha:1];
Run Code Online (Sandbox Code Playgroud)
然后吐出来:
错误:'[self'不是有效的命令.
奇怪的是我可以打电话po [self someIvarHoldingAnObject],它将打印出它的描述.
我相信我在一年前看过一个视频,其中有人演示了如何在运行时通过控制台执行代码,如果我没有弄错,这个人也提供了参数并为指针分配了对象.怎么做?
每当我构建XCode 6 beta 4时,我都会收到此错误.这似乎让我的应用程序变得非常慢.
警告:使用空的LLDB目标在路径'/***/***/***/***.app'创建LLDB目标时出错,这可能导致从远程设备读取内存缓慢.
这究竟是什么意思,我该如何解决?
提前致谢!
这样的事情在调试时让我发疯:
(lldb) p self.bounds
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: 2 errors parsing expression
(lldb) p (CGRect)self.bounds
error: unsupported expression with unknown type
error: unsupported expression with unknown type
error: C-style cast from '<unknown type>' to 'CGRect' is not allowed
error: 3 errors parsing expression
(lldb) p [self bounds]
error: 'bounds' has unknown return type; cast the call to its declared return type
error: 1 errors parsing expression
(lldb) p (CGRect)[self bounds]
(CGRect) …Run Code Online (Sandbox Code Playgroud) GDB和LLDB调试器有什么区别?我最近将我的Xcode版本从4.2升级到4.3并开始收到警告,将我的调试器从GDB升级到LLDB.
由于我更新到xcode 4.3并让它将我的调试器切换到lldb,因此任何打印成员变量的请求都会失败,并显示以下错误消息:
(lldb) print request
error: error: reference to 'id' is ambiguous
note: candidate found by name lookup is 'id'
note: candidate found by name lookup is 'id'
error: 1 errors parsing expression
Run Code Online (Sandbox Code Playgroud)
'自我'没问题:
(lldb) print self
(LoginViewController *) $6 = 0x1cd54d50
Run Code Online (Sandbox Code Playgroud)
打印成员变量的其他形式也会失败:
(lldb) print self.request
error: property 'request' not found on object of type 'LoginViewController *'; did you mean to access ivar 'request'?
error: 1 errors parsing expression
(lldb) print self->request
error: error: reference to 'id' is ambiguous
note: …Run Code Online (Sandbox Code Playgroud) (前言:我对C/C++很陌生,我真的不知道本机代码的调试实际上是如何工作的.)
一些消息来源说gdb和lldb可以调试任何编译成机器代码的程序.其他人说要使用gdb进行调试,你必须使用-g标志在gcc中编译.gcc本身的文档表明这是可选的,实际上如果你使用它,它可能会导致gdb 以外的调试器出现问题.Clang还有一个-g标志,文档基本上只是说"生成调试信息".
那么这些调试器是否仅限于它们自己的工具链(GNU和LLVM),还是它们在某种程度上独立于所使用的编译器?