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

Michael Snyder
2010-03-04T02:05:26Z

Pedro Alves wrote:
> Anyone else things this is useful? Here's a 5 minute hack at it.
>
> It allows for e.g.:
>
> (top-gdb) watch $rax
> Watchpoint 4: $rax
> (top-gdb) c
> Continuing.
> Watchpoint 4: $rax
>
> Old value = 11802104
> New value = 140737488347216
> 0x0000000000456647 in main (argc=1, argv=0x7fffffffe158) at ../../src/gdb/gdb.c:28
> 28 memset (&args, 0, sizeof args);
> (top-gdb)
>
> Current GDB will successfuly create the watchpoint in the
> breakpoint list, but it never triggers, because since the
> watchpoint isn't watching any memory, it ends up with
> no bp_location associated.
>
>
> For extra fun, even watching $_siginfo works.

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

Expressions on a varobj sound useful to watch too.

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