Re: How do I patch my binary

Pedro Alves
2010-11-23T21:53:55Z

On Tuesday 23 November 2010 21:31:22, Marc Khouzam wrote:

> There is doc section "Patching Programs". This got me hoping I could somehow
> patch my binary while I was debugging.
>
> My hope was that I could modify the source code (outside of GDB), recompile
> the binary and have GDB load and use the new binary, without having to restart
> the program. I couldn't get this to work (using 'set write on' and reloading
> the new binary).

Doesn't work that way. You make it sound like you want edit&continue, which
GDB doesn't do (or rather the toolchain doesn't, since it requires coordination
between the compiler/linker/debugger). For some extremely lucky scenarios, against
simple remote targets, you might be able to get around with "load", but forget I
said that.

> When the doc says "Patching" does it mean I actually have to modify the memory
> where the code is written, using GDB commands?

Yes.

> Or can I do it high-level like I originally hoped.

No.

--
Pedro Alves