Watch Detectors

You can use watch detectors to determine when a variable or other memory location is read or written and/or changed. Breakpoints with watch detectors are also known as watchpoints.

watch_detector

: basic_watch_detector watch_detector_modifiers

basic_watch_detector

: variable expression

| memory start_address_expression

| memory start_address_expression , end_address_expression

| memory start_address_expression : byte_count_expression

watch_detector_modifiers

: [ access_modifier ] [ within_modifier ]

access_modifier

: write

| read

| changed

| any

within_modifier

: within function_name

You can specify a variable whose memory is to be watched, or specify the memory directly. The accesses that are considered can be limited to those that write (the default), read, write and actually change the value, or can include all accesses.

If you specify a variable, the memory to be watched includes all of the memory for that variable, as determined by the variable's type. The following example watches for write access to variable _nextNode:

(idb) whatis _nextNode

class Node* Node::_nextNode

(idb) print "sizeof(_nextNode) =", sizeof((_nextNode))

sizeof(_nextNode) = 4

(idb) stop variable _nextNode write

[#3: stop variable _nextNode write]

The specified variable is watched. If "p" is a pointer, watch variable p will watch the content of the pointer, not the memory pointed to by "p". Use watch memory *p to watch the memory pointed to by "p".

If you specify memory directly in terms of its address, the memory to be watched is defined as follows:

If you specify the within modifier, then only those accesses that occur within the given function (but not any function it calls) are watched. For example:

(idb) whatis t

int t

(idb) stop variable t write within C::foo(void)

[#3: stop variable t write within void C::foo(void)]

(idb) cont

Select from

----------------------------------------------------

     1 int C::foo(double*)

     2 void C::foo(float)

     3 void C::foo(int)

     4 void C::foo(void)

     5 None of the above

----------------------------------------------------

5

Value of <overloaded function> not completely specified

foo is not a valid breakpoint address

[3] Address 0x0804d5d0 was accessed at:

void C::foo(void): src/x_overload.cxx

 [line 22, 0x08048789] foo+0x3:                      movl     $0x0, 0x804d5d0

0x0804d5d0: Old value = 0x0000000f

0x0804d5d0: New value = 0x00000000

[3] stopped at [void C::foo(void):22 0x08048793]

     22 void C::foo()         { t = 0; state++; return; }