Gdbinit v8.0: simultaneous support for x86/x86_64 and ARM architectures!

Here it is, a merge between the x86 and ARM versions of gdbinit. The only inconvenience is that you need to manually change the target, using the “32bits” and “64bits” commands for x86/x86_64 architectures, and “arm” for ARM. That’s a small price to pay for πŸ™‚

This version features a lot of cosmetic fixes (indentation mostly) but also some fixes to the ARM related code, and a new command – dumpmacho. This command will dump the Mach-O header to a file. You need to supply the start address and the output filename. Only the header information is dumped – sometimes I need to dump the header and load it into otool or machoview to verify some things. Just a command to automate things!

The next step is to try to compile a new iOS gdb version that features my fixes. I think I will do another attempt to add the armv7 instructions to gdb so it’s not a major pain to debug these binaries. Let’s see if I can succeed this time.

There’s no test suite for gdbinit (<xxxxxxxx> testing is for chumps) ! From my tests everything is working, if not leave a msg here or at github.

Enjoy,
fG!

gdbinit8.gz
SHA256(gdbinit)= fb510d812dabbad968e68ad1e4916aa85400d6375e0e404f5893946151420238

17 thoughts on “Gdbinit v8.0: simultaneous support for x86/x86_64 and ARM architectures!

  1. I went a while without using your .gdbinit and let me tell you how completely vanilla gdb is without it. Thanks for continuing to improve upon it, for it’s not easy trying to go without it.

    btw — i’ve encountered some more code like we discussed a while back, and never got your take on the whole thing. I’ve figured out a few things in the meantime, and would be interested in your input.

  2. Is this compatible with 10.8? I keep trying to get this to load but version 8.0.2 (and any previous versions) won’t load on gdb. I installed XCode 4.4 and am using gdb version 6.3.50-20050815 (Apple version gdb-1820). I followed the instructions that made it work on previous osx installs (copying to ~/.gdbinit) but it’s not loading any of the commands. What should I try?

          1. Not sure what is going wrong:

            box:~ name$ cp ~/Downloads/gdbinit ~/.gdbinit
            box:~ name$ source ~/.gdbinit
            -bash: /Users/name/.gdbinit.local: No such file or directory
            -bash: /Users/name/.gdbinit: line 154: syntax error near unexpected token `else’
            -bash: /Users/name/.gdbinit: line 154: ` else’
            box:~ name$ mv .gdbinit .gdbinit.local
            box:~ name$ source .gdbinit.local

            [Process completed]

            Source doesn’t give errors after I rename the file, but gdb still won’t recognize any commands from the file.

  3. Thanks, that worked! :[ After typing that, the terminal prompt changed colors and it understood the “help user” command. Any idea why it needed that to recognize the file?

    1. Now that it recognizes the file, when I use the context command it says “Invalid type combination in equality test.” Is this a bug in the script or a mistake on my part?

      1. You probably are trying to analyze a 64bits target. You need to use the 32bits and 64bits commands to switch between target architectures.
        Try to use the 64bits command and then issue a context command again. It should display ok.
        I still have no idea why it’s not loading the gdbinit. Don’t have a ML install to test it.

        1. I tried both commands (its running as a 64-bit app) and it gives the same error on either command 64bits or 32bits. 64bits gives the error “Invalid type combination in equality test.” in the default console color, and running the context command gives the same error but in blue. I also tried loading it in 32-bit mode (-arch i386) and got the same errors after running the commands.

  4. I have the same problem as below:

    Error while running hook_stop:
    Invalid type combination in equality test.

    I used exec-file to solve it, but I find the gdb can not have the symbols here. Such as:

    gdb$ exec-file debugme
    Reading symbols for shared libraries …. done
    gdb$ b main
    Function “main” not defined.

    How can I solve this things?

  5. I’m new to debugging with gdb and gdbinit. I’ve noticed that the registers section only shows the value of the most recently changed register and not any currently held values. Is the way it’s supposed to operate or do I have it configured incorrectly?

    Awesome work, btw. This is really improving my ability to learn assembly. Thanks.

    1. The registers section shows current values, always.
      The change of colors is to indicate if value changed from previous instruction or not.

Leave a Reply

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