[英]XCode LLDB - Get self from a given frame
I want to get "self" from a given frame. 我想从给定的框架中获得“自我”。 Is there a way to do this? 有没有办法做到这一点?
I tried "frame info" and a few other options. 我尝试了“框架信息”和其他一些选项。
(lldb) frame info frame #11: 0x0000000102767ab8 UIKit`-[UIImageView _resolveImageForTrait:] + 463 (lldb)
For instance in the following example I want the button object from the 11th frame. 例如,在以下示例中,我想要第11帧中的按钮对象。
It's fairly easy to get the parameters to optimized functions w/o debug information if you are stopped when the function is invoked, since then they will still be in the ABI specified argument passing registers. 如果在调用函数时停止调用信息,那么将参数调整为优化函数是相当容易的,因为它们仍将在ABI指定的参数传递寄存器中。 So if the problem you are investigating is one you can reproduce, putting an auto-continue breakpoint on -[UIImageView _resolveImageForTrait:]
and printing or po'ing $arg1
in its commands will help you figure it out. 因此,如果你正在研究的问题是你可以重现的问题,那么在其上放置一个自动继续断点-[UIImageView _resolveImageForTrait:]
并在其命令中打印或po'ing $arg1
将帮助你弄明白。
But if you're trying to figure the value out starting from this stack, your life is considerably harder. 但如果你试图从这个堆栈开始计算出价值,你的生活就会变得更加艰难。 Since the frame you are interested in has called another function, you are guaranteed that your self
no longer lives in the argument passing register, it has been reused. 由于您感兴趣的帧调用了另一个函数,因此可以保证您的self
不再存在于参数传递寄存器中,它已被重用。 And there is no required place where arguments are put within the body of the function. 并且没有必要的地方将参数放在函数体内。 In optimized code the compiler is expected to do with self whatever makes the code run the fastest. 在优化的代码中,无论什么使代码运行最快,编译器都应该使用self。
Indeed, if self is not referenced in the frame in question after the call you are stopped at, the information may not exist at all anymore. 实际上,如果在您停止呼叫之后未在相关帧中引用self,则信息可能根本不存在。
If self is still alive in that frame, it was most likely pushed on the stack somewhere in the function before calling into imageWithTraitCollection:. 如果self在该帧中仍处于活动状态,则很可能在调用imageWithTraitCollection之前将其推送到函数中的某个堆栈中。 The debug information would tell you where that was, but without that your only choice is to read the assembly code and follow the propagation of self from the first argument register at the beginning of the function to the point where you are stopped. 调试信息会告诉你它在哪里,但没有它,你唯一的选择是读取汇编代码并跟踪self从函数开头的第一个参数寄存器到你被停止点的传播。 This might not be too bad for a small function. 对于小功能来说,这可能不是太糟糕。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.