Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending messages to objects while debugging Objective-C in gdb, without symbols

I'm trying to send messages to Objective-C objects in gdb.

(gdb) p $esi
$2 = (void *) 0x1268160
(gdb) po $esi
<NSArray: 0x1359c0>
(gdb) po [$esi count]
Target does not respond to this message selector.

I can't send any message to it. Am I missing something? Do I really need the symbols, or something else?

like image 716
asksol Avatar asked Sep 11 '08 12:09

asksol


2 Answers

If you must override gdb and send a message to an object when it will not let you, you can use 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

If you need to pass an argument use withObject:

(gdb) print (int)[receivedData performSelector:@selector(count) withObject:myObject ]
like image 82
Kendall Helmstetter Gelner Avatar answered Nov 19 '22 08:11

Kendall Helmstetter Gelner


Is it possible that you need to cast $esi?

p (NSUInteger)[(NSArray *)$esi count]
like image 40
John Calsbeek Avatar answered Nov 19 '22 09:11

John Calsbeek