While I was messing with gdbinit three weeks ago, I added a small feature that displays the messages being sent to objc_msgSend. Usually I follow the otool or IDA dump and see what’s being sent, but that it’s not very practical! So I made a dirty hack with gdbinit so that information appears automatically into gdb window. It’s not very pretty, but gdbinit is very limited
Example:
gdb$ 0x00002bc5 in main () --------------------------------------------------------------------------[regs] EAX: 9FF43924 EBX: 00002B9D ECX: 9FF37B64 EDX: 00403250 o d I t S z a P c ESI: BFFFF8F4 EDI: BFFFF898 EBP: BFFFF838 ESP: BFFFF7F0 EIP: 00002BC5 CS: 0017 DS: 001F ES: 001F FS: 0000 GS: 0037 SS: 001F [001F:BFFFF7F0]----------------------------------------------------------[stack] BFFFF840 : 01 00 00 00 98 F8 FF BF - A0 F8 FF BF F4 F8 FF BF ................ BFFFF830 : A0 F8 FF BF F4 F8 FF BF - 78 F8 FF BF 92 23 00 00 ........x....#.. BFFFF820 : 2C 0C 05 90 C2 6D E0 8F - 00 00 00 00 A0 F8 FF BF ,....m.......... BFFFF810 : 24 F8 FF BF 00 10 00 00 - 38 F8 FF BF D0 C5 E4 8F $.......8....... BFFFF800 : E4 F1 E3 8F DA 29 00 00 - 38 F8 FF BF FE 29 00 00 .....)..8....).. BFFFF7F0 : 80 5E A7 A0 10 3B F4 9F - F0 2E 40 00 00 00 00 00 .^...;....@..... --------------------------------------------------------------------[ObjectiveC] 0x9ff43924 <objc_msgSend_stub+548>: "init" [0017:00002BC5]-----------------------------------------------------------[code] 0x2bc5 : mov DWORD PTR [esp+0x4],eax 0x2bc9 : mov DWORD PTR [esp],edx 0x2bcc : call 0x404c <dyld_stub_objc_msgSend> 0x2bd1 : mov DWORD PTR [ebp-0x14],eax 0x2bd4 : lea eax,[ebx+0x24cb] 0x2bda : mov eax,DWORD PTR [eax] 0x2bdc : mov edx,eax 0x2bde : lea eax,[ebx+0x249b] --------------------------------------------------------------------------------
After the call to _objc_msgSend, that display will be removed until the next time such argument is found. There will be false positives, since I’m grabbing the mov to esp+0×4 (maybe this can be avoided, but for me it’s not a big deal and I can live with it!).
Grab it here, version 7.1.1: gdbinit
Any comments, suggestions, patches & improvements are welcome !
-
Thanks for this one fG, was on the go and needed just that!
Btw, Tapas for tomorrow
Cya
1 comment
Comments feed for this article
Trackback link: http://reverse.put.as/2008/12/29/a-lazy-xmas-gift-or-a-lazy-addon-to-gdbinit/trackback/