This command replaces the standard GDB watch command, which is not suitable for multi-threaded, multi-process, distributed execution. A thread can have up to four watched addresses. Defining a watchpoint uses the next available of the four watch slots. This command directly allocates a hardware debug register for the current thread such that when the condition occurs on the specified address, the thread will stop.
This applies on a per-thread basis. Watchpoints are implicitly removed when the UDF for which they are set exits. They must be reestablished for each UDF, even if it runs on a thread that also ran a previous UDF.
Syntax
watch[/mode] location
Syntax Elements
- mode
- Specifies the kind of memory access to watch for:
- d deletes a watchpoint
- r memory read access
- w memory write access
- x instruction execute access
- location
- An expression that evaluates to the address of the location that is to be monitored.
Usage Notes
You can make watchpoints apply to every UDF with a breakpoint set on entry to the function. This sets the desired watchpoint and continues:
(gdb) break funcname Breakpoint 1 at ... (gdb) command 1 > silent > watch location/w > continue >end (gdb)