Set a watchpoint on a specified expression.
awatch expr
expr |
The expression on which to set the watchpoint. |
This command sets a watchpoint on the specified expression. When the debuggee reads the value of the specified expression or writes to it, it stops.
Watchpoints are also referred to as data breakpoints.
The following example illustrates the behavior of a watchpoint set on a variable, glob, when the debuggee writes to it.
Consider lines 16-25 of code in hello_simple.c:
16 printf("Hello world!\n"); 17 18 glob = 1; 19 glob = 11; 20 glob = 111; 21 glob = 1111; 22 23 readGlob(glob); 24 readGlob(glob); 25 readGlob(glob);
At the beginning of the example, glob=1.
(idb) break 19 Breakpoint 1 at 0x1f75: file /site/c_code/hello_simple.c, line 19. (idb) run Starting program: /site/c_code/hello_simple.darwin.9.exe.dSYM/Contents/Resources/DWARF/hello_simple.darwin.9.exe Hello world! Breakpoint 1, main () at /site/c_code/hello_simple.c:19 19 glob = 11;(idb) next 20 glob = 111; (idb) print glob $1 = 11
Now glob=11. Line 19 has executed but line 20 has not.
Create the watch:
(idb) awatch glob Watchpoint 2: Access memory (any) 0x00002048 to 0x0000204b (idb) continue Continuing. Old value = 11 New value = 111 Watchpoint 2, main () at /site/c_code/hello_simple.c:21 21 glob = 1111;
The watchpoint hits as result of the assignment on line 20, but because the variable was accessed in line 20, the debugger stops on line 21, before executing line 21.
(idb) continue
Continuing.
Old value = 111
New value = 1111
Watchpoint 2, main () at /site/c_code/hello_simple.c:23
23 readGlob(glob);
The watchpoint hits as a result of the assignment on line 21. There is no code on line 22 so the debugger stops on line 23.
Copyright © 2001-2011, Intel Corporation. All rights reserved.