我正在尝试向gdb中的Objective-C对象发送消息。
(gdb) p $esi
$2 = (void *) 0x1268160
(gdb) po $esi
<NSArray: 0x1359c0>
(gdb) po [$esi count]
Target does not respond to this message selector.
我无法发送任何消息。我错过了什么吗?我真的需要符号或其他东西吗?
我正在尝试向gdb中的Objective-C对象发送消息。
(gdb) p $esi
$2 = (void *) 0x1268160
(gdb) po $esi
<NSArray: 0x1359c0>
(gdb) po [$esi count]
Target does not respond to this message selector.
我无法发送任何消息。我错过了什么吗?我真的需要符号或其他东西吗?
如果必须覆盖gdb并在不允许的情况下向对象发送消息,则可以使用performSelector:
(gdb) print (int)[receivedData count]
Target does not respond to this message selector.
(gdb) print (int)[receivedData performSelector:@selector(count) ]
2008-09-15 00:46:35.854 Executable[1008:20b] *** -[NSConcreteMutableData count]:
unrecognized selector sent to instance 0x105f2e0
如果需要传递参数,请使用withObject:
(gdb) print (int)[receivedData performSelector:@selector(count) withObject:myObject ]
是否有可能需要施放 $esi
?
p (NSUInteger)[(NSArray *)$esi count]
@ [John Calsbeek]
然后它抱怨缺少符号。
(gdb) p (NSUInteger)[(NSObject*)$esi retainCount]
No symbol table is loaded. Use the "file" command.
(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.
我试图加载基金会的符号:
(gdb) add-symbol-file /System/Library/Frameworks/Foundation.framework/Foundation
add symbol table from file "/System/Library/Frameworks/Foundation.framework/Foundation"? (y or n) y
Reading symbols from /System/Library/Frameworks/Foundation.framework/Foundation...done.
但仍然没有运气:
(gdb) p [(NSArray *)$esi count]
No symbol "NSArray" in current context.
无论如何,我不认为cast是解决这个问题的方法,你不应该知道它是什么类型的对象,能够向它发送消息。 奇怪的是我发现了一个NSCFArray我发送消息没有问题:
(gdb) p $eax
$11 = 367589056
(gdb) po $eax
<NSCFArray 0x15e8f6c0>(
file://localhost/Users/ask/Documents/composing-fractals.pdf
)
(gdb) p (int)[$eax retainCount]
$12 = 1
所以我猜我正在调查的对象有什么问题......或者其他什么。
谢谢你的帮助!