gdb での Objective-C のデバッグ中にシンボルを使用せずにオブジェクトにメッセージを送信する

StackOverflow https://stackoverflow.com/questions/56472

質問

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]

@[ジョン・カルスビーク]

次に、シンボルが見つからないというメッセージが表示されます。

(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.

Foundation のシンボルをロードしようとしました。

(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.

とにかく、キャストがこの問題の解決策であるとは思いません。オブジェクトにメッセージを送信するために、オブジェクトがどのような種類であるかを知る必要はありません。奇妙なことに、メッセージの送信に問題がない 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

ということは、私が調査していたオブジェクトに問題があったのだと思われます...か何か。

ご協力いただきありがとうございます!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top