Patching
Using GDB, you can open your program's executable code (and the core file) for both reading and writing. This allows alterations to machine code, such that you can intentionally patch your program's binary. For example, you might want to turn on internal debugging flags, or even to make emergency repairs.
Note that depending on your operating system, special preparation steps, such as setting permissions, may be needed before you can change executable files.
To patch the binary, enable Edit =>
GDB Settings => Writing into executable and core files
. This makes GDB open executable and core files for both reading and writing. If you have already loaded a file, you must load it again (using Edit => Open File
or Edit => Open Core
), for your new setting to take effect.
Be sure to turn off Writing into executable and core files
as soon as possible, to prevent accidental alterations to machine code.
Node:Commands, Next:Application Defaults, Previous:Changing the Program, Up:Top