RE: How do I patch my binary

Marc Khouzam
2010-11-25T14:16:53Z

On Thu, 25 Nov 2010, Jan Kratochvil wrote:

> On Wed, 24 Nov 2010 16:00:39 +0100, Marc Khouzam wrote:
> > So, if GDB can't do it on its own, can we involve the compiler/linker
> > to make this happen? Is there more complexity with C/C++ than with Java?
>
> http://www.opensource.apple.com/tarballs/gdb/gdb-1472.tar.gz
> /* APPLE LOCAL fix-and-continue */
> src/gdb/fix-and-continue.c
>
> Howdy from Apple; Fix and Continue implemented Yet Again
> http://sourceware.org/ml/gdb/2003-06/msg00500.html

This is awesome! Thanks Jan!

From the email description, this seems to be exactly what I was looking for.
It allows the user to recompile a program, as any other compilation is done,
and ask GDB to patch it in.

The email mentions that this feature works with the IDE. But it also
gave me the impression that you could edit with emacs/vi, recompile with GCC
from a shell, and then give GDB the 'fix and continue' command. To me, that
fits very well with GDB and would have not outside dependencies.
(Of course, I would add this support in Eclipse, but that is not a requirement
for GDB).

From the email:
"Fix and continue is a feature implemented by many other debuggers:
[...] Sun Workshop, SGI ProDev WorkShop, Microsoft's Visual Studio,
HP's wdb, and Sun's Hotspot Java VM all provide this feature in one way or another"

I don't know enough about GDB to be able to port the feature myself.
I wonder if anyone else in the community would be interested in
porting this feature?

I think this would be a really nice addition to FSF GDB.

Here is the XCode doc about Fix and Continue which explains it nicely for a user:
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/XcodeDebugging/230-Modifying_Running_Code/modifying_running_code.html

Thanks

marc