Re: Watching expressions that don't involve memory (e.g., watch $regfoo)

Pedro Alves
2010-03-04T02:13:42Z

On Thursday 04 March 2010 02:05:18, Michael Snyder wrote:

> I think watching registers, or expressions involving registers
> (such as $sp > 0x10000000) could be incredibly useful.

Yeah, that works.

(top-gdb) p $rsp
$1 = (void *) 0x7fffffffe040
(top-gdb) watch $rsp < 0x7fffffffe040
Watchpoint 4: $rsp < 0x7fffffffe040
(top-gdb) c
Continuing.
Watchpoint 4: $rsp < 0x7fffffffe040

Old value = 0
New value = 1
0x0000000000454fd8 in memset@plt ()
(top-gdb) bt
#0 0x0000000000454fd8 in memset@plt ()
#1 0x0000000000456659 in main (argc=1, argv=0x7fffffffe158) at ../../src/gdb/gdb.c:28
(top-gdb)

> Expressions on a varobj sound useful to watch too.

What do you mean by varobj here? If that's something
that you can "(gdb) print", it should work too. It sounds
like it opens pathway for some crazy watching :-)

> One question; what will happen if I watch a constant?

The watchpoint never triggers, as is today.

--
Pedro Alves