One known problem with Apple’s fork of open source software is their slowness in fixing vulnerabilities and bugs. Gdb fork isn’t immune to this; it was forked around release 6.6 or something like that and lots of stuff isn’t kept in sync with GNU’s gdb version.
The short story for this bug is that you can’t have a “commands” command inside a “define” command. This creates some problems for useful scripting. The funny thing is that I had hit this bug a few weeks ago but didn’t paid any attention to it, just worked around it and never bothered to understand why my script didn’t work.
What I did here was to find where the bug was, compare with GNU gdb to find where it was fixed (version 6.7) and backport the required code. So all coding work was done by someone else (thank you :-)). I just “reversed” the problem!
Hey Apple, I am not your codebase maintainer 😉 (but I would be interested in working for you, probably in Strategy or Marketing, since you rock at those areas [well I also love design but I can’t draw anything] and I suck at coding, LOL :-)).
For now I will only post the patch – the version that includes all previous patches, and another just for this bug. Later I will put up patched binaries for Leopard/Snow Leopard and Lion.
I have to format my computer since I had to install some Chinese kernel drivers for Internet access. I do not trust their shit, especially low level stuff such as kernel drivers (TODO list has one more item – verify the code for those modules!). It’s a real sad state of affairs! But a format once in a while is always healthy, despite what is commonly said in Mac space.
Here is the binary version for Snow Leopard, 32/64 bits fat binary. Replace as gdb-i386.apple-darwin in /usr/libexec/gdb and don’t forget to fix permissions 🙂
And the version for Lion, also a fat binary for 32/64 bits.
End of update.
Here’s how the problem looks like:
$ gdb GNU gdb 6.3.50-20050815 (Apple version gdb-1344) (Mon Feb 28 15:50:14 UTC 2011) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "x86_64-apple-darwin". gdb$ define test >b *0x1000 >commands 1 >set $eax=1 >end gdb$ bpl No breakpoints or watchpoints. gdb$ test Breakpoint 1 at 0x1000 ^CQuit gdb$ bpl Num Type Disp Enb Address What 1 breakpoint keep y 0x00001000 gdb$