简体   繁体   English

XCode LLDB - 从给定帧中获取自己

[英]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.

相关问题 Xcode lldb 错误:无法打印出 Swift 变量 - 改为获取“$__lldb_injected_self.$__lldb_wrapped_expr_x” - Xcode lldb error: can't print out Swift variable - get "$__lldb_injected_self.$__lldb_wrapped_expr_x" instead Xcode 调试器 (lldb) 从内存地址获取对象描述 - Xcode debugger (lldb) get object description from memory address XCode不会在LLDB调用的方法中停止断点 - XCode not stopping on breakpoint in method called from LLDB 使用Python脚本时,Xcode lldb调试器中的lldb.frame变量为空 - Empty lldb.frame variables in Xcode lldb debugger when using Python scripts Xcode 断点和 LLDB - 如何从存储在变量中的给定文件 URL 打开文件(例如在预览中)? - Xcode Breakpoint and LLDB - How do I open a file (e.g. in Preview) from a given fileURL stored in a variable? xcode上的lldb与独立版本上的lldb - lldb on xcode vs lldb on standalone 如何在 Xcode 中使用 LLDB 将所有手势识别器附加到视图? - How to get all the gesture recognizers attached to a view using LLDB in Xcode? Xcode / LLDB:如何获取有关刚抛出的异常的信息? - Xcode/LLDB: How to get information about an exception that was just thrown? 可以从LLDB中的另一个堆栈帧读取变量 - Possible to read variables from another stack frame in LLDB LLDB与Xcode调试器用户界面不同(可能是错误?) - LLDB differs from Xcode debugger UI (possible bug?)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM