xcode 使用LLDB进行IOS调试类成员变量NSArray

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10290082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:04:11  来源:igfitidea点击:

Using LLDB for IOS debug class member variable NSArray

objective-ciosxcodelldb

提问by kkurni

Does anyone know how to get the value for class member variable in IOS ?

有谁知道如何在 IOS 中获取类成员变量的值?

I try to use LLDB to debug NSArray in class member variable.

我尝试使用 LLDB 来调试类成员变量中的 NSArray。

After I run this

在我运行这个之后

__cellDataShadowArray2D = [[NSArray alloc] initWithObjects:[NSArray arrayWithObjects:obj1, obj2, nil], nil];

When I check the value using LLDB (print object), I always get this.

当我使用 LLDB(打印对象)检查值时,我总是得到这个。

(lldb) po __cellDataShadowArray2D
(NSArray *)  = 0x001e8894 <object returned empty description>

(lldb) p __cellDataShadowArray2D
(NSArray *)  = 0x001e8894

(lldb) po [__cellDataShadowArray2D count]
2012-04-24 10:10:38.535 SOME [61985:15803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x1e8894
(id)  = 0x00000000 <nil>

(lldb) po [__cellDataShadowArray2D retainCount]
(id)  = 0xffffffff [no Objective-C description available]

(lldb) p (int) [__cellDataShadowArray2D retainCount]
(int)  = -1

(lldb) p (int) [__cellDataShadowArray2D count]
2012-04-24 10:11:31.333 SOME [61985:15803] -[__NSCFConstantString count]: unrecognized selector sent to instance 0x1e8894
(int)  = 0

回答by bbum

  • make sure the line of code is actually evaluated before doing the test.
  • 确保在进行测试之前实际评估了这行代码。

It is clear that __cellDataShadowArray2D is pointing to an empty instance of a compiled constant string; @"". That means it cannot be an over-release or anything like that; it means that the assignment has not yet happened (or you are attempting to debug optimized code and the debugger is confused due to optimizations).

很明显 __cellDataShadowArray2D 指向的是一个编译后的常量字符串的空实例;@""。这意味着它不能过度释放或类似的东西;这意味着分配尚未发生(或者您正在尝试调试优化的代码并且调试器由于优化而感到困惑)。

  • po of non-object types doesn't make sense

  • retainCountis useless. Don't call it.

  • 非对象类型的 po 没有意义

  • retainCount没用。不要叫它。

回答by Valerio

It is definitely a LLDB problem. I had the same, coud not debug at all. I switched back to GDB and it was ok

这绝对是一个 LLDB 问题。我也有同样的情况,根本无法调试。我切换回 GDB 没问题