如何在self.view属性上设置lldb观察点? [英] How do I set an lldb watchpoint on a property of self.view?

查看:81
本文介绍了如何在self.view属性上设置lldb观察点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想跟踪什么东西改变了self.view的大小。什么是正确的格式?

 (lldb)po self.view 
(UIView *)$ 1 = 0x0a8aba20< UIView :0xa8aba20; frame =(0 0; 480 864); autoresize = W + TM + BM; layer =< CALayer:0xa8aba50>>
(lldb)watch set变量self.view.frame.size.width
错误:self是指针和。用于尝试访问视图。你的意思是self-> view.frame.size.width?
(lldb)watch set variable self-> view
error:view不是(PlayViewController *)self的成员。
(lldb)watch set variable self-> view.frame.size.width
错误:view不是(PlayViewController *)self的成员。

我已经尝试了文档和其他lldb观察点问题,但找不到任何针对此特定情况的内容。



感谢您的帮助。

解决方案

视图控制器从其 _view 实例变量引用其视图。 / p>

视图不直接存储其框架。它只返回它的图层的'frame'。



该视图从其 _layer 实例变量引用它的图层。



图层也不存储框架。它从边界位置 anchorPoint 计算其框架,和转换。大小是 bounds 的一部分。



图层不会将其边界直接存储在实例变量中。相反,它的实例变量引用私有C ++类的实例, CA :: Layer 。此类的成员布局没有记录。



换句话说,你可以去 self-> _view-> _layer->图层进入 CA :: Layer 实例,但是因为你不知道 CA :: Layer 来查找边界。



因此,尝试使用观察点来检测视图大小的变化是相当困难的。



上设置断点更容易 - [CALayer setBounds:]



在模拟器上



请记住在断点条件下使用图层地址不是查看地址。

 (lldb)po self.view 
(UIView *)$ 1 = 0x0a034690< UIView:0xa034690; frame =(0 20; 768 1004); autoresize = W + H; layer =< CALayer:0xa034780>>
(lldb)break set -F' - [CALayer setBounds:]' - c'((int *)$ esp)[1] == 0xa034780'
创建的断点:2:name =' - [CALayer setBounds:]',locations = 1,resolved = 1

当断点被击中时, CALayer 实例由((int *)$ esp)[1] 引用,新边界 *(CGRect *)($ esp + 12)

 (lldb) po((int *)$ esp)[1] 
(int)$ 8 = 167987072< CALayer:0xa034780; position = CGPoint(384 480); bounds = CGRect(0 0; 768 1004); delegate =< UIView:0xa034690; frame =(0 -22; 768 1004); autoresize = W + H; layer =< CALayer:0xa034780>> ;; sublayers =(< CALayer:0xa033010>); backgroundColor =< CGColor 0xa034960> [< CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)](1 1 1 1)>
(lldb)p *(CGRect *)($ esp + 12)
(CGRect)$ 9 = origin =(x = 0,y = 0)size =(width = 768,height = 960)
(lldb)完成
(lldb)po 0xa034780
(int)$ 10 = 167987072< CALayer:0xa034780; position = CGPoint(384 480); bounds = CGRect(0 0; 768 960); delegate =< UIView:0xa034690; frame =(0 0; 768 960); autoresize = W + H; layer =< CALayer:0xa034780>> ;; sublayers =(< CALayer:0xa033010>); backgroundColor =< CGColor 0xa034960> [< CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)](1 1 1 1)>



在设备上



请记住使用断点条件中的图层地址视图地址。

 (lldb)po self.view 
(UIView *)$ 0 = 0x1f031a10< UIView:0x1f031a10; frame =(0 20; 768 1004); autoresize = W + H; layer =< CALayer:0x1f031b00>>
(lldb)break set -F' - [CALayer setBounds:]' - c'$ r0 == 0x1f031b00'
创建的断点:2:name =' - [CALayer setBounds:]',locations = 1,已解决= 1

当遇到断点时, CALayer 实例由 $ r0 引用,新的X原点在 $ r2 中,新的Y来源是 $ r3 ,新的大小是 *(CGSize *)$ sp

 (lldb)po $ r0 
(unsigned int)$ 7 = 520297216< CALayer:0x1f031b00; position = CGPoint(384 480); bounds = CGRect(0 0; 768 1004); delegate =< UIView:0x1f031a10; frame =(0 -22; 768 1004); autoresize = W + H; layer =< CALayer:0x1f031b00>> ;; sublayers =(< CALayer:0x1f030840>); backgroundColor =< CGColor 0x1f031ce0> [< CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)](1 1 1 1)>
(lldb)p / f $ r2
(unsigned int)$ 14 = 0
(lldb)p / f $ r3
(unsigned int)$ 15 = 0
(lldb)p *(CGSize *)$ sp
(CGSize)$ 16 =(宽度= 768,高度= 960)
(lldb)完成
(lldb)po 0x1f031b00
(int)$ 17 = 520297216< CALayer:0x1f031b00; position = CGPoint(384 480); bounds = CGRect(0 0; 768 960); delegate =< UIView:0x1f031a10; frame =(0 0; 768 960); autoresize = W + H; layer =< CALayer:0x1f031b00>> ;; sublayers =(< CALayer:0x1f030840>); backgroundColor =< CGColor 0x1f031ce0> [< CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)](1 1 1 1)>


