This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Compare contents when evaluating an array watchpoint
- From: Jim Blandy <jimb at redhat dot com>
- To: Andrew Cagney <ac131313 at redhat dot com>
- Cc: Klee Dienes <klee at apple dot com>, Eli Zaretskii <eliz at is dot elta dot co dot il>, gdb-patches at sources dot redhat dot com
- Date: 18 Nov 2002 12:35:29 -0500
- Subject: Re: [PATCH] Compare contents when evaluating an array watchpoint
- References: <C66935B8-D9BB-11D6-9563-00039396EEB8@apple.com><3DB49F6C.3060106@redhat.com>
Andrew Cagney <ac131313@redhat.com> writes:
> int a[10];
> int *b;
> (gdb) watch a
> (gdb) watch b
> (gdb) watch *b@10
> (gdb) watch *a@sizeof(a)
>
> While the existing ``watch a'' might have annoying semantics, it would
> make its behavior consistent with C. An array is converted to a
> pointer in an expression.
Well, whether arrays are coerced to pointers depends on what you're
doing with them: see ISO C 6.3.2. In most cases they are, but if
they're an operand to & or sizeof, then they aren't. It's a
case-by-case thing: C chooses the most useful interpretation given the
context. It seems consistent with C for GDB to do the same.
And in fact, GDB doesn't do "the usual unary conversions" on the final
value of an expression. That's why when you have:
int a[10];
then GDB does this:
(gdb) print a
$1 = {1, 0, 1074017445, 1075174868, 1075159808, 1073833280, 1075175900,
1074103810, 1073933620, 1075174868}
(gdb)
and not:
(gdb) print a
$1 = (int *) 0xbfffc100
(gdb)
So I think Klee's patch makes GDB's behavior more consistent with
itself, more useful, and is still completely consistent with C
semantics.