patch (idb mode only)

Modify an executable by writing the value of an expression to a specific address or variable.

Syntax

patch addr = expr  

Parameters

addr

The address or variable whose value you want to set.

expr

The value for the address.

Description

This command modifies an executable by writing the value of an expression to a specified address or variable.

Use this command to correct bad data or instructions in executable disk files. You can patch text, initialized data, or read-only data areas. You cannot patch the bss segment, or stack and register locations, because they do not exist on disk files.

Patching the code directly is very risky. You need to be careful that the source and target fit in structure, size, byte order, etc. Any mismatch may damage your application.

Only use this command to change the on-disk binary file. To modify debuggee memory, use the assign command. If the image is executing when you issue the patch command, the corresponding location in the debuggee address space is updated as well. The debuggee is updated regardless of whether the patch to disk succeeded, as long as the assign command can process the source and destination expressions. If your program is loaded but not yet started, the patch to disk is performed without the corresponding assign to memory.

When you use the patch command, the debugger saves the original binary with the string ~backup appended to the file name, so you can revert to the original binary if necessary. The debugger may also create a file with the string ~temp appended to the file name. The debugger may delete this file after the debugging session is over.

Example

(idb) run
[1] stopped at [int main(void):24 0x120001324] 
24 return 0; 
(idb) patch i = 10
0x1400000d0 = 10 
(idb) patch j = i + 12
0x1400000d8 = 22 
(idb)  

See Also


Submit feedback on this help topic

Copyright © 2001-2011, Intel Corporation. All rights reserved.