This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I patch my binary

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?  


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


Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]