LLDB(Swift):将原始地址转换为可用类型 [英] LLDB (Swift): Casting Raw Address into Usable Type

查看:368
本文介绍了LLDB(Swift):将原始地址转换为可用类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可以将原始地址转换为可用的Swift类的LLDB命令?

Is there an LLDB command that can cast a raw address into a usable Swift class?

例如:

(lldb) po 0x7df67c50 as MKPinAnnotationView

我知道该地址指向MKPinAnnotationView,但它不在我可以选择的框架中。但是,我想将原始地址转换为MKPinAnnotationView,以便我可以检查其属性。这可能吗?

I know that this address points to a MKPinAnnotationView, but it is not in a frame that I can select. But, I want to cast the raw address into a MKPinAnnotationView so that I can examine its properties. Is this possible?

推荐答案

在xCode 8.2.1和Swift 3下,lldb命令 po p 不适用于输入的变量。您需要使用swift命令 print 来检查键入的对象实例的属性。 (感谢 cbowns的回答!)例如:

Under xCode 8.2.1 and Swift 3, the lldb command po or p won't work with the typed variable. You will need to use the swift command print to examine the properties of the typed object instance. (Thanks to cbowns's answer!) E.g.:

(lldb) expr -l Swift -- import UIKit
(lldb) expr -l Swift -- let $pin = unsafeBitCast(0x7df67c50, to: MKPinAnnotationView.self)
(lldb) expr -l Swift -- print($pin.alpha)

这篇关于LLDB(Swift):将原始地址转换为可用类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