This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Compare contents when evaluating an array watchpoint


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]