More gdbinit addons!

End of the year is slow and I was a bit inspired so I decided to hack around another features I was missing from gdbinit!

First one is about conditional jump display. Original gdbinit doesn’t tell you what will be the decision that will be taken on a conditional jump. You must look at the flags and check that! Well… I can’t memorize this kind of stuff (in reality I can but it’s useless so I refuse to) and computers were created to automate tasks! So I just added a nice Jump is taken or Jump is NOT taken (ripped from Ollydbg 😉) display!


jump pic

Much easier to follow the code! JCXZ and JECXZ are the only jumps not implemented.

The other feature is a step over calls. I don’t know why but GDB instructions to step over calls sometimes fail (mainly with objc_msgSend), which is a pain because you either follow into the call or set a manual breakpoint on next instruction. That’s what I’ve implemented, a temporary breakpoint on next instruction after the call. The call opcode which is most interesting is 0xE8 (I grepped most of my disassembled files). The whole call will take 6 bytes so we can easily calculate the next address and set a temporary breakpoint (using GDB tbreak function). I have called this new command stepo.
You can use it when the current instruction to be executed is a call or, if you don’t mind stepping over calls, you can use it always since when it’s not a call opcode, it will call the nexti command (step one instruction). Else just use it when you want to skip over the calls.
I have added a few other call opcodes but the list is incomplete. The code for this is a real mess and there is certainly a better way to do it. Suggestions? 😄
Anyway, opcode 0xE8 is really the most interesting one to skip over!

I made a few tests and things seem to be working as expected. If you find any bugs please report it or fix and send the patch 😃.

These three addons fill some personal missing features while working with GDB. If you have any suggestions or code to add, feel free to share.

After all this bla bla bla, here it is the code: gdbinit713

Have fun and a Happy 2009!

Grab version 7.1.4 here: gdbinit714

I think I fixed the Objective-C bug (I suspect it’s due to the fact I was using the same $_byte1 variable since I can’t reproduce it on Tiger) and added range support to nop and null routines (Thanks gln!)

Update 2:
Grab version 7.1.5 here: gdbinit715

The latest version can always be found here.

This one is really working on Leopard (forgot I had a Leopard at hand to test, duh!!!). The bug was really nice! I had a If Else construct where the else code was empty! GDB on Leopard doesn’t like such thing 😉.