I want to trace when something changes the size of self.view. What's the correct format?

(lldb) po self.view
(UIView *) $1 = 0x0a8aba20 <UIView: 0xa8aba20; frame = (0 0; 480 864); autoresize = W+TM+BM; layer = <CALayer: 0xa8aba50>>
(lldb) watch set variable self.view.frame.size.width
error: "self" is a pointer and . was used to attempt to access "view". Did you mean "self->view.frame.size.width"?
(lldb) watch set variable self->view
error: "view" is not a member of "(PlayViewController *) self"
(lldb) watch set variable self->view.frame.size.width
error: "view" is not a member of "(PlayViewController *) self"

I've tried the documentation and other lldb watchpoint questions but can't find anything for this specific case.

Thanks for your help.

解决方案

The view controller references its view from its _view instance variable.

The view doesn't store its frame directly. It just returns its layer's `frame'.

The view references its layer from its _layer instance variable.

The layer doesn't store the frame either. It computes its frame from its bounds, position, anchorPoint, and transform. The size is part of bounds.

The layer doesn't store its bounds directly in an instance variable. Instead, its layer instance variable references an instance of a private C++ class, CA::Layer. The member layout of this class is undocumented.

In other words, you can go self->_view->_layer->layer to get to the CA::Layer instance, but then you're stuck because you don't know where in the CA::Layer to find the bounds.

So, trying to use a watchpoint to detect changes to the view's size is rather difficult.

It is easier to put a breakpoint on -[CALayer setBounds:].

On the simulator

Remember to use the layer address in the breakpoint condition, not the view address.

(lldb) po self.view
(UIView *) $1 = 0x0a034690 <UIView: 0xa034690; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0xa034780>>
(lldb) break set -F '-[CALayer setBounds:]' -c '((int*)$esp)[1] == 0xa034780'
Breakpoint created: 2: name = '-[CALayer setBounds:]', locations = 1, resolved = 1

When the breakpoint is hit, the CALayer instance is referenced by ((int *)$esp)[1], and the new bounds is *(CGRect *)($esp+12):

(lldb) po ((int*)$esp)[1]
(int) $8 = 167987072 <CALayer:0xa034780; position = CGPoint (384 480); bounds = CGRect (0 0; 768 1004); delegate = <UIView: 0xa034690; frame = (0 -22; 768 1004); autoresize = W+H; layer = <CALayer: 0xa034780>>; sublayers = (<CALayer: 0xa033010>); backgroundColor = <CGColor 0xa034960> [<CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>
(lldb) p *(CGRect*)($esp+12)
(CGRect) $9 = origin=(x=0, y=0) size=(width=768, height=960)
(lldb) finish
(lldb) po 0xa034780
(int) $10 = 167987072 <CALayer:0xa034780; position = CGPoint (384 480); bounds = CGRect (0 0; 768 960); delegate = <UIView: 0xa034690; frame = (0 0; 768 960); autoresize = W+H; layer = <CALayer: 0xa034780>>; sublayers = (<CALayer: 0xa033010>); backgroundColor = <CGColor 0xa034960> [<CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>

On the device

Remember to use the layer address in the breakpoint condition, not the view address.

(lldb) po self.view
(UIView *) $0 = 0x1f031a10 <UIView: 0x1f031a10; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0x1f031b00>>
(lldb) break set -F '-[CALayer setBounds:]' -c '$r0 == 0x1f031b00'
Breakpoint created: 2: name = '-[CALayer setBounds:]', locations = 1, resolved = 1

When the breakpoint is hit, the CALayer instance is referenced by $r0, the new X origin is in $r2, the new Y origin is in $r3, and the new size is *(CGSize *)$sp:

(lldb) po $r0
(unsigned int) $7 = 520297216 <CALayer:0x1f031b00; position = CGPoint (384 480); bounds = CGRect (0 0; 768 1004); delegate = <UIView: 0x1f031a10; frame = (0 -22; 768 1004); autoresize = W+H; layer = <CALayer: 0x1f031b00>>; sublayers = (<CALayer: 0x1f030840>); backgroundColor = <CGColor 0x1f031ce0> [<CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>
(lldb) p/f $r2
(unsigned int) $14 = 0
(lldb) p/f $r3
(unsigned int) $15 = 0
(lldb) p *(CGSize *)$sp
(CGSize) $16 = (width=768, height=960)
(lldb) finish
(lldb) po 0x1f031b00
(int) $17 = 520297216 <CALayer:0x1f031b00; position = CGPoint (384 480); bounds = CGRect (0 0; 768 960); delegate = <UIView: 0x1f031a10; frame = (0 0; 768 960); autoresize = W+H; layer = <CALayer: 0x1f031b00>>; sublayers = (<CALayer: 0x1f030840>); backgroundColor = <CGColor 0x1f031ce0> [<CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>

这篇关于如何在self.view属性上设置lldb观察点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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