A lazy xmas gift or a lazy addon to gdbinit

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 🙁


0x00002bc5 in main ()
  EAX: 9FF43924  EBX: 00002B9D  ECX: 9FF37B64  EDX: 00403250  o d I t S z a P c
  CS: 0017  DS: 001F  ES: 001F  FS: 0000  GS: 0037  SS: 001F
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 .^...;....@.....
0x9ff43924 <objc_msgSend_stub+548>:      "init"
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+0x4 (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 !

One thought on “A lazy xmas gift or a lazy addon to gdbinit

Leave a Reply

Your email address will not be published. Required fields are marked *